/* ==========================================================
   THE DAYDREAMER — an invitation to the nightmare
   festomanolo.com
   The website is built around the poem, not the poem
   placed on a website.
   ========================================================== */

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

:root {
  --ink: #000000;
  --bone: #e9e9f2;
  --pale: #c6c8d8;
  --silver: #9fa3b8;
  --mist: #6c7086;
  --smoke: #474b5e;
  --ash: #2b2e3c;
  --ember: #d99a52;
  --ember-dim: #8a5a2c;
  --blood: #7e2430;
  --steel: #cfd6e6;

  --serif: 'Cormorant Garamond', Georgia, serif;
  --display: 'Cinzel', serif;
  --fell: 'IM Fell English', serif;

  /* camera drift, written by script.js every frame */
  --camx: 0px;
  --camy: 0px;
}

html {
  background: var(--ink);
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar { display: none; }

body {
  background: var(--ink);
  color: var(--pale);
  font-family: var(--serif);
  font-weight: 300;
  cursor: none;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body.locked {
  overflow: hidden;
  height: 100dvh;
}

::selection {
  background: rgba(120, 130, 170, 0.25);
  color: var(--bone);
}

/* ==========================================================
   WORLD LAYERS
   ========================================================== */
#atmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Fallback sky if WebGL is unavailable */
body.no-webgl {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(60, 70, 105, 0.20) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 110%, rgba(20, 24, 40, 0.5) 0%, transparent 60%),
    #010103;
}

#stage {
  position: relative;
  z-index: 2;
}

/* ==========================================================
   THE LANTERN — the light you carry
   ========================================================== */
#lantern {
  position: fixed;
  top: 0;
  left: 0;
  width: 5px;
  height: 5px;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease;
}

#lantern i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(250, 232, 190, 0.95);
  box-shadow:
    0 0 6px 2px rgba(250, 232, 190, 0.55),
    0 0 22px 7px rgba(226, 200, 150, 0.22),
    0 0 60px 22px rgba(200, 172, 120, 0.08);
  animation: lantern-flicker 2.4s ease-in-out infinite;
}

@keyframes lantern-flicker {
  0%, 100% { opacity: 0.85; }
  18%      { opacity: 1; }
  41%      { opacity: 0.78; }
  63%      { opacity: 0.95; }
  82%      { opacity: 0.72; }
}

body.touch #lantern { display: none; }
body.touch { cursor: auto; }

/* ==========================================================
   PROLOGUE
   ========================================================== */
#prologue {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
}

.title-pre {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(0.85rem, 2.2vw, 1.4rem);
  letter-spacing: 0.85em;
  text-indent: 0.85em; /* recenters the tracked text */
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0;
}

.title-main {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.6rem, 10vw, 7.5rem);
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: var(--bone);
  text-shadow:
    0 0 90px rgba(190, 200, 240, 0.10),
    0 0 160px rgba(160, 175, 220, 0.06);
  opacity: 0;
  margin: 0.15em 0 0.5em;
}

.title-sub {
  font-family: var(--fell);
  font-style: italic;
  font-size: clamp(0.72rem, 1.6vw, 1rem);
  letter-spacing: 0.42em;
  color: var(--smoke);
  text-transform: lowercase;
  opacity: 0;
}

.title-sig {
  font-family: var(--fell);
  font-style: italic;
  font-size: clamp(0.6rem, 1.2vw, 0.78rem);
  letter-spacing: 0.35em;
  color: var(--ash);
  margin-top: 4.5rem;
  opacity: 0;
}

/* ==========================================================
   BEATS — every line is its own moment in the dark
   ========================================================== */
.act { position: relative; }

.beat {
  min-height: 76vh;
  display: flex;
  align-items: center;
  padding: 0 8vw;
}

.beat--tall { min-height: 105vh; }

.beat.pos-c { justify-content: center; text-align: center; }
.beat.pos-l { justify-content: flex-start; text-align: left; }
.beat.pos-r { justify-content: flex-end; text-align: right; }

.beat-inner {
  max-width: 880px;
  transform: translate3d(calc(var(--camx) * var(--d, 1)), calc(var(--camy) * var(--d, 1)), 0);
}

.moment {
  min-height: 100vh;
  justify-content: center;
  text-align: center;
}

.line {
  display: block;
  line-height: 1.75;
  text-wrap: balance;
  will-change: transform, opacity, filter;
  opacity: 0; /* every line is born in darkness; script reveals it */
}

/* split characters (burial / dissolution) */
.ch {
  display: inline-block;
  white-space: pre;
  will-change: transform, opacity;
}

/* ==========================================================
   ACT I — THE INVITATION
   ========================================================== */
