/* HARMATTAN — an interactive shader poem
   Palette: haze #E8E2D6 · dust rose #C9977B · dry sky #B9C4C9 · ember #8A3B22 · night #211D1B
   One font: Epilogue variable (wght 100–900), weight driven per-frame by the wind field. */

@font-face {
  font-family: 'Epilogue';
  src: url('../fonts/epilogue-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --haze: #E8E2D6;
  --rose: #C9977B;
  --sky: #B9C4C9;
  --ember: #8A3B22;
  --night: #211D1B;
  --ink: #211D1B;
  --fs-line: clamp(1.5rem, 0.85rem + 2.9vw, 3.15rem);
  --fs-body: clamp(1rem, 0.94rem + 0.3vw, 1.125rem);
  --wind: 0; /* 0..1, written by JS every frame */
}

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

html { scroll-behavior: smooth; overflow-x: hidden; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: 'Epilogue', system-ui, sans-serif;
  font-size: var(--fs-body);
  background: var(--haze);
  color: var(--ink);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--ember); color: var(--haze); }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 2px; }
body.dark :focus-visible { outline-color: var(--haze); }

@supports (scrollbar-width: thin) {
  html { scrollbar-width: thin; scrollbar-color: var(--rose) transparent; }
}

.skip {
  position: fixed; top: -4rem; left: 1rem; z-index: 100;
  background: var(--night); color: var(--haze);
  padding: .6rem 1rem; border-radius: 4px; text-decoration: none;
  transition: top .15s ease;
}
.skip:focus-visible { top: 1rem; }

.sr-status {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- canvas ---------- */

#gl {
  position: fixed; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  display: block;
  background: var(--haze);
}
body.textmode #gl, body.still #gl, body.nogl #gl { display: none; }

/* ---------- header ---------- */

.site-head {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(.8rem, 2vw, 1.3rem) clamp(1rem, 3.5vw, 2.4rem);
  pointer-events: none;
}
.site-head > * { pointer-events: auto; }

.mark {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--ink); text-decoration: none;
  font-weight: 640; font-size: .92rem; letter-spacing: .22em;
  transition: color .5s ease;
}
body.dark .mark { color: var(--haze); }

.site-nav { display: flex; align-items: center; gap: clamp(.6rem, 1.6vw, 1.4rem); }
.site-nav a {
  color: var(--ink); text-decoration: none;
  font-size: .82rem; font-weight: 560; letter-spacing: .14em; text-transform: uppercase;
  border-bottom: 1px solid transparent;
  transition: color .5s ease, border-color .2s ease;
}
.site-nav a:hover { border-bottom-color: currentColor; }
body.dark .site-nav a { color: var(--haze); }

.txt-toggle {
  display: inline-flex; align-items: center; gap: .5rem;
  font: inherit; font-size: .82rem; font-weight: 620; letter-spacing: .1em; text-transform: uppercase;
  color: var(--haze); background: var(--night);
  border: 1px solid var(--night); border-radius: 999px;
  padding: .5rem 1rem; cursor: pointer;
  transition: background .3s ease, color .3s ease, transform .15s ease;
}
.txt-toggle:hover { transform: translateY(-1px); }
.txt-toggle[aria-pressed="true"] { background: var(--ember); border-color: var(--ember); }
body.dark .txt-toggle { background: var(--haze); color: var(--night); border-color: var(--haze); }
body.dark .txt-toggle[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); color: var(--night); }
body.still .txt-toggle { display: none; }

/* ---------- the stage ---------- */

#stage { position: relative; }
body.textmode #stage, body.still #stage, body.nogl #stage { display: none; }

.scene { height: 170vh; padding-top: 62vh; }
.scene.cover { height: 120vh; padding-top: 0; }
.scene.last { height: 185vh; }

.scene .hold { height: 100%; }

.cover .hold {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  display: grid; place-content: center; justify-items: center;
  text-align: center; padding: 0 5vw;
}

