/* ==========================================================================
   MudBlazor → "Terroir" remap.
   Loaded AFTER _content/MudBlazor/MudBlazor.min.css (and after terroir.css) so
   these win. Every value points at a theme-aware Terroir token (defined in
   terroir.css), so Mud components follow the light/dark toggle automatically
   from this single block — no second dark theme stylesheet required, and no
   [data-theme] selector here (the tokens themselves flip under
   :root[data-theme="dark"] in terroir.css).

   The C# TerroirMudTheme.Build()
   factory anchors the Mud palette with hex approximations (MudColor cannot parse
   oklch), so THIS FILE is the authoritative runtime surface source — it re-points
   Mud's generated --mud-palette-* vars at the real Terroir oklch tokens.
   ========================================================================== */

:root {
  /* --- Neutrals: black/white anchors Mud derives many surfaces from --------- */
  --mud-palette-black:            var(--ink);
  --mud-palette-white:            var(--surface);

  /* --- Backgrounds & surfaces ---------------------------------------------- */
  --mud-palette-background:       var(--paper);
  --mud-palette-background-gray:  var(--surface-2);
  --mud-palette-surface:          var(--surface);
  --mud-palette-drawer-background: var(--surface);
  --mud-palette-drawer-text:      var(--ink);
  --mud-palette-drawer-icon:      var(--ink-2);
  --mud-palette-appbar-background: var(--surface);
  --mud-palette-appbar-text:      var(--ink);

  /* --- Text ---------------------------------------------------------------- */
  --mud-palette-text-primary:     var(--ink);
  --mud-palette-text-secondary:   var(--ink-2);
  --mud-palette-text-disabled:    var(--ink-3);

  /* --- Actions ------------------------------------------------------------- */
  --mud-palette-action-default:            var(--ink-2);
  --mud-palette-action-disabled:           var(--ink-3);
  --mud-palette-action-disabled-background: var(--surface-2);

  /* --- Lines / borders / dividers ------------------------------------------ */
  --mud-palette-lines-default:    var(--line);
  --mud-palette-lines-inputs:     var(--line);
  --mud-palette-divider:          var(--line);
  --mud-palette-divider-light:    var(--line-soft);
  --mud-palette-table-lines:      var(--line-soft);
  --mud-palette-table-striped:    var(--surface-2);
  --mud-palette-table-hover:      var(--surface-2);

  /* --- Primary (pine; per-tenant accent overrides via --brand in app.css) -- */
  --mud-palette-primary:               var(--brand);
  --mud-palette-primary-text:          var(--brand-contrast);
  --mud-palette-primary-lighten:       var(--brand-soft);
  --mud-palette-primary-darken:        var(--pine-deep);
  --mud-palette-primary-hover:         var(--brand-soft);

  /* --- Secondary (wine) ---------------------------------------------------- */
  --mud-palette-secondary:             var(--wine);
  --mud-palette-secondary-text:        oklch(0.97 0.02 30);

  /* --- Semantic (kept distinct but in-palette) ----------------------------- */
  --mud-palette-info:        var(--sky);
  --mud-palette-info-text:   #ffffff;
  --mud-palette-success:     var(--pine);
  --mud-palette-success-text: var(--on-pine);
  --mud-palette-warning:     var(--wheat-deep);
  --mud-palette-warning-text: var(--ink);
  --mud-palette-error:       var(--wine);
  --mud-palette-error-text:  oklch(0.97 0.02 30);
  --mud-palette-dark:        var(--ink);
  --mud-palette-dark-text:   var(--surface);

  /* --- Shape (Mud reads border radius from a layout property, mirrored here) */
  --mud-default-borderradius: var(--r-sm);
}

/* A few component touch-ups the theme object alone can't reach --------------- */

/* Headings inside Mud surfaces read as editorial serif to match the app. */
.mud-card .mud-card-header .mud-typography-h5,
.mud-card .mud-card-header .mud-typography-h6,
.mud-card .mud-card-header-content .mud-typography,
.mud-dialog-title {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Cards / papers sit on the warm surface with a hairline + soft shadow. */
.mud-card,
.mud-paper-outlined {
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}

/* DataGrid / table: warm hairlines, uppercase editorial header, surface-2 hover. */
.mud-table .mud-table-cell {
  border-color: var(--line-soft);
}
.mud-table-head .mud-table-cell,
.mud-table-head th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t--2);
  color: var(--ink-3);
}
.mud-table-hover .mud-table-row:hover {
  background: var(--surface-2);
}

/* Dialog / popover on the warm surface with the deeper shadow. */
.mud-dialog {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-3);
  border-radius: var(--r-md);
}

/* Mud buttons inherit the primary remap; nudge weight/letterspacing to match. */
.mud-button-root { font-weight: 600; letter-spacing: 0.01em; }

/* --- Multi-date month grid day states (SCHED-03 / D-10 / D-11 / D-12) ------
   These three classes are emitted by MultiDateMonthGrid's AdditionalDateClassesFunc,
   but they land on MudBlazor's OWN day button — markup rendered by MudBaseDatePicker,
   a DIFFERENT component. Blazor's CSS-isolation scope attribute is therefore absent
   from that element, so a scoped MultiDateMonthGrid.razor.css rule could never match
   it. They belong here because this file is loaded after MudBlazor.min.css precisely
   so rules like these win the cascade (see this file's header).
   Every value is a Terroir token, so all three states follow the light/dark toggle
   with no [data-theme] selector of their own. */

/* Selected (D-10) — filled with the tenant accent: the state the user chose. */
.mud-picker-calendar-day.ev-day-picked {
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 600;
  box-shadow: var(--sh-1);
}

/* Anchor (D-11) — the locked first occurrence. Deliberately NOT the filled accent:
   it is a fact about the series, not a choice, so it reads as a wheat ring rather
   than a selection. The button renders `disabled`, so color/opacity are restated
   here or Mud's disabled treatment dims it into illegibility. */
.mud-picker-calendar-day.ev-day-anchor,
.mud-picker-calendar-day.ev-day-anchor:disabled {
  background: var(--wheat-tint);
  color: var(--wheat-ink);
  box-shadow: inset 0 0 0 2px var(--wheat-deep);
  font-weight: 600;
  opacity: 1;
}

/* Already in the series (D-14 / D-15) — present but not on offer: muted, dashed,
   neither filled nor ringed, so it never competes with the two live states above. */
.mud-picker-calendar-day.ev-day-existing,
.mud-picker-calendar-day.ev-day-existing:disabled {
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px dashed var(--line);
  opacity: 1;
}

/* The live "N of 52" counter beneath the grid (D-12). */
.ev-day-counter {
  color: var(--ink-2);
  font-size: var(--t--1);
}
