/* ===============================================================
   Operation Imaginal, Imagine poem
   Page-local styles. Pairs with the canvas painter in scene.js.
   The canonical site header/footer are styled by assets/style.css,
   so this file deliberately does NOT define .site-header, .brand,
   or .cta. The poem's call-to-action buttons live under the
   .imagine-cta class to keep them scoped.
   =============================================================== */

:root {
  --imagine-forest-deep: #1a2218;
  --imagine-forest-mid:  #243024;
  --imagine-paper:       #f3ecd8;
  --imagine-paper-warm:  #ece2c5;
  --imagine-paper-deep:  #d9caa0;
  --imagine-ink:         #1a1a18;
  --imagine-ink-soft:    #3a3631;
  --imagine-terracotta:  #c14e2a;
  --imagine-terracotta-soft: #d97a52;
  --imagine-olive:       #6f7842;
  --imagine-gold:        #c89548;
  --imagine-gold-soft:   #d9b274;
  --imagine-rule:        rgba(193, 78, 42, 0.55);

  /* progress-driven (set from JS) */
  --imagine-grain: 0.06;
}

/* Page-local reset, scoped to the imagine body so the rest of the
   site's typography is untouched. */
body.imagine-body,
body.imagine-body * { box-sizing: border-box; }
body.imagine-body { margin: 0; padding: 0; }

body.imagine-body {
  background: var(--imagine-paper);
  color: var(--imagine-ink);
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
}

/* ============================================
   The fixed stage: canvas with the painted scene
   ============================================ */
.imagine-scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  background: var(--imagine-paper);
}

.imagine-grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--imagine-grain);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
}

/* ============================================
   Hero band, sits BELOW the canonical site-header.
   The dark green slab establishes the poem's mood.
   ============================================ */
.imagine-hero {
  position: relative;
  z-index: 5;
  background: var(--imagine-forest-deep);
  color: var(--imagine-paper);
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 80px 32px 120px;
}

.imagine-hero h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(80px, 14vw, 200px);
  line-height: 0.95;
  color: var(--imagine-paper);
  letter-spacing: -0.01em;
  margin: 0;
}
.imagine-hero h1 .dot { color: var(--imagine-terracotta); font-style: normal; }

.imagine-hero .scroll-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--imagine-paper);
  opacity: 0.65;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.imagine-hero .scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 38px;
  background: currentColor;
  opacity: 0.7;
  animation: imagine-pulseLine 2.4s ease-in-out infinite;
}
@keyframes imagine-pulseLine {
  0%,100% { transform: scaleY(0.6); opacity: 0.4; }
  50%     { transform: scaleY(1);   opacity: 0.8; }
}

/* ============================================
   Poem body (the 27 stanzas + final divider)
   ============================================ */
.imagine-poem {
  position: relative;
  z-index: 5;
  background: transparent;          /* canvas shows through */
  padding: 80px 32px 120px;
}

.imagine-poem-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.imagine-stanza {
  position: relative;
  padding: 8vh 0;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 32px;
  align-items: start;
}

.imagine-numeral {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 22px;
  color: var(--imagine-terracotta);
  line-height: 1;
  padding-top: 8px;
  position: relative;
}
.imagine-numeral::after {
  content: "";
  display: block;
  width: 32px;
  height: 1px;
  background: var(--imagine-rule);
  margin-top: 10px;
}

.imagine-stanza p {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: clamp(34px, 3.4vw, 51px);
  line-height: 1.4;
  color: var(--imagine-ink);
  text-wrap: pretty;
  letter-spacing: 0.005em;
  margin: 0;
}

.imagine-stanza p .I {
  color: var(--imagine-terracotta);
  font-weight: 600;
  font-style: italic;
}

/* ----------------------------------------------------------------
   Reading scrim. A soft cream "vellum" wash that sits behind each
   stanza ONLY when the canvas behind has gone busy (cocoon phase
   through the meadow phase). Invisible during the cream-paper
   stanzas at the top, where text already has full contrast.
   ---------------------------------------------------------------- */