.season {
  font-size: clamp(.68rem, .6rem + .4vw, .82rem);
  font-weight: 620; letter-spacing: .42em; text-indent: .42em;
  color: var(--ink); mix-blend-mode: multiply; opacity: .82;
}

.title {
  font-size: clamp(3.4rem, 13.5vw, 12.5rem);
  line-height: .95;
  font-weight: 300;
  font-variation-settings: 'wght' var(--tw, 300);
  letter-spacing: var(--tls, .02em);
  color: var(--ink);
  mix-blend-mode: multiply;
  margin: .35em 0 .4em;
  white-space: nowrap;
}

.define {
  max-width: 44ch;
  font-size: clamp(.95rem, .85rem + .5vw, 1.15rem);
  font-weight: 430; line-height: 1.65;
  color: var(--ink); mix-blend-mode: multiply;
}

.hint {
  margin-top: clamp(2rem, 5vh, 3.4rem);
  font-size: .8rem; font-weight: 480; letter-spacing: .08em;
  color: var(--ink); opacity: .68; mix-blend-mode: multiply;
}
.hint-key {
  display: inline-block; border: 1px solid currentColor; border-radius: 5px;
  padding: .1em .5em; font-weight: 640; font-size: .72rem; letter-spacing: .12em;
}

/* Poem lines — sticky, blended into the shader weather */

.line {
  position: sticky;
  top: 38vh;
  display: block;
  margin: 0 auto;
  max-width: min(88vw, 21ch);
  text-align: center;
  font-size: var(--fs-line);
  line-height: 1.32;
  font-weight: 400;
  color: var(--ink);
  mix-blend-mode: multiply;
  letter-spacing: var(--lls, 0.005em);
  opacity: var(--vis, 0);
  text-wrap: balance;
}
body.dark .line { color: var(--haze); mix-blend-mode: screen; }

.line::before {
  content: attr(data-n);
  display: block;
  font-size: clamp(.68rem, .62rem + .3vw, .8rem);
  font-weight: 660; letter-spacing: .5em; text-indent: .5em;
  opacity: .62;
  margin-bottom: 1.1em;
}

.line .w {
  display: inline-block; white-space: pre-wrap;
  font-variation-settings: 'wght' var(--ww, 420);
  transform: translateY(calc(var(--wy, 0) * 1px));
  will-change: font-variation-settings, transform;
}

/* no-JS fallback: lines fully visible */
.no-js .line, html:not(.js) .line { opacity: 1; }

/* ---------- read as text ---------- */

.text-poem {
  position: relative; z-index: 2;
  background: var(--haze);
  padding: clamp(6rem, 14vh, 9rem) clamp(1.2rem, 6vw, 4rem) clamp(4rem, 9vh, 7rem);
}
.tp-inner { max-width: 46rem; margin: 0 auto; }

.tp-kicker {
  font-size: .72rem; font-weight: 660; letter-spacing: .42em;
  color: var(--ember);
  margin-bottom: 1.2rem;
}

.tp-title {
  font-size: clamp(2.4rem, 2rem + 3.4vw, 4.6rem);
  font-weight: 260; letter-spacing: .01em; line-height: 1.05;
  margin-bottom: 1rem;
}

.tp-note { max-width: 52ch; opacity: .78; margin-bottom: 3rem; }

.tp-lines { list-style: none; counter-reset: ln; }
.tp-lines li {
  counter-increment: ln;
  font-size: clamp(1.2rem, 1rem + 1.1vw, 1.7rem);
  font-weight: 350; line-height: 1.5;
  padding: 1.1em 0;
  border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  display: grid; grid-template-columns: 3.2rem 1fr; gap: 1rem; align-items: baseline;
}
.tp-lines li::before {
  content: counter(ln, upper-roman);
  font-size: .72rem; font-weight: 660; letter-spacing: .18em;
  color: var(--ember);
}
.tp-sig { margin-top: 2.6rem; font-style: italic; font-weight: 380; opacity: .7; }

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

