/* ============================================================
   PLANOTRIX DESIGN TOKENS — "Daylight"
   Single source of truth for colour. The marketing site loads
   this same file. Nothing outside this file should contain a
   raw hex value.

   Values here match design/daylight-system.md (the approved
   spec) and design/daylight-prototype.html (the reference
   implementation — wins on any disagreement with the prose).

   Two layers:
     1. Canonical names — what the colour MEANS, using the
        spec/prototype's own vocabulary. Use these.
     2. Legacy aliases  — the old names this codebase already
        uses, kept only so app.css and views/*.css keep working
        unmodified during the UI rebuild. Delete an alias the
        moment its last usage is migrated to the canonical name.

   Colour is a signal here, not a mood. Most of the interface is
   neutral grey; saturation is reserved for things that mean
   something.

   29 Oct 2026: the neutrals (ground, surface, sunk, lines, ink,
   muted, faint, shadows) moved from warm to neutral grey, in both
   themes, and the Won't chip with them. The signals (primary,
   alarm, caution, calm, meters, the Must/Should/Could chips and
   every tint) did not change. design/
   daylight-system.md carries the new tables; the prototype still
   shows the old neutrals and does not win on those.

   public/home.html loads this file too, published at /tokens.css
   by the build (vite.config.js), so the two cannot drift.
   ============================================================ */

:root {
  /* ---- type ---- */
  --disp: 'Fraunces', Georgia, serif;
  --ui: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;

  /* Fraunces ships variable axes. SOFT rounds the terminals — that's
     where the warmth comes from. WONK stays at 0; the quirky variant
     undercuts the seriousness of a verdict. */
  --display-axes: 'SOFT' 40, 'WONK' 0;

  --ground:      #F4F4F1;
  --surface:     #FFFFFF;
  --sunk:        #E9E9E4;
  --line:        #E2E2DC;
  --line-soft:   #EDEDE8;
  --line-strong: #C4C5BE;

  --ink:   #1A1C1F;
  --muted: #5A5F66;
  --faint: #6B7078;

  /* What every shadow is cast in: the ink, as channels, so a shadow
     anywhere reads rgba(var(--shade), .08) instead of carrying its
     own copy of a colour. Not redefined for dark, where cards use a
     hairline instead and the few shadows left fall on near-black. */
  --shade: 26, 28, 31;

  /* What you press: buttons, links, focus, a control's on-state. Ink,
     not blue: blue read as a template default (30 Oct 2026). Blue
     (--primary) stays for what informs: today, New, the Should
     chip, progress, info tints. */
  --action:       #1A1C1F;
  --on-action:    #FFFFFF;
  --action-hover: #33363B;
  /* 2px surface, then 2px ink, around whatever has focus. The inset
     one is for controls whose edge sits against their container. */
  --focus-ring:       0 0 0 2px var(--surface), 0 0 0 4px var(--action);
  --focus-ring-inset: inset 0 0 0 2px var(--action), inset 0 0 0 4px var(--surface);

  --primary:       #1F5AC4;
  --primary-hover: #17479C;
  --alarm:         #C4341C;
  --caution:       #996107;
  --calm:          #0C7A5E;

  --tint-caution:    #F6EBD4;
  --on-tint-caution: #965F07;
  --attn-line:       rgba(150, 95, 7, .25);
  --tint-calm:       #D9EDE4;
  --on-tint-calm:    #0C775C;
  --tint-alarm:      #F7E2D9;
  --on-tint-alarm:   #C0331C;

  --must:      #B8253C;
  --must-bg:   #F9DDE1;
  --should:    #1F5AC4;
  --should-bg: #DFE7F7;
  --could:     #0C775C;
  --could-bg:  #D9EDE4;
  --wont:      #5A5F66;
  --wont-bg:   #E9E9E4;

  --meter-ok:   #0C7A5E;
  --hover-wash: rgba(31, 90, 196, .06);
  --row-hover:  var(--ground);

  --sh-sm:     0 1px 2px rgba(var(--shade), .05), 0 2px 6px rgba(var(--shade), .04);
  --card-line: 1px solid transparent;
  --r-card: 16px;
  --r-btn:  10px;
  --r-pill: 999px;

  /* which theme-toggle glyph shows — crescent in light, sun in dark */
  --show-sun: none;
  --show-moon: block;

  /* Not part of the Daylight spec (no gradient / no second meter
     rank / no primary tint are specified there) — kept so nothing
     that already depends on them breaks, recoloured to sit inside
     the palette. */
  --ground-gradient: linear-gradient(155deg, var(--surface) 0%, var(--ground) 55%, var(--sunk) 100%);
  --tint-primary:    #DDE8FA;
  --on-primary:      var(--surface);
  --meter-tight:     var(--caution);
  --meter-over:      var(--alarm);

  /* ---- legacy aliases — delete as app.css is rewritten ---- */
  --font-display: var(--disp);
  --font-ui:      var(--ui);

  --surface-sunk: var(--sunk);
  --shadow-card:  rgba(var(--shade), .08);
  --hover:        var(--hover-wash);

  --scope-must:      var(--must);
  --scope-should:    var(--should);
  --scope-could:     var(--could);
  --scope-wont:      var(--wont);
  --scope-must-bg:   var(--must-bg);
  --scope-should-bg: var(--should-bg);
  --scope-could-bg:  var(--could-bg);
  --scope-wont-bg:   var(--wont-bg);

  --paper:        var(--ground);
  --card:         var(--surface);
  --ink-soft:     var(--muted);
  --ink-faint:    var(--faint);
  --ink-on-light: var(--on-primary);
  --coral:        var(--primary);
  --coral-hover:  var(--primary-hover);
  --rust:         var(--alarm);
  --teal:         var(--calm);
  --teal-text:    var(--calm);
  --amber:        var(--caution);
  --track:        var(--surface-sunk);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #0E1013;
    --surface:     #171A1F;
    --sunk:        #08090B;
    --line:        #262A31;
    --line-soft:   #1D2026;
    --line-strong: #3A3F48;

    --ink:   #ECEEF2;
    --muted: #A6ADB8;
    --faint: #858C97;

    --action:       #ECEEF2;
    --on-action:    #0E1013;
    --action-hover: #FFFFFF;

    --primary:       #8CBBF2;
    --primary-hover: #A8CCF6;
    --alarm:         #FF9270;
    --caution:       #EFB84E;
    --calm:          #5FD9A8;

    --tint-caution:    rgba(239, 184, 78, .09);
    --on-tint-caution: #EFB84E;
    --attn-line:       rgba(239, 184, 78, .35);
    --tint-calm:       rgba(95, 217, 168, .14);
    --on-tint-calm:    #5FD9A8;
    --tint-alarm:      rgba(255, 146, 112, .12);
    --on-tint-alarm:   #FF9270;

    --must:      #FF9BAB;
    --must-bg:   rgba(255, 155, 171, .12);
    --should:    #8CBBF2;
    --should-bg: rgba(140, 187, 242, .12);
    --could:     #5FD9A8;
    --could-bg:  rgba(95, 217, 168, .12);
    --wont:      #A6ADB8;
    --wont-bg:   rgba(166, 173, 184, .12);

    --meter-ok:   #4FE0AC;
    --hover-wash: rgba(140, 187, 242, .08);
    --row-hover:  rgba(140, 187, 242, .05);

    /* "not muddy": no shadows in dark, a hairline instead */
    --sh-sm:     0 0 0 1px var(--line);
    --card-line: 1px solid var(--line);

    --ground-gradient: linear-gradient(155deg, var(--surface) 0%, var(--ground) 55%, var(--sunk) 100%);
    --tint-primary:    rgba(140, 187, 242, .12);
    --on-primary:      var(--surface);
    --show-sun: block;
    --show-moon: none;
    --meter-tight:     var(--caution);
    --meter-over:      var(--alarm);

    --shadow-card: rgba(0, 0, 0, 0);
  }
}

