/* ==========================================================================
   Cozy Tactile · tokens.css
   Single source of truth. Components consume these names, never hex.

   THE PAIR RULE
   Every colour ships as a pair: --color-x (the face) and --color-x-deep
   (its ledge). The deep tone is 15–20% darker and a touch more saturated.
   A new colour without a -deep partner is not a token; it is a bug.

   THE LEDGE RULE
   Anything pressable has a zero-blur bottom shadow in its own -deep tone
   (the ledge) and sinks by exactly that height on press, so it lands flush.
   sm/md controls use a 3px ledge, lg uses 4px. Disabled collapses the ledge
   to 0. Icon tiles use a matching 3px (small) or 5px (default) sink.
   Glass icon tiles use a 2px ledge and sink.

   THE LABEL-INK RULE (why bright tones carry dark text)
   WCAG AA at 13px needs 4.5:1. Paper text on the bright tones measures
   1.95–2.56:1 (mint 2.15, gold 1.95, up 2.08, danger 2.56, down 2.50) and
   can only pass by darkening them to their own -deep values, which would
   flatten the palette. Ink text passes on all of them (mint 5.51, gold 6.08,
   up 5.71, danger 4.64, down 4.74). So: bright tones (action, gold, up,
   danger, down) carry --color-ink; deep tones (plum) and glass carry
   --color-ink-on-colour. Each tone exposes its own --on-* token so a
   component never has to decide. check.mjs enforces exactly these pairings.
   ========================================================================== */

