﻿/* =========================================================
   THEMES — 5 cinematic palettes (default: midnight)
   ========================================================= */
:root {
  /* Fonts and layout (shared across themes) */
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-prose: 'Crimson Pro', 'Crimson Text', Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-width: 272px;

  /* Default: MIDNIGHT BLUE */
  --color-bg: #01050f;
  --color-surface: #050d1e;
  --color-sidebar: #03091a;
  --color-border: #0e1e3a;
  --color-text: #b8cce8;
  --color-text-muted: #3a5070;
  --color-text-strong: #d0e4ff;
  --color-title: #e8f2ff;
  --color-quote: #7aacde;
  --color-accent: #1e90ff;
  --color-highlight: #60b4ff;
  --color-accent-dim: rgba(30, 144, 255, 0.08);
  --color-bg-glow: rgba(10, 40, 100, 0.14);
  --color-header-glow: rgba(10, 60, 140, 0.12);
  --frame-bg: linear-gradient(135deg, #8a6a2b 0%, #d4af5a 12%, #f4e08a 28%, #b88a3a 45%, #6e5020 58%, #d4af5a 72%, #f0d878 88%, #8a6a2b 100%);
  --frame-highlight: rgba(255, 220, 140, 0.6);
  --frame-shadow: rgba(60, 40, 10, 0.7);
  --frame-glow: rgba(212, 175, 90, 0.15);
  --frame-accent: #f0d878;
  --frame-accent-border: rgba(212, 175, 90, 0.4);
}

[data-theme="crimson"] {
  --color-bg: #0a0306;
  --color-surface: #1a0810;
  --color-sidebar: #08020a;
  --color-border: #2a0e1a;
  --color-text: #e8c8d0;
  --color-text-muted: #6a3045;
  --color-text-strong: #f8d8e0;
  --color-title: #fde8ee;
  --color-quote: #c88498;
  --color-accent: #c8324a;
  --color-highlight: #e85d75;
  --color-accent-dim: rgba(200, 50, 74, 0.10);
  --color-bg-glow: rgba(100, 20, 40, 0.16);
  --color-header-glow: rgba(140, 30, 60, 0.14);
  --frame-bg: linear-gradient(135deg, #8a6a2b 0%, #d4af5a 12%, #f4e08a 28%, #b88a3a 45%, #6e5020 58%, #d4af5a 72%, #f0d878 88%, #8a6a2b 100%);
  --frame-highlight: rgba(255, 220, 140, 0.6);
  --frame-shadow: rgba(60, 40, 10, 0.7);
  --frame-glow: rgba(212, 175, 90, 0.15);
  --frame-accent: #f0d878;
  --frame-accent-border: rgba(212, 175, 90, 0.4);
}

[data-theme="forest"] {
  --color-bg: #04100a;
  --color-surface: #0a1f15;
  --color-sidebar: #03100a;
  --color-border: #143025;
  --color-text: #c0e0d0;
  --color-text-muted: #3a604a;
  --color-text-strong: #d8f0e0;
  --color-title: #eaf8ee;
  --color-quote: #82b89a;
  --color-accent: #4ac98a;
  --color-highlight: #7eddb0;
  --color-accent-dim: rgba(74, 201, 138, 0.08);
  --color-bg-glow: rgba(20, 80, 50, 0.14);
  --color-header-glow: rgba(30, 100, 65, 0.12);
  --frame-bg: linear-gradient(135deg, #6b3a18 0%, #b87838 12%, #dba068 28%, #9a6028 45%, #4f2a10 58%, #b87838 72%, #d89060 88%, #6b3a18 100%);
  --frame-highlight: rgba(240, 180, 130, 0.6);
  --frame-shadow: rgba(40, 20, 8, 0.7);
  --frame-glow: rgba(184, 120, 56, 0.18);
  --frame-accent: #dba068;
  --frame-accent-border: rgba(184, 120, 56, 0.45);
}

[data-theme="sepia"] {
  --color-bg: #f1e7d0;
  --color-surface: #e6dabe;
  --color-sidebar: #d9caa8;
  --color-border: #b8a578;
  --color-text: #3d2e1a;
  --color-text-muted: #8a7350;
  --color-text-strong: #1f1408;
  --color-title: #2a1a0a;
  --color-quote: #6e5530;
  --color-accent: #8b4513;
  --color-highlight: #6b3508;
  --color-accent-dim: rgba(139, 69, 19, 0.10);
  --color-bg-glow: rgba(180, 140, 80, 0.10);
  --color-header-glow: rgba(160, 120, 60, 0.10);
  --frame-bg: linear-gradient(135deg, #5a3a14 0%, #8a6028 12%, #b88a3a 28%, #6e4818 45%, #3a2208 58%, #8a6028 72%, #a07830 88%, #5a3a14 100%);
  --frame-highlight: rgba(220, 180, 120, 0.55);
  --frame-shadow: rgba(40, 22, 8, 0.7);
  --frame-glow: rgba(140, 95, 40, 0.20);
  --frame-accent: #b88a3a;
  --frame-accent-border: rgba(120, 80, 30, 0.55);
}

[data-theme="obsidian"] {
  --color-bg: #0a0a0a;
  --color-surface: #181818;
  --color-sidebar: #0d0d0d;
  --color-border: #2a2a2a;
  --color-text: #c8c8c8;
  --color-text-muted: #606060;
  --color-text-strong: #f0f0f0;
  --color-title: #ffffff;
  --color-quote: #909090;
  --color-accent: #e0e0e0;
  --color-highlight: #ffffff;
  --color-accent-dim: rgba(224, 224, 224, 0.06);
  --color-bg-glow: rgba(100, 100, 100, 0.08);
  --color-header-glow: rgba(150, 150, 150, 0.07);
  --frame-bg: linear-gradient(135deg, #5a5a5a 0%, #9a9a9a 12%, #d8d8d8 28%, #888888 45%, #3a3a3a 58%, #9a9a9a 72%, #c0c0c0 88%, #5a5a5a 100%);
  --frame-highlight: rgba(240, 240, 240, 0.65);
  --frame-shadow: rgba(20, 20, 20, 0.75);
  --frame-glow: rgba(200, 200, 200, 0.12);
  --frame-accent: #d8d8d8;
  --frame-accent-border: rgba(200, 200, 200, 0.4);
}

[data-theme="ivory"] {
  --color-bg: #fafaf7;
  --color-surface: #f1efe8;
  --color-sidebar: #ecebe3;
  --color-border: #d8d5cb;
  --color-text: #2a2620;
  --color-text-muted: #8a8478;
  --color-text-strong: #0e0c08;
  --color-title: #0a0908;
  --color-quote: #5a5448;
  --color-accent: #1a1a1a;
  --color-highlight: #000000;
  --color-accent-dim: rgba(20, 20, 20, 0.06);
  --color-bg-glow: rgba(180, 170, 150, 0.10);
  --color-header-glow: rgba(150, 140, 120, 0.08);
  --frame-bg: linear-gradient(135deg, #4a4438 0%, #7a6f5a 12%, #a89b7c 28%, #6e5f44 45%, #2e2820 58%, #7a6f5a 72%, #948660 88%, #4a4438 100%);
  --frame-highlight: rgba(220, 200, 160, 0.55);
  --frame-shadow: rgba(40, 30, 15, 0.65);
  --frame-glow: rgba(120, 100, 60, 0.18);
  --frame-accent: #4a4438;
  --frame-accent-border: rgba(80, 70, 50, 0.45);
}

[data-theme="noir"] {
  --color-bg: #000000;
  --color-surface: #0c0606;
  --color-sidebar: #050202;
  --color-border: #1f0e10;
  --color-text: #d8c8c8;
  --color-text-muted: #604848;
  --color-text-strong: #f4eaea;
  --color-title: #ffffff;
  --color-quote: #a07878;
  --color-accent: #d8324a;
  --color-highlight: #ff5872;
  --color-accent-dim: rgba(216, 50, 74, 0.10);
  --color-bg-glow: rgba(80, 10, 20, 0.12);
  --color-header-glow: rgba(120, 20, 35, 0.12);
  --frame-bg: linear-gradient(135deg, #2a2a2a 0%, #6a6a6a 12%, #b0b0b0 28%, #5a5a5a 45%, #1a1a1a 58%, #6a6a6a 72%, #909090 88%, #2a2a2a 100%);
  --frame-highlight: rgba(220, 220, 220, 0.55);
  --frame-shadow: rgba(0, 0, 0, 0.85);
  --frame-glow: rgba(216, 50, 74, 0.18);
  --frame-accent: #c8c8c8;
  --frame-accent-border: rgba(200, 200, 200, 0.35);
}

/* =========================================================
   RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background-color: var(--color-bg);
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0%, var(--color-bg-glow) 0%, transparent 70%);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

a { color: inherit; }
img, video { max-width: 100%; display: block; }

/* =========================================================
   HOMEPAGE
   ========================================================= */
.home-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Stage that holds the background video, story grid, and footer.
   Header sits ABOVE the stage and is untouched. */
.home-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg);
}

/* Background video reel — fills only the .home-stage area, behind content */
.bg-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--color-bg);
  pointer-events: none;
}

.bg-video__el {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
  will-change: transform, opacity;
}

.bg-video__el.is-ready {
  opacity: 1;
}

/* Ken-Burns drifts — slow, subtle motion to keep stills feeling alive.
   One variant is added by JS each time a new clip loads. */
.bg-video__el.kb-in       { animation: bgKbIn       28s ease-in-out forwards; }
.bg-video__el.kb-out      { animation: bgKbOut      28s ease-in-out forwards; }
.bg-video__el.kb-pan-left { animation: bgKbPanLeft  28s ease-in-out forwards; }
.bg-video__el.kb-pan-right{ animation: bgKbPanRight 28s ease-in-out forwards; }
.bg-video__el.kb-up       { animation: bgKbUp       28s ease-in-out forwards; }
.bg-video__el.kb-down     { animation: bgKbDown     28s ease-in-out forwards; }

@keyframes bgKbIn        { from { transform: scale(1.04) translate(0,0); }     to { transform: scale(1.16) translate(-1.5%, -1%); } }
@keyframes bgKbOut       { from { transform: scale(1.16) translate(-1%, 1%); } to { transform: scale(1.04) translate(0,0); } }
@keyframes bgKbPanLeft   { from { transform: scale(1.10) translate(2.5%, 0); } to { transform: scale(1.10) translate(-2.5%, -0.5%); } }
@keyframes bgKbPanRight  { from { transform: scale(1.10) translate(-2.5%, 0); } to { transform: scale(1.10) translate(2.5%, 0.5%); } }
@keyframes bgKbUp        { from { transform: scale(1.10) translate(0, 2%); }   to { transform: scale(1.13) translate(-0.5%, -2%); } }
@keyframes bgKbDown      { from { transform: scale(1.10) translate(0, -2%); }  to { transform: scale(1.13) translate(0.5%, 2%); } }

/* Dark veil + theme-tinted vignette over the video so text stays readable. */
.bg-video__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 0%, var(--color-bg) 100%),
    linear-gradient(to bottom, var(--color-bg) 0%, rgba(0,0,0,0.55) 25%, rgba(0,0,0,0.55) 75%, var(--color-bg) 100%);
  opacity: 0.92;
}

/* Interlude title card shown between story groups */
.bg-video__interlude {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 2rem;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.4) 0%, var(--color-bg) 80%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease;
}

