/* ─────────────────────────────────────────────────────────────────────────
   Theme — the light-ground corrections, and the picker's own chrome.

   Two thirds of this file exists because of one physical fact: every board
   picture on this page is a SCREENSHOT of a viewer whose backdrop is dark, and
   a screenshot cannot be relit by CSS. So on a light ground the board keeps its
   own dark stage — the scrub becomes a full-bleed dark band, and the hero still
   sits in a dark panel. That reads as a deliberate chapter rather than a
   mistake, and it is the same decision Apple and Stripe make on a white page
   when the product itself is dark.

   If you ever recapture the frames on a light backdrop, delete the
   [data-tone="light"] board rules and nothing else changes.
   ───────────────────────────────────────────────────────────────────────── */

[data-tone="light"] {
  --stage-fade: 8 8 10;
  --plate-shadow-a: .16;
  --grain-a: .028;
  --grain-blend: multiply;
}

/* ── light: the board keeps its own dark room ────────────────────────────── */

[data-tone="light"] .turn .stage {
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bot));
}
/* Inside that room the ink goes back to the dark ground's ink, so the beats
   stay legible without a second set of classes in the markup.
   BOTH forms have to be redeclared. `--fg: rgb(var(--fg-rgb))` was substituted
   back at :root, so overriding only the triplet here changes nothing that
   already reads `var(--fg)` — a custom property resolves where it is DECLARED,
   not where it is used. Redeclaring the triplet alone is a silent no-op and
   cost a round of screenshots to notice. */
[data-tone="light"] .turn .stage {
  --fg-rgb: 238 240 243;
  --fg2-rgb: 164 172 184;
  --fg3-rgb: 109 118 131;
  --line-rgb: 40 46 56;
  --fg:   rgb(238 240 243);
  --fg-2: rgb(164 172 184);
  --fg-3: rgb(109 118 131);
  --line: rgb(40 46 56);
  color: var(--fg);
}
[data-tone="light"] .board-figure canvas,
[data-tone="light"] .board-figure img {
  -webkit-mask-image: none;
  mask-image: none;
}

[data-tone="light"] .hero-board {
  /* The dark panel is a hard edge, so it may not sit under the headline the
     way the feathered version could. */
  margin-top: 0;
  margin-right: calc(var(--gut) * -1 - 2vw);
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--stage-top), var(--stage-bot));
  box-shadow: 0 30px 70px -40px rgb(var(--shadow-rgb) / .35);
}
[data-tone="light"] .hero-board img {
  -webkit-mask-image: none;
  mask-image: none;
}
@media (max-width: 940px) {
  [data-tone="light"] .hero-board { margin-right: calc(var(--gut) * -1); }
}

/* The app screenshots are dark too, so a plate on a light page gets the dark
   room rather than a white card with a dark picture rattling around in it. */
[data-tone="light"] .plate { background: var(--stage-bot); border-color: rgb(var(--line2-rgb)); }
[data-tone="light"] .plate figcaption {
  background: rgb(var(--void-rgb));
  border-top-color: rgb(var(--line-rgb));
}

/* One dark thing left over: the transcript reads as a terminal, and on paper it
   should read as a printed listing instead. */
[data-tone="light"] .turnbox { background: var(--card); }

/* ── the picker ──────────────────────────────────────────────────────────── */

.themer {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 200;
  font-family: var(--sans);
}

.themer__open {
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 15px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgb(var(--void-rgb) / .82);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  color: var(--fg-2);
  font-size: 13.5px; font-weight: 560;
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.themer__open:hover { color: var(--fg); border-color: var(--fg-3); transform: translateY(-1px); }
.themer__dot {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--cu);
  box-shadow: 0 0 0 1px rgb(var(--sheen-rgb) / .25) inset;
}

.themer__panel {
  position: absolute;
  right: 0; bottom: 50px;
  width: 288px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgb(var(--void-rgb) / .94);
  backdrop-filter: saturate(150%) blur(18px);
  -webkit-backdrop-filter: saturate(150%) blur(18px);
  box-shadow: 0 30px 70px -30px rgb(var(--shadow-rgb) / .8);
  padding: 16px;
  display: none;
}
.themer[data-open="true"] .themer__panel { display: block; }

.themer h4 {
  margin: 0 0 9px;
  font-variation-settings: 'wdth' 72;
  font-weight: 620; font-size: 11.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg-3);
}
.themer h4 + * + h4, .themer h4 ~ h4 { margin-top: 18px; }

.themer__grounds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.themer__ground {
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 7px 4px 6px;
  background: none;
  color: var(--fg-3);
  font-family: inherit; font-size: 10.5px; font-weight: 560;
  cursor: pointer;
  display: grid; gap: 6px; justify-items: center;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.themer__ground i { width: 100%; height: 20px; border-radius: 3px; border: 1px solid rgb(var(--sheen-rgb) / .1); }
.themer__ground:hover { color: var(--fg-2); }
.themer__ground[aria-pressed="true"] { border-color: var(--cu); color: var(--fg); }

.themer__accents { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.themer__swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgb(var(--sheen-rgb) / .16);
  cursor: pointer; padding: 0;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.themer__swatch:hover { transform: scale(1.1); }
.themer__swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--void), 0 0 0 3.5px currentColor; }

.themer__custom {
  width: 26px; height: 26px; padding: 0;
  border: 1px dashed var(--line-2); border-radius: 50%;
  background: none; cursor: pointer;
  overflow: hidden;
}
.themer__custom::-webkit-color-swatch-wrapper { padding: 2px; }
.themer__custom::-webkit-color-swatch { border: none; border-radius: 50%; }

.themer__hex {
  width: 100%; margin-top: 10px;
  background: rgb(var(--sheen-rgb) / .05);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--fg-2);
  font-family: var(--mono); font-size: 12px;
  padding: 7px 9px;
}
.themer__hex:focus { outline: none; border-color: var(--cu); color: var(--fg); }

.themer__row { display: flex; gap: 7px; margin-top: 16px; }
.themer__act {
  flex: 1;
  height: 32px; border-radius: 5px;
  border: 1px solid var(--line-2);
  background: none; color: var(--fg-2);
  font-family: inherit; font-size: 12.5px; font-weight: 560;
  cursor: pointer;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.themer__act:hover { border-color: var(--fg-3); color: var(--fg); }
.themer__act--go { background: var(--cu); color: var(--cta-ink); border-color: transparent; font-weight: 640; }
.themer__act--go:hover { background: var(--cu-hi); color: var(--cta-ink); }

.themer__note { margin: 11px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--fg-3); }

@media (max-width: 560px) {
  .themer { right: 12px; bottom: 12px; }
  .themer__panel { width: calc(100vw - 24px); }
}
@media print { .themer { display: none; } }
