/* ─────────────────────────────────────────────────────────────────────────
   tokens.css — the shared foundation for every brignano surface.

   Consumers:
     brignano.io   (Next / Tailwind v4)  — marketing tier
     life          (Astro)               — tool tier
     homelab, driftwood, future tools    — tool tier

   ── ONE HUE, ONE MEANING ───────────────────────────────────────────────
   Every colour here answers exactly one question, everywhere it appears,
   on every surface. That is the whole design of this file.

     NEUTRAL     the page. Most of every screen.
     --i-*       "you can act on this"      cobalt
     --success   "settled, confirmed, done" forest
     --attention "this wants you"           larch amber
     --danger    "this has gone wrong"      rust
     --mark      identity — a drawn mark, not a UI colour

   Two consequences worth stating out loud, because both were mistakes in
   earlier drafts of this system:

   1. ATTENTION IS ONE MEANING. A warning toast, the NEXT UP strip, and a
      deposit closing in six days are the same message at different
      volumes, so they are the same colour. There is no separate "warning"
      hue and no separate "now/next" hue.

   2. IDENTITY IS NOT A FILL. Amber used to be the brand colour AND the
      warning colour, managed by a rule about scale. Rules enforced by
      remembering get forgotten. So identity moved to the thing that was
      always carrying it — the monogram, the type, restraint — and --mark
      exists only to ink a graphic. It is never a button, chip, wash, or
      border. The naming is the enforcement.

   ── RULES THAT MAKE THIS FILE TRUSTWORTHY ──────────────────────────────
   1. NEVER hardcode a hex outside this file. A literal survives a theme
      change silently — that is how `life`'s status pills sat light grey in
      dark mode for months.
   2. Every colour is ONE declaration holding both themes:
      `light-dark(<light>, <dark>)`. There is no dark list to keep in step.
      The arguments are always concrete colours, never a var() to another
      theme-dependent token — nested light-dark() is legal CSS, but not
      every engine has been verified to resolve it. Where that forces a
      value to repeat (a wash repeats its hue), `npm run check` holds the
      copies to their source.
   3. Ratios in the comments are MEASURED. Change a value, re-measure it.

   See DESIGN.md for the rules that govern use, DECISIONS.md for why.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Themes ─────────────────────────────────────────────────────────────
   One declaration per colour, light value first: light-dark(<light>, <dark>).
   The browser picks the side from the element's color-scheme:

     default            follows the OS (light dark below)
     [data-theme]       the in-app toggle, which must WIN over the OS
                        — `light` forces light under a dark OS

   Because the pick happens where a colour is USED, not where it's declared,
   [data-theme] (or color-scheme) on ANY element themes that subtree — a dark
   hero band on a light page is one attribute. Give that element its own
   `background: var(--bg)`; it doesn't inherit the page's.

   Dark is selected, not inverted:
   1. Not pure black. #0d0d0f — pure black behind bright text causes
      halation and is fatiguing at night, which is when a personal tool
      actually gets opened.
   2. Surfaces LIGHTEN with elevation instead of gaining borders.
   3. Accents lift in luminance rather than shifting hue, and washes carry
      a higher mix — 12% over #0d0d0f is invisible where it reads on white.

   Ratios are given light / dark. */
:root {
  color-scheme: light dark;
}
[data-theme='light'] {
  color-scheme: light;
}
[data-theme='dark'] {
  color-scheme: dark;
}