.l-open {
  font-family: var(--fell);
  font-size: clamp(1.7rem, 4.6vw, 3.3rem);
  color: var(--bone);
  line-height: 1.5;
  text-shadow:
    0 0 55px rgba(150, 165, 200, 0.13),
    0 0 110px rgba(130, 145, 180, 0.07);
}

.l-dim {
  font-size: clamp(1rem, 2.1vw, 1.4rem);
  color: var(--silver);
  letter-spacing: 0.14em;
}

.l-ital {
  font-style: italic;
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  color: var(--mist);
  letter-spacing: 0.05em;
}

.l-med {
  font-size: clamp(1.2rem, 2.8vw, 1.9rem);
  color: var(--pale);
}

.l-whisper {
  font-family: var(--fell);
  font-style: italic;
  font-size: clamp(0.8rem, 1.6vw, 1.05rem);
  color: var(--smoke);
  letter-spacing: 0.28em;
}

/* ==========================================================
   ACT II — THE PURSUIT
   ========================================================== */
.l-run {
  font-size: clamp(1.15rem, 2.7vw, 1.85rem);
  color: var(--pale);
  letter-spacing: 0.04em;
}

.l-glow {
  font-size: clamp(1.05rem, 2.3vw, 1.55rem);
  font-style: italic;
  color: rgba(198, 210, 245, 0.95);
  text-shadow:
    0 0 45px rgba(165, 185, 240, 0.30),
    0 0 100px rgba(140, 160, 220, 0.16);
}

/* the echo — two ghost copies drift away from the voice */
.l-echo {
  position: relative;
  font-size: clamp(1.2rem, 2.9vw, 2rem);
  color: var(--pale);
  --echo: 0;
}

.l-echo::before,
.l-echo::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--mist);
  pointer-events: none;
  user-select: none;
}

.l-echo::before {
  transform: translate(calc(var(--echo) * -18px), calc(var(--echo) * -12px)) scale(calc(1 + var(--echo) * 0.05));
  opacity: calc(var(--echo) * 0.4);
  filter: blur(calc(var(--echo) * 3px));
}

.l-echo::after {
  transform: translate(calc(var(--echo) * 22px), calc(var(--echo) * 10px)) scale(calc(1 + var(--echo) * 0.1));
  opacity: calc(var(--echo) * 0.25);
  filter: blur(calc(var(--echo) * 5px));
}

/* the reflection — a drowned copy beneath the surface */
.l-mirror {
  position: relative;
  font-size: clamp(1.05rem, 2.4vw, 1.6rem);
  color: var(--silver);
  --mirror: 0;
}

.l-mirror::after {
  content: attr(data-text);
  position: absolute;
  top: 108%;
  left: 0;
  right: 0;
  transform: scaleY(-1) skewX(-4deg);
  transform-origin: top;
  opacity: calc(var(--mirror) * 0.16);
  filter: blur(2.5px);
  color: var(--mist);
  pointer-events: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 10%, rgba(0,0,0,1) 90%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0) 10%, rgba(0,0,0,1) 90%);
}

/* the first question */
.l-q {
  font-family: var(--display);
  font-weight: 600;
  text-transform: none;
  font-size: clamp(1.05rem, 3vw, 2rem);
  letter-spacing: 0.06em;
  line-height: 2;
  color: var(--bone);
}

.l-calvary .w-cold,
.l-calvary .w-fire { display: inline-block; }

.l-calvary .w-cold {
  color: var(--silver);
  text-shadow: 0 0 40px rgba(140, 150, 180, 0.25);
}

.l-calvary .w-fire {
  color: var(--ember);
  text-shadow:
    0 0 40px rgba(217, 154, 82, 0.30),
    0 0 90px rgba(217, 154, 82, 0.14);
}

/* ==========================================================
   ACT III — FIRE AND BURIAL
   ========================================================== */
.l-torch {
  font-family: var(--fell);
  font-size: clamp(1.5rem, 4vw, 2.8rem);
  line-height: 1.5;
  color: #e8ddc8;
  text-shadow:
    0 0 45px rgba(217, 154, 82, 0.22),
    0 0 110px rgba(190, 130, 60, 0.12);
}

.l-mock {
  font-family: var(--fell);
  font-style: italic;
  font-size: clamp(0.78rem, 1.5vw, 1rem);
  color: var(--smoke);
  letter-spacing: 0.2em;
}

.l-sink {
  font-size: clamp(1.15rem, 2.7vw, 1.85rem);
  color: var(--pale);
  line-height: 2;
}

.l-roots {
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  color: #a89e90;
  line-height: 2;
  letter-spacing: 0.03em;
}