.imagine-stanza::before {
  content: "";
  position: absolute;
  inset: -2vh -8vw;
  background: radial-gradient(
    ellipse at center,
    rgba(243, 236, 216, 0.78) 0%,
    rgba(243, 236, 216, 0.62) 55%,
    rgba(243, 236, 216, 0.0) 100%
  );
  filter: blur(8px);
  z-index: -1;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}
body.phase-imaginal .imagine-stanza::before,
body.phase-cocoon   .imagine-stanza::before,
body.phase-flight   .imagine-stanza::before { opacity: 1; }

/* divider star between stanza xx and xxi */
.imagine-divider {
  text-align: center;
  font-size: 24px;
  color: var(--imagine-terracotta);
  padding: 12vh 0;
  letter-spacing: 0.4em;
}

/* In the imaginal half (xxi+), text rests above the new world */
body.phase-imaginal .imagine-stanza p,
body.phase-flight   .imagine-stanza p {
  color: var(--imagine-ink);
}

/* End spread */
.imagine-ending {
  position: relative;
  z-index: 5;
  padding: 100px 32px 140px;
  text-align: center;
  min-height: 220vh; /* extra scroll real estate for cocoon ripening + meadow + butterfly */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* The ending sits ON TOP of the painted Maggiori meadow.
   Add a soft, edgeless "vellum" scrim to create a calm reading zone
   without framing the content like a card. */
.imagine-ending-scrim {
  position: relative;
  margin: 0 auto;
  max-width: 880px;
  padding: 80px 60px 70px;
  isolation: isolate;
}
.imagine-ending-scrim::before {
  content: "";
  position: absolute;
  inset: -40px -80px;
  background: radial-gradient(
    ellipse at center,
    rgba(243, 236, 216, 0.92) 0%,
    rgba(243, 236, 216, 0.82) 45%,
    rgba(243, 236, 216, 0.45) 75%,
    rgba(243, 236, 216, 0.0) 100%
  );
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

.imagine-ending .epigraph {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(30px, 3.4vw, 48px);
  line-height: 1.3;
  color: var(--imagine-ink);
  max-width: 720px;
  margin: 0 auto 56px;
  text-wrap: balance;
}
.imagine-ending .epigraph .I { color: var(--imagine-terracotta); font-weight: 600; }

.imagine-ending .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 44px;
}

/* Scoped CTA, styled like the in-poem accent buttons. Does NOT
   inherit from the global .btn/.cta because it lives on a painted
   backdrop, not a cream surface. */
.imagine-cta {
  display: inline-block;
  padding: 15px 28px;
  border: 1.5px solid var(--imagine-terracotta);
  border-radius: 100px;
  background: var(--imagine-terracotta);
  color: var(--imagine-paper);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(122, 44, 18, 0.22);
  transition: background .25s ease, color .25s ease, border-color .25s ease;
}
.imagine-cta:hover {
  background: #a83f1f;
  border-color: #a83f1f;
  color: var(--imagine-paper);
}
.imagine-cta .arrow { display: inline-block; margin-left: 8px; transform: translateY(-1px); }

.imagine-ending .closing {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 19px;
  color: var(--imagine-ink);
  max-width: 540px;
  margin: 0 auto;
  text-wrap: balance;
  letter-spacing: 0.005em;
}

/* ============================================
   Right-edge progress thread
   ============================================ */
.imagine-thread {
  position: fixed;
  top: 0;
  right: 22px;
  height: 100vh;
  width: 1px;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(26,34,24,0.18) 18%, rgba(26,34,24,0.18) 82%, transparent);
}
.imagine-thread .bead {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--imagine-terracotta);
  box-shadow: 0 0 12px rgba(193,78,42,0.5);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* A small toast for the "Find three others" share fallback. */
.imagine-share-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--imagine-ink);
  color: var(--imagine-paper);
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 100px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 60;
}
.imagine-share-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 720px) {
  .imagine-stanza { grid-template-columns: 40px 1fr; gap: 18px; padding: 6vh 0; }
  .imagine-numeral { font-size: 18px; }
  .imagine-stanza p { font-size: 31px; }
  .imagine-poem { padding: 60px 22px 100px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .imagine-hero .scroll-hint::after { animation: none; }
}

