/* ============================================================
   THE MOON MENDER — a bedtime story to scroll
   Night navy → dawn peach. Baloo 2 + Literata.
   ============================================================ */

:root {
  --night: #141b33;
  --ink: #0c1226;
  --ink-plum: #2a2140;
  --cream: #f6ecd9;
  --cream-dim: #d9cdb4;
  --gold: #f7c96b;
  --gold-deep: #d9a13e;
  --coral: #ff7a6b;
  --dawn: #ffd9b8;
  --card-night: rgba(12, 18, 38, 0.74);
  --card-day: rgba(255, 248, 238, 0.92);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--night);
  color: var(--cream);
  font-family: "Literata", Georgia, serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: var(--ink); }

img, svg { max-width: 100%; display: block; }

/* ---------- fixed chrome ---------- */

.wordmark {
  position: fixed;
  top: 1.1rem;
  left: 1.2rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.95rem 0.45rem 0.6rem;
  background: rgba(12, 18, 38, 0.62);
  border: 1px solid rgba(247, 201, 107, 0.22);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  color: var(--cream);
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}
.wordmark svg { width: 22px; height: 22px; }
.wordmark { transition: border-color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.wordmark:hover { border-color: rgba(247, 201, 107, 0.55); transform: translateY(-1px); }
.wordmark:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.moon-progress {
  position: fixed;
  top: 1.1rem;
  right: 1.2rem;
  z-index: 60;
  width: 46px;
  height: 46px;
  padding: 7px;
  background: rgba(12, 18, 38, 0.62);
  border: 1px solid rgba(247, 201, 107, 0.22);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.moon-progress svg { width: 100%; height: 100%; overflow: visible; }

/* ---------- star field ---------- */

.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.star {
  position: absolute;
  border-radius: 50%;
  background: var(--cream);
  animation: twinkle var(--tw-dur, 3.4s) ease-in-out var(--tw-delay, 0s) infinite;
  opacity: 0.85;
}
.star--gold { background: var(--gold); }
@keyframes twinkle {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 0.15; transform: scale(0.6); }
}

/* ---------- scenes ---------- */

main { position: relative; z-index: 1; }

.scene {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12vh 1.4rem;
}

.scene__inner {
  width: min(1060px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.6rem;
}

.scene__art {
  width: min(880px, 100%);
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, 0.35));
}
.scene__art svg { width: 100%; height: auto; overflow: visible; }

/* tall pinned scenes */
.scene--tall {
  display: block;
  min-height: 280vh;
  padding: 0;
}
.scene__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8vh 1.4rem 4vh;
  overflow: hidden;
}
.scene--tall .scene__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  align-items: center;
  gap: 2.6rem;
  width: min(1080px, 100%);
}
.scene--tall .scene__art { width: 100%; }
.scene--tall .scene__art svg { width: 100%; height: auto; max-height: 80vh; margin: 0 auto; }
.scene--tall .story-card { padding: 1.9rem 2.1rem 2.1rem; }

/* ---------- story typography ---------- */

