/* =========================================================================
   manaruler public site stylesheet
   -------------------------------------------------------------------------
   Served from /static/css/site.css and consumed by _base_public.html.

   Design system notes (kept here so the next person does not have to guess):

   * Token naming deliberately mirrors the admin layout's vocabulary
     (--bg, --surface, --border, --text, --accent, --radius, --space-N) so the
     two surfaces read as one product, even though they look different.
   * DARK-FIRST (Mana Night, Option 4). `:root` IS the dark theme; the
     explicit "dark" attribute and the OS-dark "system" state inherit it with
     no override. Daylight lives in `:root[data-theme="light"]` and in
     `@media (prefers-color-scheme: light) { :root[data-theme="system"] }`.
     Dark is the product default (decision D2) and must not be reversed.
   * ONE accent per area, driven by the colour pie as wayfinding. Each page
     sets `data-hue` on <body> (w/u/b/r/g/c, or "pie" for the all-five hub);
     the `[data-hue]` remap below swaps --accent/--accent-tint/--area-glow/
     --rim to that area's mana colour. Area hues are WAYFINDING; --pip-* and
     --rar-* are DATA. Never reuse one for the other (Option 4 §7).
   * ONE radius scale. Nothing on this page is a pill and nothing is square.
   * Typography carries the point of view: --font-display (Exo 2) is for
     headings and the brand, --font-sans (Inter) is for UI and body, and the
     mono stack is reserved EXCLUSIVELY for things the reader can go and
     verify (rule numbers, card counts, deck limits). If a number is set in
     mono on this page, it is a checkable fact. Do not spend the mono face on
     decoration.
   * Web fonts are SELF-HOSTED under /static/fonts/ (SIL OFL, woff2,
     font-display: swap). No Google Fonts or CDN request is made at runtime.
   * No JavaScript on purpose. Everything below is CSS-only; the theme switch
     is a plain <form method="post"> to POST /settings/theme.
   ========================================================================= */

/* ---------- Tokens ------------------------------------------------------ */

:root {
  color-scheme: dark;

  /* Surfaces and ink (dark -- the default) */
  --bg: #0b0f1a;
  --surface: #131a2b;
  --glass: rgba(19, 26, 43, 0.72);
  --surface-sunken: #0f1524;
  --border: rgba(154, 166, 192, 0.16);
  --border-strong: rgba(154, 166, 192, 0.32);
  /* --control-border is the outline that IS the affordance on an
     outline-only control, so WCAG 1.4.11 wants 3:1 against the surface
     behind it (it is 3.9:1 on #131a2b). --border-strong is a decorative
     divider and is not held to that rule. */
  --control-border: #6b7894;
  --text: #e8ecf6;
  --text-muted: #9aa6c0;

  /* Brand accent (gold = the White hue, Option 2 §2.1 / Option 4 §2.3).
     `[data-hue]` remaps this per area; --accent-label stays a per-theme
     constant because every dark hue label and every daylight hue label share
     one contrast pair (Option 4 §2.2). */
  --accent: #f0b44c;
  --accent-strong: #f6c46a;
  --accent-tint: #323030;   /* color-mix(in srgb, #f0b44c 14%, #131a2b) */
  --accent-contrast: #0b0f1a;
  --accent-label: #0b0f1a;
  --area-glow: rgba(240, 180, 76, 0.22);
  --rim: #f0b44c;

  /* The colour the primary button's gradient mixes its TOP stop toward.
     It is whichever of white/black moves AWAY from --accent-label, so the
     --accent stop is always the worst case for the label and the §2.2
     contrast figures stay the floor. On dark, the label is near-black ink, so
     the gradient lightens. See the .btn--primary comment: on daylight this
     flips to #000, and it has to. */
  --accent-grad-mix: #ffffff;

  /* Focus ring / informational light (the "blue mana" focus light). */
  --info: #7cc0ff;

  /* Nebula atmosphere on body: CSS gradients only, fixed attachment. */
  --nebula-base: radial-gradient(1200px 600px at 70% -10%, #1d2a4a 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 0%, #2a1840 0%, transparent 55%);

  /* Rim glow colours (Option 2 §2.1). Glow only, never text. */
  --rim-w: #f5e6b0;
  --rim-u: #4fa3ff;
  --rim-b: #b18cff;
  --rim-r: #ff5a4f;
  --rim-g: #3fd08a;

  /* Area hues -- WAYFINDING (Option 4 §2.2, dark). Precomputed for WCAG 2.2
     AA against --surface/--bg/--surface-sunken and for button labels. Copy
     verbatim; do not substitute or "improve" these. */
  --hue-w: #f0b44c;
  --hue-u: #6fb0ff;
  --hue-b: #b9a2ff;
  --hue-r: #ff7a6b;
  --hue-g: #5fd39a;
  --hue-c: #c3cad8;

  /* Semantic danger: shared by errors, banned status and destructive actions. */
  --danger: #e2887f;
  --danger-strong: #f0aaa2;
  --danger-tint: #2a1a18;
  --danger-contrast: #2a1a18;

  /* Semantic OK, the counterpart to --danger: a deck that passed its legality
     check (V3-a, #284). It is NOT --hue-g and must never be swapped for it:
     the hues are WAYFINDING (green means "you are in Collections") and this is
     DATA (green means "this deck is legal"), and Option 4 §2.2 keeps those two
     jobs on different values. It also cannot be --accent, the way
     `.legality .yes` does it on card detail: Decks is the RED area, so an
     accent-coloured "Legal" would be a red tick. Measured against the surfaces
     it is painted on: 10.18:1 on --surface, 10.69:1 on --surface-sunken,
     11.23:1 on --bg, 7.87:1 on its own tint. */
  --ok: #86d7ab;
  --ok-tint: #21313a;   /* color-mix(in srgb, #86d7ab 12%, #131a2b) */

  /* Restricted legality status: an amber distinct from the area gold (Legal)
     and the danger red (Banned), AA against --bg in the dark theme. */
  --status-restricted: #e8963c;

  /* Component effects: exact RGBA values. */
  --tap-highlight: rgba(240, 180, 76, 0.18);
  --scroll-shadow-clear: rgba(0, 0, 0, 0);
  --mana-pip-border: rgba(0, 0, 0, 0.16);
  --mana-pip-highlight: rgba(255, 255, 255, 0.18);
  --mana-shade: rgba(0, 0, 0, 0.12);
  --colorchip-highlight: rgba(255, 255, 255, 0.2);
  --qtybadge-shadow-color: rgba(0, 0, 0, 0.4);

  /* Shell geometry and glass (Option 4 §4.3/§4.4, wave V2).
     --header-h is the sticky header's height. It is referenced by the header
     itself, by [id]'s scroll-margin and by the hero's top padding, so the
     three cannot drift apart. The spec fixes it at 64px.
     --glass-blur is the ONE blur radius every glass surface uses; keeping it
     a token is what makes the "at most 3 glass layers" budget auditable. */
  --header-h: 64px;
  --glass-blur: 14px;

  /* The gem mark's facet edges. Gold on EVERY page, deliberately not
     following --accent: Option 4 §2.3 keeps the wordmark recognisable from
     any area, so this is the one thing a data-hue must not repaint. */
  --gem-edge: #f0b44c;

  /* Shape: one radius scale, tinted shadow (never pure black) */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);

  /* Space: same names as the admin layout, plus two larger steps */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4.5rem;
  --space-8: 6rem;

  /* Type */
  --font-display: "Exo 2", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* #357: the display size's upper bound is the demo's h1 ceiling, 3.1rem /
     49.6px (option-4-mana-night.html line 49,
     `clamp(2.1rem, 1.7rem + 2vw, 3.1rem)`). Only the ceiling was ported: the
     demo's wider floor and steeper slope would move every h1 at every width,
     which is not what #357 asked for. */
  --fs-display: clamp(1.875rem, 1.55rem + 1.6vw, 3.1rem);
  --fs-h2: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --fs-h3: 1.125rem;
  --fs-lead: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-micro: 0.75rem;

  --measure: 62ch;
  --container: 1120px;

  /* Semantic mana pip palette (Epic #166). These are DATA, not decorative
     accents -- the five Magic colours are load-bearing information in a card
     catalogue, exactly as a red error is a semantic colour, not a brand
     accent. Retuned for the dark default: fills brighten, inks flip dark so
     AA contrast holds. */
  --pip-w-bg: #efe7c8;  --pip-w-ink: #2b271c;
  --pip-u-bg: #2f7fc1;  --pip-u-ink: #062033;
  --pip-b-bg: #0a0a09;  --pip-b-ink: #efece6;
  --pip-r-bg: #e03a45;  --pip-r-ink: #2a0608;
  --pip-g-bg: #1f9c5c;  --pip-g-ink: #06210f;
  --pip-c-bg: #c7c2b8;  --pip-c-ink: #26221c;
  --pip-m-bg: #d8b24a;  --pip-m-ink: #2b2410;
  --pip-num-bg: #cfcbc3; --pip-num-ink: #26221c;
  --pip-snow-bg: #7fb3d9; --pip-snow-ink: #0a2233;
  --pip-energy-bg: #d98f1f; --pip-energy-ink: #241300;

  /* Rarity dot colours -- a decorative cue only; the word next to the dot
     always carries the meaning (WCAG 1.4.1). */
  --rar-common: #7a7a7a;
  --rar-uncommon: #8f9ba6;
  --rar-rare: #c2a24b;
  --rar-mythic: #d05a2a;

  font-size: 16px;
}

/* Daylight theme (Option 2 §2.1, Option 4 §2.1). The explicit "light"
   attribute and the OS-driven "system" override share one token map; keep
   them identical. */
