/* ============================================================================
   FONT TOKENS — drives the pixel / readable switch
   ----------------------------------------------------------------------------
   Every font-size in home.css / article.css / guide.css is written as

       font-size: calc(<original value> * var(--display-scale));

   using --display-scale for text set in the display face and --body-scale for
   text set in the body/mono face.

   In pixel mode both scales are exactly 1, so the pages render identically to
   the original hand-written HTML. Readable mode only has to change the two
   families and the two scale factors.

   Why two scales, and why these numbers (measured, not guessed):

     VT323 at 20px has an x-height of only 8px, where a system sans at 20px has
     10.44px. So the original body text reads like a normal font at ~15px —
     below a comfortable size for long-form text. Matching that apparent size
     would keep readable mode just as small, so --body-scale deliberately
     overshoots: 0.95 gives 19px sans (x-height 9.9px), roughly 24% more
     apparent size than the pixel original.

     Press Start 2P is a pixel face whose cap height equals its font-size
     exactly (10px caps at 10px), while the sans manages 0.705 of that. Headings
     therefore need 1/0.705 = 1.42 just to look the same height. Its glyphs are
     also 1.68x as wide, so at 1.42 the sans still sets narrower than the
     original and nothing re-wraps.

   --font-brand never switches: the "GO AGENTIC" wordmark and the guide hero
   title stay pixel art in both modes.
   ========================================================================== */

:root {
  /* ---- The two pixel faces. These never switch; they are what "pixel mode"
          means, and they are reused to pin individual regions (see footer). ---- */
  --font-brand: "Press Start 2P", monospace;
  --font-body-pixel: "VT323", monospace;
  /* VT323's x-height is only 0.40 em, so the original 20px body read like a
     normal font at ~15px. 1.15 lifts it to 23px (~17.6px apparent) while keeping
     the pixel face. Set this back to 1 to get the original sizes exactly. */
  --pixel-body-scale: 1.15;

  /* ---- Pixel mode (default) ---- */
  --font-display: var(--font-brand);
  --font-body: var(--font-body-pixel);
  --font-mono: var(--font-body-pixel);

  --display-scale: 1;
  --body-scale: var(--pixel-body-scale);
}

/* The footer stays pixel art in both modes. Re-declaring the tokens on <footer>
   makes every existing rule resolve to the pixel values inside that subtree, so
   no font rule has to be duplicated — the page stylesheets are untouched. */
footer {
  --font-display: var(--font-brand);
  --font-body: var(--font-body-pixel);
  --font-mono: var(--font-body-pixel);
  --display-scale: 1;
  --body-scale: var(--pixel-body-scale);
  /* The page stylesheets never set font-family on <footer>; it inherits the
     already-resolved family from <body>, which the token override above cannot
     undo. Re-stating it here makes the subtree resolve against the pixel tokens. */
  font-family: var(--font-body);
}

:root[data-font="readable"] {
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 1.42 = cap-height parity with Press Start 2P; 0.95 = 19px body, chosen for
     comfortable reading rather than parity with VT323's very small x-height. */
  --display-scale: 1.42;
  --body-scale: 0.95;
}

/* ----------------------------------------------------------------------------
   Readable-mode corrections
   The originals tune line-height and letter-spacing for the pixel faces, which
   leaves proportional text looking loose. These only apply in readable mode.
   -------------------------------------------------------------------------- */

:root[data-font="readable"] h2,
:root[data-font="readable"] h3,
:root[data-font="readable"] h4,
:root[data-font="readable"] article header h1 {
  line-height: 1.3;
  letter-spacing: normal;
}

:root[data-font="readable"] header .subtitle,
:root[data-font="readable"] .nav-logo,
:root[data-font="readable"] .badge,
:root[data-font="readable"] .tag,
:root[data-font="readable"] .date,
:root[data-font="readable"] .breadcrumb {
  letter-spacing: normal;
}

/* The pixel faces have no real bold or italic; proportional fonts do. */
:root[data-font="readable"] strong,
:root[data-font="readable"] th,
:root[data-font="readable"] .sop-heading {
  font-weight: 600;
}

/* ============================================================================
   SEGMENTED TOGGLES
   The language switch and the font switch share one visual language, taken from
   the guide's original language toggle: a thin bordered box holding two
   segments, the active one filled in.

   Both live here rather than in the page stylesheets so all three page types
   get the identical control.
   ========================================================================== */

.lang-toggle,
.font-toggle {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 2px;
  border: 2px solid var(--toggle-accent);
  flex: none;
}

.lang-toggle {
  --toggle-accent: var(--neon-yellow);
}

.font-toggle {
  --toggle-accent: var(--neon-purple);
}

/* Segments share a fixed height so both controls line up and neither resizes
   when the font mode changes — chrome should stay put while content reflows.
   `border: none` / `border-bottom: none` undo the guide's global dashed-underline
   link styling. */
.lang-toggle a,
.font-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 8px;
  border: none;
  border-bottom: none;
  border-radius: 0;
  background: transparent;
  color: var(--toggle-accent);
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.lang-toggle a:hover,
.font-toggle button:hover {
  color: var(--toggle-accent);
  text-shadow: none;
}

/* Explicit rgba rather than color-mix() so older browsers get the hover too.
   The yellow value is the one the guide's original toggle used. */
.lang-toggle a:hover {
  background: rgba(255, 230, 0, 0.15);
}

.font-toggle button:hover {
  background: rgba(180, 77, 255, 0.18);
}

.lang-toggle a.lang-active,
.font-toggle button.ft-active {
  background: var(--toggle-accent);
  color: var(--bg-dark);
  text-shadow: none;
}

.lang-toggle a:focus-visible,
.font-toggle button:focus-visible {
  outline: 2px solid var(--toggle-accent);
  outline-offset: 2px;
}

/* Pixel-font labels: EN / DE and the left-hand Aa. These use --font-brand, which
   never switches, so the controls keep their pixel character in both modes and
   all three labels share one size. */
.lang-toggle a,
.font-toggle .ft-pixel {
  font-family: var(--font-brand);
  font-size: 9px;
}

/* The single exception: this segment is drawn in the face it selects, since that
   is what makes the control self-explanatory. 12.8px is not arbitrary — the sans
   has a cap height of 0.705em against Press Start 2P's 1.0em, so 9 / 0.705 =
   12.8px puts both labels at exactly the same 9px cap height. */
.font-toggle .ft-readable {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 12.8px;
  font-weight: 600;
}

/* Floating placement for the home and article pages, which have no nav bar to
   hang the controls off. */
.toggle-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  /* Above the guide's fixed nav bar (z-index 1000). */
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 700px) {
  .lang-toggle a,
  .font-toggle button {
    padding: 0 6px;
  }
}

/* Users who ask for less motion get no reveal animation and no transitions. */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ============================================================================
   SHARED UTILITIES
   Extracted from inline style attributes in the original pages so their font
   sizes participate in the switch. Used by the home page and the guide.
   ========================================================================== */

.footer-gameover {
  font-family: var(--font-display);
  font-size: calc(10px * var(--display-scale));
  color: var(--neon-green);
  margin-bottom: 12px;
}