.kicker {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.kicker::before, .kicker::after {
  content: "";
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
  opacity: 0.7;
}
.kicker::after { background: linear-gradient(90deg, var(--gold), transparent); }

.story-card {
  max-width: 37rem;
  background: var(--card-night);
  border: 1px solid rgba(247, 201, 107, 0.18);
  border-radius: 22px;
  padding: 2.1rem 2.5rem 2.3rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 24px 70px rgba(4, 7, 18, 0.45);
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.5s ease, box-shadow 0.5s ease;
}
.story-card:hover {
  transform: translateY(-4px);
  border-color: rgba(247, 201, 107, 0.36);
  box-shadow: 0 32px 84px rgba(4, 7, 18, 0.55);
}
.story-card .kicker { justify-content: center; margin-bottom: 1.05rem; }
.story-card h2 {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: clamp(1.6rem, 3.6vw, 2.2rem);
  line-height: 1.15;
  color: var(--cream);
  margin-bottom: 0.9rem;
  text-wrap: balance;
}
.story-card p {
  font-size: clamp(1.02rem, 1.5vw, 1.16rem);
  line-height: 1.9;
  color: var(--cream-dim);
  text-align: left;
  text-wrap: pretty;
}
.story-card p + p { margin-top: 1rem; }
.story-card em { color: var(--cream); font-style: italic; }
.story-card strong { color: var(--gold); font-weight: 600; }

.scene--light .story-card {
  background: var(--card-day);
  border-color: rgba(58, 33, 64, 0.16);
  box-shadow: 0 24px 70px rgba(122, 62, 42, 0.22);
}
.scene--light .story-card:hover {
  border-color: rgba(58, 33, 64, 0.32);
  box-shadow: 0 32px 84px rgba(122, 62, 42, 0.3);
}
.scene--light .story-card h2 { color: #3a2140; }
.scene--light .story-card p { color: #5b4358; }
.scene--light .story-card em { color: #3a2140; }
.scene--light .story-card strong { color: #b0562f; }
.scene--light .kicker { color: #b0562f; }
.scene--light .kicker::before { background: linear-gradient(90deg, transparent, #b0562f); }
.scene--light .kicker::after { background: linear-gradient(90deg, #b0562f, transparent); }

/* ---------- hero ---------- */

.hero { min-height: 108vh; flex-direction: column; text-align: center; }
.hero .scene__inner { gap: 0; }

.hero__title {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: clamp(3.1rem, 10vw, 6.8rem);
  line-height: 0.98;
  color: var(--cream);
  text-shadow: 0 6px 40px rgba(247, 201, 107, 0.25);
  margin: 0.5rem 0 1.1rem;
}
.hero__title .t-moon { color: var(--gold); }
.hero__title span.w { display: inline-block; }

.hero__sub {
  font-family: "Literata", serif;
  font-style: italic;
  font-size: clamp(1.02rem, 2vw, 1.25rem);
  color: var(--cream-dim);
  max-width: 30rem;
  margin: 0 auto;
  line-height: 1.7;
}

.hero__eyebrow {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--gold);
}

.hero__art { margin-top: 2.6rem; width: min(980px, 100%); }
.hero__art svg { width: 100%; height: auto; overflow: visible; }

.scroll-hint {
  margin-top: 2.2rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--cream-dim);
  font-family: "Baloo 2", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.scroll-hint svg { width: 18px; height: 26px; animation: hintDrop 2.2s ease-in-out infinite; }
@keyframes hintDrop {
  0%, 100% { transform: translateY(0); opacity: 0.9; }
  55% { transform: translateY(8px); opacity: 0.4; }
}

/* ---------- colour bridge ---------- */

.bg-bridge {
  min-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.4rem;
}
.bridge-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.4rem;
}
.bridge-stars {
  width: min(380px, 74vw);
  height: auto;
  overflow: visible;
}
.bridge-line {
  font-family: "Literata", serif;
  font-style: italic;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  line-height: 1.9;
  color: #3a2140;
  text-align: center;
}

/* ---------- ending ---------- */

.ending .story-card { max-width: 40rem; }

.moral {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  line-height: 1.5;
  color: #3a2140;
  text-align: center !important;
  margin-top: 1.4rem;
}

.read-again {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.9rem;
  padding: 0.95rem 2.1rem;
  border: none;
  border-radius: 999px;
  background: #3a2140;
  color: var(--dawn);
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(58, 33, 64, 0.35);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}
.read-again:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 20px 44px rgba(58, 33, 64, 0.45); }
.read-again:active { transform: translateY(0) scale(0.98); }
.read-again svg { width: 20px; height: 20px; }
.read-again:focus-visible { outline: 3px solid #b0562f; outline-offset: 3px; }

/* ---------- footer ---------- */

footer {
  position: relative;
  z-index: 1;
  background: var(--ink);
  color: var(--cream-dim);
  padding: 3.4rem 1.4rem 3.8rem;
  text-align: center;
  border-top: 1px solid rgba(247, 201, 107, 0.16);
}
footer .foot-moon { width: 34px; height: 34px; margin: 0 auto 1rem; }
footer p {
  font-size: 0.95rem;
  line-height: 1.8;
  max-width: 34rem;
  margin: 0 auto;
}
footer a { color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(247, 201, 107, 0.4); padding-bottom: 1px; }
footer a:hover { border-bottom-color: var(--gold); }
footer .foot-note { margin-top: 0.9rem; font-size: 0.83rem; opacity: 0.75; font-style: italic; }

/* ---------- svg helper classes ---------- */

.window { animation: windowFlicker 5s ease-in-out infinite; }
@keyframes windowFlicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 1; }
  50% { opacity: 0.55; }
  53% { opacity: 1; }
}

.svg-star { animation: twinkle var(--tw-dur, 3s) ease-in-out var(--tw-delay, 0s) infinite; transform-box: fill-box; transform-origin: center; }

.smoke { animation: smokeRise 7s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom center; }
@keyframes smokeRise {
  0% { opacity: 0; transform: translateY(6px) scale(0.85); }
  30% { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-26px) scale(1.25); }
}

.gear { animation: gearSpin 10s linear infinite; }
.gear--rev { animation-direction: reverse; animation-duration: 7.5s; }
@keyframes gearSpin { to { transform: rotate(360deg); } }

.bird { animation: birdDrift 9s ease-in-out infinite; }
@keyframes birdDrift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-26px, -10px); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .star, .svg-star, .scroll-hint svg, .window, .smoke, .gear, .bird { animation: none !important; }
  .star { opacity: 0.7; }
  .read-again, .story-card, .wordmark { transition: none; }
  .story-card:hover, .wordmark:hover { transform: none; }
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .scene { padding: 9vh 1rem; }
  .story-card { padding: 1.6rem 1.35rem 1.8rem; border-radius: 18px; }
  .story-card p { line-height: 1.8; }
  .scene--tall { min-height: 230vh; }
  .scene--tall .scene__inner { grid-template-columns: 1fr; gap: 1.1rem; justify-items: center; }
  .scene--tall .scene__art svg { max-height: 44vh; }
  .scene--tall .story-card { padding: 1.2rem 1.2rem 1.35rem; }
  .scene--tall .story-card h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
  .scene--tall .story-card p { font-size: 0.95rem; line-height: 1.7; }
  .scene--tall .story-card .kicker { margin-bottom: 0.6rem; }
  .scene__sticky { padding-top: 10vh; }
  .wordmark { font-size: 0.8rem; padding: 0.38rem 0.8rem 0.38rem 0.5rem; }
  .moon-progress { width: 40px; height: 40px; }
  .hero__art { margin-top: 1.8rem; }
  .kicker { letter-spacing: 0.22em; }
}