:root[data-theme="light"] {
  color-scheme: light;

  /* Restricted legality status (amber, AA on --bg in daylight). */
  --status-restricted: #9c4a00;

  --bg: #eef1f7;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.78);
  --surface-sunken: #e4e9f2;
  --border: #d5dbe7;
  --border-strong: #c3ccdc;
  --control-border: #7a869f;
  --text: #121827;
  --text-muted: #4a5572;

  --accent: #8a5a00;
  --accent-strong: #6f4700;
  --accent-tint: #efe8db;   /* color-mix(in srgb, #8a5a00 14%, #ffffff) */
  --accent-contrast: #ffffff;
  --accent-label: #ffffff;
  --area-glow: rgba(138, 90, 0, 0.22);
  --rim: #8a5a00;

  /* MUST be #000 on daylight, not #fff. The label here is white, so mixing
     the top stop toward white erodes it instead of protecting it: measured,
     daylight Green goes 5.35 -> 4.23, which fails AA. Mixing toward black
     takes it to 6.53 and keeps --accent as the floor. */
  --accent-grad-mix: #000000;

  --info: #1f5fbf;

  --nebula-base: radial-gradient(1200px 600px at 70% -10%, #dfe6f5 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 0%, #e6ddf2 0%, transparent 55%);

  /* Area hues -- WAYFINDING (Option 4 §2.2, daylight). Precomputed for
     WCAG 2.2 AA. Copy verbatim. */
  --hue-w: #8a5a00;
  --hue-u: #1d5fa3;
  --hue-b: #5b3fa0;
  --hue-r: #b3261e;
  --hue-g: #1f7a45;
  --hue-c: #4a5572;

  /* Daylight gold, so the gem edges stay the brand colour in both themes. */
  --gem-edge: #8a5a00;

  --danger: #a3352c;
  --danger-strong: #8c2c24;
  --danger-tint: #fdf0ee;
  --danger-contrast: #ffffff;

  /* Semantic OK, daylight. 7.62:1 on --surface, 6.26:1 on --surface-sunken,
     6.74:1 on --bg, 6.32:1 on its own tint -- the same footing daylight
     --danger-strong has (8.40 / 6.89 / 7.42). Distinct from --hue-g #1f7a45. */
  --ok: #146035;
  --ok-tint: #e3ece7;   /* color-mix(in srgb, #146035 12%, #ffffff) */

  --tap-highlight: rgba(138, 90, 0, 0.18);
  --qtybadge-shadow-color: rgba(20, 30, 60, 0.16);

  --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px -12px rgba(20, 30, 60, 0.16);

  /* Mana pip palette, daylight scheme. */
  --pip-w-bg: #f6f1df;  --pip-w-ink: #3a352a;
  --pip-u-bg: #0e5f9e;  --pip-u-ink: #ffffff;
  --pip-b-bg: #2b2a28;  --pip-b-ink: #f6f4ef;
  --pip-r-bg: #c1121f;  --pip-r-ink: #ffffff;
  --pip-g-bg: #0a7a3d;  --pip-g-ink: #ffffff;
  --pip-c-bg: #d6d1c8;  --pip-c-ink: #3a352a;
  --pip-m-bg: #b98a1e;  --pip-m-ink: #241b06;
  --pip-num-bg: #dedad2; --pip-num-ink: #3a352a;
  --pip-snow-bg: #dcebf5; --pip-snow-ink: #1c3346;
  --pip-energy-bg: #f2b03d; --pip-energy-ink: #3a2703;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;

    /* Restricted legality status (amber, AA on --bg in daylight). */
    --status-restricted: #9c4a00;

    --bg: #eef1f7;
    --surface: #ffffff;
    --glass: rgba(255, 255, 255, 0.78);
    --surface-sunken: #e4e9f2;
    --border: #d5dbe7;
    --border-strong: #c3ccdc;
    --control-border: #7a869f;
    --text: #121827;
    --text-muted: #4a5572;

    --accent: #8a5a00;
    --accent-strong: #6f4700;
    --accent-tint: #efe8db;
    --accent-contrast: #ffffff;
    --accent-label: #ffffff;
    --area-glow: rgba(138, 90, 0, 0.22);
    --rim: #8a5a00;

    /* See the :root[data-theme="light"] block: #000, not #fff. */
    --accent-grad-mix: #000000;

    --info: #1f5fbf;

    --nebula-base: radial-gradient(1200px 600px at 70% -10%, #dfe6f5 0%, transparent 60%),
      radial-gradient(900px 500px at 0% 0%, #e6ddf2 0%, transparent 55%);

    --hue-w: #8a5a00;
    --hue-u: #1d5fa3;
    --hue-b: #5b3fa0;
    --hue-r: #b3261e;
    --hue-g: #1f7a45;
    --hue-c: #4a5572;

    --gem-edge: #8a5a00;

    --danger: #a3352c;
    --danger-strong: #8c2c24;
    --danger-tint: #fdf0ee;
    --danger-contrast: #ffffff;

    /* Semantic OK, daylight (kept identical to the explicit light map). */
    --ok: #146035;
    --ok-tint: #e3ece7;

    --tap-highlight: rgba(138, 90, 0, 0.18);
    --qtybadge-shadow-color: rgba(20, 30, 60, 0.16);

    --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px -12px rgba(20, 30, 60, 0.16);

    --pip-w-bg: #f6f1df;  --pip-w-ink: #3a352a;
    --pip-u-bg: #0e5f9e;  --pip-u-ink: #ffffff;
    --pip-b-bg: #2b2a28;  --pip-b-ink: #f6f4ef;
    --pip-r-bg: #c1121f;  --pip-r-ink: #ffffff;
    --pip-g-bg: #0a7a3d;  --pip-g-ink: #ffffff;
    --pip-c-bg: #d6d1c8;  --pip-c-ink: #3a352a;
    --pip-m-bg: #b98a1e;  --pip-m-ink: #241b06;
    --pip-num-bg: #dedad2; --pip-num-ink: #3a352a;
    --pip-snow-bg: #dcebf5; --pip-snow-ink: #1c3346;
    --pip-energy-bg: #f2b03d; --pip-energy-ink: #3a2703;
  }
}

/* ---------- Area hue remap (Option 4 §2.2) -------------------------------
   Each page sets data-hue on <body>; this remaps --accent, --accent-tint,
   --area-glow and --rim to that area's mana colour. --accent-label stays a
   per-theme token (dark ink on the dark theme, white on daylight). The
   derived tint/glow use color-mix; a @supports fallback below carries the
   precomputed equivalents for engines without color-mix.
   ------------------------------------------------------------------------ */

[data-hue="w"] {
  --accent: var(--hue-w);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

[data-hue="u"] {
  --accent: var(--hue-u);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

[data-hue="b"] {
  --accent: var(--hue-b);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

[data-hue="r"] {
  --accent: var(--hue-r);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

[data-hue="g"] {
  --accent: var(--hue-g);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

[data-hue="c"] {
  --accent: var(--hue-c);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

/* All-five hub: brand gold for CTAs, plus the five-colour pie aurora in the
   nebula. The aurora is a CSS gradient only -- five --rim-* radial blobs at
   10-14 % alpha (Option 4 §4.2). */
[data-hue="pie"] {
  --accent: var(--hue-w);
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --area-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --rim: var(--accent);
}

/* Light-theme tint for the Green (Collections) area, overriding the 14 %
   color-mix above.

   Why: active-state chrome paints `--accent` (#1f7a45 in daylight) on
   `--accent-tint`. At the default 14 % mix over a white surface that tint is
   #e0ece5, which measures 4.40:1 -- just under the 4.5:1 AA floor for 14px
   text -- and axe-core flagged it on `.cc-tab--active`, `.seg__link--active`,
   the checked mana-value radio and the theme button. The lighter wash below
   puts the same pinned §2.2 hue at 4.67:1. The hue itself is untouched: mana
   colour is data, and this is chrome.

   The other five hues already clear the floor (w 4.87, u 5.31, b 6.31,
   r 5.19, c 6.00), so only Green needs the exception. `:root[data-theme] ...`
   outranks the bare `[data-hue="g"]` block above, and a matching hardcoded
   value lives in the color-mix-less @supports fallback below. */
:root[data-theme="light"] [data-hue="g"] {
  --accent-tint: #e8f2ec;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] [data-hue="g"] {
    --accent-tint: #e8f2ec;
  }
}

body[data-hue="pie"] {
  background:
    radial-gradient(520px 320px at 12% 0%, color-mix(in srgb, var(--rim-w) 12%, transparent), transparent 70%),
    radial-gradient(520px 320px at 32% -8%, color-mix(in srgb, var(--rim-u) 14%, transparent), transparent 70%),
    radial-gradient(520px 320px at 52% 0%, color-mix(in srgb, var(--rim-b) 12%, transparent), transparent 70%),
    radial-gradient(520px 320px at 72% -8%, color-mix(in srgb, var(--rim-r) 12%, transparent), transparent 70%),
    radial-gradient(520px 320px at 92% 0%, color-mix(in srgb, var(--rim-g) 12%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* Precomputed tint/glow fallback for engines without color-mix. The tint is
   `accent 14% over --surface`, the glow is `accent 22% over transparent`,
   computed in sRGB for both themes. */
@supports not (color: color-mix(in oklab, red, blue)) {
  [data-hue="w"] { --accent-tint: #323030; --area-glow: rgba(240, 180, 76, 0.22); }
  [data-hue="u"] { --accent-tint: #202f49; --area-glow: rgba(111, 176, 255, 0.22); }
  [data-hue="b"] { --accent-tint: #2a2d49; --area-glow: rgba(185, 162, 255, 0.22); }
  [data-hue="r"] { --accent-tint: #342734; --area-glow: rgba(255, 122, 107, 0.22); }
  [data-hue="g"] { --accent-tint: #1e343b; --area-glow: rgba(95, 211, 154, 0.22); }
  [data-hue="c"] { --accent-tint: #2c3343; --area-glow: rgba(195, 202, 216, 0.22); }
  [data-hue="pie"] { --accent-tint: #323030; --area-glow: rgba(240, 180, 76, 0.22); }

  body[data-hue="pie"] {
    background:
      radial-gradient(520px 320px at 12% 0%, rgba(245, 230, 176, 0.12), transparent 70%),
      radial-gradient(520px 320px at 32% -8%, rgba(79, 163, 255, 0.14), transparent 70%),
      radial-gradient(520px 320px at 52% 0%, rgba(177, 140, 255, 0.12), transparent 70%),
      radial-gradient(520px 320px at 72% -8%, rgba(255, 90, 79, 0.12), transparent 70%),
      radial-gradient(520px 320px at 92% 0%, rgba(63, 208, 138, 0.12), transparent 70%),
      var(--bg);
    background-attachment: fixed;
  }

  :root[data-theme="light"] [data-hue="w"] { --accent-tint: #efe8db; --area-glow: rgba(138, 90, 0, 0.22); }
  :root[data-theme="light"] [data-hue="u"] { --accent-tint: #dfe9f2; --area-glow: rgba(29, 95, 163, 0.22); }
  :root[data-theme="light"] [data-hue="b"] { --accent-tint: #e8e4f2; --area-glow: rgba(91, 63, 160, 0.22); }
  :root[data-theme="light"] [data-hue="r"] { --accent-tint: #f4e1df; --area-glow: rgba(179, 38, 30, 0.22); }
  :root[data-theme="light"] [data-hue="g"] { --accent-tint: #e8f2ec; --area-glow: rgba(31, 122, 69, 0.22); }
  :root[data-theme="light"] [data-hue="c"] { --accent-tint: #e6e7eb; --area-glow: rgba(74, 85, 114, 0.22); }
  :root[data-theme="light"] [data-hue="pie"] { --accent-tint: #efe8db; --area-glow: rgba(138, 90, 0, 0.22); }

  @media (prefers-color-scheme: light) {
    :root[data-theme="system"] [data-hue="w"] { --accent-tint: #efe8db; --area-glow: rgba(138, 90, 0, 0.22); }
    :root[data-theme="system"] [data-hue="u"] { --accent-tint: #dfe9f2; --area-glow: rgba(29, 95, 163, 0.22); }
    :root[data-theme="system"] [data-hue="b"] { --accent-tint: #e8e4f2; --area-glow: rgba(91, 63, 160, 0.22); }
    :root[data-theme="system"] [data-hue="r"] { --accent-tint: #f4e1df; --area-glow: rgba(179, 38, 30, 0.22); }
    :root[data-theme="system"] [data-hue="g"] { --accent-tint: #e8f2ec; --area-glow: rgba(31, 122, 69, 0.22); }
    :root[data-theme="system"] [data-hue="c"] { --accent-tint: #e6e7eb; --area-glow: rgba(74, 85, 114, 0.22); }
    :root[data-theme="system"] [data-hue="pie"] { --accent-tint: #efe8db; --area-glow: rgba(138, 90, 0, 0.22); }
  }
}

/* ---------- Self-hosted web fonts (SIL OFL, woff2, no CDN) --------------- */

@font-face {
  font-family: "Exo 2";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("/static/fonts/exo2-var.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-var.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-var-italic.woff2") format("woff2");
}


/* ---------- Reset and base ---------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  /* Nebula that follows the area (Option 4 §4.2): the area glow on top,
     then the fixed nebula base, then the solid --bg. CSS gradients only,
     fixed attachment so it does not scroll with the page. Pie pages swap
     the first layer for the five-colour aurora (see body[data-hue="pie"]). */
  background: radial-gradient(1100px 560px at 75% -10%, var(--area-glow), transparent 60%),
    var(--nebula-base), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Kill the 300ms double-tap-zoom delay, and pick the tap highlight rather
     than inheriting the platform's translucent blue-black. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: var(--tap-highlight);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
  font-family: var(--font-display);
}

/* In-page anchors (the hero's "See what it does" jump) must not land with the
   target heading flush against the top edge.

   The offset is the STICKY HEADER's height plus a breath, not just a breath:
   since V2 the header is `position: sticky` (64px), so an anchor that only
   cleared --space-5 landed with its heading hidden underneath the header.
   Keep this in step with --header-h. */
[id] {
  scroll-margin-top: calc(var(--header-h) + var(--space-3));
}

p {
  margin: 0;
  text-wrap: pretty;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Layout helpers ---------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  /* Respect notches and rounded display corners on full-bleed sections. */
  padding-inline: max(var(--space-4), env(safe-area-inset-left))
    max(var(--space-4), env(safe-area-inset-right));
}

/* Grid hygiene: grid and flex children default to `min-width: auto`, which
   resolves to min-content and lets a wide child push the page past the
   viewport. Every layout child on this site is allowed to shrink. */
.hero__copy,
.hero__grid > *,
.split > *,
.duo > *,
.facts > *,
.site-footer__inner > * {
  min-width: 0;
}

.section {
  padding-block: var(--space-7);
}

.section--tight {
  padding-block: var(--space-6);
}

.section--divided {
  border-top: 1px solid var(--border);
}

.section__head {
  display: grid;
  gap: var(--space-3);
  max-width: var(--measure);
  margin-bottom: var(--space-5);
}

.section__title {
  font-size: var(--fs-h2);
  font-weight: 680;
  letter-spacing: -0.022em;
}

.section__intro {
  color: var(--text-muted);
  font-size: var(--fs-lead);
}

.section__more {
  margin-top: var(--space-4);
  font-size: var(--fs-small);
  font-weight: 560;
}

/* Clip-path rather than a -9999px offset: the offset version is an element
   sitting far outside the viewport, which shows up as horizontal overflow in
   layout audits and can affect scroll extents in some engines. */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus-visible {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  width: auto;
  height: auto;
  clip-path: none;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
}

/* ---------- Wordmark: the five-facet gem ---------------------------------
   WAS three rising ticks (a measure, for "ruler"), drawn in CSS because it
   was three rectangles. Design README §1 finding F3: that reads as an
   analytics product, not as Magic. Since V2 the mark is the five-facet gem
   from gem_mark() in templates/_macros.html -- an inline SVG, because the
   five facets have to be individually addressable (below) and a CSS
   background cannot be.

   The SVG is inline rather than an <img>/background so the facets inherit the
   page's --hue-* tokens. A referenced SVG file cannot read them, which is
   also why favicon.svg has to carry its own copy of the palette.
   ------------------------------------------------------------------------ */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 660;
  font-size: 1.0625rem;
  letter-spacing: -0.028em;
  text-decoration: none;
}

.wordmark:hover {
  color: var(--text);
}

.wordmark__mark {
  flex: none;
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  line-height: 0;
}

.wordmark__mark .gem {
  display: block;
}

/* Facet fills: the hue tokens, so the gem is the colour pie in miniature.
   These are WAYFINDING colours, not pip data (Option 4 §7 rule 4). */
.gem .facet-w { fill: var(--hue-w); }
.gem .facet-u { fill: var(--hue-u); }
.gem .facet-b { fill: var(--hue-b); }
.gem .facet-r { fill: var(--hue-r); }
.gem .facet-g { fill: var(--hue-g); }

/* Gold edges on every page (Option 4 §2.3). --gem-edge deliberately does not
   follow --accent: the brand has to stay recognisable from a blue or red
   area, so this is the one mark element a data-hue must not repaint.
   vector-effect keeps the stroke 1px-ish at 20px rather than scaling down to
   invisibility with the viewBox. */
.gem__edge {
  fill: none;
  stroke: var(--gem-edge);
  stroke-width: 1.1;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* "You are here", drawn as light (Option 4 §4.3): every facet sits at 45 %
   and the current area's facet comes up to full. Subtle on purpose -- it is a
   reinforcement of the nav's own active state, never the only signal (§7
   rule 5), so nothing is lost if it goes unnoticed. */
.gem__facets .facet {
  opacity: 0.45;
  transition: opacity 200ms ease;
}

body[data-hue="w"] .gem .facet-w,
body[data-hue="u"] .gem .facet-u,
body[data-hue="b"] .gem .facet-b,
body[data-hue="r"] .gem .facet-r,
body[data-hue="g"] .gem .facet-g {
  opacity: 1;
}

/* Pie pages (home, about, features, dashboard hub) are every area at once, so
   the whole gem lights up. Same reason the favicon is always fully lit. */
body[data-hue="pie"] .gem .facet {
  opacity: 1;
}

/* Colourless pages (auth, consent, settings, account, legal) are not an area
   in the colour-pie sense, so no facet is singled out. The gem stays evenly
   dimmed, which reads as "nowhere in particular" and is correct. */

/* ---------- Header: sticky glass ----------------------------------------
   Option 4 §4.3: a sticky 64px glass header.

   GLASS, WITH A REAL FALLBACK. --glass is >= 72 % opaque in both themes, so
   the nav's text contrast is carried by the background colour and the blur is
   pure decoration. Engines without backdrop-filter get the fully opaque
   --surface instead (the @supports block below), which is what the header
   looked like before V2. Nothing about legibility depends on the blur.

   Z-INDEX, and why it is 50. Three things on this site stack above the page
   and they have to stay in this order:
       100  .skip-link:focus-visible  (must beat everything, it is the escape)
        60  .cc-pop                   (the card enlargement overlay)
        50  .site-header              (this)
        40  the collection/catalogue sticky toolbars
        30  the collections page shell's sticky bar
   Putting the header above .cc-pop would let it cover the top of a card
   enlargement, so it sits below it.

   WHAT STICKY DOES NOT BREAK. backdrop-filter creates a containing block for
   position: fixed descendants. .cc-pop is position: fixed and is anchored to
   the VIEWPORT on purpose (see its own comment). The header is not an
   ancestor of any tile, so the blur here cannot capture it. A .panel wrapped
   around a card grid COULD -- which is why the guardrails section at the end
   of this file strips the blur in exactly that case. Read it before adding
   glass anywhere near .cc-grid.
   ------------------------------------------------------------------------ */

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 50;
  /* The hairline is an INSET shadow, not a border-bottom. A 1px border would
     be added to the 64px content box and make the header 65px, and the spec
     says 64. Measured: border-bottom gave 65.0, this gives 64.0. */
  box-shadow: inset 0 -1px 0 var(--border);
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
}

@supports not (backdrop-filter: blur(1px)) {
  .site-header {
    background: var(--surface);
  }
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--header-h);
}

/* Both header children must be allowed to shrink, or the nav's horizontal
   scroll container (below 62rem) resolves to min-content and pushes the page
   wider than the viewport instead of scrolling inside itself. */
.site-header__inner > * {
  min-width: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 560;
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.site-nav__link:hover {
  color: var(--accent);
}

/* The active item (Option 4 §4.3): its area's tint behind it, a 2px underline
   in its colour, and an under-glow. box-shadow does all three so nothing
   moves -- an added border would shift the row by 2px on navigation.
   aria-current is the contract; the styling only follows it. */
.site-nav__link[aria-current="page"] {
  color: var(--text);
  background: var(--accent-tint);
  box-shadow:
    inset 0 -2px 0 var(--accent),
    0 10px 16px -12px var(--accent);
}

.site-nav__link--cta {
  color: var(--accent);
}

/* ---------- Nav as a glowing legend --------------------------------------
   Option 4 §4.3: each link carries a 7px dot in its own area colour, so the
   header doubles as the legend for the whole colour system. Catalogue is
   gold, Rules blue, Collections green, Decks red, Dashboard the full pie,
   Settings silver. Features and About get no dot, because they are not areas.

   The dot is a ::before pseudo-element, not markup: it is decoration that
   repeats the link's own text, and a real element would be one more thing for
   a screen reader to announce for no gain. The text label always stays, so
   colour is never the only signal (§7 rule 5) and the legend degrades to a
   plain nav for anyone who cannot see the hues at all.

   data-dot (rather than a class per hue) keeps the template honest: the
   attribute value IS the hue letter, so it reads the same as body[data-hue].
   ------------------------------------------------------------------------ */

.site-nav__link[data-dot]::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--text-muted));
}

.site-nav__link[data-dot="w"] { --dot: var(--hue-w); }
.site-nav__link[data-dot="u"] { --dot: var(--hue-u); }
.site-nav__link[data-dot="b"] { --dot: var(--hue-b); }
.site-nav__link[data-dot="r"] { --dot: var(--hue-r); }
.site-nav__link[data-dot="g"] { --dot: var(--hue-g); }
.site-nav__link[data-dot="c"] { --dot: var(--hue-c); }

/* The dashboard is the hub for all five areas, so its dot is the whole pie
   rather than one colour. A conic gradient, so it costs no image and no
   extra element. The --rim-* glow palette is the right source here (it is
   what §4.2's aurora uses), not --pip-*, which is card data. */
.site-nav__link[data-dot="pie"]::before {
  background: conic-gradient(
    var(--rim-w) 0 20%,
    var(--rim-u) 0 40%,
    var(--rim-b) 0 60%,
    var(--rim-r) 0 80%,
    var(--rim-g) 0 100%
  );
}

/* A soft glow on the dots, dark theme only: on the daylight theme a glow
   around a 7px dot just muddies it, and the dark canvas is the only place the
   "light emission" language reads. Scoped to the explicit dark attribute and
   to system-dark, matching how the token blocks are organised. */
:root[data-theme="dark"] .site-nav__link[data-dot]::before,
:root[data-theme="system"] .site-nav__link[data-dot]::before {
  box-shadow: 0 0 6px -1px var(--dot, transparent);
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] .site-nav__link[data-dot]::before {
    box-shadow: none;
  }
}

@media (max-width: 26rem) {
  .site-nav {
    gap: var(--space-2);
  }
  .site-nav__link,
  .linkbutton {
    font-size: 0.8125rem;
  }
}

/* ---------- Narrow nav: a scroll-snap row --------------------------------
   With the Wave 11 pages the signed-in nav holds ten items and needs roughly
   820px of content width on one line.

   BEFORE V2 the header wrapped: the wordmark kept its own line and the nav
   took the full width below it, on as many lines as it needed. That is wrong
   for a STICKY header -- a wrapped ten-item nav is about 140px tall, and
   pinning that to the top of a phone screen spends a fifth of the viewport on
   chrome that never changes.

   SO: below 62rem the nav becomes one horizontally scrollable row and the
   header keeps its 64px at every width. Option 4 §4.3 specifies this
   behaviour "below 48rem"; it is applied from 62rem instead, because 62rem is
   where this nav actually stops fitting, and a sticky header that changes
   height is worse than one that scrolls its own nav. 48rem is inside this
   range, so the spec's requirement still holds.

   NO PAGE OVERFLOW: overflow-x on the nav plus min-width: 0 on the header
   children (above) keeps the scroll inside the nav. The document's own
   scrollWidth is untouched, which matters because the catalogue tests assert
   the page does not widen.

   KEYBOARD: this is a real scroll container of real links, so Tab moves
   through them and the browser scrolls each into view by itself. Nothing is
   hidden behind a toggle, and no JavaScript is involved.
   ------------------------------------------------------------------------ */
@media (max-width: 62rem) {
  .site-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    /* Room for the focus ring, which would otherwise be clipped by the
       scroll container's own edge. */
    padding-block: var(--space-1);
    scrollbar-width: thin;
  }
  .site-nav > * {
    scroll-snap-align: start;
  }
}

/* ---------- Buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.7rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 620;
  font-size: var(--fs-small);
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease,
    color 140ms ease, transform 140ms ease;
}

.btn:active {
  transform: translateY(1px);
}

/* ---------- Primary: the area's own light ---------------------------------
   Option 4 §2.2: a gradient from color-mix(--accent 88%, white) to --accent,
   with an --accent-label label.

   ONE DELIBERATE CORRECTION TO THE SPEC, and it is a real accessibility fix
   rather than a preference.

   The spec mixes the top stop toward #fff and then says "the label contrast is
   computed against the darker stop, so it is still >= 7:1". That reasoning
   only holds on the DARK theme, where the label is near-black ink: lightening
   the top stop moves it away from the label and contrast goes UP (measured:
   every dark hue improves, e.g. W 10.33 -> 11.14, R 7.52 -> 8.37, so --accent
   really is the floor and the >= 7:1 claim is true).

   On the DAYLIGHT theme it inverts. There --accent is dark and the label is
   WHITE, so mixing toward white moves the stop TOWARD the label and contrast
   goes DOWN. Measured against the §2.2 daylight values:

       hue   --accent stop     mixed toward #fff     mixed toward #000
       w     5.93              4.58                  7.16
       u     6.53              5.02                  7.75
       b     7.88              5.84                  9.24
       r     6.54              5.34                  7.82
       g     5.35              4.23  <-- FAILS AA    6.53
       c     7.41              5.46                  8.69

   Daylight Green is 4.23:1, under the 4.5:1 AA floor for a button label at
   this size. That is the Collections CTA on the light theme, so it is not a
   corner case.

   So the mix target is a token: #fff on dark, #000 on daylight. In both themes
   it moves AWAY from --accent-label, which makes the --accent stop the worst
   case and restores exactly the guarantee the spec was reaching for. The hue
   values themselves are untouched -- this changes the gradient's direction,
   not the palette.
   ------------------------------------------------------------------------ */
.btn--primary {
  background: linear-gradient(
    color-mix(in srgb, var(--accent) 88%, var(--accent-grad-mix)),
    var(--accent)
  );
  border-color: var(--accent);
  color: var(--accent-label);
}

.btn--primary:hover {
  /* Hover shifts the gradient further, it does not flatten it: the label's
     floor is still the --accent stop, which is unchanged. */
  background: linear-gradient(
    color-mix(in srgb, var(--accent) 76%, var(--accent-grad-mix)),
    var(--accent)
  );
  border-color: var(--accent);
  color: var(--accent-label);
}

/* Engines without color-mix get the flat --accent fill the button had before
   V2. Flat rather than a --accent-strong gradient on purpose: --accent-strong
   is lighter on dark but DARKER on daylight, so using it here would invert the
   gradient in one theme. A flat fill is correct in both. */
@supports not (color: color-mix(in oklab, red, blue)) {
  .btn--primary,
  .btn--primary:hover {
    background: var(--accent);
  }
}

/* ---------- Secondary: glass with an accent edge -------------------------
   Option 4 §4.3. Translucent over the nebula, with the area colour as the
   edge.

   NO backdrop-filter HERE, on purpose. Blur is a per-element GPU cost and
   buttons are the most numerous control on the site -- the collections manage
   panel alone has several. Blurring each one would blow the "at most 3 glass
   layers in the viewport" budget (Option 2 §7) on a single screen. The
   translucency carries the glass look; the blur is reserved for the two
   surfaces that are big enough to show it, the header and .panel.

   --control-border stays as the edge until hover, because WCAG 1.4.11 wants
   3:1 for the outline that IS the affordance, and --control-border is the
   token chosen for that (see the token block).
   ------------------------------------------------------------------------ */
.btn--quiet {
  background: var(--glass);
  border-color: var(--control-border);
  color: var(--text);
}

.btn--quiet:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Danger: glass with a red rim ---------------------------------
   Option 4 §4.3's third button. The rim is --danger, which is tokenised per
   theme, and the label stays --text rather than --danger: red-on-glass label
   text at this size is the weakest contrast pair in the set, and the word in
   the button already says what it does, so colour is not the only signal.

   Not yet used by any template. account.css owns .btn--destructive for the
   account-deletion flow and is out of scope for this wave, so this is the
   shared variant for whoever needs it next; it is not a rename of that one.
   ------------------------------------------------------------------------ */
.btn--danger {
  background: var(--glass);
  border-color: var(--danger);
  color: var(--text);
}

.btn--danger:hover {
  border-color: var(--danger-strong);
  color: var(--danger-strong);
}

.btn--danger:focus-visible {
  outline-color: var(--danger);
}

.btn--large {
  padding: 0.875rem 1.6rem;
  font-size: var(--fs-body);
}

/* A form-submit styled to sit in the nav next to text links. */
.linkbutton {
  background: none;
  border: 0;
  padding: var(--space-1) 0;
  margin: 0;
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--text-muted);
  cursor: pointer;
}

.linkbutton:hover {
  color: var(--accent);
  text-decoration: underline;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ---------- Hero --------------------------------------------------------- */

.hero {
  padding-block: var(--space-7) var(--space-7);
}

.hero__grid {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

@media (min-width: 62rem) {
  .hero {
    padding-block: var(--space-8) var(--space-7);
  }
  .hero__grid {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-7);
  }
}

.hero__copy {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
}

.hero__title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.035em;
  max-width: 14ch;
}

.hero__lead {
  font-size: var(--fs-lead);
  color: var(--text-muted);
  max-width: 46ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.hero__secondary {
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--accent);
}

/* ---------- Area-lit art hero (Option 4 §4.1) ----------------------------
   Rendered only by art_hero() in templates/_macros.html. Do not hand-roll a
   second one: the contrast and performance guarantees below live in the macro
   plus these rules as a pair, and a hand-rolled copy gets neither.

   Layer order, back to front. The art layer (.hero--art__figure) is an
   absolute sibling BEHIND the copy: art_hero() renders only the figure, and
   the page renders .hero--art__inner above it at z 1.
     1  .hero--art__art      the <picture>, object-fit: cover
     2  .hero--art__overlay  the scrim and the area wash
     3  .hero--art__glyph    the area glyph at 8 %
     4  .hero__credit        the artist credit (flex-end, bottom of the figure)
     -- .hero--art__inner    the page's eyebrow + heading, a SIBLING at z 1

   -------------------------------------------------------------------------
   CONTRAST BY CONSTRUCTION, and how it is actually achieved
   -------------------------------------------------------------------------
   §4.1 gives the overlay as
       linear-gradient(90deg, var(--bg) 0%,
                       color-mix(in srgb, var(--bg) 88%, var(--accent)) 40%,
                       transparent 75%)
   and asserts "the >= 90 % --bg stop under the text is unchanged".

   Those PERCENTAGE stops are relative to the section, which is full-bleed,
   while the copy sits inside a 1120px centred container. So whether the copy
   lands on the opaque part depends on the viewport width: at 1600px the
   container starts at 15 % and a 46ch lead can reach past 50 %, i.e. into the
   band that is already fading toward transparent. The spec's claim is true for
   a wide desktop and quietly false in between.

   So the stop is expressed as a LENGTH that tracks the container instead:
       --hero-scrim: left gutter + 62 % of the container
   which is the right-hand edge of the copy column at any width. Everything
   left of it is solid --bg (ratio identical to body text: 16.2 dark,
   15.7 daylight), the wash tints the next few rem, and the art only becomes
   visible past the copy. Below the container width the gutter clamps to 0 and
   the scrim covers almost the whole hero, which is correct -- there is no room
   for art next to text on a small screen.

   The wash itself was measured and is not the risk: on mix(--bg 88%, accent),
   --text is 12.9-14.3:1 and --text-muted 5.4-6.9:1 across all six hues in both
   themes. The risk was only ever the transparent tail, and the copy can no
   longer reach it.

   -------------------------------------------------------------------------
   PERFORMANCE (Option 2 §7)
   -------------------------------------------------------------------------
     * ONE hero per page: the shell's per-render namespace suppresses a
       second macro call before it can emit another picture. The sibling CSS
       rule is a defensive paint guard only, not a network budget.
     * NO art fetched below 40rem: done in the macro's <picture>, not here.
       A CSS `display: none` would not have worked -- a hidden <img> with a
       real src is still fetched.
     * fetchpriority="low": in the macro.
     * NO glass: this hero is gradients only, so it adds nothing to the
       3-glass-layer budget. Do not add backdrop-filter to it.
   ------------------------------------------------------------------------ */

.hero--art {
  position: relative;
  overflow: hidden;
  padding-block: 0;
  /* The right-hand edge of the copy column, as a length. See above.
     `.hero--art--duo` re-derives this for the two-column hero; that block
     carries the reasoning. */
  --hero-scrim: calc(
    max(0px, (100vw - var(--container)) / 2) + var(--container) * 0.62
  );
}

.hero--art__figure {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0;
  /* Failed-load fallback (Option 2 §7 forbids retry JS). The figure's
     gradient + rim panel below is decorative and painted BEHIND the <img>, so
     a successful fetch hides it entirely. It does NOT suppress the native
     broken-image glyph and does NOT make alt text visible on its own: a
     failed <source> does not retry the <img>'s data-URI src, so currentSrc
     stays the failed URL and naturalWidth reads 0. In the tested Chromium
     layout the broken glyph is masked by the FOREGROUND .hero--art__overlay
     scrim; removing it or making it transparent may expose that glyph. The
     panel is a gradient + rim, NOT a background-image: the <img>/<picture>
     stays the primary art mechanism. */
  background:
    radial-gradient(72% 130% at 94% -12%, var(--area-glow), transparent 62%),
    linear-gradient(90deg, var(--bg) 0%, var(--accent-tint) 100%);
  box-shadow: inset 0 0 0 1px var(--rim);
}

.hero--art__art {
  position: absolute;
  inset: 0;
  display: block;
}

.hero--art__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* #347: the demo's own treatment of this layer, restored verbatim
     (option-4-mana-night.html line 70, `.hero__art img`). The art is a
     backdrop, not a photograph to study: a 2px blur stops it competing with
     the copy for focus and the slight saturation lift keeps it from reading
     grey once the veil is over it. A filter on the one already-downscaled
     image, never backdrop-filter -- the .hero--art block's performance note
     forbids a fourth composited surface here.

     Scoped pages that need a heavier blur set their own filter at two-class
     specificity and win outright: .authpage-hero (blur(14px), with a
     companion scale() for the fringe) and .cardpage-hero (blur(22px)). At 2px
     the fringe is under a pixel at the element's edges and is covered by the
     figure's own gradient panel, so no scale() is needed here.

     Below 40rem the macro serves an empty inline SVG here, so there is
     nothing to show and nothing was fetched. */
  filter: blur(2px) saturate(1.1);
}

.hero--art__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    /* The area glow, top-right (§4.1). A gradient, so it costs no image. */
    radial-gradient(72% 130% at 94% -12%, var(--area-glow), transparent 62%),
    /* The scrim and the wash. Solid --bg under the copy, then the 88 % wash,
       then the art. */
    linear-gradient(
      90deg,
      var(--bg) 0%,
      var(--bg) var(--hero-scrim),
      color-mix(in srgb, var(--bg) 88%, var(--accent)) calc(var(--hero-scrim) + 7rem),
      /* #347: the veil's terminal stop is a 70 % --bg alpha, not `transparent`
         (the demo's own last stop, option-4-mana-night.html line 72). A fully
         transparent end let the art reach full strength at the right edge,
         which is brighter than anything else on the page and pulls the eye
         off the copy. 30 % of the art still shows through. */
      color-mix(in srgb, var(--bg) 70%, transparent) calc(var(--hero-scrim) + 18rem)
    ),
    /* #347: the demo's third layer (line 73). Listed last, so it paints
       BEHIND the two above and only shows where they are see-through: it
       settles the art into the page's bottom edge instead of letting it stop
       at a hard seam against the next section. */
    linear-gradient(0deg, var(--bg) 0%, transparent 40%);
}

/* Engines without color-mix lose only the wash's tint and the veil's 70 % end
   stop, not the scrim. The mid-stop becomes plain --bg and the end stop plain
   `transparent`, which is strictly safer for contrast. The bottom-edge layer
   uses no color-mix, so it is mirrored here unchanged. */
@supports not (color: color-mix(in oklab, red, blue)) {
  .hero--art__overlay {
    background:
      radial-gradient(72% 130% at 94% -12%, var(--area-glow), transparent 62%),
      linear-gradient(
        90deg,
        var(--bg) 0%,
        var(--bg) var(--hero-scrim),
        transparent calc(var(--hero-scrim) + 18rem)
      ),
      linear-gradient(0deg, var(--bg) 0%, transparent 40%);
  }
}

/* The area glyph: large, 8 %, in --accent, aria-hidden in the macro. It sits
   on the art side so it never dilutes the copy. `color` drives both the fills
   and the strokes inside the SVG via currentColor. */
.hero--art__glyph {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: 4%;
  translate: 0 -50%;
  width: min(38vw, 320px);
  aspect-ratio: 1;
  opacity: 0.08;
  color: var(--accent);
  pointer-events: none;
}

.area-glyph {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.area-glyph__stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero--art__inner {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-4);
  justify-items: start;
  padding-block: var(--space-7);
  min-height: 16rem;
  align-content: center;
}

/* Keep every child inside the scrim, WITH MARGIN.

   The cap is 56 % while the scrim ends at 62 %, and the gap between the two
   numbers is the whole point. They are also measured from different boxes:
   the scrim is 62 % of the --container TOKEN (1120px), while this cap is 56 %
   of the inner's CONTENT box (1120px minus the container's own
   padding-inline, so 1072px at desktop). Setting both to 62 % left only 5px
   of clearance at 1440px -- measured -- which is not a margin, it is a
   coincidence. At 56 % the same measurement gives about 70px.

   This also overrides .hero__title's 14ch, which is deliberate: 14ch is right
   for the old two-column hero and far too narrow for a full-bleed one. */
.hero--art__inner > * {
  max-width: min(46ch, 56%);
}

/* ---------- Two-column art hero (#353, page spec `.hero__grid`) ----------
   ONE page uses this today: the signed-out home hero, which puts the ruling
   panel in the hero's right-hand cell. The modifier goes on the SECTION
   (`hero hero--art hero--art--duo`) because the scrim below is a property of
   the section, and the column geometry is a property of its inner.

   -------------------------------------------------------------------------
   THE SCRIM, RE-DERIVED. DO NOT ASSUME THE ONE-COLUMN NUMBERS CARRY OVER.
   -------------------------------------------------------------------------
   The .hero--art block above documents a ONE-SIDED construction: solid --bg
   left of --hero-scrim, art only past it, and `.hero--art__inner > *` keeping
   every piece of copy inside the solid part. That argument is about ONE
   region. A two-column hero puts text in a SECOND region -- the panel sits
   over art that is now behind it rather than beside it -- so the geometry is
   re-derived here rather than inherited.

   The new guarantee is a two-part one, and it is exhaustive -- every text
   pixel in this hero is covered by exactly one of these:

     1  THE COPY is over solid --bg, with a full grid gap of margin. The
        scrim no longer ends at "62 % of the --container token" (a number
        chosen for a full-bleed copy column); it ends at THE PANEL'S LEADING
        EDGE, computed from the same quantities the grid itself uses:
            left gutter + .container padding + the 1.1fr copy column + the gap
        So the solid run covers the copy column AND the empty gap after it,
        and stops exactly where the panel starts. The copy's last pixel is one
        whole gap (3rem) inside the solid region, and that margin is a named
        quantity rather than a coincidence.

        This moved the scrim's end INWARD, not outward: at 1440 the old stop
        was 854px and the copy could reach 56 % of the inner (~890px of
        container, 55.7 % => x=783); the new stop is 795px and the copy cannot
        pass 747px. The copy is strictly better protected than it was, and
        more art is revealed, which is the point of the composition.

     2  THE PANEL'S TEXT is over the panel, and the panel's own fill IS its
        local scrim. `.ruling` is `color-mix(--surface 70 %, --glass)`, which
        resolves to 91.6 % alpha on dark and 93.4 % on daylight, so at most
        8.4 % / 6.6 % of the backdrop reaches the text -- and that backdrop is
        itself >= 70 % --bg wherever the veil has run out, so the ART's own
        share of the text background is at most 2.5 % (dark) / 6.6 % (light).
        Measured, worst case, white art on dark and black art on daylight:
        --text 14.0 -> 13.0:1 and --text-muted 7.1 -> 6.5:1 on dark; on
        daylight --text-muted 7.1 -> 6.6:1. All clear AA for body text.

        Which is why `.ruling`'s fill is NOT made glassier here to match the
        spec's 72 % `.panel`. The accepted trade: the panel reads as a
        near-solid card rather than true glass, and in exchange its text needs
        no scrim of its own. `.ruling` is also shared with /features, so a
        glassier fill could not be changed here without forking it.

   The wash and veil STOPS are untouched (+7rem and +18rem off --hero-scrim),
   so only the origin moved. The `@supports not (color-mix)` fallback above
   reads the same `var(--hero-scrim)` and needed no edit: it follows the new
   origin automatically and still loses only the tint and the 70 % end stop,
   which is strictly safer.

   WHY THE SCRIM OVERRIDE IS INSIDE THE MEDIA QUERY. Below 64rem this hero is
   ONE column, and the formula would then be wrong by a hair in the worst
   direction: at 1023px it computes 582px while the single-column copy, capped
   at 35rem, reaches 584px. Two pixels is not a margin. Below 64rem the base
   .hero--art scrim (694px) applies unchanged and the copy stops 110px inside
   it. The formula also assumes .container's padding resolves to --space-4,
   which is only false when env(safe-area-inset-*) is larger -- a notched
   phone, i.e. below 48rem, where the guardrail block pins --hero-scrim to
   100vw anyway.
   ------------------------------------------------------------------------ */

/* The panel fills its cell and the copy column carries the measure; without
   this, `.hero--art__inner`'s `justify-items: start` would shrink both cells
   to min-content. Stated at three classes so it beats both
   `.hero--art__inner > *` (one class) and the guardrail block's
   `.hero--art-none .hero--art__inner > *` (two classes) by SPECIFICITY rather
   than by source order -- the guardrails are written last on purpose, and
   this must not depend on sitting after them. */
.hero--art--duo .hero--art__inner {
  justify-items: stretch;
}

/* One column until 64rem. 35rem is the two-column copy column's own width at
   desktop (563px), so the copy's line length barely changes across the
   breakpoint instead of jumping from a 46ch cap to the full container. */
.hero--art--duo .hero--art__inner > .hero__copy {
  max-width: min(100%, 35rem);
  min-width: 0;
}

/* ONE declaration covers both modes, because `100%` resolves against the grid
   AREA: in the two-column layout the cell is 418-461px so min() picks the
   cell, and in one column it picks 35rem. Without the cap the one-column
   panel ran the full container -- measured 654px of answer text at 768px, an
   82ch line, well past comfortable. (HEAD was worse still: the panel was a
   bare `.container` child, so 1072px at 1440.) 35rem is the copy's cap, so
   stacked, the hero reads as one column with one measure. */
.hero--art--duo .hero--art__inner > .ruling {
  max-width: min(100%, 35rem);
  min-width: 0;
}

/* The copy column is the measure now, so its children fill it. This replaces
   `.hero__title`'s 14ch and `.hero__lead`'s 46ch, which applied to the
   children directly and would otherwise re-narrow the heading to 252px on a
   390px phone -- the one-column guardrail used to override them, and no
   longer reaches them because they are grandchildren of the inner. */
.hero--art--duo .hero__copy > * {
  max-width: 100%;
}

/* The artist credit is the figure's LAST flex child and paints at z 0, BEHIND
   the inner at z 1, so the inner's bottom padding is what keeps the credit
   clear of the inner's last child. Below 48rem the guardrail block shortens
   that padding to --space-5 (32px), which is less than the credit's own line
   box plus padding (measured: 35.2px) -- so the last child lands on the
   credit's ascenders by 3.2px.

   That is NOT new: measured at HEAD, the credit overlaps `.hero__actions` by
   the same 3.2px at 390 and 768. What IS new is the consequence -- the last
   child is now a full-width, 92 %-opaque panel rather than a 240px button
   row, so it clips the whole credit line instead of a corner of it, and D8
   requires the credit to stay visible. Reserve the credit's height here.

   Scoped to the duo and to <= 48rem on purpose: the same arithmetic is true
   of every other art hero on the site, and repairing those is a separate
   change, not a side effect of this one. Two classes beat the guardrail
   block's one, so this does not depend on source order. */
@media (max-width: 48rem) {
  .hero--art--duo .hero--art__inner {
    padding-block-end: 2.75rem;
  }
}

@media (min-width: 64rem) {
  /* The page spec's ratio, kept: 1.1fr .9fr. At 1024 -- the narrowest width
     this applies at -- .9fr is a 418px cell, 354px of it inside the panel's
     padding, which is a ~44ch measure for the 16px answer and ~37ch for the
     19px question. Both sit inside the comfortable band, so the spec's ratio
     survives the real content length and there was no reason to change it.
     The breakpoint is 64rem rather than the spec preview's 900px so that the
     narrowest two-column case is exactly the 1024px width this is checked
     at, and 768px tablets stay stacked. */
  .hero--art--duo .hero--art__inner {
    grid-template-columns: 1.1fr 0.9fr;
    column-gap: var(--hero-duo-gap);
    align-items: center;
  }

  .hero--art--duo .hero--art__inner > .hero__copy {
    max-width: 100%;
  }

  /* The panel's leading edge, as a length. See the derivation above. */
  .hero--art--duo {
    /* The two-column hero's grid gap. Declared on the duo modifier, not on the
       shared `.hero--art`, so it cannot bleed into the single-column art heroes
       (/auth/login, /features). Both consumers are duo-scoped -- `column-gap`
       on `.hero--art--duo .hero--art__inner` and the `--hero-scrim` formula
       below -- and custom properties inherit, so one declaration still keeps
       them from drifting apart. */
    --hero-duo-gap: var(--space-6);

    --hero-scrim: calc(
      max(0px, (100vw - var(--container)) / 2) + var(--space-4) +
        (min(100vw, var(--container)) - var(--space-4) * 2 - var(--hero-duo-gap)) *
        0.55 + var(--hero-duo-gap)
    );
  }
}

/* The eyebrow ("DECKS · RED"). In --accent, which §2.2 measured against --bg
   for every hue: 7.5-11.6 on dark, 4.7-7.0 on daylight. It is a real text
   label, which is what keeps colour from being the only signal (§7 rule 5) --
   someone who cannot tell the hues apart still reads the area name. */
.hero__eyebrow {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* The artist credit: always visible on an art-backed surface (product
   decision D8, design README §3.3). It is a <figcaption>, so it is the
   figure's own caption rather than a tooltip. It sits on the solid part of the
   scrim, so --text-muted keeps its 7.8:1 (dark) / 6.6:1 (daylight). */
.hero__credit {
  position: relative;
  z-index: 1;
  margin: 0;
  padding-block-end: var(--space-3);
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

/* <figcaption> is only valid as the first or last child of <figure>, so the
   credit cannot live inside .container and has to rebuild its geometry. */
.hero__credit-inner {
  display: block;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: max(var(--space-4), env(safe-area-inset-left))
    max(var(--space-4), env(safe-area-inset-right));
}

/* The no-art path: the page's own section, eyebrow and heading, with no
   figure (art_hero bailed, or the page never called it). The page applies
   hero--art-none so the copy can use the full measure. */
.hero--art-none {
  overflow: visible;
}

/* ---------- Account-flow art hero (Option 4 §5, V3-e #284) --------------
   The COLOURLESS band above the six account-flow pages: sign in, register,
   check your email, the consent gate, delete account and settings. §5 asks
   for "a blurred neutral art hero", and every word of that is load-bearing
   here.

   WHY IT IS NOT THE ORDINARY .hero--art TREATMENT
   The standard hero is a LEFT-COLUMN composition: a one-sided scrim holds
   solid --bg under a left-aligned heading + lead, and the art is revealed in
   the right-hand third. These six pages have no hero copy at all -- their
   <h1> lives inside the card below, because six aria-labelledby wirings and
   two scripts' focus paths point at ids in those cards. All this band carries
   is the area eyebrow and the artist credit, so a left-column reveal would be
   a scrim with nothing to protect on one side and an unread picture on the
   other.

   So the scrim here is SYMMETRIC, and it runs top-to-bottom rather than
   left-to-right: --bg at full strength along the top and bottom EDGES,
   thinning to roughly half across the middle, mirrored about the centre
   line. The eyebrow is pulled to the TOP by the `align-content: start`
   override below -- it has to be, because the inherited `center` would park
   it in the middle, which is the thinnest part of the scrim. The
   <figcaption> credit is pinned to the bottom of the figure by
   .hero--art__figure's own flex-end. So the two stops the band actually
   puts text on are the --hero-scrim pair, at 92 % --bg, and each sits
   inside a run that only gets more opaque toward its edge. That clears the
   >= 90 % floor §4.1 claims for the left-column hero, measured at the
   positions THIS hero puts text in.

   N % IS ALPHA HERE, NOT A MIX WITH --accent. §4.1's stops are
   `color-mix(--bg N%, --accent)`, which is an OPAQUE colour: a gradient
   built only from those hides the illustration completely however low N
   goes, and the first draft of this block did exactly that -- an empty band
   with an artist credit under it, art credited and not shown. Mixing toward
   `transparent` instead (the same construction --area-glow uses) gives real
   alpha, so "92 % --bg" means the reader sees 8 % of the art there and the
   number is a contrast floor rather than a hue.

   A SMOOTH RAMP, NOT A WINDOW. The second draft cut straight from opaque to
   `transparent` and back, which rendered the art as a hard-edged horizontal
   stripe across the band -- a slot, not an atmosphere. The stops below ease
   the whole height instead, so the illustration reads as the soft wash §5
   asks for.

   THE OVERLAY IS NEVER REMOVED AND NEVER GOES FULLY OPAQUE.
   Not removed: .hero--art__figure's note explains that a failed <source>
   does not retry the <img>'s data-URI src, so the native broken-image glyph
   is masked by this foreground scrim and by nothing else. Making it
   transparent exposes that glyph on a dead network.
   Not fully opaque: a --hero-scrim of 100vw hides the illustration outright,
   which would be an uncredited-art problem dressed up as a styling choice --
   the credit would still be rendered (D8) for a picture nobody can see.

   WHICH IS WHY --hero-scrim IS SET AT .hero--art.authpage-hero SPECIFICITY.
   The guardrails block at the end of this file sets `.hero--art {
   --hero-scrim: 100vw }` below 48rem. That is correct for the left-column
   hero (there is no room for art beside text on a phone) and wrong here,
   where it would mean exactly the fully-opaque case above. Two classes beat
   one regardless of source order, so this cannot silently regress if either
   block moves.

   THE BLUR IS A FILTER ON THE IMAGE, NOT backdrop-filter.
   The .hero--art block's own performance note forbids adding backdrop-filter
   to this hero, and that stands: it would be a fourth composited glass
   surface on top of the header plus the page's card, over the Budget-3 cap.
   `filter: blur()` on the <img> is a cheap one-off raster of a single
   already-downscaled image instead, and below 40rem there is no image at all
   (the macro's <picture> never fetches one), so the filter costs nothing on
   a phone. The companion `scale()` hides the transparent fringe a blur
   leaves at the element's edges.
   ------------------------------------------------------------------------ */

.hero--art.authpage-hero {
  /* Read as a vertical band height here, not as the left-column width the
     base .hero--art rule computes. See the specificity note above. */
  --hero-scrim: 4rem;
}

/* Shorter than the 16rem content hero -- these pages exist to be completed
   and the form should not be pushed below the fold by decoration -- but tall
   enough that the two --hero-scrim runs do not meet in the middle and close
   the scrim over the art.

   `align-content: start` is the load-bearing half: it moves the eyebrow out
   of the thinnest part of the scrim and into the opaque top run. See the
   note above. */
.authpage-hero .hero--art__inner {
  min-height: 12rem;
  padding-block: var(--space-5);
  align-content: start;
}

/* The "blurred" half of §5's "blurred neutral art hero". A filter on the
   image, never backdrop-filter (see above). The companion scale() hides the
   transparent fringe a blur leaves at the element's own edges; without it
   the band shows four soft seams. */
.authpage-hero .hero--art__art img {
  filter: blur(14px);
  transform: scale(1.14);
}

/* Below 40rem the macro's <picture> serves no art and the guardrails block
   hides the layer, so the 12rem above would be reserving room for something
   that is not there -- 100-odd px of empty band between the visitor and the
   form they came to fill in. Shrink to what the eyebrow and the credit
   actually need. The breakpoint is the macro's, deliberately: this must move
   with the network gate, not independently of it. */
@media (max-width: 39.999rem) {
  .authpage-hero .hero--art__inner {
    min-height: 6rem;
  }
}

.authpage-hero .hero--art__overlay {
  background:
    /* The area glow, centred rather than top-right: this band is symmetric. */
    radial-gradient(70% 130% at 50% -20%, var(--area-glow), transparent 62%),
    linear-gradient(
      180deg,
      var(--bg) 0%,
      color-mix(in srgb, var(--bg) 92%, transparent) var(--hero-scrim),
      color-mix(in srgb, var(--bg) 55%, transparent) 50%,
      color-mix(in srgb, var(--bg) 92%, transparent)
        calc(100% - var(--hero-scrim)),
      var(--bg) 100%
    );
}

/* Engines without color-mix cannot express an alpha stop, so the ramp above
   would collapse to solid --bg and hide the art behind its own credit.
   Thin the IMAGE instead: an 8 %-opacity picture under a glow-only overlay
   is the same ">= 92 % --bg behind the text" floor reached the other way
   round, and it keeps the illustration faintly present rather than absent.
   The overlay itself is never removed -- .hero--art__figure's note explains
   that it is also what masks the native broken-image glyph when the fetch
   fails. */
@supports not (color: color-mix(in oklab, red, blue)) {
  .authpage-hero .hero--art__art img {
    opacity: 0.08;
  }

  .authpage-hero .hero--art__overlay {
    background:
      radial-gradient(70% 130% at 50% -20%, var(--area-glow), transparent 62%),
      linear-gradient(
        180deg,
        var(--bg) 0%,
        transparent var(--hero-scrim),
        transparent calc(100% - var(--hero-scrim)),
        var(--bg) 100%
      );
  }
}

/* ---------- Glass panel (Option 4 §4.4) ---------------------------------
   Not used by any template yet; waves #283 and #284 are its consumers. It is
   defined here so both arrive at the same panel instead of inventing one each.

   GLASS WITH A REAL FALLBACK, same contract as the header: --glass is >= 72 %
   opaque in both themes, so text contrast comes from the background colour and
   the blur is decoration. Without backdrop-filter the panel is a solid
   --surface card.

   THE RIM IS THE HOVER/FOCUS STATE (§4.4): 0 0 0 1px var(--rim) plus a soft
   0 0 26px -4px var(--rim). :focus-within means a keyboard user gets the same
   light a mouse user gets. --rim defaults to the area accent through the
   [data-hue] remap, and [data-identity] overrides it per object, so a card or
   deck glows in ITS colours inside any area.

   READ THIS BEFORE PUTTING A CARD GRID IN A PANEL. backdrop-filter makes an
   element the containing block for position: fixed descendants. .cc-pop is
   position: fixed and is deliberately anchored to the VIEWPORT (see its own
   comment, and the test that asserts the page does not widen). A .panel with
   live blur wrapped around .cc-grid would silently re-anchor every card
   enlargement to the panel. The guardrails section at the end of this file
   strips the blur in exactly that case, which is also how the "no
   backdrop-filter on grid tiles" budget is kept.
   ------------------------------------------------------------------------ */

.panel {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  transition: box-shadow 200ms ease;
}

@supports not (backdrop-filter: blur(1px)) {
  .panel {
    background: var(--surface);
  }
}

.panel:hover,
.panel:focus-within {
  box-shadow: 0 0 0 1px var(--rim), 0 0 26px -4px var(--rim);
}

/* Identity rims (§4.4 / §7 rule 3). The item's own colour identity, not the
   area's. Space-separated tokens, so data-identity="W U" matches both with
   ~=. These are the --rim-* glow palette, NOT --pip-*: pips are card data and
   rims are light around an object (§7 rule 4). */
[data-identity~="W"] { --rim: var(--rim-w); }
[data-identity~="U"] { --rim: var(--rim-u); }
[data-identity~="B"] { --rim: var(--rim-b); }
[data-identity~="R"] { --rim: var(--rim-r); }
[data-identity~="G"] { --rim: var(--rim-g); }
[data-identity=""]   { --rim: var(--hue-c); }

/* Multicolour: a gradient ring, drawn by a pseudo-element because a border
   cannot hold a gradient. The standard two-mask xor trick -- paint the
   gradient over the whole box, then punch out everything but a 1px frame.

   The CONSUMER supplies the gradient, because only it knows the colours:
       <article class="panel" data-identity="W U"
                style="--rim-grad: linear-gradient(100deg, var(--rim-w), var(--rim-u))">
   With no --rim-grad set this paints nothing, so a mono-coloured panel falls
   back to the single-colour box-shadow rim above and costs no extra layer. */
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--rim-grad, none);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.panel:hover::after,
.panel:focus-within::after {
  opacity: 1;
}

/* Legal pages stay plain (§4 non-negotiables, Option 2's rule): no art and no
   glass on privacy/terms/disclosures, so a solid reading column it is. Keyed
   off the page's own hue plus an opt-in class rather than a page name, so it
   cannot drift as routes are added. */
.panel--plain,
.panel--plain:hover,
.panel--plain:focus-within {
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

/* ---------- Ruling (the signature element) -------------------------------
   A worked example of what the product actually returns: a question a new
   player really asks, a plain-language answer, and the rule it came from.
   Presented as a <figure> with a visible caption so nobody mistakes it for a
   live widget.
   ------------------------------------------------------------------------ */

.ruling {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-3);
  position: relative;
}

/* The accent edge is the only ornament on the page. */
.ruling::before {
  content: "";
  position: absolute;
  inset-block: var(--space-5);
  inset-inline-start: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.ruling__question {
  font-size: 1.1875rem;
  font-weight: 640;
  letter-spacing: -0.018em;
  line-height: 1.35;
}

.ruling__answer {
  color: var(--text-muted);
  font-size: var(--fs-body);
}

.ruling__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.citation {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
}

.citation__ref {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ruling__caption {
  color: var(--text-muted);
  font-size: var(--fs-micro);
}

/* ---------- Statement ---------------------------------------------------- */

.statement {
  background: var(--surface-sunken);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Note: this sits INSIDE .container, it is not a .container itself. Putting
   both classes on one element makes .container's `margin-inline: auto` centre
   the narrower box, which visibly breaks the page's left alignment. */
.statement__inner {
  display: grid;
  gap: var(--space-4);
  max-width: 46rem;
}

.statement__title {
  font-size: var(--fs-h2);
  font-weight: 680;
  letter-spacing: -0.024em;
}

.statement__body {
  font-size: var(--fs-lead);
  color: var(--text-muted);
  max-width: var(--measure);
}

.statement__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---------- Signed-in panel ---------------------------------------------- */

.welcome {
  padding-block: var(--space-7);
}

.welcome__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
  justify-items: start;
  max-width: 44rem;
}

.welcome__title {
  font-size: var(--fs-h2);
  font-weight: 690;
  letter-spacing: -0.026em;
}

.welcome__body {
  color: var(--text-muted);
  max-width: var(--measure);
}

.welcome__identity {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.welcome__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

/* ---------- Five-ways hub (Option 4 §4.5) --------------------------------
   Five glass tiles, one per product area, each carrying its own `data-hue`
   so its strip, eyebrow and hover rim light in that area's colour. It is the
   same row on the home page (signed out and signed in) and the dashboard, and
   it replaces both the signed-out bento and the signed-in quick links.

   The hue strips carry real card art as of #346 -- a plain <img> per tile,
   pulled from _art.html's ART map by the tile's data-hue, over the hue
   gradient that is now the fallback and under an accent-tinted veil. They are
   still NOT art_hero() calls: the hero budget is per-render (one figure per
   page, see _base_public.html's `_hero_budget` namespace and _macros.html's
   art_hero guard), so five art_hero calls would silently emit only the first
   figure and drop four. See .hub__strip / .hub__art / .hub__strip::after
   below for the three layers and what each one is for.

   GLASS WITHOUT BLUR. The tiles are translucent glass (the same reinforced
   fill the header and .panel use) but deliberately carry NO backdrop-filter:
   five blurred tiles plus the header would blow the "at most 3 glass layers"
   budget (Option 2 §7). The translucency over the nebula carries the glass
   look; blur stays reserved for the header and .panel.

   §7 rule 2: the hue lights the strip (ambient), the eyebrow (wayfinding) and
   the hover rim (interactive) only -- never the title (--text) or the copy
   (--text-muted).
   ------------------------------------------------------------------------ */

.hub {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hub > li {
  display: flex;
  min-width: 0;
}

/* #350: the five-up row now arrives at 64rem instead of 75rem, with a 3-up
   step filling the band below it.

   The spec holds five-up from 901px (option-4-mana-night.html line 119 drops to
   2-up only under max-width:900px). Taken literally that is 56rem here, so it
   was measured before it was adopted. Tile and text widths from a real
   Chromium at the container's 1120px cap, WITH #352's body padding applied --
   `textW` is the width the eyebrow/title/copy actually get:

     viewport  2-up            3-up            5-up
     768       352 / 318 text  229 / 195 text  131 /  97 text
     896       416 / 382       272 / 238       157 / 123
     960       448 / 414       293 / 259       170 / 136
     1024      480 / 446       315 / 281       182 / 148
     1120+     528 / 494       347 / 313       202 / 168

   The reference the design already accepts is the five-up it shipped at
   >=75rem: 202px wide, 152px of text before #352 and 168px after. Against that:

     * 56rem five-up (the literal spec breakpoint) gives 157px / 123px text --
       19% under the accepted text width -- and the copy wraps to 3,4,4,3,3
       lines, so five tiles in one row disagree about their height and the
       titles stop aligning across the row. Tile aspect reaches 1.71 (height /
       width): a column, not a tile. That is the cramped case, so it is not
       adopted.
     * 60rem five-up gives 136px text (-11%), uniform 3-line copy, aspect 1.45.
       Workable but still visibly narrower than the design's own row.
     * 64rem five-up gives 148px text -- within 4px of the 152px the shipped
       five-up had before #352 -- uniform 3-line copy, aspect 1.34. This is the
       step: it is the lowest breakpoint at which a five-up tile is no narrower
       than the one the design was approved with, and it fixes the symptom #350
       was filed for (a 1024px desktop no longer gets a ragged 2x3).

   The 896-1023 band it leaves behind goes to 3-up rather than staying 2-up:
   272-315px tiles with uniform 2-line copy and aspect 0.71-0.82. Five tiles
   cannot divide evenly into anything but 1 or 5 columns, so the choice there is
   between kinds of raggedness, and 3+2 beats 2+2+1 -- two rows instead of
   three, with the short row 2/3 full instead of 1/2 full.

   4-up is deliberately absent at every width: 5 tiles over 4 columns is 4+1,
   a single orphan tile on its own row, which reads as broken however wide the
   tiles get.

   3-up is not pushed below 56rem either: at 768px it is 229px / 195px text
   with copy at 2,2,3,2,2 lines, which is worse than the 2-up it would replace
   (352px, 1-2 lines). 2-up keeps 48-56rem. */
@media (min-width: 48rem) {
  .hub {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 56rem) {
  .hub {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .hub {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.hub__tile {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 200ms ease;
}

@supports (color: color-mix(in srgb, red, blue)) {
  .hub__tile {
    background: color-mix(in srgb, var(--surface) 70%, var(--glass));
  }
}

.hub__tile:hover,
.hub__tile:focus-visible {
  border-color: var(--rim);
  box-shadow: 0 0 0 1px var(--rim), 0 0 26px -4px var(--rim);
}

/* #346: the strip now carries the tile's real card art (the demo's
   `.way__art`, option-4-mana-night.html lines 93-96) at EVERY width -- there
   is no min-width gate, phones get it too.

   The gradient STAYS on this base rule. It is no longer the strip's only
   appearance, but it is still what the reader sees when the Scryfall hotlink
   is slow or fails, and it is still what keeps the tile lit by its own hue.
   Painting it as a background rather than as a sibling element means a failed
   image leaves a hue-lit panel, not a hole.

   `position: relative` is for ::after below; `overflow: hidden` clips the
   image to the tile's rounded top corners, which .hub__tile's own overflow
   would otherwise have to do alone. */
.hub__strip {
  position: relative;
  display: block;
  height: 5.5rem;
  overflow: hidden;
  background:
    radial-gradient(130% 160% at 85% -20%, var(--area-glow), transparent 62%),
    linear-gradient(160deg, var(--accent) 0%, var(--accent-tint) 100%);
}

/* The art itself. A plain <img>, NOT art_hero(): the hero budget is one
   figure per render (_macros.html's art_hero guard), so five macro calls
   would emit one and silently drop four. The <img> sits inside the strip's
   existing aria-hidden span with alt="", so it adds nothing to the tile's
   accessible name -- the name stays eyebrow + title + copy. Lazy and async:
   none of these five is above the fold on a phone. */
.hub__art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The veil the strip hosts (the demo's `.way__art::after`, line 96). It is
   what makes five pieces of unrelated art read as one system: each is pulled
   down into --surface at the bottom edge, where the tile's body begins, and
   tinted by its own --accent at the top. Without it the tiles are five
   photographs in a row. */
.hub__strip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    0deg,
    var(--surface) 0%,
    color-mix(in srgb, var(--accent) 30%, transparent) 100%
  );
}

/* Engines without color-mix lose the accent tint, not the veil: the art still
   settles into --surface at the body edge, it just is not hue-lit on the way
   up. A dropped `background` would leave the art unveiled instead. */
@supports not (color: color-mix(in oklab, red, blue)) {
  .hub__strip::after {
    background: linear-gradient(0deg, var(--surface) 0%, transparent 100%);
  }
}

/* #352: the spec's asymmetric body padding (option-4-mana-night.html line 96,
   `.way__body{padding:14px 16px 18px}`) rather than a uniform --space-4 (24px).

   WHY ASYMMETRIC, AND WHY ONLY NOW. The top edge is the tight one (14px)
   because the strip's veil already fades into --surface right above it, so the
   body reads as starting higher than its padding says; 24px there left a
   visible dead band between the art and the eyebrow. The bottom is the loose
   one (18px) so the copy does not sit on the tile's bottom rim. That reasoning
   only holds once there IS art above the body -- before #346 the strip was a
   flat gradient with no fade to compensate for, which is why this was
   sequenced after it rather than shipped with the original tile.

   Side effect that matters for #350: 16px side padding instead of 24px returns
   16px of text width to every tile, which is what makes a five-up row viable
   below 1200px at all. See the breakpoint ladder above.

   14px and 18px have no --space token (the scale steps 8 -> 16 -> 24); they are
   written as rem so they still scale with the user's root font size. The one
   value that does have a token uses it. */
.hub__body {
  display: grid;
  gap: var(--space-1);
  padding: 0.875rem var(--space-3) 1.125rem;
  align-content: start;
}

.hub__eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hub__title {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
  color: var(--text);
}

/* #356: exact route counts in the tile body; no empty chip for unknowns.
   Keep the label in markup for AT, and allow long totals to wrap at zoom. */
.hub__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
}

.hub__count {
  color: var(--accent);
  font: 700 1.6rem / 1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  min-width: 0;
}

.hub__copy {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: 44ch;
}

/* #346 / product decision D8: the artist credit is ALWAYS visible wherever
   art renders. The hub renders five pieces of art, so it carries one credit
   line beneath the listing naming all five -- not five captions inside the
   tiles, which would put a second block of text inside each link's
   accessible name and bury the wayfinding the tiles exist for. Reuses
   `.credits` (the same treatment as the artband's figcaption) so the two
   credit surfaces on the home page read as one thing. */
.hub__credits {
  margin-top: var(--space-3);
}

/* #354: representative art shelf, not inventory. Art crops only, plain
   name strips and letter pips for AREAS; no card frames or WotC typeface.
   Captions/credits are always in flow, including on narrow screens. */
.area-art-shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.area-art-shelf > li,
.area-art-shelf__tile {
  min-width: 0;
}

.area-art-shelf__tile {
  margin: 0;
}

.area-art-shelf__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.area-art-shelf__caption {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
  overflow-wrap: anywhere;
}

.area-art-shelf__name {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.35;
}

.area-art-shelf__area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.area-art-shelf .area-art-shelf__credit {
  display: block;
  margin: 0;
}

@media (min-width: 36rem) {
  .area-art-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 48rem) {
  .area-art-shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 64rem) {
  .area-art-shelf { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* The ruling (a rules answer) is a glass panel, not a solid card; its accent
   edge and citation are lit by data-hue="u" on the figure (home.html). Same
   reinforced translucent fill as the hub tiles, solid --surface otherwise, no
   backdrop-filter (the blur budget is the header plus at most two panels). */
@supports (color: color-mix(in srgb, red, blue)) {
  .ruling {
    background: color-mix(in srgb, var(--surface) 70%, var(--glass));
  }
}

@media (prefers-reduced-transparency: reduce) {
  .hub__tile,
  .ruling {
    background: var(--surface) !important;
  }
}

/* ---------- Card artwork -------------------------------------------------
   Real Magic card art hotlinked from Scryfall (permitted). Always art crops,
   never full card frames: a card frame reads as a product screenshot, the
   artwork alone reads as atmosphere.

   Every frame carries a fixed aspect-ratio and a sunken background, so the
   image never causes layout shift and a failed load leaves a tinted panel
   rather than a hole in the page.
   ------------------------------------------------------------------------ */

.art {
  display: block;
  margin: 0;
  background: var(--surface-sunken);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* If the image fails to load, the alt text is what the reader gets. Style it
     so it reads as a small caption inside the tinted frame rather than as
     oversized broken-image text. */
  font-size: var(--fs-micro);
  line-height: 1.45;
  color: var(--text-muted);
}

/* #348: 4:3, not 1:1. The source family is Scryfall `art_crop`, which is
   landscape (a nominal 626x457, ~1.37:1). Cropping it into a square discarded
   ~27 % of every illustration's width at every viewport width -- art that is
   credited on the page and then not shown. 4:3 (1.333:1) is inside the
   source ratio, so the crop drops to ~2.7 % and the composition survives.

   This now matches `.art`'s own base ratio, so the class is a no-op in CSS
   terms. It is deliberately kept rather than deleted: the markup says which
   frames are the artband's, and a future ratio change for that band has a
   hook to land on. */
.art--square {
  aspect-ratio: 4 / 3;
}

/* Content-page hero art: copy and a 4:3 card-art frame side by side. The
   frame caps the art under its 626px source width so it downscales cleanly
   instead of upscaling into a full-bleed banner. */
.art-duo {
  display: grid;
  gap: var(--space-5);
  align-items: start;
  padding-top: var(--space-2);
}

@media (min-width: 62rem) {
  .art-duo {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-6);
  }
}

/* #314: hidden below 40rem, shown at and above it -- the SAME breakpoint as
   the `<source media>` in the markup, and that pairing is the whole point.
   The <picture> gate means a phone resolves the 1x1 inline SVG and fetches no
   art_crop; without this rule the frame would still paint as an empty sunken
   4:3 box with a visible artist credit underneath it, i.e. crediting art that
   is not on the page (D8 requires the credit to be visible wherever the art
   renders, not where it does not). Hiding the figure instead of the <img> is
   not an optimisation -- `display: none` does NOT stop an <img> loading, so the
   gate has to stay in the markup; this rule only stops the empty frame.
   Keep the two 40rem values in step. */
.art-duo__art {
  margin: 0;
  display: none;
}

@media (min-width: 40rem) {
  .art-duo__art {
    display: block;
  }
}

/* The <picture> is an inline box by default, which would leave the img's
   `height: 100%` resolving against auto and collapse the fill. */
.art-duo__picture {
  display: block;
  width: 100%;
  height: 100%;
}

.art-duo__frame {
  background: var(--surface-sunken);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow);
}

.art-duo__frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.art-duo .credits {
  color: var(--text-muted);
  font-size: var(--fs-micro);
  margin-top: var(--space-2);
}

/* Horizontal band of art crops. Scrolls sideways on narrow screens rather
   than shrinking each crop into an unreadable sliver.

   `min-width: 0` is load-bearing, not decoration: this is a grid item whose
   default `min-width: auto` resolves to its min-content width (five 11rem
   columns), which pushes the whole page wider than a phone viewport and breaks
   every other section's layout with it. */
.artband {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(11rem, 1fr);
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: var(--space-2);
  overscroll-behavior-x: contain;
}

.artband > * {
  scroll-snap-align: start;
}

@media (min-width: 62rem) {
  .artband {
    overflow-x: visible;
  }
}

.art-figure,
.artband-figure {
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

/* Artist credits. Not decoration: these name real illustrators whose work is
   on the page, and the card names are what the images actually depict. */
.credits {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  color: var(--text-muted);
  font-size: var(--fs-micro);
  line-height: 1.5;
}

/* ---------- Media + prose split ------------------------------------------ */

.split {
  display: grid;
  gap: var(--space-5);
  align-items: center;
}

/* Placement is explicit rather than done with `order`, so source order can stay
   body-first (which is also the order it stacks in on mobile and the order a
   screen reader hears) while either side can carry the media visually. Text
   always gets the wider column. */
@media (min-width: 52rem) {
  .split {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-6);
  }
  .split__body {
    grid-column: 1;
  }
  .split__media {
    grid-column: 2;
  }
  .split--reverse {
    grid-template-columns: 5fr 7fr;
  }
  .split--reverse .split__body {
    grid-column: 2;
  }
  .split--reverse .split__media {
    grid-column: 1;
  }
}

.split__body {
  display: grid;
  gap: var(--space-3);
  max-width: var(--measure);
}

/* ---------- Page hero (features / about) --------------------------------- */

.page-hero {
  padding-block: var(--space-5) var(--space-4);
}

.page-hero__copy {
  display: grid;
  gap: var(--space-3);
  max-width: 42rem;
  margin-bottom: var(--space-5);
}

.page-hero__title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-hero__lead {
  font-size: var(--fs-lead);
  color: var(--text-muted);
}

/* ---------- Prose blocks -------------------------------------------------- */

.prose {
  display: grid;
  gap: var(--space-3);
  max-width: var(--measure);
}

.prose p {
  color: var(--text-muted);
}

.prose h3 {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
  color: var(--text);
  margin-top: var(--space-2);
}

/* Two-column prose. Used where a section has exactly two peer explanations
   and neither should dominate. */
.duo {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 52rem) {
  .duo {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

/* ---------- Plain fact list ---------------------------------------------- */

/* Deliberately not a card grid and not a bulleted <ul> with a hairline under
   every row. Each entry is a term plus a short definition, grouped, with one
   divider above the group only. */
.facts {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

@media (min-width: 52rem) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-6);
  }
}

.facts__term {
  font-weight: 640;
  letter-spacing: -0.012em;
  margin-bottom: var(--space-1);
}

.facts__def {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: 46ch;
}

/* A citation sitting inside running text rather than in a ruling footer. */
.facts__def .citation {
  vertical-align: baseline;
  margin-inline-start: 0.15rem;
}

/* ---------- Honest "not built yet" note ---------------------------------- */

.note {
  border-inline-start: 3px solid var(--border-strong);
  padding: var(--space-1) 0 var(--space-1) var(--space-4);
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
  display: grid;
  gap: var(--space-2);
}

.note strong {
  color: var(--text);
  font-weight: 640;
}

/* The one positive variant. There is still only ONE accent on this site, so a
   good outcome is the accent tint and a problem is the plain grey .note above.
   No red, no green-vs-red pair: adding semantic status colours here would mean
   inventing two new hues for one page, and the neutral note already reads as
   "something to deal with" without shouting. */
.note--accent {
  border-inline-start-color: var(--accent);
  background: var(--accent-tint);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  font-size: var(--fs-small);
}

/* ---------- Interstitial (post-registration "check your email") -----------
   A dead-end page: one panel, one message, one recovery action. It is the only
   place on the public site where the content is centred rather than
   left-aligned, and that is the point -- there is no page to read here, so
   nothing should suggest scrolling on. The text inside the panel still rags
   left like everywhere else.
   ------------------------------------------------------------------------ */

.interstitial {
  padding-block: var(--space-7);
}

.interstitial__panel {
  position: relative;
  max-width: 34rem;
  margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-4);
}

/* Padding grows in two steps rather than one. The smallest step is not
   cosmetic: on a 320px screen the panel's own padding is what decides whether
   the button below still fits on a single line. */
@media (min-width: 24rem) {
  .interstitial__panel {
    padding: var(--space-5);
  }
}

@media (min-width: 34rem) {
  .interstitial__panel {
    padding: var(--space-6);
  }
}

/* The same accent edge the homepage's ruling card carries: this site has one
   ornament and this is it. */
.interstitial__panel::before {
  content: "";
  position: absolute;
  inset-block: var(--space-5);
  inset-inline-start: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.interstitial__title {
  font-size: var(--fs-h2);
  font-weight: 690;
  letter-spacing: -0.026em;
}

.interstitial__lead {
  font-size: var(--fs-lead);
  color: var(--text-muted);
}

.interstitial__body {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* The address is set in mono for the same reason rule numbers are: it is a
   fact the reader is being asked to check, character by character, and a
   proportional face makes rn/m and l/I harder to tell apart. `anywhere` rather
   than `break-word` so a long address wraps inside the box on a phone instead
   of widening the panel. */
.interstitial__address {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow-wrap: anywhere;
}

.interstitial__help {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.interstitial__subtitle {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
}

.interstitial__help .prose {
  gap: var(--space-2);
  font-size: var(--fs-small);
}

.resend {
  margin: 0;
  justify-self: start;
}

/* The one button on the page carries a long, unambiguous label. Overriding
   .btn's nowrap lets it wrap on a very narrow phone rather than push out of
   the panel; it stays on one line at every size that matters. */
.resend__button {
  white-space: normal;
  text-align: center;
}

.interstitial__aside {
  max-width: 34rem;
  margin: var(--space-4) auto 0;
  text-align: center;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* ---------- Long-form document pages ------------------------------------- */

/* /privacy, /terms and /disclosures are the first public pages that contain
   running lists and tabular data, and the reset above deliberately strips list
   markers site-wide. Everything in this block is ELEMENT-scoped inside .prose
   or .section rather than a new class vocabulary, on purpose: no page shipped
   before these three contains a <ul>, <ol> or <table>, so nothing existing
   changes appearance, and a legal document does not earn its own components. */

.prose ul,
.prose ol {
  margin: 0;
  padding-inline-start: var(--space-4);
  color: var(--text-muted);
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

/* Rows in a legal document are often a full sentence each, so they need real
   separation from one another, not just line spacing. */
.prose li + li {
  margin-top: var(--space-2);
}

.prose li > ul,
.prose li > ol {
  margin-top: var(--space-2);
}

/* A wide data table inside a long-form document. Hairline-and-space rather
   than a boxed grid: one rule per row is enough separation, and a bordered
   cell grid would be the densest thing on the whole site.

   On narrow viewports the table keeps its real semantics and the WRAPPER
   scrolls. Reflowing a <table> into stacked blocks with display:block is the
   common trick and it silently destroys the row/column associations assistive
   tech depends on. The wrapper is a labelled, focusable region instead, so the
   table can be reached and scrolled from the keyboard as well as by touch.
   Selected by [role="region"] because that role is what makes it reachable;
   nothing else on the public site uses it.

   LONG-FORM LEGAL SECTIONS SHARE THESE RULES (V3-f #284). privacy.html and
   terms.html carry data tables inside `.legal__section` rather than
   `.section`, because the legal shell sets its own rhythm. The table rules
   below are therefore written for BOTH owners: without the second selector a
   data table loses its wrapper's overflow-x, its min-width and the cell
   borders, and a four-column table pushes the whole page sideways on a
   phone. That is a real regression this list exists to prevent, so add any
   future table-bearing section container here rather than re-scoping it. */
.section [role="region"],
.legal__section [role="region"] {
  overflow-x: auto;
  margin-block-start: var(--space-4);
  /* Scroll shadows, CSS only. The two --bg layers are attached to the content
     ("local") so they slide away as you scroll; the two tinted layers are
     attached to the frame ("scroll") and stay put. The result is a soft edge
     that appears only on the side that still has hidden columns, so a table
     that fits shows nothing at all. Without this the clipped column reads as a
     broken layout rather than as something you can push sideways. */
  background:
    linear-gradient(to right, var(--bg) 40%, var(--scroll-shadow-clear)) 0 0 / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--bg) 40%, var(--scroll-shadow-clear)) 100% 0 / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--border-strong), var(--scroll-shadow-clear)) 0 0 / 0.75rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--border-strong), var(--scroll-shadow-clear)) 100% 0 / 0.75rem 100% no-repeat scroll;
}

.section table,
.legal__section table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.section th,
.section td,
.legal__section th,
.legal__section td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.section thead th,
.legal__section thead th {
  color: var(--text);
  font-weight: 640;
  letter-spacing: -0.012em;
  border-bottom-color: var(--border-strong);
}

/* The row header is the thing being described, so it stays full-strength ink
   while the cells explaining it drop to muted, exactly like .facts. */
.section tbody th,
.legal__section tbody th {
  color: var(--text);
  font-weight: 640;
  width: 24%;
}

.section td,
.legal__section td {
  color: var(--text-muted);
}

.section tbody tr:last-child th,
.section tbody tr:last-child td,
.legal__section tbody tr:last-child th,
.legal__section tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Footer ------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: var(--space-5);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 48rem) {
  .site-footer__inner {
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: var(--space-6);
  }
}

.site-footer__brand {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--fs-small);
}

.site-footer__nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer__nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer__legal {
  display: grid;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--fs-micro);
  line-height: 1.65;
  max-width: 70ch;
}

.site-footer__version {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: calc(var(--fs-micro) * 0.9);
  letter-spacing: 0.08em;
  line-height: 1.6;
  white-space: nowrap;
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  /* The stamp is the footer's terminal build marker, not a third legal
     paragraph. A hairline rule above and a one-step size drop below
     --fs-micro pull it out of the legal-text flow; wide mono tracking
     gives the machine its visible character; the muted colour is
     inherited so it stays quieter than the legal copy, never louder.
     Deliberately not a link and not accent-coloured, per plan. */
}

/* ---------- Footer theme switch ------------------------------------------
   A plain <form method="post"> to POST /settings/theme (no JavaScript). The
   pressed button reflects the current theme via aria-pressed and a tinted
   "on" state; the legend is the text, so colour is never the only signal.
   ------------------------------------------------------------------------ */
.themeform {
  margin: 0;
}

.themeform__fieldset {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.themeform__legend {
  padding: 0;
  margin-inline-end: var(--space-1);
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--text-muted);
}

.themebtn {
  font: inherit;
  font-size: var(--fs-micro);
  font-weight: 560;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.themebtn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.themebtn[aria-pressed="true"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 620;
}

/* ---------- Utilities ---------------------------------------------------- */

/* Same clip-path technique as .skip-link, but for text that must never become
   visible on focus (screen-reader-only clarifications, e.g. "opens in a new
   tab"). Kept as a utility because the register/verify-email forms will want
   the same thing. */
.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Inline messages ---------------------------------------------- */

/* One message component, not one per page. The tinted-panel-with-an-edge
   shape deliberately echoes .note (the "not built yet" aside) so a warning
   does not arrive as a foreign object from another design language.

   Colour alone never carries the meaning: the copy inside always states the
   problem, per WCAG 1.4.1. */
.alert {
  margin: 0;
  border-inline-start: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-sunken);
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

.alert--error {
  /* Semantic danger is separate from the evergreen accent so an error reads
     as a problem. The tint replaces --surface-sunken so a red message is
     never set on a green-tinted panel. Text on tint measures 7.5:1 (light)
     and 8.7:1 (dark). */
  background: var(--danger-tint);
  border-inline-start-color: var(--danger);
  color: var(--danger-strong);
}

/* ---------- Consent gate (/consent) --------------------------------------
   A hard gate, per decision D3: no dismiss, no "later", no skip link past it.
   So the page is deliberately one column, one panel, one decision. There is
   no second call to action competing with "Accept and continue" -- signing
   out is styled as the quiet alternative it is, not as an equal choice.
   ------------------------------------------------------------------------ */

.gate {
  padding-block: var(--space-6) var(--space-7);
}

.gate__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-5);
  /* Narrower than .welcome__panel: this is a reading-and-deciding surface,
     and the checkbox rows below need a short line to stay scannable. Centred
     rather than flush-left like every other panel on the site, because this
     page has exactly one thing on it and a left-hugging card leaves a large
     dead area that reads as a broken layout rather than as breathing room. */
  max-width: 38rem;
  margin-inline: auto;
}

@media (min-width: 40rem) {
  .gate__panel {
    padding: var(--space-6);
  }
}

/* ---------- Glass on the two account-flow panels (V3-e #284) ------------
   The consent gate and the "check your email" interstitial are the two
   account-flow pages that load NO stylesheet but this one, so their glass
   lives here rather than in auth.css/account.css with the other four.

   BY PROPERTY, NOT BY ADDING .panel. Both panels own a padding and gap
   scale, a max-width and an ::before accent edge that .panel does not have
   and would partly overwrite. What they want from .panel is its SURFACE --
   the translucent fill, the blur and the honest fallback -- so that is what
   is copied, and the geometry above is left exactly as it was.

   Same three-part contract as .panel itself: --glass is >= 72 % opaque in
   both themes, so text contrast comes from the fill and the blur is pure
   decoration; engines without backdrop-filter get the opaque --surface they
   had before; and a reader who asks for reduced transparency gets it too.
   Budget 3 (header + at most two composited surfaces) is respected: these
   pages render exactly one panel each, so each is header + 1.
   ------------------------------------------------------------------------ */

.gate__panel,
.interstitial__panel {
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
}

@supports not (backdrop-filter: blur(1px)) {
  .gate__panel,
  .interstitial__panel {
    background: var(--surface);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .gate__panel,
  .interstitial__panel {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.gate__intro {
  display: grid;
  gap: var(--space-3);
}

.gate__title {
  font-size: var(--fs-h2);
  font-weight: 690;
  letter-spacing: -0.026em;
}

.gate__lead {
  color: var(--text-muted);
  font-size: var(--fs-lead);
}

.gate__form {
  display: grid;
  gap: var(--space-5);
}

/* A fieldset is the right grouping element for "these checkboxes are one
   question", but its default border and inline padding are not. */
.gate__fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.gate__legend {
  padding: 0;
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 600;
}

.gate__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* The refusal path. Separated by a rule and set small, because it must be
   findable (consent is only real if declining is possible) without reading
   as an equally weighted option. */
.gate__decline {
  display: grid;
  justify-items: start;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

.gate__aside {
  color: var(--text-muted);
  font-size: var(--fs-micro);
}

/* ---------- Checkbox field ------------------------------------------------
   Shared component, not consent-specific: the registration form's own terms
   checkbox (REG-1) should reuse .checkfield rather than growing a second
   checkbox style. Checkbox first, then label, then a supporting line -- the
   label is the accept statement itself, so it stays full-strength ink while
   the explanation drops to muted.

   The native control is kept and merely enlarged. A custom-drawn checkbox
   would have to re-earn focus, high-contrast-mode and forced-colors
   behaviour that the platform control already has.
   ------------------------------------------------------------------------ */

.checkfields {
  display: grid;
  gap: var(--space-3);
}

.checkfield {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  align-items: start;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  transition: border-color 140ms ease;
}

.checkfield:focus-within {
  border-color: var(--accent);
}

.checkfield__input {
  /* 20px. Under WCAG 2.5.8's 24px minimum on its own, which is allowed here
     via the spacing exception: the row padding and the --space-3 gap between
     rows keep a 24px circle around each box clear of every other target, and
     the `for`-associated label gives a much larger second target for the same
     action. Sizing it up further starts to look like a checkbox pretending to
     be a button. */
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  /* Nudge onto the label's first-line baseline rather than its box top. */
  margin-block-start: 0.2rem;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.checkfield__text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.checkfield__label {
  font-weight: 620;
  letter-spacing: -0.012em;
  cursor: pointer;
}

.checkfield__detail {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* The link out and the version stamp are metadata about the document, not
   part of the sentence describing it, so they get their own row rather than
   trailing the summary and wrapping mid-phrase. */
.checkfield__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-1);
  font-size: var(--fs-small);
  font-weight: 560;
}

/* Mono, because a document version is a checkable fact, exactly like the
   rule numbers and deck limits elsewhere on this site. */
.checkfield__version {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Collection & deck management ---------------------------------
   /dashboard/collections (PAGES-3) and /dashboard/decks (PAGES-4).

   Both pages render the signed-in user's rows as a data table via
   .section table (see "Long-form document pages" above) and act on each row
   with small plain-HTML POST forms. Five things are genuinely new here and
   land together because they share one job: turn a data table into a small
   workspace without introducing cards, pills or a second accent.

   * .mono        -- a checkable fact set in the mono stack: set codes,
                     collector numbers and card quantities. site.css reserves
                     mono for facts the reader can verify (rule numbers, deck
                     limits, footer version) but until now baked it into whole
                     components; these pages are the first to need it as a span
                     inside a table cell.
   * .table-form  -- an inline row form: a number input and its action button
                     on one line that wraps instead of widening the table.
   * .qty-input   -- a compact numeric input, the same single-input look as
                     auth.css's .field__input (--control-border outline,
                     --radius-sm, hover to accent), sized to a cell.
   * .btn--row    -- a small outline button for row actions, because .btn's
                     padding is built for nav and forms, not a data row. Its
                     --danger variant reuses .alert--error's one red per scheme
                     so the site does not grow a second red.
   * .empty       -- an invitation-to-act empty state: a title and a pointer,
                     no card, no icon.

   No new tokens: every value comes from :root, including dark-scheme
   overrides.
   ------------------------------------------------------------------------ */

/* Checkable facts inside table cells. tabular-nums so a column of set codes
   or collector numbers lines up digit-for-digit. */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* Inline row form: input and button share one line, wrapping rather than
   pushing the cell (and with it the whole table) wider. */
.table-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

/* Compact numeric input, sized to a cell. Same single-input look as
   .field__input: --control-border is the affordance (3:1 per WCAG 1.4.11),
   hover moves it to the accent, and the global :focus-visible outline still
   owns focus. */
.qty-input {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  width: 5ch;
  padding: 0.35rem 0.5rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color 140ms ease;
}

.qty-input:hover {
  border-color: var(--accent);
}

/* Row-action button. Extends .btn (radius, cursor, transitions, active press)
   with the size of a data cell rather than a nav item. */
.btn--row {
  padding: 0.35rem 0.75rem;
  font-size: var(--fs-micro);
  line-height: 1.4;
  background: transparent;
  border-color: var(--control-border);
  color: var(--text);
}

.btn--row:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* The destructive row action (remove a card, delete a deck). The calm outline
   stays; only the ink and edge change to .alert--error's one red per scheme,
   so it reads as distinct from Save without the heavy filled red account.css
   reserves for deleting the whole account. The word Delete carries the meaning;
   the red only reinforces it (WCAG 1.4.1). */
.btn--row--danger {
  border-color: var(--danger);
  color: var(--danger-strong);
}

.btn--row--danger:hover {
  border-color: var(--danger-strong);
  color: var(--danger-strong);
}

/* Page-level flash messages (an import result: a success note, optionally a
   "some lines skipped" note, or a single error). One grid so two notes keep
   their own identity but share one rhythm; left-aligned so a message never
   stretches to a full-width band. */
.flash {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  margin: 0 0 var(--space-4);
}

/* The paste-a-list import control. A textarea and its label/hint/actions in a
   left-aligned grid, matching the .field rhythm auth.css uses for its forms
   without importing that file. The textarea inherits the site font (browsers
   default textareas to a mono 13px that reads off-brand). */
.import-form {
  display: grid;
  gap: var(--space-3);
  max-width: 46rem;
  justify-items: start;
}

.import-form__label {
  font-weight: 620;
  letter-spacing: -0.012em;
}

.import-form__textarea {
  font: inherit;
  width: 100%;
  min-height: 9rem;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 140ms ease;
}

.import-form__textarea:hover {
  border-color: var(--accent);
}

.import-form__hint {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

.import-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* Empty state: a title and a pointer to the next action, not a card and not
   an icon. */
.empty {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
  max-width: var(--measure);
}

.empty__title {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
}

.empty__body {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: 46ch;
}

/* ---------- Search + browse surfaces (PAGES-7 / PAGES-8) -----------------
   The card catalogue (/catalogue) and rules search (/rules). Two public,
   indexable content pages sharing one search form and a hairline-separated
   result list each. No new tokens: every value below comes from :root,
   including the dark-scheme overrides, so these pages inherit light/dark
   for free.

   The result lists are hairline-and-space rather than boxed grids, matching
   the data-table treatment the long-form pages already use: this is a browse
   surface, and a wall of framed tiles would be the densest thing on the
   site. The mono face stays reserved for checkable facts (mana costs, set
   codes, rule numbers, source versions), never decoration.
   ------------------------------------------------------------------------ */

/* One search form for both pages: a visible label, then one row of input
   plus button. The input is the same native-control treatment as .field__input
   in auth.css (font: inherit so it never drops to the browser's 13px default;
   --control-border as the affordance, which clears WCAG 1.4.11's 3:1 rule;
   hover moves the edge to the accent). It lives here rather than importing
   auth.css because these public pages do not load that file. */
.searchform {
  display: grid;
  gap: var(--space-2);
  max-width: 36rem;
  min-width: 0;
}

.searchform__label {
  font-weight: 620;
  letter-spacing: -0.012em;
}

.searchform__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.searchform__input {
  font: inherit;
  flex: 1 1 16rem;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.searchform__input:hover {
  border-color: var(--accent);
}

.searchform__input::placeholder {
  color: var(--text-muted);
}

/* The global :focus-visible rule owns focus here, as everywhere else. */

/* ============ Catalogue browse surface (Epic #166, W2b) ==================
   The redesigned /catalogue browse surface: a faceted filter bar, a
   sort/dedupe toolbar, a grid-or-list card wall, and state-carrying
   pagination. Structure and rationale per the accepted prototype
   docs/design/catalogue-redesign-prototype.html.

   Two deliberate extensions beyond the shared tokens above:

   * The semantic mana pip palette (--pip-*, declared with the tokens) for
     the |mana filter's chips (W2a, app/template_filters.py). The five Magic
     colours are data, not brand accents.
   * Rarity dots (--rar-*), decorative only -- the rarity WORD is always
     present next to the dot.
   ======================================================================== */

/* ---------- Mana pips (the |mana filter's markup contract) -----------------
   The wrapper carries the accessible label; chips are aria-hidden
   decoration. Chips scale with the surrounding text (em sizing) so one
   component works in a tile, a detail header, and running oracle text. */
.mc {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.14em;
}

.mc__sep {
  color: var(--text-muted);
  font-size: 0.82em;
  margin-inline: 0.18em;
}

.mana {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.42em;
  height: 1.42em;
  flex: none;
  border-radius: 50%;
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--mana-pip-border);
  box-shadow: inset 0 1px 0 var(--mana-pip-highlight),
    inset 0 -1px 2px var(--mana-shade);
}

.mana--w { background: var(--pip-w-bg); color: var(--pip-w-ink); }
.mana--u { background: var(--pip-u-bg); color: var(--pip-u-ink); }
.mana--b { background: var(--pip-b-bg); color: var(--pip-b-ink); }
.mana--r { background: var(--pip-r-bg); color: var(--pip-r-ink); }
.mana--g { background: var(--pip-g-bg); color: var(--pip-g-ink); }
.mana--c { background: var(--pip-c-bg); color: var(--pip-c-ink); }

/* Generic {1}, variable {X}/{Y}/{Z}, half {H} and the tap/untap arrows all
   read as "not one of the five colours" -- same neutral pip, so the eye
   learns one rule: coloured fill = coloured mana. */
.mana--num,
.mana--x,
.mana--y,
.mana--z,
.mana--half {
  background: var(--pip-num-bg);
  color: var(--pip-num-ink);
}

.mana--tap,
.mana--untap {
  background: var(--pip-num-bg);
  color: var(--pip-num-ink);
  font-size: 0.78em;
}

.mana--snow { background: var(--pip-snow-bg); color: var(--pip-snow-ink); }
.mana--energy { background: var(--pip-energy-bg); color: var(--pip-energy-ink); }

/* Hybrid ({W/U}) and phyrexian ({W/P}) tokens are three glyphs -- they can
   never fit a 1.42em circle. They become capsules: same height, horizontal
   padding, smaller type, and a dashed inner edge for phyrexian so the two
   mechanics stay distinguishable by shape alone, not colour alone. */
.mana--hybrid,
.mana--phyrexian {
  width: auto;
  min-width: 1.42em;
  padding-inline: 0.3em;
  border-radius: 1em;
  font-size: 0.62em;
  letter-spacing: 0.01em;
}

.mana--hybrid { background: var(--pip-num-bg); color: var(--pip-num-ink); }
.mana--phyrexian {
  background: var(--pip-c-bg);
  color: var(--pip-c-ink);
  border-style: dashed;
}

/* Colour filter chips reuse the pip palette at a larger tap-target size
   (2rem). The checkbox is visually hidden but stays focusable; focus and
   checked states land on the pip. */
.colorchips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.colorchip {
  position: relative;
  display: inline-flex;
}

.colorchip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.colorchip__pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--fs-small);
  line-height: 1;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--colorchip-highlight),
    inset 0 -1px 2px var(--mana-shade);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.colorchip__pip--w { background: var(--pip-w-bg); color: var(--pip-w-ink); }
.colorchip__pip--u { background: var(--pip-u-bg); color: var(--pip-u-ink); }
.colorchip__pip--b { background: var(--pip-b-bg); color: var(--pip-b-ink); }
.colorchip__pip--r { background: var(--pip-r-bg); color: var(--pip-r-ink); }
.colorchip__pip--g { background: var(--pip-g-bg); color: var(--pip-g-ink); }
.colorchip__pip--c { background: var(--pip-c-bg); color: var(--pip-c-ink); }

.colorchip input:checked + .colorchip__pip {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.colorchip input:focus-visible + .colorchip__pip {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Rarity filter chips: word chips, same hidden-checkbox pattern as the
   colour pips. The word is the meaning; no rarity colour coding here so the
   control doesn't borrow the rarity dots' semantics. */
.rarchips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.rarchip {
  position: relative;
  display: inline-flex;
}

.rarchip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rarchip__label {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.rarchip__label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rarchip input:checked + .rarchip__label {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 620;
}

.rarchip input:focus-visible + .rarchip__label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Rarity dot (card meta) ----------------------------------------
   Decorative cue next to the rarity word; the word carries the meaning. */
.rarity {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.rarity::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--rar-common);
}

.rarity--uncommon::before { background: var(--rar-uncommon); }
.rarity--rare::before { background: var(--rar-rare); }
.rarity--mythic::before { background: var(--rar-mythic); }

/* ---------- Chips & flags ------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-micro);
  font-weight: 560;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.55rem;
}

.chip--arena {
  background: var(--accent-tint);
  color: var(--accent);
}

.chip--arena::before {
  content: "\2713";
  font-weight: 700;
}

.chip--absent {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

/* Non-playable card-object badge (ADR-010, epic #219). Rendered only when
   the viewer has opted into "Include tokens & extras"; the category word is
   the meaning, the treatment just tells it apart from the Arena chips. Same
   sunken fill and muted ink as .chip--absent, plus a hairline edge so the
   two stay visually distinct side by side. Tokens only -- no new colours. */
.chip--extra {
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

/* "In your collection" marker (W4c: rendered only when the route provides
   owned_oracle_ids; the template guards on `is defined`). */
.owned {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: var(--fs-micro);
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.18rem 0.5rem;
}

.card__flag {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  font-weight: 560;
}

/* ---------- Filter bar ----------------------------------------------------
   One plain GET form. Groups wrap on narrow screens instead of shrinking
   their controls. */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

/* Colour + rarity chips share the primary row; the more-specialist filters
   (mana value, card type, set, Arena-only) collapse behind the disclosure
   below so the box's resting height stays compact. */
.filterbar__primary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  flex: 1;
}

.fgroup {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fgroup > label,
.fgroup > legend {
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--text-muted);
  padding: 0;
}

.fgroup select,
.fgroup input[type="number"],
.fgroup__text {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  transition: border-color 140ms ease;
}

.fgroup select:hover,
.fgroup input[type="number"]:hover,
.fgroup__text:hover {
  border-color: var(--accent);
}

.fgroup__text {
  width: 11rem;
}

/* Set code is a checkable fact: mono, and narrow. */
.fgroup__text--code {
  width: 6.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.cmcrange {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.cmcrange input {
  width: 3.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cmcrange__dash {
  color: var(--text-muted);
}

.filterbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-inline-start: auto;
}

/* "More filters" disclosure: native <details>/<summary>, zero JS. The summary
   keeps the browser's focus + arrow-key affordance (its default triangle is
   cleared and replaced by a +/- prefix), and the grid reuses the same .fgroup
   controls as the primary row -- no new colours or fonts. */
.morefilters {
  flex-basis: 100%;
  border-top: 1px dashed var(--border);
  margin-top: var(--space-1);
  padding-top: var(--space-3);
}

.morefilters summary {
  cursor: pointer;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.morefilters summary::-webkit-details-marker {
  display: none;
}

.morefilters summary::before {
  content: "+ ";
}

.morefilters[open] summary::before {
  content: "\2212 ";
}

.morefilters__grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
}

/* Inline checkbox ("On MTG Arena only"). Native input, accent-coloured, so
   it stays keyboard-operable and high-contrast for free. */
.chk {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-small);
  font-weight: 560;
  cursor: pointer;
}

.chk input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* "Include tokens & extras" opt-in (ADR-010, epic #219): the checkbox reuses
   .chk; the wrapper stacks the hint on its own muted line so checkbox and
   explanation move as one unit inside the more-filters grid. Tokens only. */
.extras {
  display: grid;
  gap: var(--space-1);
}

.extras__hint {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  max-width: 32ch;
}

/* ---------- Toolbar (count / sort / dedupe / view toggle) ----------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  margin-block: var(--space-4);
}

.resultcount {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-inline-end: auto;
}

.resultcount strong {
  color: var(--text);
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

/* The sort/dedupe form and the (formless) view toggle sit on one line,
   wrapping as a unit on narrow screens. */
.toolbarform {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  margin: 0;
}

/* Segmented control (dedupe / view): visually hidden radios + label
   segments. Radios stay focusable; the checked segment is tint + ink, never
   colour alone -- its pressed-in weight difference also marks it. */
.seg {
  display: inline-flex;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.seg label {
  padding: 0.4rem 0.75rem;
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.seg label + label {
  border-inline-start: 1px solid var(--control-border);
}

.seg input:checked + label {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 620;
}

.seg input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Label-inline select used in the toolbar. */
.finline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.finline label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-muted);
}

.finline select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  transition: border-color 140ms ease;
}

.finline select:hover {
  border-color: var(--accent);
}

/* ---------- Results grid / list --------------------------------------------
   CSS-only view switch via :has() on the .browse wrapper. Default is grid
   (#view-grid is checked); #view-list flips .results to a single column and
   each .card to a horizontal row. The toggle radios are deliberately outside
   every form so the choice never enters the URL.

   The column ladder deliberately does NOT live here any more (epic #259): the
   catalogue grid carries .cc-grid .cc-grid--dense alongside .results, and the
   ascending 2 -> 3/4/5/6 min-width ladder on .cc-grid is the single source of
   truth. Keeping a second, descending max-width ladder here would leave two
   rules fighting over the same tracks at every breakpoint. .results stays as
   the hook the list-view toggle and the pager are written against. */
.results {
  display: grid;
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

/* Card tile -- grid view (art on top). */
.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* Art frame: sunken background, so a missing image leaves a tinted panel,
   never a layout shift (same contract as .art). The frame RATIO is no longer
   set here: since epic #259 the catalogue serves full card faces (488x680
   portrait) and the ratio comes from .cc-tile__art, which every tile also
   carries. A 4/3 declaration left behind would only be a landscape rule
   waiting to win a specificity tie. */
.card__art {
  display: block;
  background: var(--surface-sunken);
  overflow: hidden;
}

.card__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

.card__body {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem 0.75rem 0.8rem;
}

.card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

/* Single-line name, truncated visually only: the full name stays in the DOM
   (and on the detail page). overflow:hidden is what lets this flex item
   shrink below its content width so text-overflow can do its job; the link
   inside is untouched and stays the reachable path into the card. */
.card__name {
  font-size: 0.9375rem;
  font-weight: 660;
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__name a {
  color: var(--text);
  text-decoration: none;
}

.card__name a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.card__type {
  color: var(--text-muted);
  font-size: var(--fs-micro);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The card's identifying facts: set code + collector number in mono
   (checkable), rarity as a word with its decorative dot. */
.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem var(--space-2);
  color: var(--text-muted);
  font-size: var(--fs-micro);
}

.card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

/* Dignified missing-art state (W2a). A card with no image at all (~3.5% of
   rows, mostly Arena "A-" alternates) renders this quiet placeholder instead
   of a ragged gap: the card's own initial in a tinted panel. It is never an
   <img>, so there is no alt-text concern, and the card-name link above stays
   the reachable way into the detail page. Reuses existing tokens
   only (--accent-tint / --accent / --font-mono) -- no new colours.

   Two callers, two shapes: on the catalogue it IS the tile's art frame (a
   <div>, direct child of the tile), so it needs the portrait ratio itself; in
   collections it is a <span> filling an ancestor frame that already has the
   ratio, where width/height:100% make both dimensions definite and the
   aspect-ratio is simply not used. One portrait ratio therefore serves both --
   the old 4/3 was dead on one caller and wrong on the other. */
.missing-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  aspect-ratio: 488 / 680;
  background: var(--accent-tint);
  color: var(--accent);
}

.missing-art__glyph {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  opacity: 0.55;
}

/* List view: flip the card to a horizontal row.

   The row axis is flipped on .cc-tile__inner, not on the <li>: the tile's
   opening tag is pinned verbatim (`<li class="card cc-tile">`), so C3 moved
   every layout hook onto that inner wrapper. The .card rule is kept for any
   non-cc-tile card inside a .browse container; on a cc-tile the <li> has a
   single child and its own axis is moot. */
.browse:has(#view-list:checked) .results {
  grid-template-columns: 1fr;
}

.browse:has(#view-list:checked) .card:not(.cc-tile),
.browse:has(#view-list:checked) .cc-tile__inner {
  flex-direction: row;
  align-items: stretch;
}

/* The row thumb stays PORTRAIT (epic #259). It used to be an ~11rem-wide
   landscape box with aspect-ratio:auto, which on a full card face would crop
   a horizontal band out of the middle -- name and type line sliced off. Width
   is the driven dimension and height follows the ratio, so align-self must be
   start: the row's align-items:stretch would otherwise make the height
   definite and the ratio moot.

   The width now sits on .cc-tile__frame (the flex child that wraps the art
   link or the placeholder); .cc-tile__art keeps the ratio and fills it. The
   bare .cc-tile__art / .missing-art selectors stay for frameless tiles. */
.browse:has(#view-list:checked) .cc-tile__frame,
.browse:has(#view-list:checked) .cc-tile__art,
.browse:has(#view-list:checked) .missing-art {
  width: 8.5rem;
  flex: none;
  align-self: flex-start;
  height: auto;
  min-height: 0;
}

.browse:has(#view-list:checked) .cc-tile__art,
.browse:has(#view-list:checked) .missing-art {
  aspect-ratio: 488 / 680;
}

/* Inside a frame the art is no longer the flex child, so it must fill the
   frame's width rather than claim its own. */
.browse:has(#view-list:checked) .cc-tile__frame > .cc-tile__art,
.browse:has(#view-list:checked) .cc-tile__frame > .missing-art {
  width: 100%;
}

.browse:has(#view-list:checked) .card__body {
  align-content: start;
  padding: var(--space-4);
}

@media (max-width: 30rem) {
  .browse:has(#view-list:checked) .cc-tile__frame,
  .browse:has(#view-list:checked) .cc-tile__art,
  .browse:has(#view-list:checked) .missing-art {
    width: 6rem;
  }

  .browse:has(#view-list:checked) .cc-tile__frame > .cc-tile__art,
  .browse:has(#view-list:checked) .cc-tile__frame > .missing-art {
    width: 100%;
  }
}

/* Signed-out nudge (C3): one quiet glass line above the grid, never a modal. */
.browse__nudge {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-block: var(--space-2) var(--space-3);
}

.browse__nudge a {
  color: var(--accent);
}

/* Pagination. Prev/next as quiet buttons with a page counter between them;
   every link carries the full filter/sort/dedupe state (built by the
   template's browse_url macro). */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}

.pager__status {
  font-size: var(--fs-small);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Rules result list. Numberless, hairline-separated passages, each with its
   citation line underneath. */
.ruleslist {
  display: grid;
  gap: var(--space-4);
  margin: 0;
}

.rule {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.ruleslist > :last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* The passage is plain text from the source; pre-line keeps the rule's own
   line breaks without injecting markup, while still wrapping to the measure. */
.rule__content {
  max-width: var(--measure);
  white-space: pre-line;
}

/* The "show your work" line: a citation chip, the heading path, and the
   source version. All muted except the chip, which carries the site's one
   accent. */
.rule__cite {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.rule__path {
  font-size: var(--fs-micro);
}

.rule__version {
  font-size: var(--fs-micro);
}

/* ============ Catalogue card-detail surface (Epic #166, W3c) =============
   The /catalogue/cards/{id} detail page: full-frame card image with artist
   credit, a faces-aware rules-text surface, a P/T-or-loyalty stat box, an
   Arena-formats legality panel, external links, and a horizontal printings
   scroller. Structure per the accepted prototype
   docs/design/catalogue-redesign-prototype.html (Surface 2 + the MDFC
   demo), adapted to real CardResponse keys. Reuses the shared tokens, .seg,
   .chip, .rarity, .mono and the |mana pip component -- no new colour
   vocabulary beyond the site's one error red for "Banned". Zero JS: the
   double-faced flip is the same :has() pattern as the browse view toggle.
   ======================================================================== */

/* Back link restoring the browse state (route-derived back_query). */
.backlink {
  display: inline-block;
  font-size: var(--fs-small);
  font-weight: 560;
  margin-bottom: var(--space-4);
}

/* Two columns on wide screens (art rail + reading column), one column on
   narrow. When a printing has no image at all the art column is omitted
   from the markup, so the lone body child spans the full row. */
.detail__grid {
  display: grid;
  gap: var(--space-6);
  align-items: start;
}

.detail__grid > :only-child {
  grid-column: 1 / -1;
}

@media (min-width: 48rem) {
  .detail__grid {
    grid-template-columns: 320px 1fr;
  }
}

/* The full-frame card image. Fixed 5:7 frame + sunken background: a missing
   or slow image leaves a tinted panel, never a layout shift. width/height
   attributes on the <img> itself pin the intrinsic ratio (672x936 =
   Scryfall "large"). */
.detail__art {
  margin: 0;
  min-width: 0;
  max-width: 22rem;
}

@media (min-width: 48rem) {
  .detail__art {
    max-width: none;
  }
}

.detail__art .frame {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 5 / 7;
  box-shadow: var(--shadow);
}

.detail__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

.credits {
  color: var(--text-muted);
  font-size: var(--fs-micro);
  line-height: 1.5;
  margin-top: var(--space-2);
}

/* CSS-only front/back flip for double-faced cards (modal_dfc / transform /
   reversible_card). The toggle reuses the .seg segmented control (visually
   hidden but focusable radios); the swap is pure :has(), instant (no
   animation, so nothing to disable under prefers-reduced-motion). */
.flipart {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  min-width: 0;
}

.flipart .detail__art {
  width: 100%;
}

.flipart__back {
  display: none;
}

.flipart:has(#face-back:checked) .flipart__front {
  display: none;
}

.flipart:has(#face-back:checked) .flipart__back {
  display: block;
}

/* Reading column: name, cost, type, facts, then the stacked panels. */
.detail__body {
  min-width: 0;
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.detail__body h2,
.detail__prints h2 {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
}

.detail__name {
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.022em;
}

/* Cost pips at header size: one step up from body text, still the same
   component. */
.detail__cost {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.detail__cost .mc {
  font-size: 1.25rem;
}

.detail__type {
  font-size: var(--fs-lead);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.detail__type .rarity {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* Non-playable card-object notice (ADR-010, epic #219): a calm one-liner
   under the type line. The .chip--extra chip names the category; the muted
   trailing text states plainly that it isn't a playable card. Reuses the
   site's existing tokens only -- no new colours or fonts. */
.detail__notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* Identifying facts: set code + collector number, mana value, release date.
   Mono where the fact is checkable. */
.detail__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.detail__chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Rules text: stacked "text boxes". Multi-face layouts (adventure, split,
   DFCs) get one .face per face; the second and later faces sit on the
   sunken surface so the pairing reads at a glance. */
.detail__oracle {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.face {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.face--alt {
  background: var(--surface-sunken);
}

.face__type {
  font-size: var(--fs-small);
  font-weight: 620;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
}

.face__type .mc {
  font-size: 1rem;
}

/* Oracle text keeps the card's own line breaks (paragraph per ability) and
   its reminder text verbatim; the |mana filter's pips sit inline. */
.face__text {
  font-size: var(--fs-small);
  line-height: 1.6;
  max-width: var(--measure);
  white-space: pre-line;
  overflow-wrap: break-word;
}

.face__text .mana {
  vertical-align: -0.08em;
}

/* The |mana filter wraps a mixed prose+symbols string in ONE .mc inline-flex
   for its accessible label. That is right for a pure mana cost, but inside
   running oracle text an inline-flex wrapper would swallow the text's own
   line breaks (flex items drop boundary whitespace, so the newlines
   pre-line relies on never break) and squeeze out inter-word spacing. In
   this context the wrapper falls back to plain inline: the prose flows and
   breaks normally while each pip keeps its own inline-flex, with the pip
   gap restored as a sibling margin. */
.face__text .mc {
  display: inline;
}

.face__text .mc .mana + .mana {
  margin-inline-start: 0.14em;
}

/* Power/toughness or loyalty: a mono stat box with its own label, so it
   needs no surrounding copy and never wraps away from its meaning. */
.ptbox {
  display: inline-grid;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.ptbox__label {
  font-size: var(--fs-micro);
  font-weight: 560;
  color: var(--text-muted);
}

.ptbox__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- Flavour text & keyword chips (Epic #166, W6a / issue #189) ----
   Flavour text sits inside the SAME .face box as its oracle text, italic
   and one ink quieter -- the way the card frame itself sets it. Tokens only
   (--text-muted / --fs-small), so light and dark schemes both hold their
   already-audited contrast; pre-line keeps the card's own line breaks. */
.face__flavor {
  font-style: italic;
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.6;
  max-width: var(--measure);
  white-space: pre-line;
  overflow-wrap: break-word;
}

/* Keyword chips -> rules search. Keywords are card-level per Scryfall, so
   one row even for multi-face cards; it takes the same top-border separator
   rhythm as the panels around it. The chips are plain <a> links (zero JS)
   to GET /rules?q=<keyword>. Border-only at rest -- the row is a quiet
   metadata strip, not a call to action; hover lifts a chip into the accent
   tint, and the global :focus-visible rule owns keyboard focus. --text-muted
   on --bg measures ~6.5:1 (light) / ~7.7:1 (dark), well past 4.5:1 even at
   --fs-micro. */
.detail__keywords {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.kwchips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.kwchip {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: 560;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.55rem;
}

.kwchip:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

/* Legality panel -- Arena formats only (Standard/Alchemy/Historic/Timeless/
   Brawl, per ADR-006's Arena-first audience). One row per format the API
   actually returned a status for; formats missing from card.legalities are
   skipped, never guessed. */
.detail__legal {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.detail__legal-intro,
.detail__legal-empty {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

.legality {
  margin: 0;
  display: grid;
  gap: var(--space-1);
  width: 100%;
  max-width: 30rem;
}

.legality > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.legality > div:last-child {
  border-bottom: 0;
}

.legality dt {
  font-weight: 620;
  font-size: var(--fs-small);
}

.legality dd {
  margin: 0;
  font-size: var(--fs-small);
  font-weight: 560;
}

.legality .yes {
  color: var(--accent);
}

.legality .no {
  color: var(--text-muted);
}

/* "Banned" is the one status that must not read as evergreen or muted: it
   reuses .alert--error's single desaturated red per scheme (7.5:1 / 8.7:1
   on the page background), so the site keeps exactly one error colour. */
.legality .banned {
  color: var(--danger-strong);
  font-weight: 620;
}

/* ---------- Collection controls (Epic #166, W4c / issue #187) ----------
   One panel, three mutually exclusive states (owned / not-owned / signed
   out), all server-rendered with zero JS: the prototype's +/- stepper
   becomes a plain number input, and Update/Remove are two separate plain
   POST forms (W4b handlers, PRG). The panel sits between the legality block
   and the external links, so it takes the same top-border separator rhythm
   as .detail__oracle; its h2 is already covered by .detail__body h2. */
.card-collect {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* The owned chip here reuses the browse tile's .owned component verbatim,
   so "In your collection" reads identically on both surfaces. */
.card-collect__status {
  display: flex;
  align-items: center;
}

/* Owned state: the adjust form and the Remove form sit on one wrapping row
   (two forms can't nest, so the row is their shared layout context). */
.card-collect__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.collectform {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.collectform__label {
  font-size: var(--fs-small);
  font-weight: 620;
}

/* Quantity: a checkable count, so mono + tabular figures like every other
   numeric fact on the page; narrow like the filter bar's mana-value inputs.
   --control-border is the affordance (WCAG 1.4.11's 3:1 non-text contrast);
   the global :focus-visible rule owns focus here, as everywhere else. */
.collectform__qty {
  font: inherit;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
  width: 6.5rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.6rem;
  transition: border-color 140ms ease;
}

.collectform__qty:hover {
  border-color: var(--accent);
}

/* States the overwrite semantics of the /collect controls (×4 / Update /
   Add): they SET the total for one printing, they never add on top. The ±
   adjust forms are the only controls that nudge by a delta. */
.collect-hint {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  max-width: var(--measure);
}

/* Signed-out state: deliberately the quietest control on the page -- one
   small muted line with an ordinary inline link, never a button, so it
   doesn't compete with the page's real actions. */
.card-collect__signedout {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* Total line and per-printing ownership rows (C3, issue #283). One compact
   row per owned printing: set code + number, a mono count, and −/+/Remove
   forms (each its own POST, so they never nest). Reuses existing tokens and
   the .btn--row component. */
.card-collect__total {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.card-collect__total strong {
  color: var(--text);
  font-weight: 680;
}

.card-collect__empty {
  font-size: var(--fs-small);
  color: var(--text-muted);
  max-width: var(--measure);
}

.copies-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-1);
  width: 100%;
  max-width: 34rem;
}

.copies-list__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.copies-list__qty {
  min-width: 1.5rem;
  text-align: center;
  font-weight: 700;
}

.copies-list__form {
  display: inline-flex;
  margin: 0;
}

/* ---------- In your decks (Epic #166, W6b / issue #190) ----------
   Signed-in-only panel: the route omits in_decks entirely for anonymous
   visitors (and on any decks-read failure), so this block simply never
   renders signed-out -- there is no signed-out state to style. Same
   top-border separator rhythm as .card-collect above it; its h2 is covered
   by .detail__body h2. The list follows the accepted prototype's
   .detail__decks pattern: one compact row per deck, the deck name as a
   plain link and its format as a muted mono fact. Both render in mono per
   the page's checkable-fact convention (the user's own deck facts, like the
   set codes and mana value above). The empty state is a single quiet muted
   line -- honest, deliberately not a call to action (ADR-006). */
.card-decks {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.card-decks__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-1);
  font-size: var(--fs-small);
}

.card-decks__list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
}

/* The format is the secondary fact on the row, so it steps back one ink;
   --text-muted on the page background is ~6.5:1 light / ~7.7:1 dark. */
.card-decks__format {
  color: var(--text-muted);
}

/* Empty state: the quietest line on the page, matching .detail__legal-empty
   and .card-collect__signedout. */
.card-decks__empty {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

/* External links row. */
.detail__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* Other versions & printings: horizontal scroller, plain overflow + scroll
   snap (no JS). Always scrollable -- real printings counts (a Lightning Bolt
   has dozens) mean overflow-x: visible would blow out the page. Thumbnails
   use art_crop (landscape), so the frame matches the browse tiles' 3:2. */
.detail__prints {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.printscarousel {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(9.5rem, 42vw);
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  padding-bottom: var(--space-2);
}

.printscarousel > * {
  scroll-snap-align: start;
}

.print {
  margin: 0;
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.print__link {
  display: grid;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
}

.print .frame {
  display: block;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 2;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.print img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

.print__link:hover .frame {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* The printing currently on screen: accent edge, and it is deliberately not
   a link (it would only reload this page). */
.print--current .frame {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.print__cap {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  line-height: 1.45;
}

.print__cap strong {
  color: var(--text);
  font-weight: 640;
}

/* ---------- Card detail C3 (issue #283) ----------------------------------
   Hero backdrop blur, in-page nav, identity strip, Restricted legality and
   the shelf badge anchor. Added BEFORE the terminal performance/layer
   guardrails on purpose, so those rules still win.
   ------------------------------------------------------------------------ */

/* The card's own art, blurred into a backdrop (Option 4 §4.2). The blur
   lives on the already-rendered art <img> via this detail-scoped selector --
   the art URL is never interpolated into a CSS url(). The hero is not an
   ancestor of any .cc-pop/.cc-tile and has no position:fixed descendants, so
   this filter is outside the guardrail's reach. A small scale eats the
   blur's soft edge so the figure's own gradient never shows through. */
.cardpage-hero .hero--art__art img {
  filter: blur(22px);
  transform: scale(1.08);
}

/* Sticky in-page nav (Option 4 §4.2): a glass strip at the top of the
   reading column that stays under the sticky header while the sections
   scroll. Plain anchors; the global [id] scroll-margin-top rule already
   clears the sticky header for the targets. Solid fill so content never
   shows through when it sticks. */
.detail-nav {
  position: sticky;
  top: calc(var(--header-h) + var(--space-3));
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.detail-nav__link {
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.detail-nav__link:hover {
  color: var(--accent);
  background: var(--accent-tint);
}

/* Identity strip (Option 4 §4.7): pips plus words from card.color_identity.
   Pips are decorative (aria-hidden in markup); the words carry the meaning.
   Colourless is a plain muted line, never a fabricated colour. */
.detail__identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--fs-small);
}

.detail__identity-pips {
  display: inline-flex;
  gap: 0.2rem;
}

.detail__identity-pips .mana {
  font-size: 0.82rem;
}

.detail__identity-words {
  color: var(--text-muted);
}

.detail__identity--colourless {
  color: var(--text-muted);
}

/* Restricted is its own legality status: amber, never Legal's "yes" class. */
.legality .restricted {
  color: var(--status-restricted);
  font-weight: 620;
}

/* "Add this printing" sub-heading above the collection select. */
.collectform__title {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
}

/* The shelf frame is the positioned ancestor for the owned-count hexagon. */
.print .frame {
  position: relative;
}

/* ============ Collections tab (Epic #242, T8 / issue #250) =============
   The reworked /dashboard/collections page: Option 1 "Binder" -- a dense
   grid of full card faces under a sticky compact toolbar (collection
   switcher + manage + file import) and a top filter bar. Structure per the
   accepted prototype docs/design/collection-tab-proposal/option-1.html
   (preview.css), scoped to the classes Option 1 actually uses.

   No new tokens: every colour, space, radius, type step and shadow below
   comes from :root (including the dark-scheme overrides). The destructive
   delete affordances reuse .alert--error's single red per scheme (#8c2c24 /
   #fdf0ee / #a3352c, dark #f0aaa2 / #2a1a18 / #e2887f) rather than growing
   a second red. The only genuinely new vocabulary is layout/interaction
   composition (.cc-*), exactly as the proposal's preview.css intended.

   Zero JavaScript: the filter bar is a plain GET form (reusing .filterbar /
   .fgroup / .colorchips / .rarchips / .morefilters), every mutation is a
   plain POST form, and the hover enlargement below is CSS-only. The popover
   toggles `display` (no transform), so site.css's global
   prefers-reduced-motion rule already zeroes the remaining border/shadow
   transitions -- nothing extra is needed.
   ======================================================================== */

/* ---------- Page shell ------------------------------------------------
   .page-hero (title + lead) is site.css's own component and is reused
   verbatim. .cc is the workspace's own rhythm. */
.cc {
  padding-block: var(--space-6);
}

/* ---------- Sticky compact toolbar (option 1) -------------------------
   Sticks to the top edge while scrolling the grid beneath it. --bg is the
   opaque page background, so cards scrolling underneath never show through.
   ---------------------------------------------------------------------- */
/* The pre-C4 sticky switcher toolbar is gone (the switcher became the
   binder spines and the actions moved into the hero), so this class now only
   marks the results-header row. It is deliberately NOT sticky: removing the
   viewport-anchoring + paint (background/border/padding) cuts the fixed
   chrome from the old 177px (~21% at 840px, 28.6% with the 64px header) to
   the header alone (64px, 7.6%). */
.cc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

/* ---------- Collection switcher (tabs) --------------------------------- */

.cc-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.cc-switcher__label {
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--text-muted);
}

.cc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cc-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  font-size: var(--fs-small);
  font-weight: 560;
  line-height: 1.4;
  color: var(--text-muted);
  background: var(--surface);
  /* --border-strong is a decorative divider (1.86:1 dark / 1.62:1 light,
     both below the 3:1 UI-boundary minimum of WCAG 1.4.11); --control-border
     is the outline affordance and clears it (3.9:1 dark / 3.7:1 light). */
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.cc-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cc-tab--active,
.cc-tab[aria-current="page"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 620;
}

/* The count needs no active-state override: it was never dimmed via `opacity`
   (see `.cc-tab__count`), so it simply inherits the active tab's `--accent`,
   which the Green daylight tint is deliberately tuned to keep at 4.67:1. */

.cc-tab__count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-micro);
  /* NOT dimmed with `opacity`.

     The count inherits the tab's colour, which is already the secondary
     `--text-muted` token -- the same one the tab's own label uses. Layering
     `opacity: 0.72` on top of that compounded it into a real failure: the
     effective colour measured 3.71:1 in daylight and 4.31:1 in dark, both
     below the 4.5:1 AA floor. axe-core only catches this when a count has
     two or more digits (a single digit is reported as "too short to
     determine if it is actual text content"), so the defect sat latent
     behind small collections and would have appeared for the first user
     who reached 10 cards.

     The count stays visually secondary the way it should be: monospaced,
     micro-sized and tabular. Opacity was doing contrast work that belonged
     to the colour token. */
}

.cc-tab--new {
  border-style: dashed;
  color: var(--accent);
}

/* "+ New collection": a native <details> whose summary is the dashed tab;
   the create form floats below it. */
.cc-new {
  position: relative;
}

.cc-new > summary {
  list-style: none;
  cursor: pointer;
}

.cc-new > summary::-webkit-details-marker {
  display: none;
}

.cc-new__form {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + var(--space-2));
  z-index: 40;
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  width: min(16rem, calc(100vw - 2 * var(--space-4)));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3);
}

/* ---------- Collection text field -------------------------------------
   A minimal label + input + hint primitive for the collection page's own
   text inputs (rename, create, file upload). Same native-control treatment
   as .field__input / .searchform__input: --control-border is the affordance
   (3:1 per WCAG 1.4.11); the global :focus-visible rule owns focus. */
.cc-field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.cc-field__label {
  font-weight: 620;
  letter-spacing: -0.012em;
  font-size: var(--fs-small);
}

.cc-field__input {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.cc-field__input:hover {
  border-color: var(--accent);
}

.cc-field__hint {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

/* The file input keeps its native control but the platform "Choose file"
   button is restyled into a quiet outline button so it reads as part of the
   page rather than a raw widget. */
.cc-field__input[type="file"] {
  padding: 0.35rem;
}

.cc-field__input[type="file"]::file-selector-button {
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 620;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  margin-inline-end: var(--space-2);
  cursor: pointer;
}

/* The no-collections empty state's create form: name input + button on one
   wrapping row. */
.cc-create {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  max-width: var(--measure);
  margin-top: var(--space-2);
}

.cc-create .cc-field {
  flex: 1 1 16rem;
}

/* ---------- Manage (rename / export / delete) disclosure ---------------- */

.cc-manage {
  display: grid;
  gap: var(--space-2);
  justify-items: end;
  min-width: 0;
}

.cc-manage__summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.cc-manage__summary:hover {
  border-color: var(--accent);
}

.cc-manage__summary::-webkit-details-marker {
  display: none;
}

.cc-manage__summary::after {
  content: "\25BE";
  font-size: 0.8em;
  color: var(--text-muted);
}

.cc-manage[open] .cc-manage__summary {
  border-color: var(--accent);
}

/* In-flow, not absolute: the pre-C4 panel was absolutely positioned and
   overlapped the Import drawer at 768px and 390px. In-flow means each drawer
   expands in place and can never cover a sibling control. */
.cc-manage__panel {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

.cc-manage__group {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.cc-manage__group .cc-field {
  width: 100%;
}

.cc-manage__title {
  font-size: var(--fs-small);
  font-weight: 640;
  letter-spacing: -0.01em;
}

/* Destructive "delete collection" inside Manage: a nested <details> so the
   confirm step cannot be reached with a single click. Reuses the site's one
   error red (see .alert--error), never a new colour. */
.cc-danger {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  width: 100%;
}

.cc-danger__summary {
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-small);
  font-weight: 620;
  color: var(--danger-strong);
  padding: 0;
}

.cc-danger__summary::-webkit-details-marker {
  display: none;
}

.cc-danger__summary:hover {
  text-decoration: underline;
}

.cc-danger__panel {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  padding: var(--space-3);
  background: var(--danger-tint);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
}

.cc-danger__warning {
  font-size: var(--fs-small);
  color: var(--danger-strong);
  max-width: 32ch;
}

/* ---------- Import / Update collection --------------------------------
   Native <details>: seed import uses a file input; update offers separate
   file and paste forms that lead to review. Shared furniture, no JS. */
.cc-import {
  display: grid;
  gap: var(--space-2);
  justify-items: end;
  min-width: 0;
}

.cc-import__summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease;
}

.cc-import__summary:hover {
  border-color: var(--accent);
}

.cc-import__summary::-webkit-details-marker {
  display: none;
}

.cc-import__summary::before {
  content: "+ ";
  font-weight: 700;
  color: var(--accent);
}

.cc-import[open] .cc-import__summary::before {
  content: "\2212 ";
}

.cc-import__panel {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
}

.cc-import__panel .cc-field {
  width: 100%;
}

.cc-import__panel > form {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  width: 100%;
  min-width: 0;
}

.cc-import__panel > form + form {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.cc-import__panel textarea.cc-field__input {
  resize: vertical;
  min-height: 8rem;
}

/* ---------- Filter bar -------------------------------------------------
   Reuses site.css .filterbar/.fgroup/.colorchips/.rarchips/.morefilters
   verbatim. The proposal only adds a bottom margin so the bar reads as one
   block above the results row.

   The class is `cc-filterbar` (the C2 shared macro `command_bar` emits
   `class="filterbar cc-filterbar"` on BOTH surfaces). The pre-C3 collections
   template used `cc-filter` here; when the page switched to the shared macro
   that name stopped matching, silently dropping the margin on Collections
   (and leaving the Catalogue bar flush against the results toolbar whenever
   no chips are active). Same rule, current class. */
.cc-filterbar {
  margin-bottom: var(--space-4);
}

/* ---------- Results count / clear row ---------------------------------- */

.cc-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
}

.cc-bar .resultcount {
  margin-inline-end: auto;
}

/* ---------- Card grid (portrait, responsive ladder) --------------------
   Full card faces are portrait (488x680, ~0.718), so each tile is taller
   than the old landscape art crops. The column ladder is one column deeper:
   base 2 (~390px), then 3/4/5/6 at 30/48/64/90rem -- measured 6/5/2 columns
   at 1440/1024/390px. */
.cc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 30rem) {
  .cc-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 48rem) {
  .cc-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .cc-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 90rem) {
  .cc-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Option 1 (binder) tightens the gap so more cards fit: same columns,
   denser. */
.cc-grid--dense {
  gap: var(--space-2);
}

@media (min-width: 30rem) {
  .cc-grid--dense {
    gap: var(--space-2) var(--space-3);
  }
}

/* ---------- Card tile --------------------------------------------------- */

.cc-tile {
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.cc-tile:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.cc-tile:focus-within {
  border-color: var(--accent);
}

/* Art frame: portrait to match a full card face (488x680 natural). The
   image fills the frame exactly, so nothing is cropped. */
.cc-tile__art {
  position: relative;
  display: block;
  background: var(--surface-sunken);
  aspect-ratio: 488 / 680;
  overflow: hidden;
}

.cc-tile__art a {
  display: block;
  width: 100%;
  height: 100%;
}

.cc-tile__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

/* Enlargement happens in a dedicated .cc-pop overlay (below), not an in-tile
   zoom: a scale inside overflow-hidden is a clipped nudge, whereas the
   requirement is "the enlarged image should be shown". The popover is a
   materially bigger object, gated behind (hover: hover) with a :focus-within
   keyboard equivalent. There is no transform transition, so
   prefers-reduced-motion needs nothing extra. */

/* Quantity badge over the art's top-right corner. Mono, because the count is
   a checkable fact. On a full portrait card that corner is the mana-cost bar;
   it stays top-right because the mana cost is re-stated in the tile body,
   while the name (top-left) and power/toughness (bottom-right) are not. */
.cc-qtybadge {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.45rem;
  box-shadow: 0 1px 2px var(--qtybadge-shadow-color);
}

.cc-tile__body {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
  padding: 0.65rem 0.75rem 0.75rem;
}

/* Grid/flex children default to min-width:auto; a nowrap child would force
   its track wider than the (narrow, portrait) tile. Allow them to shrink so
   the ellipsis truncation actually engages. */
.cc-tile__body > * {
  min-width: 0;
}

.cc-tile__name {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 660;
  letter-spacing: -0.012em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-tile__name a {
  color: var(--text);
  text-decoration: none;
}

.cc-tile__name a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.cc-tile__type {
  color: var(--text-muted);
  font-size: var(--fs-micro);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-tile__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem var(--space-2);
  color: var(--text-muted);
  font-size: var(--fs-micro);
}

.cc-tile__cost {
  margin-top: 0.1rem;
}

/* ---------- Quantity editor: inline <details> --------------------------
   The "Edit" trigger opens the quantity + remove controls. */
.cc-edit {
  margin-top: 0.2rem;
}

.cc-edit__summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--accent);
  padding: 0;
}

.cc-edit__summary::-webkit-details-marker {
  display: none;
}

.cc-edit__summary::after {
  content: "\25BE";
  font-size: 0.85em;
  color: var(--text-muted);
}

.cc-edit__summary:hover {
  text-decoration: underline;
}

.cc-edit[open] .cc-edit__summary::after {
  content: "\25B4";
}

.cc-edit__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cc-qtyform {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

/* ---------- Popover enlargement ----------------------------------------
   A .cc-pop overlay sits as the first child of every tile and is revealed on
   hover/focus. It is a materially bigger card than the tile image, so the
   enlargement is unambiguous. It reuses the tile's own image URL, so showing
   it costs no extra bandwidth.

   The overlay is anchored to the VIEWPORT (position: fixed, centred), not to
   the tile: an absolutely-positioned popover bound to the tile cannot know
   the scroll position, so a tile near the top of the viewport pushed its
   ~430px-tall preview off-screen, and at narrow widths a left-aligned popover
   overflowed the document and widened scrollWidth (a layout shift, not just
   clipping). Fixed is also out of flow, so it cannot grow scrollWidth, and
   centring keeps it on-screen for every tile position with no JavaScript.
   No ancestor here carries a transform/filter/contain, so fixed really is
   viewport-relative (any such ancestor would become its containing block).

   A vh-based cap on the width keeps the 488/680 frame (plus its padding and
   border) inside short/landscape viewports while preserving the ratio --
   capping the height instead would break the ratio and make object-fit crop.
   (100vh - 4*--space-3 - 2px) is the art height that leaves a --space-3
   margin above and below; * 488 / 680 turns it into art width;
   + 2*--space-3 + 2px adds the popover's own padding and border back. */
.cc-pop {
  position: fixed;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inset-block-end: auto;
  inset-inline-end: auto;
  transform: translate(-50%, -50%);
  z-index: 60;
  width: min(24rem, 80vw, calc((100vh - 4 * var(--space-3) - 2px) * 488 / 680 + 2 * var(--space-3) + 2px));
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-3);
  gap: var(--space-2);
}

/* Image-only variant used by option 1: no text lines, slightly narrower,
   still clearly larger than the tile it enlarges. */
.cc-pop--card {
  width: min(20rem, 76vw, calc((100vh - 4 * var(--space-3) - 2px) * 488 / 680 + 2 * var(--space-3) + 2px));
}

.cc-pop__art {
  display: block;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 488 / 680;
}

.cc-pop__art a {
  display: block;
  width: 100%;
  height: 100%;
}

.cc-pop__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (hover: hover) {
  .cc-tile:hover > .cc-pop {
    display: grid;
  }
}

.cc-tile:focus-within > .cc-pop {
  display: grid;
}

/* ---------- Catalogue tiles: reconciling .card with .cc-tile -------------
   The catalogue grid (epic #259) carries BOTH class sets on one element --
   `<li class="card cc-tile">` -- so the list-view toggle and the pager keep
   working against the .card hooks while the tile looks like a Binder tile.
   Only three things genuinely collide; everything else is a later-wins
   duplicate of the same value. Scoped to .card.cc-tile so neither the
   collections grid (.cc-tile alone) nor the dashboard panels (.card alone)
   are touched. */

/* 1. .card clips to its border-radius with overflow:hidden. The enlargement
      is position:fixed (viewport-anchored) and escapes that clip, but the
      clip would still square off the art frame's own top corners that block
      2 rounds below. Release the clip on the tile and move it onto the art
      frame, which is the only child that needs clipping anyway. */
.card.cc-tile {
  overflow: visible;
}

/* 2. With the tile no longer clipping, the art's square top corners would
      poke out past the tile's rounded edge. -1px because the tile's 1px
      border sits outside the frame.

      C3 wraps the art in .cc-tile__frame (the identity-rim carrier), so the
      rounding belongs to whichever of the two is the outermost art box. Both
      are listed as DESCENDANTS rather than direct children, because the art
      is now a grandchild of the <li> via .cc-tile__inner. */
.card.cc-tile .cc-tile__frame,
.card.cc-tile .cc-tile__art,
.card.cc-tile .missing-art {
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

/* The placeholder is the frame here, not a fill inside one, so its own ratio
   has to drive its height. .missing-art carries height:100% for the
   collections case (a <span> inside an already-ratio'd frame); left in place
   here it made the panel as tall as the whole flex line, which pushed the
   name band of an imageless tile below its neighbours' -- measured at 1440px,
   a visibly ragged row. */
.card.cc-tile .missing-art {
  height: auto;
}

/* In list view the thumb is the leading edge of a horizontal row, and it does
   not necessarily reach the row's bottom (align-self:start), so only the
   top-leading corner can safely be rounded. */
.browse:has(#view-list:checked) .card.cc-tile .cc-tile__frame,
.browse:has(#view-list:checked) .card.cc-tile .cc-tile__art,
.browse:has(#view-list:checked) .card.cc-tile .missing-art {
  border-radius: calc(var(--radius) - 1px) 0 0 0;
}

/* 3. The owned marker moves from a text chip in the tile foot to the corner
      badge slot. It reuses .cc-qtybadge's box wholesale and only restates the
      accent treatment the old .owned chip carried, so no new token, colour or
      font appears. The glyph is decorative; the badge's meaning is carried by
      visually-hidden text in the markup. Unlike collections' quantity badge
      this one is a sibling of the art link rather than a child of it: the
      catalogue's art frame IS the <a>, and nesting text inside would fold it
      into that link's accessible name. .cc-tile is positioned, so the same
      absolute offsets land on the same corner either way. */
.cc-qtybadge--owned {
  color: var(--accent);
  background: var(--accent-tint);
  border-color: var(--accent);
}

/* Top-RIGHT of a horizontal row is body text, not card corner; follow the
   thumb to the leading edge instead. */
.browse:has(#view-list:checked) .cc-qtybadge {
  inset-inline-start: 0.5rem;
  inset-inline-end: auto;
}

/* ---------- Small shared bits ------------------------------------------- */

/* Grid/toolbar children must be able to shrink (same hygiene rule site.css
   uses for its own layout children). */
.cc-grid > *,
.cc-toolbar > *,
.cc-switcher > * {
  min-width: 0;
}

/* =========================================================================
   BROWSE SYSTEM (Option 4 §3, wave C2)
   -------------------------------------------------------------------------
   Shared command-bar chips, results-header view switch, pager jumps, the
   owned-count hexagon, the tile action dock, the list-row layout and the
   binder 3x3 page. Everything reuses the existing Mana Night tokens -- no
   new colour, font or radius appears. This block is deliberately placed
   BEFORE the terminal performance/layer guardrails so those rules still win.
   ========================================================================= */

/* ---------- The one DOM tile: inner wrapper and art frame ---------------

   `<li class="card cc-tile">` is pinned VERBATIM (spec §3.4, and exact-string
   matched by the tests), so nothing C3 needs may be added to it: no id, no
   layout modifier, no identity attribute. Two inner elements carry all of it:

     .cc-tile__inner   the PRG anchor id, the list modifier, and the
                       positioned ancestor for the hexagon and the dock.
     .cc-tile__frame   the identity rim and the art clip.

   Both are SIBLINGS of .cc-pop, never its ancestors. That matters: .cc-pop is
   position:fixed and viewport-anchored, so any ancestor with a transform,
   filter or contain would silently become its containing block. Nothing here
   introduces one -- the rim is a box-shadow, and there is no tilt (§6,
   reduced motion keeps glows and drops transforms). */
.cc-tile__inner {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cc-tile__frame {
  position: relative;
  display: block;
  min-width: 0;
  overflow: hidden;
}

/* THE RIM IS THE HOVER/FOCUS STATE (§4.4), and it is the CARD's own colours,
   not the area's: [data-identity] remaps --rim per tile (the [data-identity~=]
   rules near the top of this file), and the attribute is only ever emitted
   from CardResponse.colors. A tile with no colour data carries no attribute
   and therefore keeps the area --rim, rather than being given a made-up one.
   :focus-within means the keyboard path lights the same way the pointer
   path does. */
.cc-tile:hover > .cc-tile__inner > .cc-tile__frame[data-identity],
.cc-tile:focus-within > .cc-tile__inner > .cc-tile__frame[data-identity] {
  box-shadow: 0 0 0 1px var(--rim), 0 0 26px -4px var(--rim);
}

/* Active-filter chips: removable links. Same accent-tint + accent pair as
   .chip--arena, with a hairline edge and a trailing x so "click to remove"
   reads without colour alone (WCAG 1.4.1). */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-block: var(--space-3);
}

.chip--filter {
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent);
  text-decoration: none;
}

.chip--filter:hover {
  color: var(--accent-strong);
}

.chip--filter:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip__x {
  font-weight: 700;
  margin-inline-start: 0.1rem;
}

/* Results-header view switch rendered as links (grid/list/binder). It shares
   the segmented-control look with .seg but the segments are anchors, so the
   view travels in the URL and applying the layout needs no :has(). */
.seg--links {
  display: inline-flex;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg__link {
  padding: 0.4rem 0.75rem;
  font-size: var(--fs-small);
  font-weight: 560;
  color: var(--text-muted);
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.seg__link + .seg__link {
  border-inline-start: 1px solid var(--control-border);
}

.seg__link:hover {
  color: var(--accent);
}

.seg__link[aria-current="true"] {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 620;
}

.seg__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Pager numbered jump links. The bounded window is built server-side; the
   current page is a non-link span, gaps are aria-hidden ellipses. */
.pager__nums {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.pager__num,
.pager__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 0.4rem;
  font-size: var(--fs-small);
  border-radius: var(--radius-sm);
}

.pager__num {
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.pager__num:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.pager__num:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pager__current {
  font-weight: 620;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent);
}

.pager__gap {
  color: var(--text-muted);
  padding: 0 0.15rem;
}

/* Owned-count hexagon. Area accent (--accent) with --accent-label ink -- the
   AA pair Option 4 §6 names; the count is mono and the meaning lives in a
   visually-hidden sentence. Unknown is a quiet sunken hexagon with a '?',
   never a zero. */
.cc-hex {
  position: absolute;
  top: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.7rem;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: var(--accent);
  color: var(--accent-label);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.cc-hex--unknown {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

/* Action dock: -/qty/+/x4. Visually concealed with opacity (NEVER
   display:none, which would drop the buttons from the tab order); revealed on
   hover and on :focus-within, and always visible on touch. Each action is its
   own POST form; the glyphs are aria-hidden and the button name is the full
   sentence. */
.cc-dock {
  position: absolute;
  inset-inline: 0.5rem;
  inset-block-end: 0.5rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

/* Descendant, not child: C3 moved the dock inside .cc-tile__inner so the
   <li>'s class list could stay pinned. :focus-within on the tile also fires
   when focus is on the name link, which is the intended behaviour -- tabbing
   into a tile reveals its actions. */
.cc-tile:hover .cc-dock,
.cc-tile:focus-within .cc-dock {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .cc-dock {
    opacity: 1;
    pointer-events: auto;
    position: static;
    margin: 0.5rem;
  }
}

.cc-dock__form {
  display: inline-flex;
  margin: 0;
}

.cc-dock__qty {
  min-width: 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}

.cc-dock__btn {
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 620;
  line-height: 1;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.3rem 0.5rem;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.cc-dock__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cc-dock__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cc-dock__btn--danger {
  color: var(--danger-strong);
  border-color: var(--danger);
}

.cc-dock__btn--add {
  color: var(--accent);
  border-color: var(--accent);
}

/* List-row layout. A direct class on the INNER WRAPPER (the <li>'s class list
   is pinned) -- and deliberately NOT gated behind :has(), so a surface that
   carries its view in the URL gets the row layout in engines without :has()
   too. The catalogue's per-visit CSS toggle keeps using :has() because its
   view is deliberately not a URL param. */
.cc-tile__inner--list {
  flex-direction: row;
  align-items: stretch;
}

.cc-tile__inner--list > .cc-tile__frame,
.cc-tile__inner--list > .cc-tile__art {
  width: 8.5rem;
  flex: none;
  align-self: flex-start;
  height: auto;
  min-height: 0;
}

.cc-tile__inner--list > .cc-tile__frame > .cc-tile__art,
.cc-tile__inner--list > .cc-tile__frame > .missing-art {
  width: 100%;
}

.browse:has(#view-list:checked) .cc-tile__inner > .card__body,
.cc-tile__inner--list > .card__body {
  flex: 1;
  align-content: start;
}

.browse:has(#view-list:checked) .cc-tile__inner > .cc-dock,
.cc-tile__inner--list > .cc-dock {
  position: static;
  opacity: 1;
  pointer-events: auto;
  align-self: center;
  flex: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  justify-content: flex-start;
}

@media (max-width: 30rem) {
  .browse:has(#view-list:checked) .cc-tile__inner,
  .cc-tile__inner--list {
    flex-wrap: wrap;
  }

  .browse:has(#view-list:checked) .cc-tile__inner > .cc-dock,
  .cc-tile__inner--list > .cc-dock {
    flex-basis: 100%;
  }

  .cc-tile__inner--list > .cc-tile__frame,
  .cc-tile__inner--list > .cc-tile__art {
    width: 6rem;
  }
}

/* Binder 3x3 pocket page. Three fixed columns at every width (the spec's
   3x3), overriding the responsive 2..6 ladder via equal-specificity
   source order -- no :has() and no !important. */
.cc-grid--binder {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* =========================================================================
   COLLECTIONS C4 (Option 4 §5): binder cover, spines, colour spread,
   rarity row, steps, and the hero action drawers. All reuse existing tokens;
   the only new colour is --pip-m (the multicolour segment of the spread bar).
   Placed BEFORE the terminal guardrails so those rules still win.
   ========================================================================= */

/* Single-column list view (the binder 3x3 is .cc-grid--binder above). */
.cc-grid--list {
  grid-template-columns: 1fr;
}

/* Binder spines: the switcher restyled as glass spines. The tabs already
   carry .cc-tab; this only adds the cover-like rhythm and lets the active
   spine read as green-lit (its .cc-tab--active / aria-current styles). */
.cc-spines {
  margin-block: var(--space-4) var(--space-3);
}

/* Binder cover: summary (stats + spread + rarity) and actions side by side,
   collapsing to one column on narrower screens. It is the one hero child that
   must escape the 56% measure cap. */
.hero--art__inner > .cc-cover {
  max-width: 100%;
}

.cc-cover {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: end;
  width: 100%;
}

.cc-cover__summary {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.cc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin: 0;
}

.cc-stat {
  display: grid;
  gap: 0.1rem;
}

.cc-stat__num {
  font-size: var(--fs-h2);
  font-weight: 700;
  color: var(--text);
}

.cc-stat__label {
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

/* Colour spread bar: pip colours (data), with a visible legend so colour is
   never the only signal (WCAG 1.4.1). The aria-label spells out every share. */
.cc-spread {
  display: flex;
  height: 0.875rem;
  border-radius: 0.4375rem;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
  max-width: 34rem;
}

.cc-spread__seg {
  display: block;
  height: 100%;
}

.cc-spread__seg--w { background: var(--pip-w-bg); }
.cc-spread__seg--u { background: var(--pip-u-bg); }
.cc-spread__seg--b { background: var(--pip-b-bg); }
.cc-spread__seg--r { background: var(--pip-r-bg); }
.cc-spread__seg--g { background: var(--pip-g-bg); }
.cc-spread__seg--c { background: var(--pip-c-bg); }
.cc-spread__seg--m { background: var(--pip-m-bg); }

.cc-spread-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.cc-spread-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

.cc-spread-legend__swatch {
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  flex: none;
}

.cc-spread-legend__swatch--w { background: var(--pip-w-bg); }
.cc-spread-legend__swatch--u { background: var(--pip-u-bg); }
.cc-spread-legend__swatch--b { background: var(--pip-b-bg); }
.cc-spread-legend__swatch--r { background: var(--pip-r-bg); }
.cc-spread-legend__swatch--g { background: var(--pip-g-bg); }
.cc-spread-legend__swatch--c { background: var(--pip-c-bg); }
.cc-spread-legend__swatch--m { background: var(--pip-m-bg); }

/* Rarity row: the existing .rarity dot + word, plus a mono count. */
.cc-rarities {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.cc-rarities .rarity .mono {
  color: var(--text);
}

/* Hero action drawers: Import / Export / Manage, in-flow so their panels
   never overlap the other controls at 768px or 390px (the pre-C4 absolute
   Manage panel overlapped the in-flow Import panel). */
.cc-cover__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.cc-cover__actions > details {
  width: min(24rem, 100%);
}

/* Playset badge: green outline, cosmetic (4 is the constructed limit). */
.chip--playset {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* The three-step onboarding guide (empty states). */
.cc-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-block: var(--space-2);
  max-width: var(--measure);
}

.cc-step {
  display: grid;
  gap: 0.35rem;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.cc-step strong {
  color: var(--text);
}

.cc-step__num {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-label);
  font-weight: 700;
}

@media (max-width: 48rem) {
  .cc-cover {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .cc-steps {
    grid-template-columns: 1fr;
  }
}

/* ---------- Hero: the one mono fact, and the quick lanes ----------------

   Spec §3.1 asks the area-lit hero for exactly one number, and §4.1 for a row
   of preset browse states under the search field. Both reuse what is already
   here: --font-mono for the fact (a checkable number is always mono on this
   site) and the .chip component for the lanes. No new colour, face or radius
   is introduced -- the lanes are chips in the area accent, which is what
   makes them read as chrome rather than as card data (§7 rule 4). */
.hero__fact {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5ch;
}

.hero__fact-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--accent);
}

.hero__fact-label {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* The lanes are a wide row of short links, so they are the one hero child
   that must escape the 56 % measure cap meant for prose. Two classes, so it
   beats `.hero--art__inner > *` outright instead of relying on order. */
.hero--art__inner > .lanes {
  max-width: 100%;
}

.lanes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip--lane {
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid var(--accent);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  min-height: 32px;
}

.chip--lane:hover {
  color: var(--accent-strong);
  background: var(--surface);
}

.chip--lane:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Deck sleeves (Option 4 §4.6 / Option 2 §4.5, V3-a #284) ------
   /dashboard/decks and one deck's page. Nothing in this block is used by any
   other surface: every selector is .sleeve*, .deck-*, .legalbadge or
   .chip--format, so the catalogue, collections and card-detail surfaces are
   untouched by it.

   THE SLEEVE IS A .panel, ON PURPOSE. That buys the rim glow on hover and
   focus-within, and with it [data-identity] -- the one mechanism that lets a
   deck glow in ITS OWN colours inside the red area (§4.4, §7 rule 3). The
   template sets data-identity only when the identity is KNOWN, so an unknown
   identity falls back to the area accent rather than claiming "colourless":
   site.css's [data-identity=""] rule is the colourless case and absent data
   is not that.

   TWO COLOUR SYSTEMS, KEPT APART (§7 rules 2-4):
     * --accent (the area, red here) paints interactive and ambient things:
       the eyebrow, buttons, the link hover, the focus ring.
     * --rim-* paints the identity: the panel rim and the light bar. It is
       the GLOW palette, never --pip-*.
     * --pip-* paints the pips, which are card data and change for nobody.
     * --ok / --danger-strong paint legality, which is neither wayfinding nor
       identity but status, and so follows --danger's precedent of being one
       fixed value in each theme.

   NO TRANSFORMS. §6 asks for a hover "lift and tilt" on floating tiles; the
   guardrails section below explains at length why a tile that can contain a
   fixed-position child must not be transformed, and a sleeve is a tile. The
   hover state is the rim and the bar's glow, both box-shadow. The global
   prefers-reduced-motion rule near the top of this file zeroes the durations,
   so the glow still appears, just instantly -- which is exactly §6's
   "keep the glows and drop the transforms".
   ------------------------------------------------------------------------ */

.sleeves {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-4);
}

/* Free-text names, formats and issue details must wrap even at text zoom.
   Keep this local: the catalogue's compact data strips are a different UI. */
.sleeve,
.deck-banner,
.deck-panel,
.deck-hero .hero__title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sleeve {
  /* .panel pads itself for prose; a sleeve's cover must reach its own edges,
     so the padding moves inward to .sleeve__body and the actions row. */
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-areas: "cover" "body" "actions" "bar";
  grid-template-rows: auto 1fr auto auto;
}

/* #355: dashboard previews reuse the sleeve geometry without adding blur
   layers. Identity paint is palette-only; absent identity stays neutral.
   No artwork is implied by this decorative colour band. */
.dashboard-decks__sleeve {
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ---------- The cover: real art, or an honest identity gradient ---------- */
.sleeve__cover {
  grid-area: cover;
  position: relative;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  background: var(--surface-sunken);
}

.sleeve__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* No cover_art_crop_uri. The fallback is the deck's OWN colours, which is
   information rather than a placeholder, damped by a --surface veil so a
   saturated rim colour never becomes a 5:3 slab of neon. Deliberately has no
   glyph and no "no image" label: the deck name sits directly beneath it, and
   the veil reads as an empty sleeve, not a broken one. */
.sleeve__cover--none {
  background: linear-gradient(135deg, transparent, var(--surface)),
    var(--identity-paint, var(--hue-c));
}

.sleeve__cover--none::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--surface);
  opacity: 0.78;
}

/* ---------- The body ------------------------------------------------------ */
.sleeve__body {
  min-width: 0;
  grid-area: body;
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-3);
}

.sleeve__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1.25;
}

/* The whole sleeve is the target, drawn as a stretched pseudo-element rather
   than by wrapping the card in an <a>: that keeps ONE link and ONE button in
   the tab order, and keeps the delete form out of the link. The actions row
   lifts itself above this layer. */
.sleeve__link {
  color: var(--text);
  text-decoration: none;
}

.sleeve__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.sleeve__link:hover,
.sleeve__link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* With a stretched link the browser outlines the TEXT, not the card the user
   is actually on. Where :has() exists, move the ring to the whole sleeve.
   Gated by @supports so an engine without :has() keeps the ordinary outline
   instead of losing focus entirely. */
@supports selector(:has(*)) {
  .sleeve:has(.sleeve__link:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .sleeve .sleeve__link:focus-visible {
    outline: none;
  }
}

.sleeve__meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.sleeve__pips {
  font-size: var(--fs-small);
}

.sleeve__count {
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.sleeve__status {
  margin: 0;
}

.sleeve__desc {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
  /* Two lines, then stop: a sleeve is a summary and a long description must
     not set the height of its whole row. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.sleeve__when {
  margin: 0;
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

/* Above the stretched link, or the link would swallow the button. In flow at
   the foot of the sleeve rather than floated over the cover: .btn--row has a
   transparent fill, and no outline button can promise contrast over arbitrary
   card art. */
.sleeve__actions .btn {
  min-height: 44px;
}

.sleeve__actions {
  grid-area: actions;
  position: relative;
  z-index: 2;
  justify-self: end;
  padding: 0 var(--space-4) var(--space-4);
}

/* ---------- The identity light bar (§4.6) --------------------------------
   A 3px bottom edge in the deck's colours. --identity-paint is supplied
   inline by the template, because only it knows the deck: one --rim-* for a
   mono deck, a left-to-right gradient of them for a multicolour one, and
   neutral silver when the identity is colourless or unknown. */
.sleeve__bar {
  grid-area: bar;
  display: block;
  height: 3px;
  background: var(--identity-paint, var(--hue-c));
}

.sleeve:hover .sleeve__bar,
.sleeve:focus-within .sleeve__bar,
.deck-banner:hover .sleeve__bar,
.deck-banner:focus-within .sleeve__bar {
  box-shadow: 0 0 14px -1px var(--rim);
}

/* ---------- Format chip ---------------------------------------------------
   Not .chip--arena: that one is the area accent and would read as a status.
   A format is a neutral fact, so it takes the sunken fill and full-strength
   ink. The value is the user's own free-text format, echoed verbatim. */
.chip--format {
  background: var(--surface-sunken);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

/* ---------- Legality badge ------------------------------------------------
   Three states, and the WORD is the state (§7 rule 5). The tick and cross are
   aria-hidden decoration on top of it, and "Legality not checked" is a real
   answer, not a spinner: the deck LIST has no legality in its payload, so a
   sleeve says so rather than showing a tick it cannot justify. */
.legalbadge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-micro);
  font-weight: 560;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.55rem;
}

.legalbadge__mark {
  font-weight: 700;
}

.legalbadge--yes {
  background: var(--ok-tint);
  color: var(--ok);
}

.legalbadge--no {
  background: var(--danger-tint);
  color: var(--danger-strong);
}

.legalbadge--unknown {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

/* ---------- The art-less deck heroes -------------------------------------
   .hero--art__inner reserves `min-height: 16rem` because an art hero has a
   picture behind it that needs the room. The build form and the deck page
   call no art macro at all, so on those two the reservation is just a hole
   between the heading and the first real content -- measured at ~140px of
   nothing above the sleeve banner. Scoped to .deck-hero so it corrects only
   these two pages and leaves every other hero--art-none page alone. */
.deck-hero .hero--art__inner {
  min-height: 0;
  padding-block: var(--space-6) var(--space-4);
  gap: var(--space-3);
}

/* ---------- Deck detail: the sleeve banner -------------------------------
   §4.6 asks for "a sleeve banner and glass panels". This is the sleeve the
   visitor just clicked, at banner scale, so the two pages are visibly the
   same object. It carries the deck's OWN cover art, which is also why the
   detail page makes no art_hero() call: _art.html's trusted-source boundary
   says application-api card data must never be handed to that macro, and one
   page gets one art. */
.deck-banner {
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-areas: "cover" "facts" "bar";
  grid-template-rows: auto 1fr auto;
  /* Capped rather than full-bleed: a sleeve stretched to 1120px stops reading
     as the object the visitor clicked and starts reading as a toolbar. */
  max-width: 46rem;
}

.deck-banner__facts {
  min-width: 0;
  grid-area: facts;
  display: grid;
  align-content: start;
  gap: var(--space-3);
  padding: var(--space-4);
}

.deck-banner .sleeve__bar {
  grid-area: bar;
}

/* A summary may clamp; the deck's own detail must show the full description. */
.deck-banner .sleeve__desc {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

@media (min-width: 48rem) {
  .deck-banner {
    grid-template-areas:
      "cover facts"
      "bar   bar";
    grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
  }

  /* Side by side, the cover takes its height from the facts column instead of
     dictating one, so a long description cannot leave a gap beside the art. */
  .deck-banner__cover {
    aspect-ratio: auto;
    min-height: 11rem;
  }
}

/* ---------- Deck detail: the glass panels --------------------------------
   Legality, the card list and the edit form. These are NOT direct children of
   <main>, so the 3-glass-surface budget below leaves them unblurred while
   keeping the glass fill, which is the intended outcome for a page with three
   of them. There is deliberately NO mini curve panel: §5 allows one "if the
   data is available" and this route supplies no curve, no mana values and no
   card rows. The Statistics link in the banner is where that data lives. */
.deck-panel > .import-form,
.deck-panel > .prose,
.deck-panel > .empty,
.deck-panel > .note {
  margin-block: 0;
}

.deck-panel__hint {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-small);
  color: var(--text-muted);
  max-width: var(--measure);
}

/* The deck card list is a <pre>, so it inherits the browser's
   `white-space: pre` -- the site's mono fact box is a <p> everywhere else
   (check_email), so the global .interstitial__address rule never needed to
   override it. `pre-wrap` restores soft wrapping without changing a single
   character of the copyable text (the newlines are still newlines; only the
   DISPLAY breaks change). `anywhere` then lets one unbroken token -- a long
   collector number, a card name with no space -- break too instead of
   widening the panel, and min/max-width stop the box from pushing the panel
   open at phone widths. Scoped to .deck-panel so the shared mono fact box
   keeps its own behaviour. */
.deck-panel .interstitial__address {
  min-width: 0;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}


/* ---------- Statistics (Option 4 §5, hue="b", V3-b #284) -----------------
   Glass stat tiles with Exo 2 numerals; the mana curve fills with --accent
   and the colour-source bars fill with --pip-* (DATA, §7 rule 4). Guidance
   is rendered as callouts. No new colour tokens: every value comes from
   :root and the [data-hue] remap, so this page inherits light/dark for free.

   These tiles and panels are NOT direct children of <main> (they sit inside
   .section > .container), so the glass budget leaves them with the glass
   FILL and no live blur -- the intended outcome for a page with several of
   them, same as the deck detail's .deck-panel.
   ------------------------------------------------------------------------ */

/* The back link sits in the compact hero above the eyebrow; the shared
   .backlink's bottom margin is prose spacing and would double up with the
   hero's grid gap. Scoped to the statistics hero only. */
.stats-hero .backlink {
  margin-bottom: 0;
}

/* -------- Glass stat tiles --------------------------------------------
   One tile = one checkable fact: a quiet label, an Exo 2 headline number,
   and (where it matters) a muted hint. Exo 2 (--font-display) is the display
   numeral face the spec names; the mono face stays on the inline bar counts
   and the land-draw table. */
.stats-tiles {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .stats-tiles {
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  }
}

.stats-tile {
  min-width: 0;
  display: grid;
  gap: var(--space-2);
  align-content: start;
  justify-items: start;
}

.stats-tile__label {
  font-size: var(--fs-small);
  font-weight: 620;
  letter-spacing: -0.012em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stats-tile__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-size: var(--fs-h2);
  line-height: 1.05;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stats-tile__hint {
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

/* -------- Guidance callouts --------------------------------------------
   The page's headline takeaway: a glass panel with the site's one left-edge
   ornament in --accent, the message in full-strength ink, and the detail as
   a mono chip (a checkable fact, so it gets the mono face). */
.stats-callouts {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}

.stats-callout {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  border-inline-start: 3px solid var(--accent);
}

.stats-callout__message {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-small);
  max-width: var(--measure);
}

.stats-callout__detail {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-micro);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.55rem;
}

/* -------- Distribution bars (curve + colour sources) -------------------
   One bar component, two paints. The label column sizes to the widest label
   in its list ("7+" for the curve, "Black" + pip for colour sources); the
   track shrinks, never the count. The track is aria-hidden because the
   adjacent count text already conveys the magnitude. */
.stats-bars {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) 4ch;
  align-items: center;
  gap: var(--space-3);
}

.stats-bar__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-small);
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.stats-bar__count {
  text-align: end;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.stats-bar__track {
  height: 1rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stats-bar__fill {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  background: var(--accent);
}

/* The colour-source bar is a stretched mana pip: fill in the pip's own
   colour, with a 1px edge in the pip's ink. The ink edge is what keeps the
   BLACK source visible on a dark canvas -- exactly how a black mana symbol
   reads (black circle, light letter). --pip-* is DATA, never the area hue
   (§7 rule 4). The consumer supplies --bar-color/--bar-edge inline from the
   colour's pip tokens. */
.stats-bar__fill--pip {
  /* The fallback is deliberately NOT --accent: if a future consumer forgets
     --bar-color, a colour-source bar must fall back to a neutral surface, not
     to the area's hue, which §7 reserves for the mana curve (and using an
     area hue on a data fill is the exact confusion the split exists to stop).
     Pinned by tests/test_statistics_v3.py. */
  background: var(--bar-color, var(--surface-sunken));
  border: 1px solid var(--bar-edge, transparent);
}

/* -------- The two-column land-draw table -------------------------------
   The site-wide .section table min-width is 40rem, built for the wide deck
   and collection lists. Two narrow columns would force a pointless sideways
   scroll on phones. */
.section table.table--slim {
  min-width: 0;
}


/* ---------- Rules search (Option 4 §5, hue="u", V3-c #284) ---------------
   The BLUE area: a "study" art hero, glass result panels, and rule IDs as
   blue mono chips. No new colour tokens -- `--accent`/`--accent-tint` resolve
   to Blue through the [data-hue="u"] remap, so this page inherits both themes
   for free and `tests/test_theme_contrast.py` already guards the one text-on-
   tint pairing used below.

   STRICTLY ADDITIVE. The hairline list this page used before V3-c
   (`.ruleslist`, `.rule`, `.rule__content`, `.rule__cite`, `.rule__path`,
   `.rule__version`, up in "Search + browse surfaces") is UNCHANGED; the
   markup now also carries `.rules-results` on the <ul> and `.panel` on each
   <li>, and the overrides below are scoped under that class. Nothing here
   touches `.searchform`, `.filterbar`, or any catalogue/collections/
   statistics/decks declaration -- `/rules` and `/catalogue` share the search
   form on purpose and must keep sharing exactly one copy of it.

   The panels sit inside `.section > .container`, not as direct children of
   <main>, so the glass budget (guardrails, Budget 3) leaves them with the
   glass FILL and no live backdrop blur. That is the intended outcome for a
   result list of arbitrary length -- same as the deck detail's `.deck-panel`
   and the statistics tiles.
   ------------------------------------------------------------------------ */

/* The hero's grid is `justify-items: start`, which sizes children to their
   content -- a search form would shrink to its max-content width (about the
   input's 16rem flex-basis plus the button) instead of filling the copy
   column. Stretch it back to the column, which `.hero--art__inner > *` still
   caps inside the scrim, so the form never crosses onto the artwork.
   `.searchform`'s own `max-width: 36rem` is untouched and still wins at
   desktop. */
.rules-hero .hero--art__inner > .searchform {
  width: 100%;
}

/* Panels, not hairlines. The passage keeps `.rule`'s grid and `.panel`'s
   padding; what has to go is the hairline separator and the bottom padding
   that paired with it, including `.ruleslist > :last-child`'s zeroing (equal
   specificity, so the explicit `:last-child` below is what settles it rather
   than source order). */
.rules-results {
  gap: var(--space-3);
}

.rules-results > .rule {
  border-bottom: 0;
  padding-bottom: var(--space-4);
}

.rules-results > .rule:last-child {
  border-bottom: 0;
  padding-bottom: var(--space-4);
}

/* A result is a quotation, so the panel reads as a quotation: the passage is
   the panel's only full-ink text, and everything around it (the ID chip, the
   heading path, the version) is the provenance line. The quotation gets the
   reading measure from `.rule__content`; the panel does not re-cap it. */
.rules-result {
  min-width: 0;
}

.rules-result__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
}

/* The blue mono rule-ID chip. `--accent` on `--accent-tint` is the same
   pairing `.citation` and `.chip--arena` already use, and the one
   `tests/test_theme_contrast.py` pins at >= 4.5:1 for every hue in every
   theme. Mono because a rule number is a checkable fact, and the 1px edge is
   what keeps the chip legible as an object on a translucent panel. */
.rules-result__id {
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1.4;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
}

/* The source the chip's number belongs to. Muted and in the body face: the
   verifiable part is the number, not the corpus name. */
.rules-result__source {
  font-size: var(--fs-micro);
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* The abstention. Deliberately NOT styled as an error and NOT as the empty
   state: retrieval ran and declined, which is a third outcome. It keeps
   `.note`'s neutral grey body (the message is not good news and not a
   failure) and recolours only the 3px left ornament, which is the precedent
   `.note--accent` already set -- an edge ornament, never a fill or body text
   (§7 rule 2). `.note` already supplies the padding and the measure. */
.rules-abstain {
  border-inline-start-color: var(--accent);
}


/* ---- collection update review (#422) ---- */
/* The "Update collection" review screen
   (templates/collection_update_review.html): upload a newer Arena export,
   see only what changed, decide card-by-card about the cards the file did
   not mention, then confirm.

   This block adds layout and two states, not a look. Everything that can be
   borrowed is borrowed: .cc-stat for the summary numbers, .checkfield(s) for
   the decision rows (the same component the consent gate uses), .alert and
   .note for messages, .pager furniture for the pager, .btn for every
   control. No new token, no new colour, no second accent -- the one red is
   --danger, already used by .alert--error and .btn--row--danger, and the
   only new thing it does here is mark a row as armed for removal.
   ------------------------------------------------------------------------ */

/* Vertical rhythm for the page's three stacked regions. Headings inside keep
   their own .section__title margins; this only sets the gap BETWEEN blocks,
   so it cannot fight the shared heading spacing. */
.cur > * + * {
  margin-top: var(--space-5);
}

.cur,
.cur-conflict {
  overflow-wrap: anywhere;
}

.cur-conflict {
  padding-block: var(--space-4);
}

.cur-block {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

/* ---------- The stale-collection banner ----------------------------------
   The one message on this page that has to beat the rest of it, because it
   says "nothing happened and the numbers moved". It is .alert with the
   accent edge and tint rather than a new component, and it is wider than
   --measure on purpose: it is a banner, not body copy. */
.cur-banner {
  display: grid;
  gap: var(--space-2);
  max-width: none;
  background: var(--accent-tint);
  border-inline-start-color: var(--accent);
  color: var(--text);
}

.cur-banner__title {
  font-size: var(--fs-body);
  font-weight: 660;
  letter-spacing: -0.014em;
}

.cur-banner__body {
  max-width: var(--measure);
  color: var(--text);
}

/* ---------- Summary counts ------------------------------------------------
   The same .cc-stat tiles the collection cover uses, but in a grid rather
   than .cc-stats' flex row. Five counts form one desktop strip; two columns
   on mobile keep the decisions close without shrinking the type. */
.cur-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
  width: 100%;
  margin: 0;
  padding: var(--space-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cur-summary .cc-stat__label {
  /* Two short lines beat one long one in a narrow track. */
  max-width: 14ch;
}

/* ---------- Lines we could not read --------------------------------------
   User-supplied file lines. They are checkable facts (mono, like set codes
   and rule numbers) and they are arbitrary text, so they must be allowed to
   break mid-token: a 300-character line with no spaces would otherwise push
   the page sideways at 375px. */
.cur-unread {
  width: 100%;
  max-width: 46rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.cur-unread__summary {
  cursor: pointer;
  font-size: var(--fs-small);
  font-weight: 620;
  color: var(--text);
}

.cur-unread__summary:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.cur-unread__list {
  display: grid;
  gap: var(--space-1);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.cur-unread__line {
  font-size: var(--fs-small);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* ---------- The owner rule, and the "check your file" warning ------------ */

.cur-rule {
  max-width: var(--measure);
  font-size: var(--fs-lead);
}

.cur-warn {
  /* Plain .alert colours: this is a thing to check, not an error, and the
     site has exactly one red. The <strong> opener carries the emphasis. */
  width: 100%;
}

.cur-form {
  display: grid;
  gap: var(--space-4);
  width: 100%;
  justify-items: start;
}

/* ---------- Bulk actions -------------------------------------------------
   Three submit buttons on one wrapping row, with their scope spelled out
   underneath. The hint is not decoration: "Select all" acts on every page, and
   a control that silently does more than the visible list is exactly the
   kind of thing this screen exists to prevent. */
.cur-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  width: 100%;
}

.cur-bar__hint {
  flex-basis: 100%;
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* ---------- The decision list -------------------------------------------
   A fieldset is the right grouping element for "these checkboxes are one
   question" (same reasoning as .gate__fieldset), and its default border and
   inline padding are still not. The legend stays VISIBLE: it carries the
   rule and the paging scope, so hiding it would hide the instruction. */
.cur-set {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.cur-set__legend {
  padding: 0;
  margin-bottom: var(--space-3);
  max-width: var(--measure);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 640;
}

.cur-rows {
  width: 100%;
  gap: var(--space-2);
}

.cur-row {
  padding: var(--space-3);
}

/* Set and collector number remain in the real checkbox label. Allow long
   values to wrap rather than widening the fieldset on small screens. */
.cur-row__meta {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* ---------- A row armed for removal -------------------------------------
   TWO signals, never one. The tint and edge are --danger (the site's single
   red, borrowed from .alert--error, not a new hue), and the WORDS
   "Will be removed" are rendered by the template, so the state survives
   greyscale, forced-colors and colour-blind viewing (WCAG 1.4.1).
   --danger-strong on --danger-tint is the pairing .alert--error already
   measured: 8.7:1 dark, 7.5:1 light. */
.cur-row:has(input:checked) {
  background: var(--danger-tint);
  border-color: var(--danger);
}

.cur-row:has(input:checked):focus-within {
  border-color: var(--danger-strong);
}

.cur-row__flag {
  display: none;
  color: var(--danger-strong);
  font-size: var(--fs-small);
  font-weight: 620;
}

.cur-row__keep {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.cur-row input:checked + .checkfield__text .cur-row__flag {
  display: block;
}

.cur-row input:checked + .checkfield__text .cur-row__keep {
  display: none;
}

/* ---------- Pager built from submit buttons ------------------------------
   The numbers must be <button>, not <a>, or a page turn would discard the
   user's unsaved ticks (see the template header). So .pager__num has to
   survive being a button: strip the UA background, border and font, and keep
   the 2rem box the link version already sets. */
.cur-pager {
  width: 100%;
}

.cur-pager button.pager__num {
  background: none;
  font: inherit;
  font-size: var(--fs-small);
  cursor: pointer;
}

.cur-pager__note {
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* ---------- Confirm -----------------------------------------------------
   The only part of this page that writes anything, so it is the only part
   that gets a frame: a sunken panel at the end of the form, with the exact
   count in the button label and the irreversibility stated in words next to
   it. Cancel sits beside Update at the same size -- leaving without saving
   must be as easy to hit as saving. */
.cur-confirm {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.cur-confirm__title {
  font-size: var(--fs-h3);
  font-weight: 660;
  letter-spacing: -0.016em;
}

.cur-confirm__body {
  max-width: var(--measure);
  color: var(--text);
}

.cur-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.cur-confirm__aside {
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: var(--fs-small);
}

@media (max-width: 47.99rem) {
  .cur-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Narrow screens: the two confirm controls go full width and stack, so the
   primary action is never a 48px-wide stub next to a wrapped Cancel. */
@media (max-width: 29.99rem) {
  .cur-confirm__actions {
    display: grid;
    width: 100%;
  }

  .cur-confirm__actions > .btn {
    width: 100%;
    white-space: normal;
    text-align: center;
  }
}

/* ---- end collection update review (#422) ------------------------------- */

/* =========================================================================
   PERFORMANCE AND LAYER GUARDRAILS (Option 2 §7 / Option 4 §7, wave V2)
   -------------------------------------------------------------------------
   LAST IN THE FILE ON PURPOSE. These are the rules that must win, so they are
   written after everything they correct. If you add CSS below this block you
   have moved it out of the way; put it above instead.

   Four of the five budget items are mechanical here. The fifth (one hero per
   page) is half here and half in the macro.
   ========================================================================= */

/* ---------- Budget 1: at most ONE hero art per page ----------------------
   The shell's per-render namespace suppresses duplicate macro output before
   a second image can be fetched. This sibling selector is only a visual
   backstop for handwritten markup; display:none alone is NOT a fetch gate.
   ------------------------------------------------------------------------ */
.hero--art ~ .hero--art {
  display: none;
}

/* ---------- Budget 2: NO backdrop-filter on grid tiles -------------------
   Two separate reasons, and both matter:

   1  COST. Blur is per-element GPU work. A 5-6 column catalogue ladder puts
      30+ tiles on screen; blurring each one is the single most expensive
      thing this stylesheet could do, and it would undo the "cheap to run"
      stance the whole design is built on.

   2  CORRECTNESS, which is the one that would actually break something.
      backdrop-filter makes an element the containing block for its
      position: fixed descendants. .cc-pop is position: fixed and is anchored
      to the VIEWPORT on purpose -- its own comment explains that an
      absolutely-positioned popover could not know the scroll position and
      overflowed the document at narrow widths, which is a layout shift the
      tests check for. .cc-pop is a CHILD of .cc-tile, so blurring a tile
      re-anchors the enlargement to the tile and brings the bug straight back.

      The same is true of `filter`, `transform`, `perspective`, `contain:
      paint` and `will-change: transform`. The existing tile hover uses
      border-color and box-shadow and no transform, and that is not an
      accident -- see the note above .cc-pop. Option 4 §6 asks for a hover
      "lift and tilt" on floating tiles: ON A CARD TILE THAT CANNOT BE A
      TRANSFORM. Do it with box-shadow, or move .cc-pop out of the tile first.

   Stated as explicit `none` rather than just "we did not add it", so that
   anything inherited or added later is actively cancelled here.
   ------------------------------------------------------------------------ */
.cc-grid .cc-tile,
.cc-grid .cc-tile *,
.results .card,
.results .card * {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* A .panel wrapped around a card grid is the realistic way live blur ends up
   above a tile: the panel is then an ANCESTOR of .cc-pop, and it would become
   the popover's containing block even though the tiles themselves are clean.
   So a panel that contains a grid keeps the glass look (translucent --glass)
   and loses only the blur. :has() is the whole point -- it lets the stylesheet
   detect the dangerous nesting instead of relying on the next author knowing
   about it. */
.panel:has(.cc-grid),
.panel:has(.results),
.panel:has(.cc-pop) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ---------- Budget 3: at most 3 composited glass surfaces ----------------
   Header + at most the first TWO direct-main panels. All other panels keep
   the translucent glass fill/rim, but not the costly live backdrop blur.
   Counting classes or nesting depth alone would NOT cap a grid of panels.
   The selector below is deliberately `main > .panel`: wrapped/grid panels do
   NOT match it, so today only the header is actually live-blurred and the
   budget still permits at most 2 direct-main panels for future use. Do not
   broaden the selector to catch nested panels -- that would let a grid of
   panels each consume the costly blur.
   :nth-child(... of .panel) counts only panels, not the hero or other content.
   Older engines retain unblurred panels. No tile/popover ancestor may blur. */
.panel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  main > .panel:nth-child(-n + 2 of .panel):not(.panel--plain):not(:has(.cc-grid, .results, .cc-pop)):not(.cc-tile, .card) {
    backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  }
}

.panel .panel {
  background: var(--surface-sunken);
}

/* ---------- Budget 4: mobile artwork -----------------------------------
   The picture source's media condition is the NETWORK gate. This paint
   guard also removes the image's accessible name when no art is shown.
   Never reset .hero--art__overlay: its gradients are the contrast scrim. */
@media (max-width: 39.999rem) {
  .hero--art__art,
  .hero--art__glyph {
    display: none;
  }
}

@media (max-width: 48rem) {
  .hero--art { --hero-scrim: 100vw; }
  .hero--art__inner > * { max-width: 100%; }
  .hero--art__inner { padding-block: var(--space-5); }
}

.hero--art-none .hero--art__inner > * {
  max-width: min(100%, var(--measure));
}

/* Shell-only refinements. The nav always owns overflow, even at desktop
   text zoom. Keep 64px chrome and keyboard focus clear of the scroll edge. */
.site-header .wordmark { flex-shrink: 0; }
.site-nav {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding: var(--space-1);
  gap: var(--space-2);
}
.site-nav > * { flex-shrink: 0; scroll-snap-align: start; }
.site-nav__link,
.site-nav .linkbutton { min-height: 44px; }
.site-nav__link--cta,
.site-nav__link--cta:hover { color: var(--hue-w); }

/* A sticky header can pass over bright card artwork. The raw 72% glass
   token alone cannot guarantee muted-text contrast over white. Reinforce
   shell glass with the existing surface (91.6% opacity on dark, 93.4% on
   light), without changing V1 tokens or adding another composited element.
   Solid first; translucent only when BOTH colour mixing and blur work. */
.site-header,
.panel:not(.panel--plain),
.btn--quiet,
.btn--danger { background: var(--surface); }

@supports (color: color-mix(in srgb, red, blue)) {
  @supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .site-header,
    .panel:not(.panel--plain),
    .btn--quiet,
    .btn--danger {
      background: color-mix(in srgb, var(--surface) 70%, var(--glass));
    }
  }
}

.panel .panel { background: var(--surface-sunken); }

/* Solid fills are the no-blur fallback, including glass-look buttons. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header,
  .panel,
  .btn--quiet,
  .btn--danger { background: var(--surface); }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header,
  .panel,
  .btn--quiet,
  .btn--danger {
    background: var(--surface) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ---------- Reduced motion ------------------------------------------------
   Option 4 §6: reduced motion KEEPS the glows and drops the transforms. The
   global prefers-reduced-motion block near the top of this file already
   collapses every transition, which would take the rim glow's fade with it --
   that is fine, because the glow still appears, just instantly. What matters
   here is that no transform-based lift is introduced for these surfaces.
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .panel,
  .panel::after,
  .gem__facets .facet {
    transition: none;
  }
}

/* ---------- Legal reading column (privacy / terms / disclosures) --------
   Option 4 §5: the three legal pages are the colourless area (hue "c") but
   they are a plain DOCUMENT, not a product area -- no art band, no glass. A
   solid --surface column bounded by the --measure reading width, centred, with
   the existing hairline dividers between sections. Deliberately no
   border-radius, no box-shadow, no .panel and no backdrop-filter: it must read
   as paper on the page, never as a card. .page-hero is NOT used here; it stays
   for about/features/dashboard/settings.
   ------------------------------------------------------------------------ */

.legal {
  max-width: var(--measure);
  margin-inline: auto;
  background: var(--surface);
  padding-block: var(--space-7) var(--space-6);
  padding-inline: max(var(--space-4), env(safe-area-inset-left))
    max(var(--space-4), env(safe-area-inset-right));
}

.legal__head {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.legal__title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.legal__lead {
  font-size: var(--fs-lead);
  color: var(--text-muted);
}

.legal__toc,
.legal__section {
  padding-block: var(--space-6);
  border-top: 1px solid var(--border);
}