:root {
  /* ── Neutral ramp ─────────────────────────────────────────────────────
     Twelve steps, up from five. The gap that mattered most: there was no
     hover or pressed background token, so every interactive surface in
     both repos was improvising.

     Deliberately COOL — a cool grey lets the warm mark and the amber
     attention state read as warm, instead of muddying into them.

     ONE TEMPERATURE, top to bottom, both themes: every tinted step sits at
     OKLCH hue 286° (±3°, `npm run check` holds it). Chroma is a whisper at
     the ends (~0.0015 at n-25) and peaks in the mid-tones (~0.015 at
     n-700), where a grey reads most neutral-flat without it. Only pure
     white (light n-0) is untinted. An earlier ramp mixed warm hairlines
     (106°) with cool text, so a border and the label beside it disagreed.

     Changing a step: keep its OKLCH lightness, keep the hue, re-run the
     check. */
  --n-0: light-dark(#ffffff, #0d0d0f);
  --n-25: light-dark(#fafafb, #131316);
  --n-50: light-dark(#f3f3f4, #17171a);
  --n-100: light-dark(#ececee, #202024); /* hairline */
  --n-200: light-dark(#e1e1e4, #2a2a2f); /* hover surface */
  --n-300: light-dark(#cbcbce, #3a3a41); /* strong border, pressed surface */
  --n-400: light-dark(#a9a9ae, #55555e);
  --n-500: light-dark(#8a8a8f, #8b8b93); /* 3.44:1 — UI marks only, never text / 5.29:1 */
  --n-600: light-dark(#6b6b73, #9c9ca4); /* muted label 5.28:1 */
  --n-700: light-dark(#52525b, #a8a8b0); /* secondary 7.73:1 / 7.58:1 */
  --n-800: light-dark(#33333a, #d0d0d5);
  --n-900: light-dark(#111114, #f2f2f4); /* primary 18.85:1 / 16.00:1 */

  /* Semantic aliases. Components use THESE, not the raw steps.
     Where a role sits on a different step in each theme, the step's two
     hexes are written out (rule 2) and named in the comment; the check
     holds them to the ramp. */
  --bg: light-dark(#fafafb, #0d0d0f); /* n-25 / n-0 */
  --card: light-dark(#ffffff, #17171a); /* n-0 / n-50 */
  --surface-hover: var(--n-100);
  --surface-active: var(--n-200);
  /* Sticky chrome — a header or toolbar that content scrolls under, usually
     with `backdrop-filter: blur()`. 92% of the surface it sits on: the card
     in light, the page ground in dark, where cards are lighter than the
     page. A token so consumers never color-mix() one (DESIGN.md §11). */
  --surface-sticky: light-dark(color-mix(in srgb, #ffffff 92%, transparent), color-mix(in srgb, #0d0d0f 92%, transparent)); /* card / bg */
  --ink: var(--n-900);
  --ink-soft: var(--n-700);
  --slate: light-dark(#6b6b73, #8b8b93); /* n-600 / n-500 — text-safe: eyebrows, axis labels, captions */
  --line: var(--n-100);
  --line-soft: var(--n-50);
  --line-strong: var(--n-300); /* 1.62:1 — decoration, not a boundary */
  /* The edge that tells you a control is there: inputs, secondary buttons.
     WCAG 1.4.11 asks 3:1 of a boundary you need to find the control, which
     --line-strong is nowhere near. Light is n-500 (3.44:1 on card, 3.29:1
     on bg); dark sits between n-400 and n-500, which the ramp has no step
     for (3.39:1 on card, 3.68:1 on bg). */
  --line-control: light-dark(#8a8a8f, #6b6b73);
  --on-dark: light-dark(#fafafb, #0d0d0f); /* n-25 / n-0 */
  /* A phone's bezel (.pp-device). A phone is a dark object in either theme,
     so this stays dark rather than flipping with --ink, which would draw a
     near-white bezel in dark mode. Dark lifts it to n-300 so the frame still
     has an edge against the near-black page. Decoration, not a boundary. */
  --device: light-dark(#111114, #3a3a41); /* n-900 / n-300 */

  /* ── Interactive — cobalt ─────────────────────────────────────────────
     Everything you can act on: links, buttons, focus, selection. Chosen to
     be semantically INERT — it carries no inherited meaning the way amber,
     green and red do — and complementary to the mark hue, so identity and
     affordance never compete for the same attention.

     Every step sits at OKLCH hue 256° (`npm run check` holds it), as near
     to larch's opposite (~248°) as sRGB allows while keeping cobalt's
     chroma. It is deliberately NOT Tailwind's blue-600 (263°, a touch
     violet and electric): same affordance, our own colour (ADR-0008).

       --i          fill               5.18:1 / 3.78:1  (label 5.18 / 4.73)
       --i-ink      link/icon/focus    6.78:1 / 7.07:1
       --i-hover    hover fill         label 8.65:1 / 5.88:1
       --i-ink-hover  hovered link     8.65:1 / 9.95:1 on --card
       --i-pressed  pressed fill       label 10.44:1 / 7.52:1

     The fill is a saturated mid-cobalt with a WHITE label in both themes,
     and hover and pressed step darker in both. Dark used to lift the fill
     to the ink's pale blue with a dark label, which read as washed out on
     the most important control on the screen. So in dark the fill and the
     ink are now different steps: --i fills, --i-ink is what you read
     (links, icons, the focus ring). The dark fill is as light as a white
     label allows (4.5:1), which is what keeps it 3:1 as a mark on --card,
     --bg and its own wash.

     DISABLED IS NEUTRAL, NEVER HUED — a greyed-out control must stop
     signalling "click me". */
  --i: light-dark(#076bd3, #0371e0);
  --i-ink: light-dark(#0159b5, #6ba5f3);
  --i-hover: light-dark(#014a97, #0062c7);
  /* A hovered link is TEXT, so it follows the ink, not the fill: in dark the
     fill's hover is too deep to read on a dark page (about 3.3:1). */
  --i-ink-hover: light-dark(#014a97, #98c4ff);
  --i-pressed: light-dark(#003e82, #0553a6);
  --i-surface: light-dark(color-mix(in srgb, #076bd3 12%, transparent), color-mix(in srgb, #0371e0 20%, transparent));
  --i-line: light-dark(color-mix(in srgb, #076bd3 32%, transparent), color-mix(in srgb, #0371e0 44%, transparent));
  --i-selection: light-dark(color-mix(in srgb, #076bd3 26%, transparent), color-mix(in srgb, #0371e0 30%, transparent));
  --on-i: light-dark(#ffffff, #ffffff);
  /* A button filled with danger (.btn-danger), and its label. Its own
     tokens so the state hue --danger can stay a pale, readable rust in dark
     (messages, pills, field errors) while the button is as deep as the
     primary beside it: as light as a white label allows, stepping darker on
     hover and press (ADR-0015). In light the fills ARE --danger and
     --danger-ink; `npm run check` holds them to those.

       --danger-fill          label 6.10:1 / 4.58:1   on --card 3.91:1 in dark
       --danger-fill-hover    label 7.92:1 / 5.65:1
       --danger-fill-pressed  label 7.92:1 / 6.96:1 */
  --danger-fill: light-dark(#a4442c, #be563c);
  --danger-fill-hover: light-dark(#8a3722, #ad472e);
  --danger-fill-pressed: light-dark(#8a3722, #9d381e);
  --on-danger: light-dark(#ffffff, #ffffff);
  --i-disabled-bg: var(--n-200);
  --i-disabled-ink: var(--n-400);

  /* ── State ────────────────────────────────────────────────────────────
     Three hues, one meaning each, identical on every surface and both
     tiers. Always shipped with an ICON AND A WORD — colour is never the
     only signal.

       --success    settled · confirmed · done · succeeded    6.29:1 / 8.15:1
       --attention  now · next · warning · needs you          6.08:1 / 8.17:1  (ink)
       --danger     overdue · failed · invalid                6.10:1 / 6.06:1

     `--info` is the interactive hue on purpose: an informational message
     is the same "neutral, no action implied" register as a link.

     `-ink` is the text-safe step; the bare token is for marks and fills.
     `-surface` and `-line` are the wash and its edge: 12% / 32% of the hue
     in light, 20% / 44% in dark. */
  --success: light-dark(#2f6b4f, #6fbf95);
  --success-ink: light-dark(#245740, #8fd4ae);
  --attention: light-dark(#b4741f, #e0a44f); /* 3.85:1 in light — mark/fill only, NOT text */
  --attention-ink: light-dark(#8a5714, #e0a44f); /* 6.08:1 / 8.17:1 — mark and label converge in dark */
  --danger: light-dark(#a4442c, #e07a5f);
  --danger-ink: light-dark(#8a3722, #ec9880);
  --info: var(--i);
  --info-ink: var(--i-ink);

  --success-surface: light-dark(color-mix(in srgb, #2f6b4f 12%, transparent), color-mix(in srgb, #6fbf95 20%, transparent));
  --attention-surface: light-dark(color-mix(in srgb, #b4741f 12%, transparent), color-mix(in srgb, #e0a44f 20%, transparent));
  --danger-surface: light-dark(color-mix(in srgb, #a4442c 12%, transparent), color-mix(in srgb, #e07a5f 20%, transparent));
  --info-surface: var(--i-surface);
  --success-line: light-dark(color-mix(in srgb, #2f6b4f 32%, transparent), color-mix(in srgb, #6fbf95 44%, transparent));
  --attention-line: light-dark(color-mix(in srgb, #b4741f 32%, transparent), color-mix(in srgb, #e0a44f 44%, transparent));
  --danger-line: light-dark(color-mix(in srgb, #a4442c 32%, transparent), color-mix(in srgb, #e07a5f 44%, transparent));
  --info-line: var(--i-line);

  /* ── Diff ─────────────────────────────────────────────────────────────
     What a change did to a thing: a deploy, a plan, a pull request. Aliases
     of the state hues, so a diff adds no hue of its own (DESIGN.md §9):

       --diff-added    created by this change      success — settled
       --diff-changed  modified by this change     interactive — informational
       --diff-removed  removed by this change      danger — can lose data

     Always with a symbol and a word (+ added, ~ changed, − removed). */
  --diff-added: var(--success);
  --diff-added-ink: var(--success-ink);
  --diff-added-surface: var(--success-surface);
  --diff-changed: var(--i);
  --diff-changed-ink: var(--i-ink);
  --diff-changed-surface: var(--i-surface);
  --diff-removed: var(--danger);
  --diff-removed-ink: var(--danger-ink);
  --diff-removed-surface: var(--danger-surface);

  /* ── Code ─────────────────────────────────────────────────────────────
     Syntax colour without a rainbow (DESIGN.md §3): keywords take the
     interactive cobalt ink, everything else is a step of the neutral ramp,
     and weight and italics do the rest. All aliases, so code adds no hue.

       --code-surface   the block, inset one step below the card
       --code-keyword   if, return, const — cobalt ink
       --code-string    literals — secondary ink
       --code-comment   comments — slate, set in italics
       --code-highlight a highlighted line — the cobalt wash */
  --code-surface: var(--bg);
  --code-ink: var(--ink);
  --code-keyword: var(--i-ink);
  --code-string: var(--ink-soft);
  --code-comment: var(--slate);
  --code-highlight: var(--i-surface);

  /* ── Mark — identity ──────────────────────────────────────────────────
     Inks a GRAPHIC: a product's glyph, the A|B monogram, a hero rule. That is
     the entire permitted use.

     It is NOT a button, chip, badge, wash, border, or link. If you are
     reaching for it to tint a UI element, the answer is a neutral or a
     state colour — see DESIGN.md §3.

     It shares larch amber with --attention deliberately: the identity and
     the attention state are the same warmth, and because --mark never
     appears as a UI surface the two can never be mistaken for each other
     in the same context. */
  --mark: light-dark(#b4741f, #e0a44f);
  --mark-ink: light-dark(#8a5714, #e0a44f); /* when the mark carries a label, 6.08:1 / 8.17:1 */

  /* ── Product marks — one per product page ─────────────────────────────
     Each product's marketing page picks one, so Driftwood, Guidebook and
     Sites don't read as the same page with the words swapped (ADR-0011).
     Same contract as --mark: it inks the product's graphics (its glyph,
     the hero rule, the proof's stage, step numerals), never a button,
     link, text or state. Hues sit away from cobalt (act), forest
     (success), amber (attention) and rust (danger). All ≥ 3:1 on --bg and
     --card in both themes. product-page.css maps one onto --pp-mark via
     data-mark on .pp. */
  --mark-teal: light-dark(#0e7c86, #4cc0cb);
  --mark-violet: light-dark(#7148c9, #a990f2);
  --mark-magenta: light-dark(#b1366f, #ea7fb0);
  /* The mark in force here (ADR-0014): the family amber until `data-mark`
     on an ancestor, usually <html>, names a product's. A brand glyph and
     .rule draw in this, so a product's colour follows it from its marketing
     page into its app and onto its error pages. The [data-mark] rules below
     only point it at a token above; they declare no colour of their own. */
  --mark-current: var(--mark);

  /* ── Legacy aliases ───────────────────────────────────────────────────
     Kept so existing `life` components keep compiling. Do not use in new
     work — reach for the semantic tokens above.

     --larch-deep is written out rather than aliased, because "deep"
     inverts: darker in light, BRIGHTER in dark. An alias to either role
     silently changes one theme — it moved .pill-active from #f0bd74 to
     #e0a44f before this was caught. */
  --forest: var(--success);
  --forest-deep: var(--success-ink);
  --larch: var(--attention);
  --larch-deep: light-dark(#8a5714, #f0bd74);
  --rust: var(--danger);
  --rust-deep: var(--danger-ink);
  --gold: var(--slate);

  /* ── Type ─────────────────────────────────────────────────────────────
       --sans     Geist — body and headings, both tiers
       --mono     IBM Plex Mono — data that must read precise
       --display  Silkscreen — MARKETING TIER ONLY (monogram, hero eyebrows)

     NOTE: Geist is not yet installed in `life` — only brignano.io
     self-hosts it. Until added, the stack falls through to Inter and that
     repo renders as before. Adding it is a deliberate separate change. */
  --sans: 'Geist', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  --display: var(--sans);

  /* Weight, leading and tracking. Sizes are per tier (below); these are
     not. Three weights, and nothing lighter or bolder.
     (--weight-heavy is the one exception: the display treatment, .display
     and .stamp, ADR-0014.) Leading is unitless
     so it scales with the text: display for large headings, title for
     titles, ui for interface text, body for paragraphs. Tracking
     only ever tightens a heading or opens an uppercase mono eyebrow
     (and the .stamp monogram, whose bar closes up otherwise).

     Named by role, not tight/snug/normal: Tailwind owns those names
     (--leading-tight, --tracking-tight) and an unlayered token here would
     silently change what its utilities do in every consumer. */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-heavy: 800;
  --leading-display: 1.15;
  --leading-title: 1.3;
  --leading-ui: 1.4;
  --leading-body: 1.6;
  --tracking-title: -0.01em;
  --tracking-display: -0.025em;
  --tracking-caps: 0.08em;

  /* ── Stacking ─────────────────────────────────────────────────────────
     Named by what sits above what. Dialogs, popovers and sheets use the
     browser's top layer and need none of these.

       --z-raised  a control above its card's stretched link, a sticky th
       --z-sticky  a header content scrolls under
       --z-float   a label floating over the page (the rail's tooltip)
       --z-skip    the skip link, above the header it skips
       --z-toast   toasts, above everything not in the top layer */
  --z-raised: 1;
  --z-sticky: 10;
  --z-float: 20;
  --z-skip: 30;
  --z-toast: 40;

  /* ── Space ── 4px base. Tiers differ by which steps they reach for. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* ── Shape & elevation ────────────────────────────────────────────────
     In LIGHT these are shadows; in DARK the surface lightens instead, and
     the shadow only has to separate it from a near-black ground.

     light-dark() switches colours, not geometry, and the two themes' blur
     differs. So shadows 2 and 3 carry one layer per theme, with the other
     theme's layer transparent — it draws nothing. */
  --radius-sm: 6px;
  --radius-control: 8px; /* buttons, inputs, selects, the segmented control, menu items */
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px light-dark(rgba(17, 17, 17, 0.04), rgba(0, 0, 0, 0.45));
  --shadow-2:
    0 2px 8px light-dark(rgba(17, 17, 17, 0.07), transparent),
    0 2px 10px light-dark(transparent, rgba(0, 0, 0, 0.55));
  --shadow-3:
    0 8px 24px light-dark(rgba(17, 17, 17, 0.10), transparent),
    0 10px 28px light-dark(transparent, rgba(0, 0, 0, 0.65));
  --scrim: light-dark(rgba(17, 17, 17, 0.55), rgba(0, 0, 0, 0.68));
  --shadow: var(--shadow-1); /* legacy alias */

  /* ── Motion ───────────────────────────────────────────────────────────
     Content is ALWAYS visible by default; motion is enhancement layered on
     top, never the thing that makes content appear. brignano.io shipped a
     homepage whose contact CTA was invisible on 100% of loads because an
     animation library owned the visible state. See DESIGN.md §7. */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-slow: 600ms;
}

:root {
  /* Tool-tier scale — compact, because scanning beats reading.
     Declared BEFORE the marketing tier on purpose: `:root` and
     `.tier-marketing` have the same specificity, so on <html> whichever
     comes later wins. With this block last, the class did nothing. */
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --section-gap: var(--s6);
  --measure: 780px;
}

/* On a phone the tool tier's smallest step rises from 11px to 12px: fine
   beside a mouse, too small at arm's length. The marketing tier's is
   already 12px. */
@media (pointer: coarse) {
  :root:not(.tier-marketing) {
    --text-xs: 0.75rem;
  }
}

/* ── Marketing tier ─────────────────────────────────────────────────────
   `class="tier-marketing"` on <html> (brignano.io). Unlocks the display
   face and opens the type scale. COLOUR IS IDENTICAL ACROSS TIERS — that
   is the point of this file. Tool tier is the default. */
.tier-marketing {
  --display: 'Silkscreen', var(--mono);
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.75rem;
  --text-4xl: clamp(2.75rem, 1rem + 4.5vw, 4rem); /* rem term keeps it zoomable (WCAG 1.4.4) */
  --section-gap: var(--s9);
  --measure: 68ch;
}

/* ── A product's mark, wherever the product is ──────────────────────────
   One attribute per product: <html data-mark="teal">. Works on any element,
   so a page that shows two products can mark each one's section. */
[data-mark='teal'] {
  --mark-current: var(--mark-teal);
}
[data-mark='violet'] {
  --mark-current: var(--mark-violet);
}
[data-mark='magenta'] {
  --mark-current: var(--mark-magenta);
}

::selection {
  background: var(--i-selection);
}

/* Native checkboxes, radios, range and progress take the control hue
   instead of the browser's own blue. */
:root {
  accent-color: var(--i);
}

/* Paper is light. Printing a dark page spends ink on the background and
   most browsers drop backgrounds anyway, leaving pale text on white. After
   the [data-theme] rules above so it wins over an in-app dark choice. */
@media print {
  :root,
  [data-theme] {
    color-scheme: light;
  }
}

/* Ships here so no surface can forget it. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* View transitions live on pseudo-elements the rule above can't reach. */
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
