/* Studio Egregori — theme palettes (PLAN.md Track B).
   =====================================================================
   A theme is a token override block and nothing else. No page markup
   changes, no duplicated rules, no second stylesheet of components —
   that is the payoff for style.css having been written against custom
   properties in the first place.

   SEVEN THEMES. Six borrow the palette of a bespoke homebrew sheet; one
   ("light") is designed here. Themes borrow COLOUR ONLY — never the
   animated backgrounds, which belong to their sheets and are half of
   what makes each sheet distinct.

   THE BESPOKE SHEETS DO NOT CONSUME THESE TOKENS. /homebrew/* carries
   its own complete styling, so a theme cannot repaint The First Seam
   even if the attribute were somehow set on it. That enforcement is
   structural rather than a rule someone has to remember (PLAN B4).

   EVERY VALUE HERE CLEARS WCAG AA against this site's real pairings, and
   `tools/check_contrast.py` is what says so. Where a token departs from
   its source sheet, the comment says what it was and why it moved: the
   source palettes were tuned for their own sheet's layout, and this
   site's small metadata text is a harsher surface than any of them.
   Do not "restore" a source value without re-running the gate.
   ===================================================================== */

/* ---- persona — Manifold ------------------------------------------------
   Source: The Egregore / The Egregori Legacy (identical palettes).
   Red on black, high contrast, Persona-5 energy. */
:root[data-theme="persona"] {
  --ink: #f0f0f0;
  --ink-dim: #b8b8b8;
  --ink-faint: #8f8f8f;   /* sheet has no faint tier; derived to clear AA */
  --ground: #0a0a0a;
  --ground-raised: #111111;
  --rule: #2a2a2a;
  --accent: #ff3b42;      /* sheet red #ed1c24 lands at ~4.4:1 — lifted */
  --accent-dim: #b8151b;
  --live: #7fa650;
  --wip: #b17d41;
}

/* ---- seam — Paper ------------------------------------------------------
   Source: The First Seam. Black on paper, no colour at all: the sheet is
   deliberately monochrome, so links are marked by underline and weight
   rather than by hue. Keeping it colourless is the faithful choice. */
:root[data-theme="seam"] {
  --ink: #0a0a0a;
  --ground: #f4f2ee;
  --ink-dim: #555555;
  --ink-faint: #6e6e6e;   /* sheet's #8a8a8a is 3.1:1 on paper — darkened */
  --ground-raised: #fbfaf8;
  --rule: #cfcac0;
  --accent: #1a1a1a;      /* monochrome by design; underline carries the link */
  --accent-dim: #555555;
  --live: #3f6b23;
  --wip: #85541a;
}

/* ---- nebula — Second Sleep --------------------------------------------
   Source: The Second Sleep. Deep violet-blue, the dreaming palette. */
:root[data-theme="nebula"] {
  --ink: #ece9f5;
  --ink-dim: #a49dc0;
  --ink-faint: #8b84ab;   /* sheet #6f6890 is 3.2:1 on the void — lifted */
  --ground: #05040a;
  --ground-raised: #100c1e;
  --rule: #2a2440;
  --accent: #a86ce8;      /* sheet violet #8b45d6 is ~3.0:1 — lifted */
  --accent-dim: #6a34a3;
  --live: #7fa650;
  --wip: #b17d41;
}

/* ---- court — Inheritance ----------------------------------------------
   Source: The Inheritance. Black fire and bloody ember. */
:root[data-theme="court"] {
  --ink: #cfc4bb;
  --ink-dim: #8d8178;
  --ink-faint: #8a7d74;   /* sheet #5d534d is 2.6:1 on the void — lifted */
  --ground: #060405;
  --ground-raised: #0f0b0c;
  --rule: #221e1c;
  --accent: #e84256;      /* sheet blood-bright #d4243a — lifted for AA */
  --accent-dim: #9e1220;
  --live: #8fa87a;
  --wip: #ff5a24;         /* the sheet's ember, and it clears AA as-is */
}

/* ---- signal — Cutting Room --------------------------------------------
   Source: The Cutting Room. VHS grade: orange and teal. */
:root[data-theme="signal"] {
  --ink: #c9cdcb;
  --ink-dim: #8a9290;
  --ink-faint: #838b8a;   /* sheet #565e5d is 2.6:1 on the dark — lifted */
  --ground: #0b0d0e;
  --ground-raised: #101416;
  --rule: #202426;
  --accent: #ff8a1e;      /* the sheet's orange, unmodified — it clears AA */
  --accent-dim: #b35605;
  --live: #2ec4c4;        /* the sheet's teal, doing the 'shipped' job */
  --wip: #d4a03c;         /* distinct from --accent so the pills stay legible */
}

/* ---- light — Studio Light ---------------------------------------------
   Not from any sheet. The studio palette inverted: warm paper, near-black
   ink, and the imprint gold darkened enough to survive a light ground —
   #c9a227 is ~2.2:1 on paper, which is why this is a redesign and not a
   swap of --ink and --ground. */
:root[data-theme="light"] {
  --ink: #1a1813;
  --ink-dim: #4a463d;
  --ink-faint: #6a655a;
  --ground: #f7f4ec;
  --ground-raised: #fffdf7;
  --rule: #ddd8cb;
  --accent: #6f5712;      /* old gold, darkened for paper */
  --accent-dim: #5c4a10;
  --live: #3f6b23;
  --wip: #85541a;
}

/* ---- default for a first-time visitor (PLAN.md B5.4) -------------------
   No cookie means no data-theme attribute, and the site would otherwise
   force dark on someone whose machine asks for light. `:not([data-theme])`
   is what makes an explicit choice always win: the moment the middleware
   writes the attribute, this block stops applying — in BOTH directions, so
   a reader on a light OS can still choose a dark theme and keep it.

   ⚠️ These values are a DUPLICATE of [data-theme="light"] above. CSS has no
   way to share one token block between a selector and a media query, so the
   copy is deliberate — and `check_site.py` asserts the two blocks stay
   byte-identical, because a silently diverged copy is exactly the drift this
   site keeps trying not to ship. Edit both or neither. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --ink: #1a1813;
    --ink-dim: #4a463d;
    --ink-faint: #6a655a;
    --ground: #f7f4ec;
    --ground-raised: #fffdf7;
    --rule: #ddd8cb;
    --accent: #6f5712;
    --accent-dim: #5c4a10;
    --live: #3f6b23;
    --wip: #85541a;
  }
}