.bg-video__interlude.is-visible {
  opacity: 1;
}

.bg-video__interlude-kicker {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--frame-accent);
  margin-bottom: 1.25rem;
  opacity: 0.85;
}

.bg-video__interlude-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700;
  color: var(--color-title);
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0 0 1.5rem;
  text-shadow: 0 4px 32px rgba(0,0,0,0.85), 0 0 80px var(--color-accent-dim);
}

.ornament--small {
  width: min(180px, 50%);
}

/* Lift home-stage content above the bg video */
.home-stage > .home-main,
.home-stage > .site-footer {
  position: relative;
  z-index: 1;
}

.home-stage > .site-footer {
  background: transparent;
  border-top-color: var(--color-border);
}

/* Header banner — gilded strip only along the bottom edge */
.site-header {
  position: relative;
  width: 100%;
  height: 300px;
  padding-bottom: 3px;
  background:
    url('/assets/images/header-banner.png') center bottom / cover no-repeat content-box,
    var(--frame-bg);
  background-color: var(--color-surface);
  background-clip: content-box, padding-box;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    0 4px 18px var(--frame-glow);
}

/* Cinematic letterbox overlays — inset by frame padding so they sit on the image only */
.site-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 3px;
  background:
    linear-gradient(to bottom, var(--color-bg) 0%, transparent 30%),
    linear-gradient(to top, var(--color-bg) 0%, rgba(0,0,0,0.4) 35%, transparent 65%),
    linear-gradient(to right, var(--color-bg) 0%, transparent 40%, transparent 60%, var(--color-bg) 100%);
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
}

