:root {
  --paper: #f5f0e4;
  --ink: #1a1a14;
  --body: #2a2a24;
  --iron: #4a3f2e;
  --gold: #c9a84c;
  --pale-gold: #e8d48b;
  --void: #0e0e0c;
  --blue: #4a7a9b;
  --rust: #b8664a;
  --ochre: #d4a034;
  --paper-shadow: #f0e8d4;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Libre Baskerville", Georgia, serif;
  overflow-x: hidden;
}

.paper-grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(26, 26, 20, 0.55) 0 0.7px, transparent 0.9px),
    radial-gradient(circle at 72% 66%, rgba(74, 63, 46, 0.45) 0 0.55px, transparent 0.8px),
    linear-gradient(82deg, rgba(201, 168, 76, 0.25) 0 1px, transparent 1px 36px),
    linear-gradient(12deg, rgba(14, 14, 12, 0.18) 0 1px, transparent 1px 42px);
  background-size: 110px 110px, 83px 83px, 200px 200px, 160px 160px;
}

.page-turn {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background: var(--paper);
  clip-path: polygon(100% 100%, 100% 100%, 100% 100%);
}

.page-turn.turning { animation: turnPage 350ms cubic-bezier(0.4, 0, 0.2, 1); }

@keyframes turnPage {
  0% { clip-path: polygon(100% 100%, 100% 100%, 100% 100%); }
  45% { clip-path: polygon(100% 100%, 100% 0, 0 100%); }
  100% { clip-path: polygon(0 0, 100% 0, 0 100%); opacity: 0; }
}

.folio-index {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(201, 168, 76, 0.65);
  border-right: 0;
  background: rgba(245, 240, 228, 0.76);
  box-shadow: -10px 0 30px rgba(26, 26, 20, 0.08);
}

.folio-index a {
  width: 2.35rem;
  min-height: 2.5rem;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--gold);
  font-family: "Cormorant Garamond", serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  border-bottom: 1px solid rgba(201, 168, 76, 0.28);
  transition: background 220ms ease, color 220ms ease;
}

.folio-index a:hover, .folio-index a.current { background: var(--ink); color: var(--pale-gold); }

.folio {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 52% 48%;
  overflow: hidden;
  padding: clamp(2.2rem, 5vw, 5.5rem) clamp(2.2rem, 5vw, 6rem);
  border-bottom: 1px solid rgba(201, 168, 76, 0.22);
  isolation: isolate;
}

.gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  width: 1px;
  background: rgba(201, 168, 76, 0.15);
  z-index: 4;
}

.gutter::before, .gutter::after {
  content: "";
  position: absolute;
  left: -16px;
  width: 33px;
  height: 24%;
  background: radial-gradient(ellipse, rgba(26, 26, 20, 0.08), transparent 65%);
}

.gutter::before { top: 0; }
.gutter::after { bottom: 0; }

.folio-mark {
  position: absolute;
  top: 1.35rem;
  z-index: 5;
  font-family: "Libre Baskerville", serif;
  font-style: italic;
  font-size: 0.75rem;
  color: rgba(201, 168, 76, 0.4);
  letter-spacing: 0.16em;
}

.outer-left { left: 1.4rem; }
.outer-right { right: 3.6rem; }

.verso, .recto, .center-map { position: relative; z-index: 3; }
.illustration { display: grid; place-items: center; min-height: 70vh; }
.text-panel { align-self: center; max-width: 38ch; padding: clamp(1rem, 3vw, 2.5rem); }
.recto.text-panel { justify-self: center; }
.verso.text-panel { justify-self: start; }

h1, h2 {
  font-family: "Libre Baskerville", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  line-height: 1.08;
  margin: 0 0 1.15rem;
}

h1 { font-size: clamp(2.25rem, 5vw, 4.4rem); overflow-wrap: anywhere; }
h2 { font-size: clamp(2rem, 5vw, 3.8rem); }

p {
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  line-height: 1.72;
  color: var(--body);
  text-align: justify;
  hyphens: auto;
}

.lead { color: var(--ink); font-size: clamp(1.08rem, 2vw, 1.32rem); }

.atlas-label {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(0.7rem, 1.2vw, 0.85rem);
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: left;
  margin-bottom: 1.1rem;
}

.type-title::after, .typewriter.typing::after, .typewriter.done::after {
  content: "|";
  color: var(--gold);
  animation: blink 530ms steps(2, end) infinite;
}

@keyframes blink { 0%, 45% { opacity: 0; } 46%, 100% { opacity: 1; } }

.type-title { font-family: "Special Elite", "Courier New", monospace; color: var(--ink); }
.title-panel { margin-left: clamp(1rem, 4vw, 4rem); }

.circuit-field {
  position: absolute;
  inset: 8% 4% 10% 2%;
  opacity: 0.42;
  background:
    linear-gradient(90deg, transparent 0 15%, rgba(201, 168, 76, 0.16) 15% 15.4%, transparent 15.4% 100%),
    linear-gradient(0deg, transparent 0 28%, rgba(201, 168, 76, 0.13) 28% 28.4%, transparent 28.4% 100%),
    radial-gradient(circle at 15% 28%, rgba(201, 168, 76, 0.36) 0 3px, transparent 3.5px),
    radial-gradient(circle at 58% 72%, rgba(201, 168, 76, 0.28) 0 2.5px, transparent 3px),
    linear-gradient(90deg, transparent 0 58%, rgba(201, 168, 76, 0.12) 58% 58.4%, transparent 58.4% 100%);
  background-size: 210px 180px;
}