:root {
  /* ---- Paper surfaces (light UI) ------------------------------------- */
  --color-paper: #fffbf4; /* primary light surface */
  --color-paper-warm: #f5eee8; /* secondary surface, icon tiles, top bar */
  --color-paper-sunk: #eadcd4; /* wells, inputs, tracks */
  --color-paper-sunk-deep: #dcc9c2; /* inset top shadow of a well */
  --color-stroke-paper: #dacac3; /* ledge under paper chips */
  --color-stroke-paper-off: #ede1da; /* ledge under a resting/unselected chip */
  --color-panel-stroke: rgb(255 251 244 / 0.9); /* 2px rim on floating tiles */

  /* ---- Ink (text). Warm plum, never grey, never black ----------------- */
  --color-ink: #3b2e3c; /* 12.4:1 on paper */
  --color-ink-sub: #5f4b57; /* brief #71545a, nudged darker so the ladder keeps a step; 7.0:1 on paper-warm */
  --color-ink-muted: #715b67; /* DERIVED: brief #a28b93 measured 2.36:1 on paper-sunk; this is the lightest warm plum-grey at >=4.5:1 (4.6) */
  --color-ink-disabled: #51404d; /* readable on paper and the muted disabled face */
  --color-ink-on-colour: #fbf5f4; /* text on plum and on glass */

  /* ---- Semantic pairs. Face / ledge ----------------------------------- */
  --color-action: #49bd9d; /* fresh mint, paired with berry and honey */
  --color-action-deep: #2c8d73;
  --on-action: var(--color-ink);

  --color-plum: #8b4967; /* Borkshire berry; keep the existing tone API */
  --color-plum-deep: #5f2f48;
  --on-plum: var(--color-ink-on-colour);

  --color-danger: #f47381; /* brief #f36d80, lightened so ink text clears 4.5 (4.64) */
  --color-danger-deep: #b23d52;
  --on-danger: var(--color-ink);

  --color-hint-amber: #e9a63a; /* Borkshire sun yellow; gold face */
  --color-gold-hi: #ffd84d; /* top shine inside gold */
  --color-gold-deep: #d2733a; /* gold rim + thickness */
  --on-gold: var(--color-ink);

  --color-up: #3ec47a; /* stat up, fills and pips */
  --color-up-deep: #1f7f4a; /* extension to the brief; "+4.2%" passes on paper (4.86) */
  --on-up: var(--color-ink);

  --color-down: #f27a6e; /* extension to the brief; ink text clears 4.5 (4.74) */
  --color-down-deep: #b8432f; /* 5.24:1 as text on paper */
  --on-down: var(--color-ink);

  --color-focus-ring: #b76088;

  /* ---- Glass (dark UI over the world). Warm brown-black, never #000 --- */
  --color-glass-pill: #1d10189e; /* ~62% */
  --color-glass-chat: #1c1116bd; /* ~74% */
  --color-glass-well: rgb(255 251 244 / 0.1); /* input well inside glass */
  --color-glass-rim: rgb(255 252 246 / 0.18); /* 1.5px inset rim on glass */
  --color-scrim-modal: #24151fbd;
  --color-scrim-light: #2c1c2680;
  --color-scrollbar-thumb: #78644659;

  /* ---- Shadow ink. Warm brown, used as rgb(var(--shadow-ink) / a) ----- */
  --shadow-ink: 20 12 3;

  /* ---- Elevation ladder (zero-blur ledges) ---------------------------- */
  --shadow-e0: none;
  --shadow-e1: 0 2px 0 rgb(var(--shadow-ink) / 0.4);
  --shadow-e2: 0 3px 0 rgb(var(--shadow-ink) / 0.4);
  --shadow-e3: 0 4px 0 rgb(var(--shadow-ink) / 0.4);
  --shadow-e4: 0 5px 0 rgb(var(--shadow-ink) / 0.4), 0 2px 0 rgb(var(--shadow-ink) / 0.3);
  --shadow-modal: 0 4px 0 rgb(var(--shadow-ink) / 0.28), 0 10px 26px rgb(25 12 19 / 0.34);
  --shadow-menu: 0 4px 0 var(--color-stroke-paper), 0 10px 26px rgb(var(--shadow-ink) / 0.24);
  --shadow-card-on-paper: 0 3px 0 var(--color-stroke-paper), 0 8px 18px rgb(16 12 8 / 0.22);
  --shadow-glass: inset 0 0 0 1.5px var(--color-glass-rim), 0 5px 0 rgb(var(--shadow-ink) / 0.24);

  /* ---- Radii. Chosen by size: <32px tall control, tiles, containers, chips */
  --radius-control: 10px;
  --radius-tile: 14px;
  --radius-panel: 18px;
  --radius-pill: 999px;

  /* ---- Blur ------------------------------------------------------------ */
  --blur-scrim: 3px;
  --blur-glass: 4px;
  --blur-pill: 10px;
  --blur-panel: 12px;

  /* ---- Type ------------------------------------------------------------ */
  --font-display: 'Baloo 2', 'Nunito', 'Varela Round', system-ui, sans-serif;
  --font-text: 'Nunito', 'Baloo 2', 'Varela Round', system-ui, sans-serif;

  /* ---- Spacing (4px scale) -------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* ---- Ledges ---------------------------------------------------------- */
  --ledge-sm: 3px;
  --ledge-md: 3px;
  --ledge-lg: 4px;

  /* ---- Z layers -------------------------------------------------------- */
  --z-world: 0;
  --z-labels: 10;
  --z-hud: 20;
  --z-sheet: 30;
  --z-modal: 40;
  --z-toast: 50;

  /* ---- Motion ---------------------------------------------------------- */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-press: 80ms;
  --dur-fast: 140ms;
  --dur-base: 200ms;
  --dur-slow: 220ms;
  --dur-indicator: 160ms;
  --dur-tween: 480ms;

  /* ---- Skeleton tones (warm, never grey) ------------------------------- */
  --sk-base: var(--color-paper-sunk);
  --sk-shine: var(--color-paper);

  /* ---- Ground ----------------------------------------------------------
     The page sits on a warm brown-black ground near the glass tones, so
     paper and glass materials are shown the way a HUD sees them: over a dark
     world. [data-ground="paper"] on the root element swaps it for paper-warm. */
  --color-ground-dark: #21181d;
  --color-ground-dark-deep: #160f13;
  --color-ground-paper: var(--color-paper-warm);
  --color-page-bg: var(
    --color-ground-dark
  ); /* explicit body background so the page reads on any host */
}

:root[data-ground='paper'] {
  --color-page-bg: var(--color-ground-paper);
}