/* Subtle theme-tinted shimmer */
.site-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 3px;
  background: radial-gradient(ellipse 60% 80% at 30% 50%, var(--color-header-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

/* Header inner content (author name + tagline) — anchored to bottom-right */
.site-header__inner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  text-align: right;
  padding: 2rem 2.5rem;
  pointer-events: none;
}

.site-header__author {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.7vw, 2.25rem);
  font-weight: 700;
  color: var(--color-title);
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0 0 0.4rem;
  text-shadow: 0 4px 32px rgba(0,0,0,0.85), 0 0 60px var(--color-accent-dim);
}

.site-header__tagline {
  font-family: var(--font-prose);
  font-size: clamp(0.7rem, 0.95vw, 0.85rem);
  font-style: italic;
  color: var(--color-text);
  letter-spacing: 0.03em;
  text-shadow: 0 2px 16px rgba(0,0,0,0.9);
  opacity: 0.9;
  margin: 0;
}

/* Main content area */
.home-main {
  flex: 1;
  padding: 5rem 2.5rem 4rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Stories section header */
.stories-section__header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 4rem;
}

.stories-section__kicker {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--frame-accent);
  margin-bottom: 0.75rem;
  opacity: 0.85;
}

.stories-section__heading {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--color-title);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 1.5rem;
}