.celestial-field::before, .map-panel::before, .center-map::before, .deep-space-wash {
  content: "";
  position: absolute;
  z-index: -1;
  filter: blur(40px);
  mix-blend-mode: multiply;
  opacity: 0.68;
  clip-path: polygon(10% 18%, 52% 5%, 90% 24%, 84% 72%, 60% 90%, 18% 76%, 2% 46%);
}

.celestial-field::before { inset: 10% 3% 6% 4%; background: radial-gradient(circle at 40% 42%, var(--pale-gold), transparent 38%), radial-gradient(circle at 58% 52%, var(--blue), transparent 45%); }
.martian-wash::before { inset: 12% 2% 8%; background: radial-gradient(circle at 64% 36%, var(--rust), transparent 44%), radial-gradient(circle at 35% 72%, var(--pale-gold), transparent 38%); }
.amber-wash::before { inset: 5% 5% 10%; background: radial-gradient(circle at 50% 50%, var(--ochre), transparent 48%), radial-gradient(circle at 28% 38%, var(--rust), transparent 34%); }
.europa-wash::before { inset: 10% 4%; background: radial-gradient(circle at 40% 48%, var(--blue), transparent 44%), radial-gradient(circle at 60% 62%, var(--ochre), transparent 36%); }
.full-route-wash::before { inset: 6% 0 8%; background: radial-gradient(circle at 25% 60%, var(--rust), transparent 32%), radial-gradient(circle at 54% 46%, var(--ochre), transparent 34%), radial-gradient(circle at 78% 36%, var(--blue), transparent 34%); }

svg { width: min(88%, 660px); height: auto; overflow: visible; }
.compass-rose { width: min(88%, 560px); }
.thin { fill: none; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hairline { fill: none; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; opacity: 0.45; vector-effect: non-scaling-stroke; }
.gold { stroke: var(--gold); }
.ink { stroke: var(--ink); }
.fill-line { fill: rgba(201, 168, 76, 0.08); stroke-width: 1.6; }
.bright { filter: drop-shadow(0 0 12px rgba(232, 212, 139, 0.45)); }

.draw-svg path, .draw-svg circle, .draw-svg ellipse, .draw-svg line, .draw-svg polyline {
  stroke-dasharray: var(--dash, 900);
  stroke-dashoffset: var(--dash, 900);
  transition: stroke-dashoffset 1.2s cubic-bezier(0.65, 0, 0.35, 1);
}

.draw-svg.in-view path, .draw-svg.in-view circle, .draw-svg.in-view ellipse, .draw-svg.in-view line, .draw-svg.in-view polyline { stroke-dashoffset: 0; }

.route { stroke: var(--gold); stroke-dasharray: 8 4; }
.draw-svg.in-view .route.moving { animation: routeTravel 1.8s linear infinite; }
@keyframes routeTravel { to { stroke-dashoffset: -48; } }

.mission-log {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  line-height: 1.6;
  color: var(--iron);
  background: var(--paper-shadow);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.04), 0 18px 40px rgba(26, 26, 20, 0.08);
  border: 1px solid rgba(201, 168, 76, 0.26);
  padding: 1.25rem 1.35rem;
  margin: 1rem 0;
  white-space: pre-wrap;
  min-height: 4.4rem;
}

.narrow-columns {
  align-self: center;
  width: 19ch;
  padding: 1.5rem;
}

.narrow-columns p { font-size: clamp(0.95rem, 1.5vw, 1.05rem); }
.outer-spread { grid-template-columns: 24% 52% 24%; }
.outer-spread .gutter { left: 52%; }
.center-map { grid-column: 2; min-height: 76vh; }

.ships-log .margin-rose { display: grid; place-items: center; }
.small-rose { width: min(56%, 260px); opacity: 0.9; }
.log-stack { max-width: 50ch; }

.embarkation { color: var(--paper); background: var(--paper); }
.deep-space-wash {
  inset: -10% -8%;
  background: radial-gradient(circle at 48% 52%, var(--void) 0 34%, rgba(14, 14, 12, 0.9) 43%, rgba(74, 122, 155, 0.55) 58%, transparent 76%);
  opacity: 0.92;
  mix-blend-mode: normal;
  clip-path: polygon(0 5%, 75% 0, 100% 18%, 96% 86%, 68% 100%, 8% 94%);
}

.final-line { grid-column: 1 / -1; min-height: 70vh; z-index: 2; }
.final-caption {
  position: absolute;
  z-index: 5;
  left: clamp(2rem, 8vw, 8rem);
  top: clamp(4rem, 15vh, 9rem);
  max-width: 38ch;
}
.final-caption h2, .final-caption p { color: var(--paper); text-shadow: 0 1px 14px rgba(14, 14, 12, 0.45); }
.final-caption .atlas-label, .domain-seal { color: var(--pale-gold); }
.domain-seal {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: "Cormorant Garamond", serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .folio, .outer-spread {
    display: block;
    min-height: auto;
    padding: 4rem 1.35rem;
  }
  .folio { border-bottom: 1px solid rgba(201, 168, 76, 0.35); }
  .gutter {
    top: 3.1rem;
    left: 1.3rem;
    right: 1.3rem;
    bottom: auto;
    width: auto;
    height: 1px;
  }
  .text-panel, .title-panel, .narrow-columns { max-width: none; width: auto; margin: 0; padding: 1rem 0; }
  .illustration, .center-map { min-height: 44vh; margin: 1rem 0 2rem; }
  .outer-spread .center-map { min-height: 48vh; }
  .folio-index a { width: 2rem; min-height: 2.15rem; }
  .outer-right { right: 2.7rem; }
  p { text-align: left; }
  .final-caption { position: relative; left: auto; top: auto; padding: 4rem 0 0; }
  .final-line { min-height: 54vh; }
}
