/* The Suite's tokens, scoped to `.alt-app` (tasks/notes/calendar/team_board/okrs/admin.html); "alt" is historical.
   mobile.html mirrors this geometry locally (sys_design-system §14a, application-font.test.js):
   change a radius, spacing step or shadow here and update it there too.
   Roles point at canonical colours in CSS/tokens.css, plus layout-only values. */

.alt-app{
  /* The sticky header's height; alt-shell.js overwrites it inline. Narrow Notes pins its bar under it. */
  --a-top-h:0px;
  /* ---- surfaces ---- */
  --a-bg:var(--bg);
  --a-panel:var(--panel);
  --a-raised:var(--panel-2);
  /* One step above --panel-2 for things that float: menus, the drawer header, a selected row.
     Composited rather than a new hex so it tracks both themes. */
  /* Percentages must sum to 100 or the result is translucent (88+4 gave alpha 0.92 and let the page
     show through). The plain declaration above is the fallback: an engine without color-mix()
     discards the whole custom property otherwise. */
  --a-float:var(--panel-2);
  --a-float:color-mix(in srgb, var(--panel-2) 96%, var(--text) 4%);
  --a-line:var(--border);
  --a-line-soft:var(--border-soft);
  --a-line-strong:var(--border-strong);
  /* The edge of a CONTROL (input, select, textarea) is the 3:1 tier, never `--a-line` (1.91).
     On a FLOATING surface (see the rebind block below) `--a-line-strong` itself is only ~2.7:1,
     so that block raises it by mixing toward the text colour — a derived token, so a custom
     team palette follows and stays compliant with nothing re-measured by hand. */
  --a-ctl-edge:var(--a-line-strong);

  /* ---- text ---- */
  --a-text:var(--text);
  --a-dim:var(--text-dim);
  --a-faint:var(--text-faint);
  /* `--a-float` is `--panel-2` lightened toward the text colour (dark) or darkened (light), so
     the two tiers that were measured against `--panel-2` lose contrast on it: faint 4.61 -> 4.13
     (dark) and 4.62 -> 4.32 (light), accent text on its own wash 4.54 -> 4.12 / 4.26. These are
     the same roles pulled toward `--a-text`, applied only where `--a-float` is the ground. */
  /* Plain declarations first: an engine without color-mix() discards the WHOLE custom property. */
  --a-float-faint:var(--a-dim);
  --a-float-blue-text:var(--a-blue-text);
  --a-float-ctl-edge:var(--a-faint);
  --a-float-red-text:var(--a-text);
  --a-float-faint:color-mix(in srgb, var(--a-faint) 85%, var(--a-text) 15%);
  --a-float-blue-text:color-mix(in srgb, var(--a-blue-text) 85%, var(--a-text) 15%);
  --a-float-red-text:color-mix(in srgb, var(--a-red) 85%, var(--a-text) 15%);
  --a-float-ctl-edge:color-mix(in srgb, var(--a-line-strong) 82%, var(--a-text) 18%);

  /* ---- roles ---- */
  --a-blue:var(--accent);
  --a-blue-fill:var(--accent-fill);
  --a-blue-text:var(--accent-text);
  --a-blue-soft:var(--accent-soft);
  /* Gold is emphasis, never status — the wireframes use it for the star, the brand mark and the
     one figure worth looking at first; nothing else in this product means "gold" as a state. */
  --a-gold:#f5a623;
  --a-gold-soft:rgba(245,166,35,.16);
  /* The now line: vermilion (dark) / crimson (light), the clock's own colour so it is never mistaken for the accent blue of
     links and the meeting gauge. NOT a team-theme token (JS/core/theme-custom.js), so a team palette never retints it, and never
     --red (that means error). --a-on-now is text on the flag; --a-now-past is the elapsed band on today's column: a plain
     neutral veil, not derived from a palette token, so faint text on it keeps its contrast under any custom team theme. */
  --a-now:#ff6b57;
  --a-on-now:#0a1628;
  --a-now-past:rgba(0,0,0,.3);
  --a-green:var(--green-text);
  --a-green-soft:var(--green-soft);
  --a-orange:var(--orange-text);
  --a-orange-soft:var(--orange-soft);
  /* The focus, lunch and flight row washes are opaque and lighter than --a-green-soft, so a focus, lunch or flight row never
     reads as a free slot. Plain values here; the tinted mixes are in the @supports block below. */
  --a-focus-wash:var(--a-raised); --a-lunch-wash:var(--a-raised); --a-flight-wash:var(--a-raised);
  --a-amber:var(--warn-text);
  --a-amber-soft:var(--yellow-soft);
  --a-red:var(--red-text);
  --a-red-soft:var(--red-soft);
  --a-purple:var(--purple-text);
  --a-purple-soft:var(--purple-soft);
  --a-ring:var(--focus-ring);
  /* THE STAT CHIP, declared once: a tab count (`.a-count-chip.mute`) and a section-header count
     (`.a-group-h .n` and kin) read these three, so the two cannot drift. Dim ink, not faint:
     --a-faint on a gray wash fails 4.5:1 in dark. */
  --a-cnt-fill:var(--a-raised); --a-cnt-line:var(--a-line-soft); --a-cnt-ink:var(--a-dim);

  /* ---- spacing. DS-46: a 2px base (2..24) and four fixed rhythms. `--a-1`..`--a-8` are the older
     4px names, kept so existing rules resolve; new rules use `--a-sp-*` and the rhythms. ---- */
  --a-1:4px; --a-2:8px; --a-3:12px; --a-4:16px; --a-5:20px; --a-6:24px; --a-8:32px;
  --a-sp-2:2px; --a-sp-4:4px; --a-sp-6:6px; --a-sp-8:8px; --a-sp-12:12px; --a-sp-16:16px; --a-sp-20:20px; --a-sp-24:24px;
  --a-gap-label:6px; --a-gap-head:8px; --a-gap-row:4px; --a-gap-section:16px;
  /* DS-45: one body padding for every dialog, pane, drawer and editor (rail cards stay 12px). */
  --a-pad-body:16px;

  /* ---- radii. DS-05: four and no others. 6 controls, 9 items and floating lists, 14 containers, pill. ---- */
  --a-r-sm:6px; --a-r:9px; --a-r-lg:14px; --a-r-pill:999px;

  /* ---- heights. THE LADDER (DS-01): three steps and nothing else, so a select, a chip, a button and a
     field in one row read as one row. sm 26 (dense rows, toolbars, .sm), md 32, lg 36 (the top bar).
     The narrow-width rule adds 2px to each step (alt-responsive.css, DS-04); a page class never changes
     them (DS-03). Contract: _docs/tests/design-spec.json. ---- */
  --a-ctl-sm:26px;
  --a-ctl:32px;
  --a-ctl-lg:36px;
  /* The task-editor field height (owner, 2026-11-12: "Make all editors 32px"), now an alias of the
     ladder's md step so every editor field and every other field are one number. Mirrored in
     CSS/alt/alt-embed-task.css; _docs/tests/task-editor-field-height.test.js holds the pair. */
  --a-field-h:var(--a-ctl);
  /* DS-13: the open item's title field, one box everywhere. */
  --a-title-h:40px;
  --a-row:44px;

  /* ---- elevation ---- */
  --a-shadow:0 10px 30px rgba(0,0,0,.34);
  --a-shadow-sm:0 4px 14px rgba(0,0,0,.22);
  /* The dialog's own, deeper than a card's: it sits over the whole page rather than on it. */
  --a-shadow-lg:0 24px 60px rgba(0,0,0,.46);

  /* ---- motion. The canonical durations, so reduced-motion is answered once. ---- */
  --a-quick:var(--dur-quick, 160ms);
  --a-ease:var(--ease-out, cubic-bezier(.2,.7,.3,1));

  /* ---- type: roles point at CSS/tokens.css's canonical font stacks (the reader's chosen
     `:root[data-app-font]` block), so a literal stack here would be a second answer to "what
     face is the app in". `--a-mono` isn't part of it — fixed advance width is required for
     aligned figures, never a preference. ---- */
  --a-display:var(--app-font-display, system-ui, -apple-system, sans-serif);
  --a-body:var(--app-font, system-ui, -apple-system, sans-serif);
  --a-mono:'JetBrains Mono', ui-monospace, monospace;
  /* DS-47: three line-heights, plus 1 inside a fixed-height control. 'normal' is not used. */
  --a-lh-tight:1.25; --a-lh-ui:1.45; --a-lh-body:1.6; --a-lh-ctl:1;
  /* DS-17: every button and field states its font (13px md/lg, 12px sm, 600 on buttons). */
  --a-fs-ctl:13px; --a-fs-ctl-sm:12px; --a-fw-ctl:600;
  /* The type scale (design-spec.json scales.font_sizes_px): every font-size is one of these tokens. */
  --a-fs-11:11px; --a-fs-12:12px; --a-fs-13:13px; --a-fs-14:14px; --a-fs-16:16px; --a-fs-18:18px;
  --a-fs-21:21px; --a-fs-24:24px; --a-fs-28:28px;
  /* Component sizes the specification names outside the ladder (mirrored in CSS/tokens.css for token-less pages). */
  --a-chip-h:24px; --a-tab-h:34px; --a-check:16px; --a-hit-min:24px; --a-touch:44px; --a-rte-min:120px;
  --a-glyph:15px; --a-glyph-lg:18px; --a-glyph-sm:12px; --a-glyph-xs:11px; --a-dot:9px;
  --a-on-fill:#fff;
  /* Admin console (DS-A05 notices, DS-A07 charts): ALIASES of the palette only, never a new colour. */
  --a-chart-1:var(--a-blue); --a-chart-2:var(--a-green); --a-chart-3:var(--a-amber); --a-chart-4:var(--a-purple);
  --a-chart-5:var(--a-orange); --a-chart-6:var(--a-red); --a-chart-grid:var(--a-line-soft);
  --a-notice-info-edge:var(--a-blue); --a-notice-info-wash:var(--a-blue-soft);
  --a-notice-caution-edge:var(--a-amber); --a-notice-caution-wash:var(--a-amber-soft);
  --a-notice-danger-edge:var(--a-red); --a-notice-danger-wash:var(--a-red-soft);
  --a-notice-good-edge:var(--a-green); --a-notice-good-wash:var(--a-green-soft);

  /* ---- fields (DS-33 to DS-36). The edge is `--a-ctl-edge` above. A floating surface re-binds
     `--a-placeholder` with `--a-faint` below: a custom property resolves where it is declared,
     so an alias declared only here would keep this element's faint. ---- */
  --a-field-bg:var(--a-bg);
  --a-placeholder:var(--a-faint);
  --a-focus:2px solid var(--a-ring);
  --a-focus-offset:2px;
  --a-focus-inset:-2px;
}