/* the taunt — steel */
.l-slam {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.3rem, 4.6vw, 3.4rem);
  letter-spacing: 0.1em;
  line-height: 1.7;
  color: var(--steel);
  --sweep: -0.3;
}

.l-slam .w-steel {
  display: inline-block;
  background-image: linear-gradient(
    105deg,
    var(--steel) 0%,
    var(--steel) calc(var(--sweep) * 100% - 12%),
    #ffffff calc(var(--sweep) * 100%),
    var(--steel) calc(var(--sweep) * 100% + 12%),
    var(--steel) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
}

/* ==========================================================
   ACT IV — THE SWORD AND THE PRAYER
   ========================================================== */
.l-blade {
  font-size: clamp(1.15rem, 2.7vw, 1.85rem);
  color: var(--steel);
  letter-spacing: 0.02em;
}

.l-trem {
  font-size: clamp(1.05rem, 2.4vw, 1.6rem);
  color: var(--pale);
}

.l-prayer {
  font-family: var(--fell);
  font-style: italic;
  font-size: clamp(1.2rem, 2.8vw, 2rem);
  line-height: 1.8;
  color: #d8d2c4;
  text-shadow: 0 0 45px rgba(216, 200, 160, 0.14);
}

.l-blood {
  font-size: clamp(1.05rem, 2.4vw, 1.6rem);
  color: #b39098;
  letter-spacing: 0.05em;
  text-shadow: 0 0 40px rgba(126, 36, 48, 0.35);
}

.l-deepq { line-height: 2; }

.l-deepq .w-depth {
  display: inline-block;
  color: #7f9ec0;
  text-shadow:
    0 0 50px rgba(90, 130, 190, 0.35),
    0 0 120px rgba(70, 110, 170, 0.18);
}

/* ==========================================================
   ACT V — ABANDONMENT
   ========================================================== */
.l-ask {
  font-size: clamp(1.15rem, 2.7vw, 1.85rem);
  color: var(--silver);
  line-height: 1.9;
}

.l-fade {
  font-size: clamp(1rem, 2.3vw, 1.55rem);
  color: var(--mist);
  font-style: italic;
}

.l-small5 {
  font-size: clamp(0.9rem, 1.9vw, 1.25rem);
  color: var(--smoke);
  letter-spacing: 0.1em;
}

.l-last {
  font-family: var(--fell);
  font-size: clamp(1.1rem, 3vw, 2.1rem);
  letter-spacing: 0.3em;
  color: var(--silver);
  line-height: 2.2;
}

/* ==========================================================
   EPILOGUE
   ========================================================== */
#epilogue {
  position: relative;
  min-height: 280vh;
}

#wake {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1rem, 2.6vw, 1.9rem);
  letter-spacing: 0.7em;
  text-indent: 0.7em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

/* ==========================================================
   INTERFACE GHOSTS
   ========================================================== */
#hint {
  position: fixed;
  bottom: 2.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  opacity: 0;
  pointer-events: none;
}

#hint span {
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.68rem;
  letter-spacing: 0.4em;
  color: var(--ash);
  text-transform: lowercase;
}

#hint i {
  width: 1px;
  height: 46px;
  background: linear-gradient(to bottom, var(--ash), transparent);
  animation: hint-pulse 2.8s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.35; transform: scaleY(1); }
  50%      { opacity: 0.85; transform: scaleY(1.18) translateY(-4px); }
}

#sound {
  position: fixed;
  bottom: 2.4rem;
  right: 2.6rem;
  z-index: 30;
  background: none;
  border: none;
  cursor: none;
  font-family: var(--fell);
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: lowercase;
  color: var(--ash);
  padding: 0.8rem 1rem;
  opacity: 0;
  transition: color 0.6s ease, opacity 1.2s ease;
}

#sound:hover { color: var(--mist); }
body.touch #sound { cursor: pointer; }

/* ==========================================================
   SMALL SCREENS
   ========================================================== */
@media (max-width: 640px) {
  .beat { padding: 0 9vw; min-height: 68vh; }
  .beat--tall { min-height: 90vh; }
  .title-main { font-size: clamp(2.3rem, 13vw, 4rem); }
  .l-slam { letter-spacing: 0.06em; }
  .l-last { letter-spacing: 0.18em; }
  #sound { bottom: 1.6rem; right: 1.2rem; }
  #hint { bottom: 1.8rem; }
}

/* ==========================================================
   REDUCED MOTION — the poem still breathes, gently
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  #hint i, #lantern i { animation: none; }
  .l-echo::before, .l-echo::after, .l-mirror::after { display: none; }
}
