/* imouto.quest — a quiet sisterly atlas. navy-metallic, pop-art watercolor. */

:root {
  --midnight: #0b1426;
  --hull: #162236;
  --lapis: #1f3050;
  --silver: #b8c0cc;
  --chrome: #e9eef5;
  --pewter: #7a8696;
  --warm-pewter: #e9d8c4;
  --coral: #e8896a;
  --persimmon: #d96f3c;
  --moonlit: #d4dae3;

  --mag-max: clamp(8px, 1.4vw, 22px);
  --ease-soft: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--midnight);
  color: var(--moonlit);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.85;
  overflow-x: hidden;
  /* halftone ben-day field over midnight, every 7th omitted handled in JS-free static */
  background-image:
    radial-gradient(circle at center, var(--lapis) 1.6px, transparent 1.7px);
  background-size: 9px 9px;
  background-attachment: fixed;
  background-blend-mode: normal;
}

/* the page is one long scroll of spreads */
#book { position: relative; }

.spread {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6vh clamp(1.2rem, 5vw, 5rem);
  overflow: hidden;
}

/* alternate spread tint via wet-wash watercolor blocks */
#spread-2, #spread-4 { background: var(--hull); }

/* clip-path wave boundary (path injected by JS, fallback below) */
.spread::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 90px;
  background: var(--midnight);
  z-index: 5;
  pointer-events: none;
}
#spread-2::after, #spread-4::after { background: var(--hull); }
/* the wave silver edge */
.spread .wave-edge {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 110px;
  z-index: 6;
  pointer-events: none;
}
.spread .wave-edge path { fill: none; stroke: var(--silver); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.5; }
.spread .wave-edge path:nth-child(2) { stroke-width: 4; opacity: 0.22; }
.spread .wave-edge path:nth-child(3) { stroke-width: 1; opacity: 0.7; stroke: var(--chrome); }
#spread-5::after, #spread-5 .wave-edge { display: none; }

/* ---------- spread numerals ---------- */
.spread-num {
  position: absolute;
  left: clamp(1rem, 3vw, 2.4rem);
  bottom: clamp(1rem, 3vw, 2.4rem);
  font-family: "Major Mono Display", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--pewter);
  z-index: 10;
}

/* ---------- constellation index ---------- */
#constellation {
  position: fixed;
  top: clamp(1rem, 3vw, 2.2rem);
  right: clamp(1rem, 3vw, 2.4rem);
  z-index: 40;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
  pointer-events: none;
}
#constellation.visible { opacity: 1; }
.con-dot { fill: var(--silver); transition: fill 1.2s ease-in-out, r 1.2s ease-in-out; }
.con-dot.current { fill: var(--persimmon); }

/* ---------- magnetic lattice (iron-filings) ---------- */
.lattice {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}
.lattice.near { opacity: 0.06; }
.lattice .filing {
  position: absolute;
  width: 1px; height: 1px;
  border-radius: 50%;
  background: var(--silver);
  transition: transform 0.18s var(--ease-soft), width 0.18s ease, height 0.18s ease;
}

/* ---------- magnetic elements ---------- */
.mag-el {
  transition: transform 0.5s var(--ease-soft);
  will-change: transform;
}

/* halftone fill clipping — apply ben-day dots inside form silhouettes (svg <rect>/<path> get pattern via mix) */
.halftone-fill {
  /* used as an svg fill via CSS not possible; we rely on opacity layering + the body bg. Provide a real dot pattern as mask. */
}

/* ============ SPREAD 1 — HERO ============ */
#spread-1 { flex-direction: column; gap: 0; padding-top: 0; padding-bottom: 0; }

.hero-panel {
  position: relative;
  width: 100%;
  height: 88vh;
  margin-top: 0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
}
.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-title {
  position: relative;
  z-index: 4;
  font-family: "Bungee Inline", "Major Mono Display", monospace;
  font-weight: 400;
  font-size: clamp(2.6rem, 6.4vw, 5.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--silver);
  margin: 0 0 1.4rem clamp(1.2rem, 5vw, 4rem);
  text-shadow: 0 2px 0 rgba(11,20,38,0.6);
}
.hero-title .hero-dot { color: var(--silver); }
.hero-title .accent-coral { color: var(--silver); }
/* the inline stripe recolor: Bungee Inline carries its own stripe; tint with a subtle warm cast on the accent word via shadow */
.hero-title .accent-coral { filter: drop-shadow(0 0 0.6px var(--coral)); }
.hero-sub {
  position: relative;
  z-index: 4;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--warm-pewter);
  margin: 0 0 5vh clamp(1.2rem, 5vw, 4rem);
}

.scroll-ribbon {
  position: relative;
  z-index: 4;
  height: 12vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.scroll-ribbon svg { overflow: visible; }
.ribbon-path { animation: ribbon-undulate 2.4s ease-in-out infinite; }
@keyframes ribbon-undulate {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-3px) scaleY(1.18); }
}
.scroll-word {
  font-family: "Major Mono Display", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--pewter);
}