.stories-section__intro {
  font-family: var(--font-prose);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--color-text);
  margin-top: 1.5rem;
  opacity: 0.85;
}

/* Ornamental divider */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 0 auto;
  width: min(280px, 60%);
}

.ornament__line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--frame-accent-border), transparent);
}

.ornament__diamond {
  width: 8px;
  height: 8px;
  background: var(--frame-accent);
  transform: rotate(45deg);
  box-shadow: 0 0 12px var(--frame-glow);
}

/* Story grid */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 3rem;
}

.story-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  padding: 3px;
  background: var(--frame-bg);
  background-clip: padding-box;
  border: none;
  transform-origin: center center;
  box-shadow:
    inset 0 0 0 1px var(--frame-shadow),
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 12px 40px rgba(0,0,0,0.6),
    0 0 24px var(--frame-glow);
  transition:
    transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.5s ease,
    z-index 0s 0.5s;
  will-change: transform;
}

.story-card:hover {
  transform: scale(1.5);
  z-index: 5;
  box-shadow:
    inset 0 0 0 1px var(--frame-shadow),
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 40px 100px rgba(0,0,0,0.9),
    0 0 70px var(--frame-glow),
    0 0 90px var(--color-accent-dim);
  transition:
    transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.5s ease,
    z-index 0s;
}

.story-card__media {
  position: relative;
  aspect-ratio: 10 / 9;
  overflow: hidden;
}

.story-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
  filter: brightness(0.85) saturate(0.9);
}

.story-card:hover .story-card__media img {
  transform: scale(1.07);
  filter: brightness(1) saturate(1.05);
}

/* Read-time badge */
.story-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--frame-accent-border);
  border-radius: 999px;
  color: var(--frame-accent);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Card body (below image) */
.story-card__body {
  background: var(--color-bg);
  padding: 1.25rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.story-card__title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-title);
  line-height: 1.2;
  margin: 0;
  transition: color 0.3s ease;
}

.story-card:hover .story-card__title {
  color: var(--color-highlight);
}

.story-card__tagline {
  font-family: var(--font-prose);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-text);
  opacity: 0.85;
  margin: 0;
}

.story-card__meta {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0.25rem 0 0;
}

.story-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.55) 0%,
    rgba(0,0,0,0.15) 35%,
    transparent 60%
  );
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.story-card:hover .story-card__overlay {
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.45) 0%,
    var(--color-accent-dim) 50%,
    transparent 80%
  );
}

.story-card__placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, var(--color-surface) 0%, var(--color-sidebar) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-card__placeholder-icon {
  font-size: 3.5rem;
  opacity: 0.12;
}

/* Footer */
.site-footer {
  padding: 0.6rem 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  background: var(--color-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  z-index: 10;
}

.site-footer__line {
  margin: 0;
  flex: 1;
  text-align: center;
}

.site-footer__logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--color-accent);
  flex-shrink: 0;
  box-shadow:
    0 0 0 2px var(--color-accent-dim),
    0 0 10px var(--color-accent-dim),
    0 4px 12px rgba(0,0,0,0.5);
}