/* Custom team themes come free: JS/core/theme-custom.js sets inline custom properties on <html>, so
   roles follow their canonical tokens. Only `--a-float` (a mix) and `--a-gold` (not derived;
   emphasis, never status), `--a-now`, `--a-on-now` and `--a-now-past` (the now line, outside the team palette) are restated for light mode. */
/* Compound selector: `.alt-app` IS the body, so `body.theme-light .alt-app` never matched (gold stayed
   at dark's 2.03:1). Both `:root` and `body` forms are needed since the boot script stamps only <html>.
   See sys_design-system.md "The Suite's token layer". */
:root.theme-light .alt-app,
:root.theme-light.alt-app,
body.theme-light.alt-app,
body.theme-light .alt-app{
  /* Plain declaration first, for the same reason as the dark half above. */
  --a-float:var(--panel-2);
  --a-float:color-mix(in srgb, var(--panel-2) 97%, #000 3%);
  --a-gold:#b06d05;
  --a-gold-soft:rgba(176,109,5,.14);
  --a-now:#c4143c;
  --a-on-now:#fff;
  --a-now-past:rgba(255,255,255,.65);
  --a-focus-wash:#f1f6f3; --a-lunch-wash:#f9f4f0; --a-flight-wash:#f6f4f9;
  --a-shadow:0 10px 30px rgba(19,32,54,.14);
  --a-shadow-sm:0 4px 14px rgba(19,32,54,.10);
  --a-shadow-lg:0 24px 60px rgba(19,32,54,.22);
}

/* Dark: 9% accent on --a-raised. Light: 6% accent on white (focus rgb 241,246,243; lunch rgb 249,244,240), at least 17 levels lighter
   than a free slot's rgb(215,229,226) on every channel, because the dark recipe on light's --a-raised reads grey and darker. */
@supports (color: color-mix(in srgb, red, red)){
  .alt-app{
    --a-focus-wash:var(--a-raised); --a-lunch-wash:var(--a-raised); --a-flight-wash:var(--a-raised);   /* the check wants a plain value ahead in each rule */
    --a-focus-wash:color-mix(in srgb, var(--a-green) 9%, var(--a-raised));
    --a-lunch-wash:color-mix(in srgb, var(--a-orange) 9%, var(--a-raised));
    --a-flight-wash:color-mix(in srgb, var(--a-purple) 9%, var(--a-raised));
  }
  :root.theme-light .alt-app, :root.theme-light.alt-app, body.theme-light.alt-app, body.theme-light .alt-app{
    --a-focus-wash:#f1f6f3; --a-lunch-wash:#f9f4f0; --a-flight-wash:#f6f4f9;
    --a-focus-wash:color-mix(in srgb, var(--a-green) 6%, #fff);
    --a-lunch-wash:color-mix(in srgb, var(--a-orange) 6%, #fff);
    --a-flight-wash:color-mix(in srgb, var(--a-purple) 6%, #fff);
  }
}

/* Floating surfaces re-bind the faint tier, accent text and control edge to float-derived values.
   The rebind is on the container so descendants are correct without per-component overrides.
   Add every new floating surface here, or its faint text measures 4.13:1. */
.a-menu, .a-modal, .a-preview.a-preview-modal, .a-results, .a-toast, .a-org-pop, .a-info-pop,
.alt-app .sxc-tip, .a-week-h, .a-drawer-h, .a-drawer-tabs, .alt-app .sx-drawer-head, .alt-app .sx-drawer-tabs,
.alt-app .sx-drawer-foot, .a-admin-team-head, .a-tbe-addr, :root.embed-task .recur-pop,
.alt-app .mention-menu, .alt-app .cfg-popover, .alt-app .ut-range-pop, .alt-app .okr-filters-pop,
:root.embed-task .context-menu, :root.embed-task .recur-info-pop, .ofr-name-dialog,
.alt-app .a-tcard-acts .a-btn.sm.a-tcard-act, .alt-app .a-tcard-ro, .a-cg-h, .a-cg-pop,
.a-ask-pickbar, .a-guide-co, .dup-progress,
.account-card, .settings-modal, .modal-card, .mention-picker, .alt-app .mc-card, .alt-app .okr-modal .okr-modal-pane,
.account-title-row, .account-actions, .acct-sig-dlg, .chpw-card, .chpw-card .modal-title-row, .a-chart-tip{
  --a-faint:var(--a-float-faint);
  --a-blue-text:var(--a-float-blue-text);
  --a-red:var(--a-float-red-text);
  --a-ctl-edge:var(--a-float-ctl-edge);
  --a-placeholder:var(--a-float-faint);
}

/* Reduced motion: override at the token, since nearly every transition reads these. `0s` is safe because
   nothing in JS/alt/ listens for `transitionend`; if that changes, use `1ms` as CSS/components.css does. Applies to the person, so
   it is not scoped to a theme or page. */
@media (prefers-reduced-motion: reduce){
  .alt-app{
    --a-quick:0s;
    --dur-quick:0s;
    --dur-micro:0s;
    --dur-surface:0s;
    --dur-exit:0s;
    --dur-progress:0s;
  }
  /* The two places a duration is written as a literal rather than through a token. */
  .alt-app .a-scrim > *{ animation:none; }
  .alt-app *{ scroll-behavior:auto; }
}
