/*
  Tiles — every CHROME value in one file (E33.1).

  THE CONTRACT IN ONE LINE: this is the only place in the app that spells out what the chrome looks
  like. `style.css` reads these custom properties and decides LAYOUT; the Rust panels carry class
  hooks. The gate runs the lint `chrome_tokens_only` (`cargo xtask chrome-tokens-only`), which reads
  every `.css`, `index.html`, `.rs` and `.js` file under `crates/tiles-app/` except this one and fails
  on:

    * a hex / `rgb(` / `rgba(` / `hsl(` / `hsla(` / `oklch(` / `oklab(` color literal,
    * a `font-family` whose value is not a `var(`,
    * a `transition` or `animation` that names a duration instead of a `var(`.

  An exception goes in `theme-allow.txt` WITH a reason, and E33.1 expects that list to be empty — it is.

  ART IS NOT CHROME (ADR §11: "the canvas background is a document property and never follows the
  theme"). A slot's color reaches the page as one `--sw:#cba6f7` on the control that shows it, the
  scheme arrives as the `--sN`/`--bg`/`--grid` write `renderer::paint_vars` owns (E03.1), and no token
  here names either. That is why `e2e/smoke.spec.js` asserts the artwork is identical across a theme
  flip while this file is free to change.

  MOVING A VALUE HERE IS A NO-OP BY CONSTRUCTION, and it is pinned that way: `e2e/theme.spec.js`
  compares a 1600x1000 screenshot of the chrome at rest against the capture taken BEFORE the values
  were moved (`e2e/__screens__/m15u-00-chrome-1600x1000.png`), pixel for pixel. The next item that
  WANTS a new look — M15U.09's light paper workspace — changes numbers in this file on purpose,
  retakes the shot, and is the only thing that may.
*/

