/**
 * Eros, Wilted — styles
 *
 * Direction: "botanical specimen archive."
 * Warm-black ground (never pure #000), literary serif for the poem, and
 * monospace specimen labels as structural counterpoint. The WebGL layer sits
 * behind everything; type stays in the DOM so it kerns properly and stays
 * selectable.
 */

/* ── Tokens ──────────────────────────────────────────────────────────── */
:root {
  --ink:        #0a0806;
  --ink-lift:   #12100c;
  --bone:       #e8e2d4;
  --parchment:  #cfc7b5;
  --ash:        #8a8175;
  --ash-dim:    #5d564c;
  --terracotta: #c9603c;
  --gold:       #d4af37;
  --crimson:    #8f1d2f;

  --serif:   'EB Garamond', Georgia, 'Times New Roman', serif;
  --display: 'Playfair Display', Georgia, serif;
  --mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 34rem;
  --gutter:  clamp(1.25rem, 5vw, 5rem);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 100%;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

/* ── Layers ──────────────────────────────────────────────────────────── */

/* The WebGL metamorphosis. */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* Vignette + a scrim so the poem always clears its background. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 50% 42%, transparent 0%, rgba(10, 8, 6, 0.55) 62%, rgba(10, 8, 6, 0.88) 100%);
}

/* Film grain. */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 6s steps(6) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

.content { position: relative; z-index: 3; }

/* ── Specimen labels (mono) ──────────────────────────────────────────── */
.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ash-dim);
  font-weight: 400;
}

/* ── Masthead ────────────────────────────────────────────────────────── */
.masthead {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem var(--gutter);
  mix-blend-mode: difference;
}
.masthead a { color: var(--ash); text-decoration: none; transition: color 0.4s var(--ease); }
.masthead a:hover { color: var(--bone); }

.masthead-right { display: flex; align-items: center; gap: 1.5rem; }

.sound-toggle {
  background: none;
  border: 0;
  padding: 0.25rem 0;
  color: var(--ash-dim);
  cursor: pointer;
  transition: color 0.4s var(--ease);
}
.sound-toggle:hover { color: var(--bone); }
.sound-toggle[aria-pressed="true"] { color: var(--terracotta); }
.sound-toggle:focus-visible { outline: 1px solid var(--ash); outline-offset: 4px; }

/* ── Hero ────────────────────────────────────────────────────────────── */
.hero {
  min-height: 100svh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 0 var(--gutter);
}

.hero-title {
  font-family: var(--display);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(3rem, 13vw, 9.5rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--bone);
  text-wrap: balance;
}
.hero-title .comma { color: var(--terracotta); font-style: normal; }

.hero-sub {
  margin-top: 1.75rem;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-style: italic;
  color: var(--ash);
  letter-spacing: 0.04em;
}

.hero-meta {
  margin-top: 4rem;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-meta span { position: relative; }
.hero-meta span + span::before {
  content: "";
  position: absolute;
  left: -0.85rem; top: 50%;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ash-dim);
}

.scroll-cue {
  position: absolute;
  bottom: 2.5rem; left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 0.75rem;
}
.scroll-cue .rule {
  width: 1px; height: 3.5rem;
  background: linear-gradient(var(--ash-dim), transparent);
  animation: drip 2.6s var(--ease) infinite;
  transform-origin: top;
}
@keyframes drip {
  0%, 100% { transform: scaleY(0.35); opacity: 0.3; }
  50%      { transform: scaleY(1);    opacity: 1; }
}

/* ── Movements ───────────────────────────────────────────────────────── */
.movement {
  padding: 22vh var(--gutter);
  display: grid;
  justify-content: center;
}

.movement-head {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: 4.5rem;
  max-width: var(--measure);
}
.movement-numeral {
  font-family: var(--display);
  font-size: 2.75rem;
  line-height: 1;
  color: var(--terracotta);
  font-style: italic;
}
.movement-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--ash-dim), transparent);
}

/* ── The poem ────────────────────────────────────────────────────────── */
.lines { max-width: var(--measure); }

.line {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  line-height: 1.62;
  color: var(--parchment);
  margin-bottom: 1.6rem;

  /* The scene moves behind the poem; this keeps type legible over anything
     without resorting to a visible plate behind the column. */
  text-shadow:
    0 0 2px  rgba(10, 8, 6, 0.85),
    0 1px 14px rgba(10, 8, 6, 0.95);

  /* Hanging indent, so a wrapped poetic line reads as one line. */
  padding-left: 1.5rem;
  text-indent: -1.5rem;

  /* Reveal state */
  opacity: 0;
  transform: translateY(1.1rem);
  filter: blur(6px);
  transition:
    opacity 1.1s var(--ease),
    transform 1.1s var(--ease),
    filter 1.1s var(--ease);
  transition-delay: var(--stagger, 0ms);
}
.line.is-lit {
  opacity: 1;
  transform: none;
  filter: none;
}

/* The first line of each movement carries the weight. */
.lines .line:first-child { color: var(--bone); }

/* ── Rupture — the poem's own em-dash scar, made physical ────────────── */
.rupture {
  max-width: var(--measure);
  margin: 5rem 0 0;
}
.rupture-text {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.4rem, 3.5vw, 2.25rem);
  color: var(--bone);
}
.rupture-scar {
  margin-top: 1.5rem;
  height: 2px;
  background: linear-gradient(90deg, var(--crimson), var(--terracotta) 40%, transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.6s var(--ease);
}
.rupture.is-lit .rupture-scar { transform: scaleX(1); }

/* ── Colophon ────────────────────────────────────────────────────────── */
.colophon {
  padding: 24vh var(--gutter) 8rem;
  display: grid;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}
.colophon .mark {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--terracotta);
}
.colophon a { color: var(--ash); }

/* ── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .grain { animation: none; }
  .scroll-cue .rule { animation: none; opacity: 0.6; }
  .line {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }
  .rupture-scar { transform: scaleX(1); transition: none; }
}

/* ── Fallback when WebGL is unavailable ──────────────────────────────── */
body.no-webgl #stage { display: none; }
body.no-webgl {
  background:
    radial-gradient(ellipse 90% 60% at 50% 18%, rgba(201, 96, 60, 0.20), transparent 60%),
    var(--ink);
}
