/* ══════════════════════════════════════════════════════════════
   THE RICK HERNIA OMNIVERSE · SHARED SHELL
   Tokens, reset, nav, star field, page furniture.
   Page-specific styling lives inline in each document.
   ══════════════════════════════════════════════════════════════ */

/* ── TOKENS ── */
:root {
  --bg:         #111113;
  --bg-nav:     #0c0c0e;
  --fg:         #ffffff;
  --fg-muted:   #888899;
  --accent:     #ffffff;
  --nav-border: #222228;
  --star-col:   255,255,255;
  --card-bg:    #18181b;
  --card-bg-2:  #1e1e22;
  --card-border:#2a2a30;
  --well:       #0a0a0c;
  --overlay:    rgba(6,6,8,0.66);
  --shadow:     0 24px 80px rgba(0,0,0,0.55);
  --transition: 0.35s ease;
}
[data-theme="light"] {
  --bg:         #f0f0f2;
  --bg-nav:     #e4e4e8;
  --fg:         #0a0a0c;
  --fg-muted:   #55556a;
  --accent:     #0a0a0c;
  --nav-border: #ccccda;
  --star-col:   30,30,50;
  --card-bg:    #e8e8ec;
  --card-bg-2:  #dedee4;
  --card-border:#d0d0d8;
  --well:       #d8d8de;
  --overlay:    rgba(228,228,234,0.7);
  --shadow:     0 24px 80px rgba(20,20,40,0.22);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
a { text-decoration: none; color: inherit; }
img { border: 0; outline: 0; }
button, input { font: inherit; color: inherit; }
/* author display rules must never beat the hidden attribute */
[hidden] { display: none !important; }

/* ── BODY ── */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}
body.is-locked { overflow: hidden; }

::selection { background: var(--fg); color: var(--bg); }

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}

.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;
}

/* ── STAR CANVAS ── */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── NAV ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--nav-border);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  transition: background var(--transition), border-color var(--transition);
}

/* The left spacer and the right cluster each take an equal share of the
   leftover space, so .nav-links is always dead-centre in the bar no matter
   what sits on either side of it. */
.nav-brand {
  flex: 1 1 0;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: color var(--transition);
}

.nav-links {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links li a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-links li a:hover {
  color: var(--fg);
  border-color: var(--nav-border);
  background: var(--bg);
}

.nav-links li a.is-active {
  color: var(--fg);
  border-color: var(--nav-border);
  background: var(--bg);
}

.nav-links li a svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

/* ── THEME TOGGLE ── */
.nav-right {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
}

#theme-btn {
  background: none;
  border: 1px solid var(--nav-border);
  color: var(--fg-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
#theme-btn:hover {
  color: var(--fg);
  background: var(--bg);
  border-color: var(--fg-muted);
}
#theme-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

/* ══════════════════════════════════════════════════════════════
   SHARED PAGE FURNITURE  (used by sub-pages)
   ══════════════════════════════════════════════════════════════ */

.page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 120px 32px 0;
}

.page-head { text-align: center; }

.page-eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 22px;
  transition: color var(--transition);
}
.page-eyebrow a { transition: color 0.2s; }
.page-eyebrow a:hover { color: var(--fg); }
.page-eyebrow .sep { opacity: 0.4; }

.page-title {
  font-family: 'Impact', 'Arial Black', 'Haettenschweiler', sans-serif;
  font-weight: 900;
  font-size: clamp(40px, 9vw, 104px);
  letter-spacing: 0.04em;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--fg);
  transition: color var(--transition);
  user-select: none;
}

.page-rule {
  width: 48px;
  height: 2px;
  background: var(--fg-muted);
  margin: 30px auto 0;
  transition: background var(--transition);
}

.page-sub {
  max-width: 560px;
  margin: 26px auto 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--fg-muted);
  transition: color var(--transition);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 22px;
  background: none;
  border: 1px solid var(--card-border);
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s, opacity 0.2s;
}
.btn svg {
  width: 14px; height: 14px;
  flex-shrink: 0;
  stroke: currentColor; fill: none;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.btn:hover:not(:disabled) {
  color: var(--fg);
  border-color: var(--fg-muted);
  background: var(--card-bg);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.34; cursor: not-allowed; }

.btn-primary {
  border-color: var(--fg-muted);
  color: var(--fg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ── NOTICE ──
   Inline explanation when a toy cannot do what was asked. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 40px;
  padding: 18px 20px;
  border: 1px dashed var(--card-border);
  background: var(--card-bg);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--fg-muted);
}
.notice svg {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  margin-top: 2px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: square;
}
.notice b { color: var(--fg); font-weight: 700; }
.notice-body { flex: 1 1 auto; min-width: 0; }
.notice .btn { padding: 9px 16px; }

/* ── INDEX BAR ──
   Progress strip a toy shows while it builds its data index.
   Used by D36R335 (link graph) and Y3V3L1N (character roster). */
.index-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 480px;
  margin: 44px auto 0;
  padding: 9px 14px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: border-color 0.3s ease, background 0.3s ease, opacity 0.5s ease;
}
.index-bar.is-ready { opacity: 0.55; }
.index-bar.is-ready:hover { opacity: 1; }
.index-bar.is-error { border-color: var(--fg-muted); }

.index-track {
  flex: 1 1 auto;
  height: 2px;
  background: var(--card-border);
  overflow: hidden;
}
.index-fill {
  height: 100%;
  width: 0%;
  background: var(--fg-muted);
  transition: width 0.35s ease, background 0.3s ease;
}
.index-bar.is-ready .index-fill { background: var(--fg); }

.index-text {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.index-redo {
  flex: 0 0 auto;
  background: none;
  border: 0;
  padding: 0 0 0 2px;
  color: inherit;
  cursor: pointer;
  display: flex;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.4s ease;
}
.index-redo:hover { opacity: 1; transform: rotate(90deg); }
.index-redo svg {
  width: 11px; height: 11px;
  stroke: currentColor; fill: none;
  stroke-width: 2.2; stroke-linecap: square;
}

/* ── STAT GRID ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  border: 1px solid var(--card-border);
}
.stat {
  padding: 20px 18px;
  border-left: 1px solid var(--card-border);
  background: var(--card-bg);
}
.stat:first-child { border-left: 0; }
.stat-num {
  display: block;
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.stat-lab {
  display: block;
  margin-top: 9px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  z-index: 400;
  padding: 12px 20px;
  background: var(--fg);
  color: var(--bg);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── FOOTER ── */
.site-footer {
  position: relative;
  z-index: 1;
  margin-top: 120px;
  padding: 30px 32px 40px;
  border-top: 1px solid var(--nav-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: color var(--transition), border-color var(--transition);
}
.site-footer a { transition: color 0.2s; }
.site-footer a:hover { color: var(--fg); }
.site-footer .sep { opacity: 0.35; }

/* ── REVEAL ── */
[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}
[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .page { padding: 104px 20px 0; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat:nth-child(3), .stat:nth-child(4) { border-top: 1px solid var(--card-border); }
  .stat:nth-child(3) { border-left: 0; }
}

@media (max-width: 520px) {
  nav { padding: 0 16px; }
  .nav-links li a { padding: 6px 10px; letter-spacing: 0.08em; }
  .page { padding: 96px 16px 0; }
  .site-footer { padding: 26px 16px 34px; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}