/* ============ shared grid ============ */
.grid {
  width: min(1180px, 100%);
  display: grid;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
}
/* folded-letter proportions 3-2-3-2-2 across 12 → for two-col we use 7 / 5 (≈3+2+2 / 3+2) */
.grid-a { grid-template-columns: 7fr 5fr; }
.grid-b { grid-template-columns: 5fr 7fr; }

.col-art .art-wrap {
  position: relative;
  width: 100%;
}
.col-art svg { width: 100%; height: auto; display: block; }

.col-text { position: relative; }
.bubble {
  width: clamp(220px, 60%, 340px);
  height: auto;
  display: block;
  margin-bottom: -2.2rem;
  position: relative;
  z-index: 1;
  overflow: visible;
}
.caption {
  position: relative;
  z-index: 2;
  font-family: "Caveat", cursive;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.4;
  color: var(--warm-pewter);
  margin: 0 0 1.4rem 1.6rem;
  max-width: 16ch;
}
.prose {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.85;
  color: var(--moonlit);
  max-width: 56ch;
}
.prose em { font-weight: 500; font-style: italic; color: var(--warm-pewter); }

/* ============ SPREAD 3 — umbrella puddle ripple ============ */
.umbrella { overflow: visible; }
.puddle { transform-origin: center; }
.col-art .art-wrap::before {
  content: "";
  position: absolute;
  left: 5%; right: 5%;
  bottom: 2%;
  height: 14%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgba(185,192,204,0.20), transparent 70%),
    radial-gradient(closest-side, rgba(233,238,245,0.10), transparent 60%);
  background-size: 60% 100%, 30% 100%;
  background-position: 30% 50%, 70% 50%;
  background-repeat: no-repeat;
  animation: puddle-pulse 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
#spread-3 .col-art .art-wrap::before { display: block; }
.col-art .art-wrap::before { display: none; }
@keyframes puddle-pulse {
  0%, 100% { transform: scaleX(1); opacity: 0.7; }
  50% { transform: scaleX(1.06); opacity: 1; }
}

/* ============ SPREAD 4 — train window ============ */
#spread-4 { padding: 0; }
.train-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
}
.train-landscape {
  position: absolute;
  inset: 0;
  z-index: 1;
  will-change: transform;
}
.train-landscape svg { width: 130%; height: 100%; display: block; }
.train-frame {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 3;
  pointer-events: none;
}
.frame-glass {
  position: absolute;
  left: 10vw; right: 10vw; top: 12vh; bottom: 12vh;
  background: linear-gradient(120deg, rgba(185,192,204,0.05), rgba(233,238,245,0.02), rgba(185,192,204,0.06));
  border-radius: 14px;
  overflow: hidden;
}
.reflection { position: absolute; right: 6%; bottom: 0; height: 90%; width: auto; }
.frame-bar { position: absolute; background: var(--hull); border: 3px solid var(--silver); }
.frame-top { left: 0; right: 0; top: 0; height: 12vh; border-bottom-color: var(--silver); border-radius: 0 0 24px 24px; }
.frame-bottom { left: 0; right: 0; bottom: 0; height: 12vh; border-top-color: var(--silver); border-radius: 24px 24px 0 0; }
.frame-left { top: 0; bottom: 0; left: 0; width: 10vw; border-right-color: var(--silver); border-radius: 0 24px 24px 0; }
.frame-right { top: 0; bottom: 0; right: 0; width: 10vw; border-left-color: var(--silver); border-radius: 24px 0 0 24px; }
.frame-curve { position: absolute; left: 0; right: 0; top: 12vh; height: 60px; }
.train-caption {
  position: relative;
  z-index: 4;
  margin-left: auto; margin-right: auto;
  width: min(56ch, 80vw);
  padding-top: 88vh;
  padding-bottom: 12vh;
  pointer-events: none;
}
.train-prose {
  background: rgba(11,20,38,0.55);
  padding: 1.4rem 1.8rem;
  border-radius: 12px;
  color: var(--moonlit);
}

/* ============ SPREAD 5 — sleeping couch / dissolve ============ */
#spread-5 { background: var(--midnight); }
.couch-scene {
  position: relative;
  width: min(900px, 100%);
}
.couch { width: 100%; height: auto; display: block; }
.cat { animation: cat-breathe 4.2s ease-in-out infinite; transform-origin: 250px 360px; }
@keyframes cat-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.012); }
}
.dissolve-veil {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 12vh;
  background: linear-gradient(to bottom, transparent, var(--midnight));
  pointer-events: none;
  z-index: 8;
}

/* hide scrollbar in the dissolve zone — webkit */
body.dissolving::-webkit-scrollbar { opacity: 0; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--midnight); }
::-webkit-scrollbar-thumb { background: var(--lapis); border-radius: 4px; transition: opacity 0.8s ease; }
body.dissolving::-webkit-scrollbar-thumb { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .grid-a, .grid-b { grid-template-columns: 1fr; }
  .grid-b .col-text { order: 2; }
  .grid-b .col-art { order: 1; }
  .hero-panel { height: 86vh; }
  .frame-left, .frame-right { width: 6vw; }
  .frame-glass { left: 6vw; right: 6vw; }
}