.stills {
  position: relative; z-index: 2;
  background: var(--night); color: var(--haze);
  padding: clamp(4rem, 10vh, 7rem) clamp(1.2rem, 6vw, 4rem);
}
.st-inner { max-width: 72rem; margin: 0 auto; }
.stills .tp-kicker { color: var(--rose); }
.stills .tp-note { opacity: .7; }

.st-grid {
  list-style: none;
  display: grid; gap: clamp(1rem, 2.4vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}
.st-grid canvas {
  width: 100%; aspect-ratio: 16 / 9; display: block;
  border-radius: 6px; background: var(--haze);
}
.st-grid p {
  margin-top: .7rem; font-size: .8rem; font-weight: 540;
  letter-spacing: .16em; text-transform: uppercase; opacity: .72;
}

/* ---------- about ---------- */

.about {
  position: relative; z-index: 2;
  background: var(--night); color: var(--haze);
  padding: clamp(5rem, 12vh, 9rem) clamp(1.2rem, 6vw, 4rem) 0;
}
.ab-inner { max-width: 72rem; margin: 0 auto; }
.about .tp-kicker { color: var(--rose); }

.about h2 {
  font-size: clamp(1.9rem, 1.3rem + 3vw, 3.9rem);
  font-weight: 280; line-height: 1.12; letter-spacing: .005em;
  max-width: 24ch;
  margin-bottom: clamp(2.4rem, 5vw, 4rem);
}
.about h2 em { font-style: normal; color: var(--rose); font-weight: 420; }

.ab-cols {
  display: grid; gap: clamp(1.6rem, 4vw, 4rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  max-width: 64rem;
}
.ab-cols p { margin-bottom: 1.2rem; font-weight: 330; opacity: .92; }
.ab-cols em { color: var(--rose); font-style: italic; }

.ab-textbtn {
  font: inherit; font-weight: 480; color: var(--rose);
  background: none; border: none; border-bottom: 1px solid var(--rose);
  cursor: pointer; padding: 0;
  transition: color .2s ease, border-color .2s ease;
}
.ab-textbtn:hover { color: var(--haze); border-color: var(--haze); }

.ab-meta {
  margin-top: clamp(3rem, 7vw, 5rem);
  border-top: 1px solid color-mix(in srgb, var(--haze) 16%, transparent);
  padding-top: 2.4rem;
}
.ab-meta dl {
  display: grid; gap: 1.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  margin-bottom: 2.4rem;
}
.ab-meta dt {
  font-size: .7rem; font-weight: 660; letter-spacing: .32em; text-transform: uppercase;
  color: var(--rose); margin-bottom: .5rem;
}
.ab-meta dd { font-weight: 330; opacity: .88; max-width: 34ch; }

.ab-links { font-weight: 340; opacity: .88; max-width: 62ch; }
.about a { color: var(--haze); text-decoration-color: var(--rose); text-underline-offset: 3px; }
.about a:hover { color: var(--rose); }

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

.site-foot {
  max-width: 72rem; margin: clamp(3rem, 8vw, 6rem) auto 0;
  border-top: 1px solid color-mix(in srgb, var(--haze) 16%, transparent);
  padding: 2rem 0 2.6rem;
  display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; justify-content: space-between;
  font-size: .84rem; font-weight: 340;
}
.site-foot p { opacity: .72; max-width: 40ch; }
.site-foot nav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.site-foot a { color: var(--haze); }

/* ---------- text / still modes ---------- */

#textPoem[hidden], #stills[hidden] { display: none; }
body.textmode #textPoem, body.still #textPoem { display: block; }
body.still #stills { display: block; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .site-head { padding: .75rem .9rem; }
  .mark span { display: none; }
  .txt-toggle { padding: .45rem .8rem; font-size: .74rem; }
  .site-nav a { font-size: .74rem; }
  .line { max-width: 92vw; }
  .title { white-space: normal; }
  .tp-lines li { grid-template-columns: 2.2rem 1fr; gap: .6rem; }
}
