/* ==========================================================================
   Verso Base Styles — Tokens, Fonts, Reset, Shared Shell, Components & Motion
   ========================================================================== */

:root {
  /* Follows the OS unless data-theme (bottom of this file) forces a theme.
     Every themed color below is written once, as light-dark(light, dark). */
  color-scheme: light dark;

  /* Typography */
  --font-serif: "Literata", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Type Scale */
  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.1rem;
  --text-lg: clamp(1.2rem, 1.8vw, 1.4rem);
  --text-xl: clamp(1.6rem, 3vw, 2.2rem);
  --text-hero: clamp(2.4rem, 4.8vw, 3.75rem);

  --leading-tight: 1.08;
  --leading-snug: 1.28;
  --leading-body: 1.62;

  /* Layout & Spacing */
  --container-max: 1100px;
  --container-narrow: 800px;
  --nav-height: 68px;
  --gutter: clamp(1.15rem, 3vw, 2rem);
  --section-y: clamp(3.5rem, 7vw, 6rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* Radii */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.42, 0.64, 1);
  --dur-fast: 180ms;
  --dur-base: 320ms;
  --dur-slow: 520ms;

  /* Palette — Warm Editorial Paper (light), Midnight Ink (dark) */
  --bg: light-dark(#F8F6F1, #0E1118);
  --bg-subtle: light-dark(#EFECE3, #151A25);
  --surface: light-dark(#FFFFFF, #171D2A);
  --surface-raised: light-dark(#FFFFFF, #1E2536);
  --surface-glass: light-dark(rgba(248, 246, 241, 0.84), rgba(14, 17, 24, 0.84));
  --code-bg: light-dark(#F1EEE6, #1E2433);

  --ink: light-dark(#141722, #F3F0E9);
  --ink-secondary: light-dark(#414759, #C2C6D4);
  --ink-muted: light-dark(#63697B, #8B92A6);

  --border: light-dark(rgba(20, 23, 34, 0.09), rgba(243, 240, 233, 0.10));
  --border-strong: light-dark(rgba(20, 23, 34, 0.17), rgba(243, 240, 233, 0.19));
  --border-accent: light-dark(rgba(41, 82, 227, 0.32), rgba(112, 144, 255, 0.36));

  /* Primary Brand Accent — Editorial Cobalt */
  --accent: light-dark(#2952E3, #7090FF);
  --accent-hover: light-dark(#1E44CB, #8AA5FF);
  --accent-ink: light-dark(#FFFFFF, #0B0F1A);
  --accent-soft: light-dark(rgba(41, 82, 227, 0.10), rgba(112, 144, 255, 0.16));
  --accent-glow: light-dark(rgba(41, 82, 227, 0.24), rgba(112, 144, 255, 0.30));

  /* Highlighter stroke behind the hero accent word */
  --highlight: light-dark(rgba(255, 150, 72, 0.30), rgba(255, 122, 72, 0.20));
  /* Stronger stroke on a Guide heading that was jumped to */
  --highlight-jump: light-dark(rgba(255, 138, 52, 0.78), rgba(224, 96, 40, 0.88));

  /* Semantic Status & Beta Accents */
  --beta: light-dark(#B5471A, #FF9166);
  --beta-bg: light-dark(#FCEEE5, rgba(255, 122, 72, 0.13));
  --beta-border: light-dark(rgba(181, 71, 26, 0.24), rgba(255, 122, 72, 0.30));

  --status-done: light-dark(#0B6D4E, #38D39F);
  --status-done-bg: light-dark(rgba(11, 109, 78, 0.11), rgba(56, 211, 159, 0.14));
  --status-done-border: light-dark(rgba(11, 109, 78, 0.26), rgba(56, 211, 159, 0.30));

  --status-next: light-dark(#2952E3, #7090FF);
  --status-next-bg: light-dark(rgba(41, 82, 227, 0.10), rgba(112, 144, 255, 0.16));
  --status-next-border: light-dark(rgba(41, 82, 227, 0.28), rgba(112, 144, 255, 0.32));

  --status-future: light-dark(#A33F29, #FF8566);
  --status-future-bg: light-dark(rgba(163, 63, 41, 0.11), rgba(255, 133, 102, 0.15));
  --status-future-border: light-dark(rgba(163, 63, 41, 0.26), rgba(255, 133, 102, 0.30));

  /* Shadows differ in shape between themes, so each lists both themes' layers
     and makes the other theme's layers transparent. */

  /* Screenshot Sheet Framing (Frameless Floating Paper) */
  --sheet-bg: light-dark(#FFFFFF, #F6F5F1);
  --sheet-border: light-dark(rgba(20, 23, 34, 0.12), rgba(255, 255, 255, 0.18));
  --sheet-shadow:
    0 28px 60px -16px light-dark(transparent, rgba(0, 0, 0, 0.65)),
    0 24px 52px -18px light-dark(rgba(20, 23, 34, 0.20), transparent),
    0 0 0 1px light-dark(transparent, rgba(255, 255, 255, 0.08)),
    0 4px 12px -4px light-dark(rgba(20, 23, 34, 0.08), transparent);
  --sheet-shadow-back:
    0 18px 38px -14px light-dark(transparent, rgba(0, 0, 0, 0.52)),
    0 14px 32px -14px light-dark(rgba(20, 23, 34, 0.15), transparent);

  /* Shadows */
  --shadow-xs:
    0 1px 4px light-dark(transparent, rgba(0, 0, 0, 0.28)),
    0 1px 3px light-dark(rgba(20, 23, 34, 0.05), transparent);
  --shadow-sm:
    0 8px 22px -8px light-dark(transparent, rgba(0, 0, 0, 0.45)),
    0 6px 18px -8px light-dark(rgba(20, 23, 34, 0.10), transparent),
    0 1px 3px light-dark(rgba(20, 23, 34, 0.04), transparent);
  --shadow-md:
    0 20px 44px -14px light-dark(transparent, rgba(0, 0, 0, 0.58)),
    0 18px 40px -16px light-dark(rgba(20, 23, 34, 0.14), transparent),
    0 2px 6px light-dark(rgba(20, 23, 34, 0.04), transparent);
  --shadow-lg:
    0 36px 76px -18px light-dark(transparent, rgba(0, 0, 0, 0.72)),
    0 32px 64px -20px light-dark(rgba(20, 23, 34, 0.22), transparent);

  /* Ambient backdrop lights, switched on as the page opens (see base.css) */
  --light-right: light-dark(rgba(41, 82, 227, 0.15), rgba(112, 144, 255, 0.22));
  --light-right-core: light-dark(rgba(60, 100, 255, 0.12), rgba(140, 165, 255, 0.18));
  --light-left: light-dark(rgba(235, 92, 34, 0.14), rgba(255, 104, 50, 0.19));
  --light-left-core: light-dark(rgba(235, 92, 34, 0.10), rgba(255, 104, 50, 0.12));



}

/* Manual override, set by the theme toggle */
:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* Fallback for browsers without CSS light-dark() (e.g. Safari < 17.5) */
@supports not (color: light-dark(red, blue)) {
  :root {
    --bg: #F8F6F1;
    --bg-subtle: #EFECE3;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --surface-glass: rgba(248, 246, 241, 0.84);
    --code-bg: #F1EEE6;

    --ink: #141722;
    --ink-secondary: #414759;
    --ink-muted: #63697B;

    --border: rgba(20, 23, 34, 0.09);
    --border-strong: rgba(20, 23, 34, 0.17);
    --border-accent: rgba(41, 82, 227, 0.32);

    --accent: #2952E3;
    --accent-hover: #1E44CB;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(41, 82, 227, 0.10);
    --accent-glow: rgba(41, 82, 227, 0.24);

    --highlight: rgba(255, 150, 72, 0.30);
    --highlight-jump: rgba(255, 138, 52, 0.78);

    --beta: #B5471A;
    --beta-bg: #FCEEE5;
    --beta-border: rgba(181, 71, 26, 0.24);

    --status-done: #0B6D4E;
    --status-done-bg: rgba(11, 109, 78, 0.11);
    --status-done-border: rgba(11, 109, 78, 0.26);

    --status-next: #2952E3;
    --status-next-bg: rgba(41, 82, 227, 0.10);
    --status-next-border: rgba(41, 82, 227, 0.28);

    --status-future: #A33F29;
    --status-future-bg: rgba(163, 63, 41, 0.11);
    --status-future-border: rgba(163, 63, 41, 0.26);

    --sheet-bg: #FFFFFF;
    --sheet-border: rgba(20, 23, 34, 0.12);
    --sheet-shadow:
      0 24px 52px -18px rgba(20, 23, 34, 0.20),
      0 4px 12px -4px rgba(20, 23, 34, 0.08);
    --sheet-shadow-back:
      0 14px 32px -14px rgba(20, 23, 34, 0.15);

    --shadow-xs:
      0 1px 3px rgba(20, 23, 34, 0.05);
    --shadow-sm:
      0 6px 18px -8px rgba(20, 23, 34, 0.10),
      0 1px 3px rgba(20, 23, 34, 0.04);
    --shadow-md:
      0 18px 40px -16px rgba(20, 23, 34, 0.14),
      0 2px 6px rgba(20, 23, 34, 0.04);
    --shadow-lg:
      0 32px 64px -20px rgba(20, 23, 34, 0.22);

    --light-right: rgba(41, 82, 227, 0.15);
    --light-right-core: rgba(60, 100, 255, 0.12);
    --light-left: rgba(235, 92, 34, 0.14);
    --light-left-core: rgba(235, 92, 34, 0.10);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0E1118;
      --bg-subtle: #151A25;
      --surface: #171D2A;
      --surface-raised: #1E2536;
      --surface-glass: rgba(14, 17, 24, 0.84);
      --code-bg: #1E2433;

      --ink: #F3F0E9;
      --ink-secondary: #C2C6D4;
      --ink-muted: #8B92A6;

      --border: rgba(243, 240, 233, 0.10);
      --border-strong: rgba(243, 240, 233, 0.19);
      --border-accent: rgba(112, 144, 255, 0.36);

      --accent: #7090FF;
      --accent-hover: #8AA5FF;
      --accent-ink: #0B0F1A;
      --accent-soft: rgba(112, 144, 255, 0.16);
      --accent-glow: rgba(112, 144, 255, 0.30);

      --highlight: rgba(255, 122, 72, 0.20);
      --highlight-jump: rgba(224, 96, 40, 0.88);

      --beta: #FF9166;
      --beta-bg: rgba(255, 122, 72, 0.13);
      --beta-border: rgba(255, 122, 72, 0.30);

      --status-done: #38D39F;
      --status-done-bg: rgba(56, 211, 159, 0.14);
      --status-done-border: rgba(56, 211, 159, 0.30);

      --status-next: #7090FF;
      --status-next-bg: rgba(112, 144, 255, 0.16);
      --status-next-border: rgba(112, 144, 255, 0.32);

      --status-future: #FF8566;
      --status-future-bg: rgba(255, 133, 102, 0.15);
      --status-future-border: rgba(255, 133, 102, 0.30);

      --sheet-bg: #F6F5F1;
      --sheet-border: rgba(255, 255, 255, 0.18);
      --sheet-shadow:
        0 28px 60px -16px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.08);
      --sheet-shadow-back:
        0 18px 38px -14px rgba(0, 0, 0, 0.52);

      --shadow-xs:
        0 1px 4px rgba(0, 0, 0, 0.28);
      --shadow-sm:
        0 8px 22px -8px rgba(0, 0, 0, 0.45);
      --shadow-md:
        0 20px 44px -14px rgba(0, 0, 0, 0.58);
      --shadow-lg:
        0 36px 76px -18px rgba(0, 0, 0, 0.72);

      --light-right: rgba(112, 144, 255, 0.22);
      --light-right-core: rgba(140, 165, 255, 0.18);
      --light-left: rgba(255, 104, 50, 0.19);
      --light-left-core: rgba(255, 104, 50, 0.12);
    }
  }

  :root[data-theme="dark"] {
    --bg: #0E1118;
    --bg-subtle: #151A25;
    --surface: #171D2A;
    --surface-raised: #1E2536;
    --surface-glass: rgba(14, 17, 24, 0.84);
    --code-bg: #1E2433;

    --ink: #F3F0E9;
    --ink-secondary: #C2C6D4;
    --ink-muted: #8B92A6;

    --border: rgba(243, 240, 233, 0.10);
    --border-strong: rgba(243, 240, 233, 0.19);
    --border-accent: rgba(112, 144, 255, 0.36);

    --accent: #7090FF;
    --accent-hover: #8AA5FF;
    --accent-ink: #0B0F1A;
    --accent-soft: rgba(112, 144, 255, 0.16);
    --accent-glow: rgba(112, 144, 255, 0.30);

    --highlight: rgba(255, 122, 72, 0.20);
    --highlight-jump: rgba(224, 96, 40, 0.88);

    --beta: #FF9166;
    --beta-bg: rgba(255, 122, 72, 0.13);
    --beta-border: rgba(255, 122, 72, 0.30);

    --status-done: #38D39F;
    --status-done-bg: rgba(56, 211, 159, 0.14);
    --status-done-border: rgba(56, 211, 159, 0.30);

    --status-next: #7090FF;
    --status-next-bg: rgba(112, 144, 255, 0.16);
    --status-next-border: rgba(112, 144, 255, 0.32);

    --status-future: #FF8566;
    --status-future-bg: rgba(255, 133, 102, 0.15);
    --status-future-border: rgba(255, 133, 102, 0.30);

    --sheet-bg: #F6F5F1;
    --sheet-border: rgba(255, 255, 255, 0.18);
    --sheet-shadow:
      0 28px 60px -16px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(255, 255, 255, 0.08);
    --sheet-shadow-back:
      0 18px 38px -14px rgba(0, 0, 0, 0.52);

    --shadow-xs:
      0 1px 4px rgba(0, 0, 0, 0.28);
    --shadow-sm:
      0 8px 22px -8px rgba(0, 0, 0, 0.45);
    --shadow-md:
      0 20px 44px -14px rgba(0, 0, 0, 0.58);
    --shadow-lg:
      0 36px 76px -18px rgba(0, 0, 0, 0.72);

    --light-right: rgba(112, 144, 255, 0.22);
    --light-right-core: rgba(140, 165, 255, 0.18);
    --light-left: rgba(255, 104, 50, 0.19);
    --light-left-core: rgba(255, 104, 50, 0.12);
  }
}

/* Local OFL Typography (zero external requests). Latin subsets, built by
   scripts/subset-fonts.sh */
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-SemiBoldItalic.woff2") format("woff2");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/Inter-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/Inter-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* Accented Latin and Cyrillic, fetched only by pages that use them. These come
   after the Latin faces so they win for their unicode-range. */
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-Regular.ext.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-Italic.ext.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-SemiBold.ext.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: "Literata";
  src: url("../assets/fonts/Literata-SemiBoldItalic.ext.woff2") format("woff2");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/Inter-Regular.ext.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/Inter-SemiBold.ext.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-017F, U+0300-030C, U+0400-045F, U+0490-0491;
}

/* Native Cross-Document Multi-Page Transitions: the content fades, the header
   stays still and the nav pill slides. The header, the pill and the links are
   separate layers so that the pill can move between the other two. */
@view-transition {
  navigation: auto;
}

.site-header { view-transition-name: site-header; }
.nav { view-transition-name: nav; }
.nav__link[aria-current="page"]::before { view-transition-name: nav-pill; }

::view-transition-group(nav) {
  z-index: 1;
}

::view-transition-group(nav-pill) {
  animation-duration: var(--dur-base);
  animation-timing-function: var(--ease-spring);
}

/* An open lightbox covers the header, so the page stays one layer */
:root:has(.lightbox.is-open) :is(.site-header, .nav),
:root:has(.lightbox.is-open) .nav__link[aria-current="page"]::before {
  view-transition-name: none;
}

/* The links differ in width: keep the pill's height while it stretches */
::view-transition-old(nav-pill),
::view-transition-new(nav-pill) {
  height: 100%;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

main {
  flex: 1;
}

/* Ambient lights — one layer each, so they can come on one after the other.
   Each light is a soft glow with a brighter core, both true circles that end
   inside their layer. The spread is animated on the gradients themselves:
   scaling the layer would pull its edges into view. */
@property --light-spread {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

body::before,
body::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1040px;
  max-height: 100%; /* never lengthen a short page, such as filtered results */
  z-index: -1;
  pointer-events: none;
  --light-offset: clamp(120px, 18vw, 340px); /* distance from the page center: close enough to meet in the middle */
  background:
    radial-gradient(
      circle calc(var(--light-radius) * 0.42 * var(--light-spread, 1)) at var(--light-at),
      var(--light-core),
      color-mix(in srgb, var(--light-core) 55%, transparent) 35%,
      color-mix(in srgb, var(--light-core) 18%, transparent) 70%,
      transparent
    ),
    radial-gradient(
      circle calc(var(--light-radius) * var(--light-spread, 1)) at var(--light-at),
      var(--light-color),
      color-mix(in srgb, var(--light-color) 72%, transparent) 20%,
      color-mix(in srgb, var(--light-color) 42%, transparent) 42%,
      color-mix(in srgb, var(--light-color) 18%, transparent) 66%,
      color-mix(in srgb, var(--light-color) 5%, transparent) 85%,
      transparent
    );
  animation: lightOn 950ms var(--ease-out) var(--light-delay) both;
}

body::before {
  --light-delay: 100ms;
  --light-color: var(--light-right);
  --light-core: var(--light-right-core);
  --light-at: calc(50% + var(--light-offset)) 300px;
  --light-radius: clamp(340px, 48vw, 760px);
}

body::after {
  --light-delay: 260ms;
  --light-color: var(--light-left);
  --light-core: var(--light-left-core);
  --light-at: calc(50% - var(--light-offset)) 270px;
  --light-radius: clamp(320px, 45vw, 700px);
}

/* Already on when arriving from another page of the site (set in <head>) */
.lights-lit body::before,
.lights-lit body::after {
  animation: none;
}

@keyframes lightOn {
  from {
    opacity: 0;
    --light-spread: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after {
    animation: none;
  }
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
  color: inherit;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: var(--leading-snug);
  margin: 0;
  color: var(--ink);
}

p {
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.12rem 0.42rem;
  border-radius: var(--radius-xs);
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--ink);
}

/* Layout Helpers */
.container {
  width: min(var(--container-max), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
}

.container--narrow {
  width: min(var(--container-narrow), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.75rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.75rem;
}

/* ==========================================================================
   Shared Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--nav-height);
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--dur-base) var(--ease-out);
}

/* The border waits for scrolling to start (see initHeaderBorder), except while
   the menu is open and needs an edge between itself and the header */
html:not(.no-js) .site-header:not(.is-scrolled, :has([aria-expanded="true"])) {
  border-bottom-color: transparent;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand__mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px -5px var(--accent-glow);
  transition: background-color var(--dur-fast);
}

.brand__mark svg {
  overflow: visible; /* the turning page rises above the book */
}

/* The right page turns over on hover and back afterwards. The leaf lies on top of
   it and only shows while turning; its free edge lifts with the turn. */
@property --page-turn {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.brand__leaf {
  fill: var(--accent);
  transform-origin: 12px 12px;
  transform: scaleX(cos(var(--page-turn))) skewY(calc(sin(var(--page-turn)) * -24deg));
  opacity: calc(sin(var(--page-turn)) * 6);
  transition: --page-turn var(--dur-slow) ease-in-out;
}

.brand:hover .brand__leaf,
.brand:focus-visible .brand__leaf {
  --page-turn: 180deg;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav__link {
  position: relative;
  z-index: 0; /* keeps the pill behind its own label */
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}

.nav__link:hover {
  color: var(--ink);
  background: var(--bg-subtle);
}

.nav__link[aria-current="page"] {
  color: var(--ink);
  background: none;
}

.nav__link[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-base) var(--ease-spring), color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-toggle svg {
  overflow: visible;
}

.theme-toggle svg,
.theme-toggle g,
.theme-toggle path {
  transition: transform var(--dur-slow) var(--ease-spring), opacity var(--dur-base) var(--ease-out);
}

.theme-toggle:hover svg {
  transform: rotate(20deg);
}

/* The icon is the theme to switch to, drawn as a moon. Its outline is a round
   side and an edge that curves inward. Turning into the sun, the moon shrinks,
   its edge flips outward to close the circle, and the rays come out. */
:root { --is-dark: 0; }

@media (prefers-color-scheme: dark) {
  :root { --is-dark: 1; }
}

:root[data-theme="light"] { --is-dark: 0; }
:root[data-theme="dark"] { --is-dark: 1; }

.theme-icon__disc path {
  vector-effect: non-scaling-stroke;
  stroke-width: 1.42px; /* what the rays' 2 units come to at 17px */
}

.theme-icon__disc {
  transform-origin: 12px 12px;
  transform: scale(calc(1 - 0.557 * var(--is-dark)));
}

.theme-icon__edge {
  transform-origin: 16.105px 7.895px; /* middle of the line between its ends, which lies at 45deg */
  transform: rotate(45deg) scaleY(calc(1 - 1.54 * var(--is-dark))) rotate(-45deg);
}

.theme-icon__rays {
  transform-origin: 12px 12px;
  transform: rotate(calc(60deg * (var(--is-dark) - 1))) scale(calc(0.5 + 0.5 * var(--is-dark)));
  opacity: var(--is-dark);
}

/* Theme switch — the new theme spreads from the button like a frontlight (see
   initTheme). The page is one layer, with only the button kept on top of it. */
.is-switching-theme .site-header,
.is-switching-theme .nav,
.is-switching-theme .nav__link[aria-current="page"]::before {
  view-transition-name: none;
}

.is-switching-theme .theme-toggle {
  view-transition-name: theme-toggle;
}

.is-switching-theme :not(.theme-toggle, .theme-toggle *),
.is-switching-theme ::before,
.is-switching-theme ::after {
  transition: none !important;
}

@property --theme-spread {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.is-switching-theme::view-transition-old(root) {
  animation: none;
}

.is-switching-theme::view-transition-new(root) {
  mix-blend-mode: normal;
  -webkit-mask-image: radial-gradient(
    circle farthest-corner at var(--theme-x) var(--theme-y),
    #000 calc(var(--theme-spread) - 30%),
    transparent var(--theme-spread)
  );
  mask-image: radial-gradient(
    circle farthest-corner at var(--theme-x) var(--theme-y),
    #000 calc(var(--theme-spread) - 30%),
    transparent var(--theme-spread)
  );
  animation: themeSpread 780ms cubic-bezier(0.4, 0, 0.3, 1) both;
}

@keyframes themeSpread {
  from { --theme-spread: 0%; }
  to { --theme-spread: 130%; }
}

.is-switching-theme::view-transition-group(theme-toggle) {
  animation: none;
}

.is-switching-theme::view-transition-old(theme-toggle) {
  display: none;
}

.is-switching-theme::view-transition-new(theme-toggle) {
  animation: none;
}

.menu-btn {
  display: none;
}

/* The menu icon's lines cross into an X while the menu is open */
.menu-btn path {
  transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-fast);
}

.menu-btn__top { transform-origin: 12px 7px; }
.menu-btn__middle { transform-origin: 12px 12px; }
.menu-btn__bottom { transform-origin: 12px 17px; }

.menu-btn[aria-expanded="true"] .menu-btn__top {
  transform: translateY(5px) rotate(45deg);
}

.menu-btn[aria-expanded="true"] .menu-btn__middle {
  opacity: 0;
  transform: scaleX(0);
}

.menu-btn[aria-expanded="true"] .menu-btn__bottom {
  transform: translateY(-5px) rotate(-45deg);
}

/* Mobile Nav Drawer */
.mobile-nav {
  position: fixed;
  inset: var(--nav-height) 0 auto 0;
  z-index: 85;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: var(--space-4) var(--gutter) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden; /* keeps the closed menu's links out of the Tab order */
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), visibility var(--dur-fast),
    transform var(--dur-base) var(--ease-out);
}

.mobile-nav.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.mobile-nav__link {
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.mobile-nav__link:hover,
.mobile-nav__link[aria-current="page"] {
  background: var(--bg-subtle);
  color: var(--ink);
}

@media (max-width: 720px) {
  .nav {
    display: none;
  }
  .menu-btn {
    display: grid;
  }
}

/* ==========================================================================
   Buttons, Badges & Beta Callout
   ========================================================================== */
.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.88rem 1.45rem;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.96rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 26px -10px var(--accent-glow);
  transition: transform var(--dur-base) var(--ease-spring), background-color var(--dur-fast), box-shadow var(--dur-base) var(--ease-out);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 18px 34px -10px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary__icon {
  transition: transform var(--dur-base) var(--ease-spring);
}

.btn-primary:hover .btn-primary__icon {
  transform: translateY(2px);
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.52rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.btn-primary .beta-pill {
  background: light-dark(rgba(255, 255, 255, 0.22), rgba(11, 15, 26, 0.18));
}

@supports not (color: light-dark(red, blue)) {
  .btn-primary .beta-pill {
    background: rgba(255, 255, 255, 0.22);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .btn-primary .beta-pill {
      background: rgba(11, 15, 26, 0.18);
    }
  }

  :root[data-theme="dark"] .btn-primary .beta-pill {
    background: rgba(11, 15, 26, 0.18);
  }
}

.beta-pill--standalone {
  background: var(--beta-bg);
  color: var(--beta);
  border: 1px solid var(--beta-border);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-secondary);
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast), transform var(--dur-base) var(--ease-spring);
}

.btn-link:hover {
  color: var(--ink);
}

.btn-link__arrow {
  transition: transform var(--dur-base) var(--ease-spring);
}

.btn-link:hover .btn-link__arrow {
  transform: translateX(3px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease-spring), border-color var(--dur-fast), background-color var(--dur-fast);
}

.btn-secondary:hover {
  transform: translateY(-1.5px);
  border-color: var(--accent);
}

/* Subtle Download Version / Size / Release Notes Meta */
.download-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-xs);
  color: var(--ink-muted);
  line-height: 1.45;
}

.download-meta__ver {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink-secondary);
}

.download-meta__sep {
  opacity: 0.55;
}

/* Release details that arrive after the page has loaded (see renderMeta) */
.download-meta--arrived > * {
  animation: fadeIn var(--dur-slow) var(--ease-out);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.download-meta a {
  color: var(--ink-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: color var(--dur-fast), text-decoration-color var(--dur-fast);
}

.download-meta a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Simple, Honest Beta Notice */
.beta-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-sm);
  background: var(--beta-bg);
  border: 1px solid var(--beta-border);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: 1.5;
}

.beta-note__dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: var(--beta);
}

.beta-note strong {
  color: var(--ink);
}

/* ==========================================================================
   Page Header Primitive (Subpages)
   ========================================================================== */
.page-head {
  padding-block: clamp(2.8rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
}

.page-head__title {
  font-size: clamp(2rem, 4.2vw, 3rem);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-3);
}

.page-head__lead {
  font-size: var(--text-md);
  color: var(--ink-secondary);
  max-width: 56ch;
}

/* ==========================================================================
   Shared Footer
   ========================================================================== */
.site-footer {
  margin-top: var(--space-7);
  border-top: 1px solid var(--border);
  padding-block: var(--space-6);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink-secondary);
}

.site-footer__brand strong {
  font-family: var(--font-serif);
  color: var(--ink);
  font-weight: 600;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.25rem;
}

.site-footer__links a {
  text-decoration: none;
  transition: color var(--dur-fast);
}

.site-footer__links a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Shared Interactive Components (Segmented Control, Lightbox, Stage Tags)
   ========================================================================== */

/* Sliding Pill Control (reused for Screenshot Deck, Install Tabs, Roadmap Filters) */
.segmented {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.28rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.segmented__indicator {
  position: absolute;
  top: 0.28rem;
  left: 0;
  height: calc(100% - 0.56rem);
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: transform var(--dur-base) var(--ease-spring), width var(--dur-base) var(--ease-spring);
  z-index: 0;
}

.segmented__btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.44rem 0.95rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast);
}

.segmented__btn:hover {
  color: var(--ink);
}

.segmented__btn[aria-pressed="true"],
.segmented__btn[aria-selected="true"] {
  color: var(--accent-ink);
}

/* Text fades out, is replaced, then fades in (see swapText) */
.is-swapping {
  opacity: 0;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  pointer-events: none;
}

.lightbox.is-open {
  pointer-events: auto;
}

/* The backdrop and bar fade; the image grows out of its sheet (see initDeck) */
.lightbox::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 18, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.lightbox::before,
.lightbox__bar {
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.lightbox.is-open::before,
.lightbox.is-open .lightbox__bar {
  opacity: 1;
}

.lightbox__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* Last value keeps the 3:4 screenshot within 80vh */
  width: min(560px, calc(100vw - 2 * var(--space-5)), 60vh);
}

.lightbox__img {
  width: 100%;
  aspect-ratio: 948 / 1260;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-lg);
  background: #FFFFFF;
  touch-action: pan-y pinch-zoom;
}

.lightbox__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-height: 3.3em; /* two caption lines, so browsing doesn't move the image */
  color: #F3F0E9;
  font-size: var(--text-sm);
}

.lightbox__caption {
  flex: 1 1 180px;
  min-width: 0;
  transition: opacity var(--dur-fast);
}

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

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

.lightbox__btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}

.lightbox__btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.34);
}

.lightbox__btn:active {
  transform: scale(0.94);
}

.lightbox__counter {
  min-width: 2.8rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: rgba(243, 240, 233, 0.82);
}

.lightbox__close {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.85rem;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.34);
}

.lightbox__btn:focus-visible,
.lightbox__close:focus-visible {
  outline-color: #FFFFFF;
}

@media (max-width: 520px) {
  .lightbox__bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .lightbox__caption {
    flex: none;
  }
  .lightbox__controls {
    width: 100%;
    justify-content: space-between;
  }
  .lightbox__btn {
    width: 36px;
    height: 36px;
  }
}

/* Stage Tags (Install & Roadmap) */
.stage-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.18rem 0.62rem;
  border-radius: var(--radius-pill);
}

.stage-tag--done {
  background: var(--status-done-bg);
  color: var(--status-done);
  border: 1px solid var(--status-done-border);
}

.stage-tag--next {
  background: var(--status-next-bg);
  color: var(--status-next);
  border: 1px solid var(--status-next-border);
}

.stage-tag--future {
  background: var(--status-future-bg);
  color: var(--status-future);
  border: 1px solid var(--status-future-border);
}

/* ==========================================================================
   Purposeful Reveal Motion
   ========================================================================== */

/* Icon strokes that draw themselves while a state lasts: feature icons (hover),
   a copied command, a finished install step. Paths need pathLength="1". */
.icon-draw {
  opacity: 0;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: opacity var(--dur-fast), stroke-dashoffset 0s var(--dur-fast);
}

.is-acting .icon-draw,
.is-copied .icon-draw,
.step-card.is-done.is-visible .icon-draw {
  opacity: 1;
  stroke-dashoffset: 0;
  transition: opacity 0s var(--delay, 80ms), stroke-dashoffset var(--dur-base) var(--ease-out) var(--delay, 80ms);
}

@keyframes heroEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-enter {
  animation: heroEnter var(--dur-slow) var(--ease-out) var(--delay, 0ms) both;
}

@keyframes heroRise {
  from {
    transform: translateY(10px);
  }
  to {
    transform: translateY(0);
  }
}

h1.hero-enter {
  animation-name: heroRise;
  animation-delay: 0ms;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: var(--delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Always visible without JS (disabled, or app.js failed to load or run) */
.no-js .reveal {
  opacity: 1;
  transform: none;
}

/* Controls that only work with JS step aside; the content they switch
   between is all shown instead (see page stylesheets) */
.no-js [data-theme-toggle],
.no-js .menu-btn,
.no-js .segmented,
.no-js .copy-btn,
.no-js .deck-sheet__zoom-hint {
  display: none;
}

/* With no menu button, the mobile links sit in a row under the header */
@media (max-width: 720px) {
  .no-js .mobile-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-2) var(--gutter);
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition: none;
  }
  .no-js .mobile-nav__link {
    padding: 0.45rem 0.8rem;
    font-size: var(--text-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