:root[data-theme="dark"] {
  --ground:      #0E1013;
  --surface:     #171A1F;
  --sunk:        #08090B;
  --line:        #262A31;
  --line-soft:   #1D2026;
  --line-strong: #3A3F48;

  --ink:   #ECEEF2;
  --muted: #A6ADB8;
  --faint: #858C97;

  --action:       #ECEEF2;
  --on-action:    #0E1013;
  --action-hover: #FFFFFF;

  --primary:       #8CBBF2;
  --primary-hover: #A8CCF6;
  --alarm:         #FF9270;
  --caution:       #EFB84E;
  --calm:          #5FD9A8;

  --tint-caution:    rgba(239, 184, 78, .09);
  --on-tint-caution: #EFB84E;
  --attn-line:       rgba(239, 184, 78, .35);
  --tint-calm:       rgba(95, 217, 168, .14);
  --on-tint-calm:    #5FD9A8;
  --tint-alarm:      rgba(255, 146, 112, .12);
  --on-tint-alarm:   #FF9270;

  --must:      #FF9BAB;
  --must-bg:   rgba(255, 155, 171, .12);
  --should:    #8CBBF2;
  --should-bg: rgba(140, 187, 242, .12);
  --could:     #5FD9A8;
  --could-bg:  rgba(95, 217, 168, .12);
  --wont:      #A6ADB8;
  --wont-bg:   rgba(166, 173, 184, .12);

  --meter-ok:   #4FE0AC;
  --hover-wash: rgba(140, 187, 242, .08);
  --row-hover:  rgba(140, 187, 242, .05);

  --sh-sm:     0 0 0 1px var(--line);
  --card-line: 1px solid var(--line);

  --ground-gradient: linear-gradient(155deg, var(--surface) 0%, var(--ground) 55%, var(--sunk) 100%);
  --tint-primary:    rgba(140, 187, 242, .12);
  --on-primary:      var(--surface);
  --show-sun: block;
  --show-moon: none;
  --meter-tight:     var(--caution);
  --meter-over:      var(--alarm);

  --shadow-card: rgba(0, 0, 0, 0);
}