.site-footer__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.site-footer__logo-placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
}

.site-footer a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--color-highlight);
  text-decoration: underline;
}

/* =========================================================
   STORY / CHAPTER PAGES
   ========================================================= */
.story-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.story-page__inner {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Hamburger button */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 10px 12px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Home button (top-right, every chapter page) */
.home-button {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--color-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: color 0.25s, border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.home-button:hover {
  color: var(--color-highlight);
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  box-shadow: 0 0 20px var(--color-accent-dim);
}

.home-button svg {
  flex-shrink: 0;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.open {
  opacity: 0.8;
  pointer-events: auto;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  min-height: 100vh;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  padding: 2.5rem 0 3rem;
  transition: transform 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

.sidebar__story-title {
  padding: 0 1.5rem 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar__story-title a {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-highlight);
  text-decoration: none;
  line-height: 1.4;
  display: block;
  transition: color 0.2s;
}

.sidebar__story-title a:hover { color: var(--color-accent); }

.sidebar__nav {
  list-style: none;
  padding: 0.75rem 0 0;
}

.sidebar__nav-item a {
  display: block;
  padding: 0.55rem 1.5rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  border-left: 3px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.sidebar__nav-item a:hover {
  color: var(--color-text);
  background: var(--color-accent-dim);
  border-left-color: var(--color-accent);
}

.sidebar__nav-item.active a {
  color: var(--color-highlight);
  background: var(--color-accent-dim);
  border-left-color: var(--color-accent);
  font-weight: 500;
  text-shadow: 0 0 12px var(--color-accent-dim);
}

/* Chapter main area — full-bleed cinematic */
.chapter-main {
  flex: 1;
  min-width: 0;
  padding: 0 0 6rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.chapter-content {
  width: 90%;
  max-width: none;
  margin: 0 auto;
}

/* Prose blocks — no extra horizontal padding, the wrapper handles width */
.chapter-content > p,
.chapter-content > h2,
.chapter-content > h3,
.chapter-content > blockquote,
.chapter-content > ul,
.chapter-content > ol,
.chapter-content > hr,
.chapter-title {
  padding-left: 0;
  padding-right: 0;
}

.chapter-title {
  padding-top: 4rem;
}

/* Chapter title */
.chapter-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--color-title);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin-bottom: 3.5rem;
  text-shadow: 0 0 40px var(--color-accent-dim);
}
/* Prose typography */
.chapter-content p {
  font-family: var(--font-prose);
  font-size: 1.7rem;
  line-height: 1.7;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 2rem;
}

.chapter-content h2 {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--color-highlight);
  margin: 4rem 0 1.5rem;
}

.chapter-content h3 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 2.5rem 0 1rem;
}

.chapter-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 1rem 1.75rem;
  margin: 2.75rem 0;
  font-style: italic;
  font-family: var(--font-prose);
  font-size: 1.6rem;
  line-height: 1.65;
  background: var(--color-accent-dim);
  border-radius: 0 3px 3px 0;
}

.chapter-content blockquote p {
  color: var(--color-quote);
  margin-bottom: 0;
  font-size: inherit;
}

.chapter-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
  position: relative;
}

.chapter-content hr::after {
  content: '· · ·';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-bg);
  padding: 0 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.3em;
}

.chapter-content em { font-style: italic; }

.chapter-content strong {
  font-weight: 700;
  color: var(--color-text-strong);
}

/* Full-bleed cinematic images */
.chapter-content img {
  width: 100%;
  height: auto;
  display: block;
  margin: 3.5rem 0;
  border-radius: 2px;
  padding: 10px;
  background: var(--frame-bg);
  background-clip: padding-box;
  box-shadow:
    inset 0 0 0 1px var(--frame-highlight),
    inset 0 0 0 2px var(--frame-shadow),
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 12px 64px rgba(0,0,0,0.7),
    0 0 30px var(--frame-glow);
}

/* Full-bleed cinematic videos */
.chapter-content video {
  width: 100%;
  height: auto;
  display: block;
  margin: 3.5rem 0;
  border-radius: 2px;
  padding: 10px;
  background: var(--frame-bg);
  background-clip: padding-box;
  box-shadow:
    inset 0 0 0 1px var(--frame-highlight),
    inset 0 0 0 2px var(--frame-shadow),
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 12px 64px rgba(0,0,0,0.7),
    0 0 30px var(--frame-glow);
  cursor: pointer;
}