:root {
  /* E33.2 (M15U.09): "LIGHT is the default. `color-scheme` lists `light` first, so "no preference"
     means light; dark stays available (`UiSettings.theme`)". ADR §11's rule still holds — the order
     is the errata's, and it is the ONLY thing that changed in it. `data-theme="dark"|"light"` below
     pins the scheme when `UiSettings.theme` says which. */
  color-scheme: light dark;

  /* E33.2's seven approved values for the LIGHT workspace, spelled once, here. The dark half of each
     pair is today's Mocha chrome ("Dark values: keep today's dark chrome, with the same
     `--accent`"), so the two schemes are two columns of the same table rather than two designs.

     The names are the ROLES E33.2 gives them: `--paper` is the workspace ground, `--surface` what a
     button, menu or card is cut from, `--ink` text, icons and the SECONDARY ring, `--muted` the
     labels and values (6.9:1 on paper), `--rule` the 1 px dividers, `--dot` the dot grid, and
     `--accent` the ONE accent — Dracula pink in both schemes, unthemed on purpose so "the accent" is
     one color whatever the owner is looking at. The role names below (`--stage`, `--face`, `--line`,
     …) are what `style.css` reads; they are ALIASES of these seven, which is how one accent, one
     ground and one rule color stay one of each. */
  --paper: light-dark(#faf8f3, #181825);
  --surface: light-dark(#ffffff, #1e1e2e);
  --ink: light-dark(#282a36, #cdd6f4);
  --muted: light-dark(#4a5480, #bac2de);
  --rule: light-dark(#e4e0d6, #313244);
  --dot: light-dark(#cfc9bb, #313244);
  --accent: #ff79c6;

  /* THE ONE ACCENT, and the four places it may be read (E33.2: "`--accent` is used ONLY for the
     current tool, the primary swatch ring, the selection outline and the keyboard focus ring; never
     for text"). The gate's lint `accent_uses_only_four` (`cargo xtask accent-uses-only-four`) reads
     this file and `style.css` and fails on a fifth, so "sparingly" is a check rather than an intent.

     Three of the four are RINGS and rings are shorthands, so the accent is spelled into the three
     carrier tokens below and nowhere else outside the four rules: `--focus-ring` (use 1: the keyboard
     ring, read by every `:focus-visible` rule), `--mark-ring` (uses 2 and 3: the current tool and the
     PRIMARY swatch), and `--select-ring` (use 4: the outline the chrome paints over the canvas —
     E21.5's dashed rectangle, which its own text already calls "a dashed ACCENT rectangle"). The
     marching ants of a live selection keep core's black/white pair (`render::overlay`): they sit on
     ARTWORK of any color, and pink on pink is invisible. Everything else that used to be ringed is
     ink now — `--mark-ring-ink` and `--focus-ring-dashed` are the two places that used the accent
     because there was only one ring token. */
  --focus-ring: 2px solid var(--accent);
  --mark-ring: 3px solid var(--accent);
  --select-ring: var(--accent);

  /* Sizes. `--ctl-h` is WCAG 2.5.8's floor (24 px) and the ONLY control height in the app;
     `--swatch` is bigger because ADR §11 calls the strip "the largest control". The two row heights
     are one number each: the strip sizes itself, so its swatch, padding and rings cannot drift out
     of a height someone typed somewhere else. */
  /* E33.2: "`--ctl-h` goes from 24 to 30 px (the strip-era 24 px floor stays the minimum for dense
     rows)". 30 is WCAG 2.5.8's 24 px floor plus a thumb's worth, and it is STILL one number. */
  --ctl-h: 30px;
  --swatch: 44px;
  /* The gap BETWEEN swatches, and the measure the M9.04 insertion caret is positioned by (`.caret`).
     A named number because two rules read it: the row's `gap` and the caret's `left`, and a caret
     computed against a gap the row does not use points at the wrong seam. */
  --sw-gap: 10px;
  /* The tool chip (M8.20). A square, because the rail is a column of icons and a 24 x 40 chip makes
     the badge a second column of its own: 30 px is over WCAG 2.5.8's floor, and fifteen of them plus
     their gaps fit the stage row of a 720 px window without the rail needing to scroll. */
  --tool: 30px;
  /* The rail's column: a chip, its padding each side, and the scrollbar's share when a short window
     makes the column scroll. */
  --rail-w: 38px;
  /* M9.07: the right panel's column width, and the icon-tab width it collapses to below 1100 px.
     `--panel-tab-w` is over the 24 px floor with room for the letter and the chevron; the coarse
     block below raises it to the 44 px touch floor. */
  /* E27.1: the right column's width IS `UiSettings.right_width` (default 340, clamped 260..=560 in
     core). The app writes the bare NUMBER on `:root` as `--right-w`; the unit is declared here, so the
     state carries a setting and the stylesheet keeps the px — the same split as `.strip-pad`'s `--hide`.
     The fallback is the default, so the very first paint is the width the app then confirms. */
  --right-w: 340;
  --panel-w: calc(var(--right-w) * 1px);
  /* The narrow column (E27.1: "below 1100 px … a 32 px grid in a 200 px column"). */
  --panel-narrow-w: 200px;
  /* The palette grid's plate: 48 px wide (E27.1), 32 px in the narrow column, and the coarse-pointer
     bump below raises both, as it does every other control. */
  --grid-swatch: 48px;
  --grid-narrow-swatch: 32px;
  /* The splitter's visible handle; the hit area is 24 px (WCAG 2.5.8) and lives in `style.css`. */
  --splitter-w: 6px;

  /* M15L.01 (E30.1): the right side's TWO columns at a window width >= 1440 px — the user's
     `--panel-w` twice over, plus the one splitter handle between the rail and them. The breakpoint
     itself is `style.css`'s (it is layout), this is the WIDTH it switches to. */
  --panel-wide-w: calc(var(--panel-w) * 2 + var(--splitter-w));

  /* M15L.01 (E30.1): a layers row's thumbnail. One square, `--ctl-h` tall so the row that carries it
     is a row a pointer can hit, and the `viewBox` core hands over does the aspect. */
  --layer-thumb: 30px;
  --panel-tab-w: 40px;
  --topbar-h: 32px;
  --status-h: 26px;

  /* Spacing. The four values the bars and the panels actually share; a rule that needs something
     between them is a rule about one element, and it stays where that element is styled. */
  /* E33.2: "section padding 14-18 px" — the column's sections breathe at the LOW end of that, because a
     340 px column also carries the 30 px controls and the harmony row's swatches, and a section whose
     content clips is not an open one. Both numbers are still the only two a section reads. */
  --gap: 8px;
  --pad-x: 14px;
  --pad-y: 14px;
  --bar-pad-x: 10px;
  --bar-pad-y: 3px;

  /* Radii, spelled by their number so a move is checkable against the value it replaced. `--radius`
     is the 6 px the strip-era chrome was built on and the one most rules read; the ramp around it is
     what the dialogs, menus and chips ended up with, and M15U.09 is free to collapse it. */
  --radius-2: 2px;
  --radius-3: 3px;
  --radius-4: 4px;
  --radius-5: 5px;
  --radius: 6px;
  --radius-8: 8px;
  --radius-10: 10px;
  --radius-11: 11px;
  --radius-pill: 999px;
  --round: 50%;

  /* Chrome colors, resolved per scheme (Catppuccin Latte light / Mocha dark — the same two schemes
     the starter document ships, so UI and artwork read as one product).

     `light-dark(LIGHT, DARK)`: the FIRST argument is the LIGHT one, which is the opposite of how the
     app reads (Mocha is the default look — see `color-scheme` above). An argument swap is invisible in
     a screenshot taken in the wrong scheme, which is why `e2e/smoke.spec.js` pins ONE named color per
     scheme rather than "the two differ". */
  /* The roles `style.css` reads, now ALIASES of the seven values above (see the note there). A bar,
     a card and a control are all cut from `--surface`; the workspace behind them is `--paper`; every
     divider, panel edge and control edge is `--rule`. Two dark halves have no light twin because
     there is nothing to alias — `--chrome-2` (the pressed bar, the lit chip's face) and `--ctl-line`
     in dark, where Mocha has a second grey and the paper has no need of one. */
  /* The bars are `--surface` in the light (one sheet with the controls, divided by `--rule`) and
     today's Mocha base in the dark — E33.2: "Dark values: keep today's dark chrome". */
  --chrome: light-dark(#ffffff, #11111b);
  --chrome-2: light-dark(#f2efe7, #181825);
  --stage: var(--paper);
  --face: var(--surface);
  --line: var(--rule);
  --ctl-line: light-dark(#d7d1c4, #45475a);
  --ink-dim: var(--muted);
  /* The SECONDARY ring (E33.2: ink is "text, icons, the secondary ring") — the inset ring of a
     SECONDARY swatch, the scheme tab that is lit, and every mark that is not one of the four. */
  --ring: var(--ink);
  /* The "this text is not a color" red (M9.08's hex border, R3 COL-05). Catppuccin's own red per
     scheme — Latte `red`, Mocha `red` — so the alarm color is still the palette the artwork ships. */
  --bad: light-dark(#d20f39, #f38ba8);
  /* M9.12: the other half of a verdict. A contrast badge says PASS in the same voice it says FAIL, so
     the pair needs a second signal color; `--good` is Catppuccin's green in both palettes, the same
     two inks every other token here is drawn from. */
  --good: light-dark(#40a02b, #a6e3a1);
  /* E21.5's third state: a room that is neither open nor lost. Amber, one step off `--bad`, per
     scheme like everything else here (it sat on `.pairbar` until E33.1 moved it up). */
  --pair-wait: light-dark(#fe8019, #fab387);

  /* Shadows. `--shadow` is the raised card (dialogs, the flying panel); `--menu-shadow` is the deeper
     one a context menu carries because it floats over a whole window; `--thumb-shadow` and
     `--inset-ring` are the two hairline rings that are shadows only because `outline` is taken. */
  --shadow: light-dark(0 2px 10px rgb(0 0 0 / 0.16), 0 2px 10px rgb(0 0 0 / 0.45));
  --menu-shadow: 0 6px 18px rgb(0 0 0 / 35%);
  --thumb-shadow: 0 0 0 1px rgb(0 0 0 / 0.6);
  --inset-ring: 0 0 0 2px var(--ring);
  --art-edge: 0 0 0 1px var(--line);

  /* The scrim each dialog dims the page with. Six numbers because six dialogs were each tuned once,
     25 % under a context menu up to 45 % under a destructive confirm; they are listed rather than
     averaged so that E33.1's "this part changes no pixel" stays true, and whoever unifies them next
     does it on purpose, in one place. */
  --scrim-25: rgb(0 0 0 / 25%);
  --scrim-30: rgb(0 0 0 / 30%);
  --scrim-32: rgb(0 0 0 / 32%);
  --scrim-35: rgb(0 0 0 / 35%);
  --scrim-40: rgb(0 0 0 / 40%);
  --scrim-45: rgb(0 0 0 / 45%);

  /* Three colors are DELIBERATELY unthemed, each for the same reason: they sit on something whose own
     color the document decides, so a scheme cannot pick them. The digit chip keeps a dark plate and
     light ink on any swatch — a light chip on a light swatch has no contrast at all. The picker
     thumb's white edge and black keyline ride the 2D field, which can be any color at all. */
  --chip: #11111b;
  --chip-ink: #f5f5f7;
  --thumb-line: #fff;
  /* The transparency checkerboard behind an export preview (M10.06). Transparency is the same two
     greys in either scheme — that is the whole point of the pattern — and these are Catppuccin
     Latte `mantle` and `overlight`. */
  --checker-a: #f2f2f7;
  --checker-b: #cbcbd6;
  /* The Okhsl square before core has said anything about a band (M9.08): the memo has no row for it,
     and a missing ramp reads as black rather than as nothing. It belongs to neither scheme and to no
     document, and it is a token anyway: E33.1 keeps no exception for a placeholder. */
  --band-idle: #000000;

  /* Type. The interface is one 12 px system sans and the numbers are one 11/12 px mono. The four
     first are `font` SHORTHAND values (`size/line-height family`), which is why rules read them as
     `font: var(--ui-font)`; the two families are the same lists with the size taken out, for the one
     rule that wants a family alone — `.nd-seed`, whose `font-family: var(--mono-font)` is a no-op
     today because a family property cannot take a size. E33.2 bundles Instrument Sans and IBM Plex
     Mono onto these names, and switching `.nd-seed` over belongs with THAT item, not this one: it is
     a pixel, and E33.1 part 1 changes none. */
  /* E33.2's type: "Instrument Sans … for the interface, IBM Plex Mono … for values, sizes, keys and
     the status line. No display face." Both are OFL and BOTH are bundled as woff2 under
     `assets/fonts/` (the `@font-face` rules are below), so the app asks its OWN origin for every byte
     — `e2e/theme.spec.js`'s `fonts_bundled_no_network` fails if one request ever leaves it. The
     system names stay at the END of each list as the fallback a machine with a broken asset still
     renders in. */
  --ui-font: 12px "Instrument Sans", system-ui, sans-serif;
  --mono-font: 12px "IBM Plex Mono", ui-monospace, monospace;
  --chip-font: 11px/1.2 "IBM Plex Mono", ui-monospace, monospace;
  --toast-font: 12px/1.4 "IBM Plex Mono", ui-monospace, monospace;
  --ui-family: "Instrument Sans", system-ui, sans-serif;
  --mono-family: "IBM Plex Mono", ui-monospace, monospace;

  /* Motion. There is exactly ONE animation in the chrome: the flash a paired cell paints when a room
     confirms it. `prefers-reduced-motion` switches it off (ADR §11), which is the rule the durations
     in this file have to obey, not a suggestion. */
  --flash: 600ms;

  /* Focus, and the marks that borrow its paint. `--focus-ring` is WCAG 2.4.7's keyboard ring, drawn
     with `:focus-visible` only; `--mark-ring` is the same ring 1 px heavier on the control that is
     LIT — the tool that is up, PRIMARY in the strip — and `--focus-ring-dashed` is the caret of a
     selection. The two offsets are the ring's distance from the box: 2 px where the ring is the only
     signal, 1 px where a border already holds the edge. */
  /* The two INK rings that used to share the accent's token (see the four-use note above): the dashed
     ring of a scheme being previewed, and the lit scheme tab's mark. */
  --focus-ring-dashed: 2px dashed var(--ring);
  --focus-ring-ink: 2px solid var(--ring);
  --mark-ring-ink: 3px solid var(--ring);
  --ring-off: 2px;
  --ring-off-tight: 1px;
}

/* The dot grid behind the canvas (E33.2): 18 px apart, `--dot`, on the canvas AREA rather than the
   artwork — the two numbers the rule in `style.css` reads are here, and the switch that turns them
   off is `UiSettings.canvas_dots`, which the app spells as `:root[data-dots="off"]`. */
:root {
  --dot-gap: 18px;
  --dot-r: 1px;
}

/* E33.2's type, BUNDLED: "Instrument Sans (OFL, bundled as woff2 in the app's assets, no network)
   for the interface, IBM Plex Mono (OFL, bundled) for values, sizes, keys and the status line".
   The four files sit next to the licences they came with under `assets/fonts/` — Instrument Sans 400
   and 600 (the chrome's two weights), IBM Plex Mono 400 and 500 (a value and a bolder value) — and
   `latin` is the subset they carry, which is the whole alphabet this UI sets in. Trunk content-hashes
   them exactly like the CSS that names them, so ADR §12's immutable cache covers a font too. */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/instrument-sans-400.woff2") format("woff2");
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/instrument-sans-600.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

/* `UiSettings.theme`'s hook (ADR §11: "UI colors are CSS variables on :root[data-theme]"): pinning
   the attribute pins `color-scheme`, which is what `light-dark()` reads. No UI sets it yet. */
:root[data-theme="dark"] {
  color-scheme: dark;
}
:root[data-theme="light"] {
  color-scheme: light;
}

/* ADR §11's responsive half: a coarse pointer gets 44 px targets. Only the controls and the two
   fixed rows are listed; the strip grows with its own swatch. The <900px rules (right panel to a
   bottom sheet, rail to a floating bar) wait for M8/M9, which are the items that create the panels
   those rules move — writing them now would style elements that do not exist. */
@media (pointer: coarse) {
  :root {
    --ctl-h: 44px;
    --swatch: 56px;
    --grid-swatch: 56px;
    --grid-narrow-swatch: 44px;
    /* ADR §11: a coarse pointer raises every control to 44 px AND hides the key labels — the badge
       half of that rule is below, next to the chip. */
    --tool: 44px;
    --rail-w: 52px;
    --panel-tab-w: 44px;
    --topbar-h: 48px;
    --status-h: 48px;
  }
}

/* E27.1's palette GRID (M15U.01): the plate is 48 px here rather than the strip's 44 px, and it is
   written into `--swatch` for this element alone so that one number answers the plate, the hidden-row
   spacers and the caret/swap marks. The layout that reads it is `style.css`'s `#palette` block.
   SOURCE ORDER IS THE CASCADE HERE: this base rule comes FIRST, so the narrow media query
   below — same selector, same specificity — is the one that wins when it applies. */
#palette {
  --swatch: var(--grid-swatch);
}

/* M9.07's collapse, the token half of it: below 1100 px the right panel becomes an icon-tab column,
   so the column's width IS the tab width. The rules that move the panel's own parts stay in
   `style.css` next to the panel; this is the one number they all read. */
@media (max-width: 1099.98px) {
  :root {
    --panel-w: var(--panel-narrow-w);
  }
  /* E27.1's narrow palette: the grid keeps its plates at 32 px, so the swatch, the pads and the two
     drag marks — all of which measure themselves against `--swatch` — follow it with one value. A
     VALUE, so it is declared here and not in `style.css`, which declares no tokens at all — and it is
     declared AFTER the base `#palette` rule above, which is what makes it the one that wins. */
  #palette {
    --swatch: var(--grid-narrow-swatch);
  }
}

/* E27.3's color ring (M15U.03): the plate a swatch becomes when it leaves the column and hangs out
   around the pointer, the digit that still names its seat for the first ten, the ink outline that
   says "release HERE", and the layer it floats at — above the swatch menu (35), below a dialog.
   The geometry that reads them is `style.css`'s `.color-ring` block. */
:root {
  --ring-sw: 34px;
  --ring-badge-font: 10px/1 "IBM Plex Mono", ui-monospace, monospace;
  --ring-edge: 2px;
  --ring-z: 40;
}
