/* portfolio — space palette and layers. Tilt-shift and bokeh feel live here
   as CSS overlays; the WebGL canvas does the 3D. */

:root {
  --bg: #0d0b24;
  --fg: #eae6ff;
  --muted: #a79be0;
  --accent: #ff5c5c;
  --panel: #171232cc;
  --line: #4536a0;
  --chip: #ff5c5c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* Hide the scene's edge slivers behind the UI layer (no horizontal leak). */
#scene-mount, #scene-mount canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

/* --- depth-of-field / tilt-shift feel (CSS bands, cheap) --- */
.shift-top, .shift-bottom {
  position: fixed;
  left: 0;
  right: 0;
  height: 22vh;
  pointer-events: none;
  z-index: 2;
}
.shift-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(8,6,26,0.92), rgba(8,6,26,0));
}
.shift-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(8,6,26,0.92), rgba(8,6,26,0));
}

/* --- vignette for the dreamy depth --- */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(4,3,14,0.55) 100%);
}

/* --- UI layer --- */
.ui { position: relative; z-index: 5; }

.titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  pointer-events: none;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f1edff;
  text-shadow: 0 2px 18px rgba(120, 90, 255, 0.5);
}
.brand .dot { color: var(--accent); }
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  opacity: 0.85;
}

/* --- highlight of the day (depth 1) --- */
.highlight {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5.4rem); /* above the thread nav */
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 2.5rem));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.1rem 1.4rem 1.2rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: rise 0.7s ease-out;
}
@keyframes rise {
  from { transform: translateX(-50%) translateY(14px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}
/* Gilded trim: a thin gold line inside the border and a warm glow (the
   scene's gold highlight glow, not the old cool halo). */
.highlight {
  border-color: rgba(217, 189, 115, 0.55);
  box-shadow: 0 0 0 1px rgba(176, 141, 60, 0.28) inset, 0 0 26px rgba(222, 176, 84, 0.16), 0 18px 60px rgba(0, 0, 0, 0.55);
}
/* "highlight of the day": a small paper ribbon in the menu's paper and
   serif (menu.css variables) with a gold rule under the small caps and
   notched ends. */
.highlight .chip {
  position: relative;
  display: inline-block;
  margin-bottom: 0.6rem;
  padding: 0.2rem 1.3rem 0.34rem;
  color: var(--menu-ink, #3a2a1a);
  background: linear-gradient(180deg, #fbf4e2 0%, var(--menu-paper, #f4ead3) 60%, var(--menu-paper-deep, #e8d8b4) 100%);
  border-top: 1px solid var(--menu-gold, #b08d3c);
  border-bottom: 1px solid var(--menu-gold, #b08d3c);
  font: 600 0.95rem/1.2 var(--menu-serif, Georgia, serif);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.6rem) 50%, 100% 100%, 0 100%, 0.6rem 50%);
}
.highlight .chip::before { content: "\2726\00a0"; color: var(--menu-gold, #b08d3c); font-variant: normal; font-size: 0.8em; }
.highlight .chip::after {
  content: "";
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 0.16rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--menu-gold, #b08d3c) 18%, var(--menu-gold, #b08d3c) 82%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .highlight { animation: none; }
}
:root[data-motion="reduced"] .highlight { animation: none; }
.highlight h2 { margin: 0 0 0.3rem; font-size: 1.5rem; }
.highlight .h-tagline { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.95rem; }
.h-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  background: #5b3fd4;
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn:hover { background: #6d52ea; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
}
.btn.ghost:hover { background: rgba(90, 63, 212, 0.2); }

/* --- overview depth (hover tooltip) --- */
.tooltip {
  position: fixed;
  max-width: 320px;
  background: rgba(16, 12, 40, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  z-index: 6;
}
.tooltip .t-name { display: block; font-weight: 700; margin-bottom: 0.2rem; }
.tooltip .t-tagline { display: block; color: var(--muted); font-size: 0.85rem; }
.tooltip .t-meta { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 0.3rem; text-transform: capitalize; }

/* --- detailed depth: the paper on the back of the turned card ---
   card-flip.js places it with a transform only (left/top stay 0): during the
   turn a perspective rotateX + scale that meets the 3D panel edge-on, at rest
   a whole-pixel translate so the text stays sharp. The paper, serif and gold
   double rule are the projects menu's (menu.css variables). */
.detail {
  position: fixed;
  left: 0;
  top: 0;
  width: min(540px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  overscroll-behavior: contain;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  will-change: transform;
  color: var(--menu-ink);
  font-family: var(--menu-serif);
  border-radius: 6px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.1 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    repeating-linear-gradient(97deg, rgba(120, 90, 40, 0.025) 0 2px, transparent 2px 7px),
    radial-gradient(ellipse at 50% 40%, #fbf4e2 0%, var(--menu-paper) 55%, var(--menu-paper-deep) 100%);
  box-shadow: 0 24px 60px rgba(4, 3, 14, 0.6), 0 2px 0 rgba(255, 255, 255, 0.4) inset;
  scrollbar-width: thin;
  scrollbar-color: var(--menu-gold) transparent;
  outline: none;
  z-index: 8;
}
.detail::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 3px double var(--menu-gold);
  border-radius: 3px;
  pointer-events: none;
}
.detail:focus-visible::before { border-color: var(--menu-ink-soft); }
.detail .d-body { position: relative; padding: 2rem 2.1rem 1.6rem; text-align: center; }
.detail .d-built {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-variant: small-caps;
  color: var(--menu-gold);
}
.detail .d-title { margin: 0; font-size: 2.1rem; font-weight: 600; letter-spacing: 0.04em; line-height: 1.1; }
.detail .d-tagline { margin: 0.35rem 0 0; font-style: italic; color: var(--menu-ink-soft); font-size: 1.1rem; }
.detail .d-rule {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 2rem;
  color: var(--menu-gold);
}
.detail .d-rule::before, .detail .d-rule::after { content: ""; flex: 1; border-top: 1px solid var(--menu-gold-light); }
.detail .d-summary { margin: 0 0 1rem; font-size: 1.08rem; line-height: 1.45; }
.detail .d-section {
  margin: 0.4rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--menu-gold);
}
.detail .d-features { list-style: none; margin: 0 0 1rem; padding: 0; }
.detail .d-features li { margin: 0.32rem 0; font-size: 1.02rem; line-height: 1.35; }
.detail .d-features li::before { content: "\2726"; color: var(--menu-gold); margin-right: 0.5em; font-size: 0.75em; vertical-align: 0.12em; }
.detail .d-meta { margin: 0 0 1.1rem; font-size: 0.85rem; letter-spacing: 0.08em; color: var(--menu-ink-soft); }
.detail .d-tech { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; }
.detail .d-tech li { font-size: 0.8rem; letter-spacing: 0.06em; padding: 0.12rem 0.55rem; border: 1px solid var(--menu-gold); border-radius: 999px; color: var(--menu-ink-soft); }
.detail .d-clients { list-style: none; margin: 0 0 1.1rem; padding: 0; text-align: center; font-size: 0.95rem; line-height: 1.5; color: var(--menu-ink-soft); }
.detail .d-clients li { display: inline; }
.detail .d-clients li + li::before { content: " \00b7 "; color: var(--menu-gold); }
.detail .d-clients.is-long { font-size: 0.82rem; line-height: 1.4; }
.d-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.detail .btn {
  font-family: var(--menu-serif);
  font-size: 1rem;
  background: var(--menu-ink);
  color: var(--menu-paper);
  border: 1px solid var(--menu-ink);
}
.detail .btn.ghost { background: transparent; color: var(--menu-ink); border-color: var(--menu-gold); }
.detail .btn:focus-visible { outline: 2px solid var(--menu-gold); outline-offset: 2px; }
.detail .d-close { cursor: pointer; min-height: 44px; }
/* Reduced motion: no turn (main.js flips at once); the paper fades in. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .detail:not(.hidden) { animation: detail-fade 220ms ease-out; }
}
:root[data-motion="reduced"] .detail:not(.hidden) { animation: detail-fade 220ms ease-out; }
@keyframes detail-fade { from { opacity: 0; } to { opacity: 1; } }
/* A light scrim behind the turned card; clicking it turns the card back. */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 14, 0.4);
  z-index: 7;
  cursor: pointer; /* a click outside the card closes it */
}

.badge {
  font-size: 0.7rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  text-transform: capitalize;
}
.badge-success { background: #1c352a; color: #5fd38a; }
.badge-failed, .badge-error, .badge-down { background: #3a1f20; color: #ff8f8f; }
.badge-running, .badge-pending { background: #2f2a1a; color: #f0c674; }
.badge-unknown { background: #2a2d36; color: #9aa0ad; }
.badge-default { background: #2a2d36; color: #9aa0ad; }

.hidden { display: none !important; }

/* Keyboard mirror of the 3D panels: off-screen for sight, in the tab order.
   Focus shows as the hover card + the scaled panel in the scene. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- thread navigation: prev / next + "n / 13" in the bottom thumb zone --- */
.thread-nav {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.9rem);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(420px, calc(100vw - 1.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  box-sizing: border-box;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
  z-index: 6;
}
.nav-btn {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: #5b3fd4;
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, opacity 0.15s;
}
.nav-btn:hover:not(:disabled) { background: #6c50e6; }
.nav-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.nav-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.nav-count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.92rem;
}

.webgl-fail {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  font-size: 1.05rem;
  z-index: 20;
}

@media (max-width: 640px) {
  .hint { display: none; }
  .highlight { bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem); width: calc(100vw - 2rem); padding: 0.9rem 1rem; }
  .highlight h2 { font-size: 1.15rem; }
  .highlight .chip { font-size: 0.86rem; padding: 0.16rem 1.1rem 0.3rem; margin-bottom: 0.45rem; }
  .detail { width: calc(100vw - 1.2rem); }
  .detail .d-body { padding: 1.6rem 1.3rem 1.3rem; }
  .detail .d-title { font-size: 1.7rem; }
  .shift-top, .shift-bottom { height: 14vh; }
}

/* --- settings modal (Q toggles, Escape closes; no button opens it) ---
   A side sheet on desktop so the scene stays visible while tuning; full
   width on a phone. Scrolls inside itself, never past the viewport. */
.settings {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  width: min(340px, calc(100vw - 1.6rem));
  max-height: calc(100vh - 1.6rem);
  max-height: calc(100dvh - 1.6rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #171232f2;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem 0;
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  color: var(--fg);
  font-size: 0.85rem;
  z-index: 9;
  outline: none;
}
.settings .s-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.settings h2 { margin: 0; font-size: 1.1rem; }
.settings .s-hint { color: var(--muted); font-size: 0.72rem; }
.settings .s-group { border: none; border-top: 1px solid var(--line); margin: 0.7rem 0 0; padding: 0.4rem 0 0; min-width: 0; }
.settings legend { color: var(--accent); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0.3rem 0 0; }
.settings .s-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 0.3rem 0; }
.settings .s-row span { flex: 1 1 auto; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.settings input[type="number"] {
  flex: 0 0 7.2rem;
  width: 7.2rem;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 16px; /* no zoom-on-focus on iOS */
}
.settings input.changed { border-color: var(--accent); }
.settings input.governed { border-style: dashed; opacity: 0.75; }
.settings .s-status { margin: 0.2rem 0 0.4rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.settings input.invalid { outline: 2px solid #ffb02e; outline-offset: 1px; }
.settings .s-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
  padding: 0.7rem 0 0.9rem;
  background: #171232;
}
.settings .s-copied { color: #7dffb0; font-size: 0.8rem; }
.settings .s-fallback {
  display: block;
  width: 100%;
  margin: 0 0 0.9rem;
  background: rgba(0, 0, 0, 0.35);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 0.75rem/1.4 ui-monospace, monospace;
  resize: vertical;
}
@media (max-width: 520px) {
  .settings { top: 0.5rem; left: 0.5rem; right: 0.5rem; width: auto; max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); padding: 0.9rem 0.9rem 0; }
  .settings input[type="number"] { flex-basis: 6.2rem; width: 6.2rem; }
}
.detail .btn:hover { background: #241a10; }
.detail .btn.ghost:hover { background: rgba(176, 141, 60, 0.14); }

/* --- views: home placeholder and the home control (home.js) ---
   The 3D home of the later plan steps replaces .home; body.view-home hides
   the universe scene and its overlay. */
.view-home #scene-mount,
.view-home #ui,
.view-home .settings { display: none; }
.home {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.6rem;
  padding: 2rem 1.2rem;
  background: radial-gradient(ellipse at 50% 35%, #15112e 0%, var(--bg) 60%, #05040c 100%);
  z-index: 4;
  overflow-y: auto;
}
.home[hidden] { display: none; }
.home-title {
  margin: 0;
  font-family: var(--menu-serif, Georgia, serif);
  font-weight: 600;
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  letter-spacing: 0.22em;
  color: #f2f4f8; /* white letters next to the white-silver logo (R2) */
  text-shadow: 0 2px 28px rgba(205, 215, 235, 0.3);
}
.home-universes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.4rem;
}
.home-universe {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  width: 13.5rem;
  min-height: 7.5rem;
  padding: 1.4rem 1rem;
  border: 1px solid var(--u-accent, var(--line));
  border-radius: 6px;
  background: linear-gradient(160deg, var(--u-colour, #333) 0%, #0b0918 140%);
  color: #f6efe0;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
/* Hover only where there is a real hover (a tap leaves no raised button). */
@media (hover: hover) {
  .home-universe:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px -10px var(--u-accent, #fff);
  }
}
.home-universe:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px -10px var(--u-accent, #fff);
}
/* Keyboard focus: one gold ring on every home overlay button. */
.home-universe:focus { outline: none; }
.home-universe:focus-visible,
.home-skip:focus-visible,
.home-btn:focus-visible,
.si-close:focus-visible { outline: 2px solid #e2c27a; outline-offset: 3px; box-shadow: 0 0 0 5px rgba(226, 194, 122, 0.25); }
.hu-title {
  font-family: var(--menu-serif, Georgia, serif);
  font-size: 1.6rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
}
/* Round 4 U4: the back button is a ribbon bookmark sticking out from the
   left edge of the screen, in the look of the "highlight of the day" chip:
   paper fabric, gold rules top and bottom, a gold hairline under the small
   caps and a notched end. The ribbon is drawn by ::before (clip-path notch)
   so the button's own focus ring is not clipped; hover and focus slide it
   out a little. Markup, keyboard and screen-reader name are unchanged. */
.home-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.9rem);
  left: 0;
  z-index: 9;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 1.7rem 0.12rem calc(env(safe-area-inset-left, 0px) + 1.1rem);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--menu-ink, #3a2a1a);
  font: 600 0.95rem/1.2 var(--menu-serif, Georgia, serif);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  cursor: pointer;
  transform: translateX(-0.45rem);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.2, 1);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}
.home-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, #fbf4e2 0%, var(--menu-paper, #f4ead3) 60%, var(--menu-paper-deep, #e8d8b4) 100%);
  border-top: 1px solid var(--menu-gold, #b08d3c);
  border-bottom: 1px solid var(--menu-gold, #b08d3c);
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.75rem) 50%, 100% 100%, 0 100%);
}
.home-btn::after {
  content: "";
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 0.9rem);
  right: 1.5rem;
  bottom: 0.3rem;
  height: 1px;
  background: linear-gradient(90deg, var(--menu-gold, #b08d3c) 0%, var(--menu-gold, #b08d3c) 82%, transparent);
  pointer-events: none;
}
.home-btn[hidden] { display: none; }
.home-btn:hover, .home-btn:focus-visible { transform: translateX(0); }
.hb-arrow { color: var(--menu-gold, #b08d3c); font-variant: normal; }
.hb-brand { letter-spacing: 0.14em; color: var(--menu-ink, #3a2a1a); }
.hb-sep { color: var(--menu-gold, #b08d3c); }
.hb-universe { color: var(--menu-ink-soft, #6b5338); }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .home-btn { transition: none; }
}
:root[data-motion="reduced"] .home-btn { transition: none; }
.view-universe .titlebar .brand { visibility: hidden; }
/* The 3D home (home-stage.js): canvas behind, the wordmark under the logo
   and the universe buttons laid over the projected book slots (home.js sets
   top/left/width and --slot-h); each button is its book slot, with no text
   under it (round 4 step H1 dropped the description, round 5 step H4 the
   title; both are in the aria-label). */
.home-stage { display: none; }
.home--stage { background: #000; overflow: hidden; padding: 0; }
.home--stage .home-stage { display: block; position: absolute; inset: 0; z-index: 0; }
.home--stage .home-stage canvas { display: block; width: 100%; height: 100%; }
.home--stage .home-title {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  text-align: center;
  font-size: clamp(1.05rem, 2.4vw, 1.9rem);
  font-weight: 500;
  letter-spacing: 0.55em;
  padding-left: 0.55em; /* the trailing letter space, so the word centres */
  color: #f2f4f8;
  text-shadow: 0 0 18px rgba(214, 224, 245, 0.35);
  pointer-events: none;
}
.home--stage .home-universes { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.home--stage .home-universe {
  position: absolute;
  justify-content: flex-start;
  width: auto;
  min-height: 0;
  padding: var(--slot-h, 120px) 0 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  pointer-events: auto;
}
.home--stage .home-universe:hover { transform: none; box-shadow: none; }
.home--stage .home-universe:focus-visible { transform: none; box-shadow: 0 0 0 5px rgba(226, 194, 122, 0.25); }
/* Round 5 H4: no title under the 3D books; the button is the book slot and
   keeps its accessible name (aria-label). The flat home's cards keep it. */
.home--stage .hu-title { display: none; }
/* The home intro (home-intro.js): starts on black; the wordmark letters are
   inline-block spans posed per frame (opacity, rise, blur, glint); the
   buttons' opacity follows the labels. Plain CSS again when it ends. */
.home--intro { background: #000; }
.home--intro .home-universe { transition: none; }
.home--intro .hi-letter {
  display: inline-block;
  white-space: pre;
  will-change: opacity, transform, filter;
  /* the faint silver glint sweep */
  text-shadow: 0 0 calc(18px + 16px * var(--glint, 0)) rgba(228, 236, 255, calc(0.35 + 0.4 * var(--glint, 0)));
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .home-universe { transition: none; }
  :root:not([data-motion]) .home-universe:hover, :root:not([data-motion]) .home-universe:focus-visible { transform: none; }
}
:root[data-motion="reduced"] .home-universe { transition: none; }
:root[data-motion="reduced"] .home-universe:hover, :root[data-motion="reduced"] .home-universe:focus-visible { transform: none; }

/* --- the book-open transition (book-transition.js) ---
   A short light-gold flash over everything (the gold-foil dissolve after it
   is drawn in WebGL, foil-layer.js); the home's wordmark and labels fade
   while the book opens. */
.transition-fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.transition-fx[hidden] { display: none; }
.tr-flash {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(circle at 50% 55%, #fffbf0 0%, #fcefc6 28%, #f2d68e 62%, #d9b462 100%);
}
.tr-foil { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.home.home--transition .home-title,
.home.home--transition .home-universes { opacity: 0; transition: opacity 0.3s ease; }

/* Skip link (home.js): first in the Tab order, hidden until focused. */
.home-skip {
  position: absolute; top: 0.6rem; left: 50%; z-index: 5;
  transform: translate(-50%, -200%);
  padding: 0.5rem 0.9rem; border: 1px solid rgba(217, 189, 115, 0.6); border-radius: 18px;
  background: rgba(13, 11, 36, 0.92); color: #f1e3bb; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.home-skip:focus, .home-skip:focus-visible { transform: translate(-50%, 0); }
.home-skip[hidden] { display: none; }

/* Static text index (index.html, scripts/site-index.mjs): shown without JS
   (noscript style), without WebGPU/WebGL (body.no-webgl) or from the skip
   link (body.show-index, an overlay over the home). */
.site-index { display: none; max-width: 46rem; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; color: #efe6d2; line-height: 1.5; }
body.no-webgl .site-index { display: block; position: relative; z-index: 2; }
body.show-index .site-index {
  display: block; position: fixed; inset: 0; z-index: 60; max-width: none; overflow-y: auto;
  background: rgba(5, 4, 12, 0.96); padding: 1.5rem max(1.2rem, calc(50% - 23rem)) 3rem;
}
.site-index h2 { font-family: var(--menu-serif, Georgia, serif); color: #e2c27a; font-weight: 500; font-size: 1.4rem; margin: 0 2.5rem 0.4rem 0; }
.site-index h3 { font-family: var(--menu-serif, Georgia, serif); font-size: 1.15rem; margin: 1.4rem 0 0.1rem; }
.site-index h3 a { color: #e2c27a; }
.site-index p { margin: 0 0 0.4rem; opacity: 0.85; }
.site-index ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.site-index a { color: #f1e3bb; }
.site-index a:focus-visible { outline: 2px solid #e2c27a; outline-offset: 2px; }
.si-close {
  position: absolute; top: 1rem; right: 1rem; width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid rgba(217, 189, 115, 0.5); background: transparent; color: #f1e3bb; font-size: 1.4rem; cursor: pointer;
}
body.no-webgl .si-close { display: none; }
body.show-index .si-close { position: fixed; }

/* Draft entries (draft.js): "Details to follow" in a quiet italic. */
.is-draft { font-style: italic; opacity: 0.65; }

/* ?profile (profiler-ui.js): countdown badge and the report panel. */
.prof-badge {
  position: fixed; right: 0.75rem; bottom: 0.75rem; z-index: 60;
  padding: 0.3rem 0.6rem; border-radius: 0.4rem;
  background: rgba(20, 10, 30, 0.85); color: #f4d98a;
  font: 600 0.8rem/1.2 ui-monospace, monospace; pointer-events: none;
}
.prof-panel {
  position: fixed; inset: 5vh 5vw; z-index: 61;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem; border-radius: 0.6rem;
  background: rgba(14, 10, 24, 0.96); color: #eee; border: 1px solid #b08d3c;
}
.prof-panel h2 { margin: 0; font-size: 1.1rem; }
.prof-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.prof-bar button { min-height: 44px; padding: 0 0.9rem; cursor: pointer; }
.prof-status { font-size: 0.85rem; color: #f4d98a; }
.prof-text {
  flex: 1; min-height: 0; width: 100%; resize: none;
  font: 0.75rem/1.35 ui-monospace, monospace; color: #ddd; background: #0b0814; border: 1px solid #333;
}

/* First-load loader (loader.js): black overlay, the logo drawn as white
   lines, a thin progress ring. It never blocks: without scripting it is
   hidden, and it fades out on its own after 25 s (45 s once loader.js has
   taken over); loader.js fades it out (.loader--done) and removes it. */
.loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: max(18px, 3vmin) max(18px, 3vmin) 0 0;
  box-sizing: border-box;
  background: #000;
  opacity: 1;
  transition: opacity 600ms ease;
  animation: loader-giveup 600ms ease 25s forwards;
}
.loader.loader--js { animation: loader-giveup 600ms ease 45s forwards; }
.loader.loader--done { opacity: 0; pointer-events: none; }
@keyframes loader-giveup { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@media (scripting: none) { .loader { display: none; } }
body.no-webgl .loader { display: none; }
/* loader size: ~20 % of the smaller viewport side, top-right (operator: it distracted too much centred). */
.loader-svg { width: clamp(72px, 20vmin, 180px); height: auto; overflow: visible; }
.loader-track { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 10; }
.loader-ring {
  fill: none; stroke: #fff; stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.35s ease-out;
}
.loader-line {
  fill: none; stroke: #fff; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: loader-draw 2.6s ease-in-out infinite alternate;
}
.loader-ring-inner { animation-delay: 0.25s; }
.loader-head { animation-delay: 0.5s; }
.loader-tail { animation-delay: 0.75s; }
@keyframes loader-draw {
  0% { stroke-dashoffset: 1; fill: rgba(255, 255, 255, 0); }
  70% { stroke-dashoffset: 0; fill: rgba(255, 255, 255, 0); }
  100% { stroke-dashoffset: 0; fill: rgba(255, 255, 255, 0); }
}
.loader-head, .loader-tail { animation-name: loader-draw-fill; }
@keyframes loader-draw-fill {
  0% { stroke-dashoffset: 1; fill: rgba(255, 255, 255, 0); }
  70% { stroke-dashoffset: 0; fill: rgba(255, 255, 255, 0); }
  100% { stroke-dashoffset: 0; fill: rgba(255, 255, 255, 1); }
}
/* loader: reduced motion */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion]) .loader-line { animation: none; stroke-dashoffset: 0; }
  :root:not([data-motion]) .loader-head, :root:not([data-motion]) .loader-tail { fill: #fff; }
  :root:not([data-motion]) .loader-ring { transition: none; }
}
:root[data-motion="reduced"] .loader-line { animation: none; stroke-dashoffset: 0; }
:root[data-motion="reduced"] .loader-head, :root[data-motion="reduced"] .loader-tail { fill: #fff; }
:root[data-motion="reduced"] .loader-ring { transition: none; }