/* Video wrapper (created by JS) — hosts custom controls */
.video-wrap {
  position: relative;
  margin: 3.5rem 0;
}

.video-wrap > video {
  margin: 0;
}

/* Custom controls overlay (bottom-right of frame) */
.video-controls {
  position: absolute;
  bottom: 22px;
  right: 22px;
  display: flex;
  gap: 8px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.video-wrap:hover .video-controls,
.video-wrap:focus-within .video-controls {
  opacity: 1;
  pointer-events: auto;
}

.video-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--frame-accent-border);
  color: var(--frame-accent);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.video-btn:hover {
  background: var(--color-surface);
  border-color: var(--frame-accent);
  transform: scale(1.06);
}

.video-btn:active {
  transform: scale(0.96);
}

.video-btn svg {
  display: block;
}

/* Prev / Next navigation */
.chapter-nav {
  width: 100%;
  margin-top: 4rem;
  padding: 2rem 4rem 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.chapter-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-surface);
  transition: color 0.25s, border-color 0.25s, background 0.25s, box-shadow 0.25s;
  white-space: nowrap;
}

.chapter-nav a:hover {
  color: var(--color-highlight);
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  box-shadow: 0 0 16px rgba(30,144,255,0.12);
}

.chapter-nav__spacer { flex: 1; }
.chapter-nav__home { margin-left: auto; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar-overlay { display: block; }

  .home-button {
    padding: 0.5rem;
    border-radius: 50%;
  }
  .home-button span { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    padding-top: 5rem;
    height: 100dvh;
  }

  .sidebar.open { transform: translateX(0); }

  .chapter-main { padding: 5rem 0 4rem; }

  .chapter-content {
    width: 92%;
  }

  .chapter-content > p,
  .chapter-content > h2,
  .chapter-content > h3,
  .chapter-content > blockquote,
  .chapter-content > ul,
  .chapter-content > ol,
  .chapter-content > hr,
  .chapter-title {
    padding-left: 0;
    padding-right: 0;
  }

  .chapter-content p { font-size: 1.35rem; line-height: 1.65; }

  .chapter-nav { padding: 2rem 1.25rem 0; }

  .home-main { padding: 3rem 1rem 2rem; }

  .stories-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
  }

  .story-card__title { font-size: 1.15rem; }
  .story-card__tagline { font-size: 0.9rem; }
  .story-card__body { padding: 1rem 1.1rem 1.2rem; }

  .stories-section__header { margin-bottom: 2.5rem; }

  .site-header { height: 240px; }

  .site-header__inner { padding: 0 1.5rem; }

  .site-footer { padding: 0.5rem 1rem; font-size: 0.65rem; }
  .site-footer__logo { width: 30px; height: 30px; }

  .chapter-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .chapter-nav a { text-align: center; }
  .chapter-nav__home { margin-left: 0; }
}

/* =========================================================
   THEME PICKER
   ========================================================= */
.theme-picker {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 101;
  font-family: var(--font-sans);
}

/* On chapter pages, the home button takes the top-right slot.
   Push the theme picker further left of it. */
body.story-page .theme-picker {
  right: calc(1.25rem + 160px);
}

.theme-picker__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--color-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.15s;
}

.theme-picker__btn:hover {
  color: var(--color-highlight);
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  box-shadow: 0 0 20px var(--color-accent-dim);
  transform: scale(1.05);
}

.theme-picker__btn svg { display: block; }

.theme-picker__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.theme-picker.open .theme-picker__menu {
  display: flex;
}

.theme-picker__heading {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.theme-option:hover {
  background: var(--color-accent-dim);
  color: var(--color-highlight);
}

.theme-option__swatch {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: linear-gradient(135deg, var(--swatch-bg) 0%, var(--swatch-accent) 100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

.theme-option__label { flex: 1; }

.theme-option__check {
  width: 16px;
  height: 16px;
  opacity: 0;
  color: var(--color-accent);
  flex-shrink: 0;
}

.theme-option.is-active .theme-option__check {
  opacity: 1;
}

.theme-option.is-active {
  color: var(--color-highlight);
}

/* Mobile adjustments for picker */
@media (max-width: 768px) {
  body.story-page .theme-picker {
    right: calc(1.25rem + 60px);
  }
  .theme-picker__menu {
    min-width: 180px;
  }
}
