/* ==========================================================================
   The Forest Keeps Time — synchronous fireflies of the Great Smoky Mountains
   Single-theme by design: the page is the dark of the forest floor.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ground */
  --bg: #060907;
  --bg-2: #0b120e;
  --bg-panel: rgba(6, 9, 7, 0.86);
  --moss: #16211a;

  /* ink */
  --bone: #ece9dc;
  --bone-70: rgba(236, 233, 220, 0.72);
  --bone-50: rgba(236, 233, 220, 0.5);
  --bone-30: rgba(236, 233, 220, 0.3);
  --sage: #8fa394;
  --line: rgba(236, 233, 220, 0.14);
  --line-soft: rgba(236, 233, 220, 0.08);

  /* light */
  --fire: #d9f26a;
  --fire-soft: #c9dc7a;
  --fire-hot: #f4ffc4;
  --fire-glow: rgba(217, 242, 106, 0.55);
  --dusk: #2e3358;
  --ember: #b8433a;

  /* type */
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* rhythm */
  --pad: clamp(1.25rem, 4vw, 4rem);
  --measure: 60ch;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* driven by the simulation: 0 in the dark, 1 at the peak of a synced flash */
  --flash: 0;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

::selection { background: rgba(217, 242, 106, 0.35); color: var(--bone); }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--fire); outline-offset: 3px; border-radius: 3px; }

i, em { font-style: italic; }

.skip {
  position: absolute; left: -999px; top: 1rem; z-index: 100;
  padding: 0.6rem 1rem; background: var(--bone); color: var(--bg);
  font: 500 0.9rem var(--font-body); text-decoration: none; border-radius: 999px;
}
.skip:focus { left: 1rem; }

/* ---------- shared label style: the "instrument" voice ---------- */
.eyebrow, .chapter__label, .stat__label, .footer__label,
.timeline time, .history time, .hud, .def__role, .scrollcue {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.72rem;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---------- the living background ---------- */
#scene {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  display: block;
  background: var(--bg);
}

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

/* ---------- navigation ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem var(--pad);
  transition: background 0.5s var(--ease-out);
}
.nav::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(6, 9, 7, 0.78), rgba(6, 9, 7, 0.3));
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  opacity: 0; transition: opacity 0.5s var(--ease-out);
}
.nav.is-scrolled::before { opacity: 1; }

.brand {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--bone); text-decoration: none;
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 400; line-height: 1;
}
.brand__name em { color: var(--bone-70); }
.brand__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--fire-hot);
  box-shadow: 0 0 10px 3px var(--fire-glow);
  animation: blink 8.6s linear infinite;
}
/* six blips over the first three seconds, then dark: the real Photinus carolinus pattern */
@keyframes blink {
  0%, 0.5%   { opacity: 1; }   3%, 6.5%  { opacity: 0.12; }
  7%, 7.5%   { opacity: 1; }   10%, 12.5%{ opacity: 0.12; }
  13%, 13.5% { opacity: 1; }   16%, 18.5%{ opacity: 0.12; }
  19%, 19.5% { opacity: 1; }   22%, 24.5%{ opacity: 0.12; }
  25%, 25.5% { opacity: 1; }   28%, 30.5%{ opacity: 0.12; }
  31%, 31.5% { opacity: 1; }   34%, 100% { opacity: 0.12; }
}

.nav__links { display: flex; gap: 2.2rem; }
.nav__links a {
  font-size: 0.92rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--bone-50); text-decoration: none;
  transition: color 0.25s;
}
.nav__links a:hover, .nav__links a.is-active { color: var(--bone); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1.2rem; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--bone); background: transparent;
  font: 500 0.92rem/1 var(--font-body);
  text-decoration: none; white-space: nowrap;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.btn:hover { background: var(--bone); color: var(--bg); border-color: var(--bone); }
.btn--primary { background: var(--bone); color: var(--bg); border-color: var(--bone); }
.btn--primary:hover { background: var(--fire-hot); border-color: var(--fire-hot); }
.btn--sm { padding: 0.55rem 0.95rem; font-size: 0.85rem; }

/* ---------- the story: a pinned viewport, chapters scrubbed by scroll ---------- */
.story {
  position: relative; z-index: 2;
  height: 640vh;
  height: 640svh;
}
.story__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}

.chapter {
  position: absolute; inset: 0;
  display: flex; align-items: center;
  padding: calc(var(--pad) + 3.5rem) var(--pad) var(--pad);
  pointer-events: none;
  will-change: transform, opacity;
}
.js .chapter { opacity: 0; visibility: hidden; }
.js .chapter--hero { opacity: 1; visibility: visible; }

.chapter__inner { max-width: 38rem; pointer-events: auto; }
.chapter--right { justify-content: flex-end; }
.chapter--center { justify-content: center; text-align: center; }
.chapter--center .chapter__inner { max-width: 54rem; }
.chapter--center .chapter__text { margin-inline: auto; }

.chapter__label { color: var(--fire-soft); font-size: 0.76rem; margin: 0 0 1.4rem; }

.chapter h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.5rem, 5.6vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0 0 1.4rem;
  text-wrap: balance;
  text-shadow: 0 0 calc(var(--flash) * 42px) rgba(217, 242, 106, calc(var(--flash) * 0.6));
}
.chapter h2 em { font-style: italic; }
.chapter__text {
  font-size: clamp(1.02rem, 1.25vw, 1.2rem);
  line-height: 1.6;
  color: var(--bone-70);
  max-width: 34rem;
  margin: 0;
  text-wrap: pretty;
}

/* hero */
.chapter--hero { align-items: flex-end; padding-bottom: clamp(5rem, 11vh, 8rem); }
.chapter--hero .chapter__inner { max-width: none; }
.eyebrow { color: var(--fire-soft); font-size: 0.76rem; margin: 0 0 1.5rem; }
/* first paint: the hero settles in, from a visible resting state */
.chapter--hero .chapter__inner > * { animation: settle 1.1s var(--ease-out) both; }
.chapter--hero .hero__title { animation-delay: 0.12s; }
.chapter--hero .hero__lede { animation-delay: 0.26s; }
@keyframes settle {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(3.1rem, 7.4vw, 7.8rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  margin: 0 0 1.6rem;
  text-shadow: 0 0 calc(var(--flash) * 42px) rgba(217, 242, 106, calc(var(--flash) * 0.6));
}
.hero__title em { color: var(--bone); }
.hero__lede {
  max-width: 31rem;
  font-size: clamp(1.05rem, 1.3vw, 1.25rem);
  color: var(--bone-70);
  margin: 0;
  text-wrap: pretty;
}

.scrollcue {
  position: absolute; left: 50%; bottom: clamp(1.4rem, 3.5vh, 2.2rem);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  color: var(--bone-50);
}
.scrollcue__line {
  position: relative; display: block; width: 1px; height: 54px;
  background: linear-gradient(var(--bone-30), transparent);
  overflow: hidden;
}
.scrollcue__line i {
  position: absolute; left: -1px; top: 0; width: 3px; height: 12px;
  background: var(--fire-hot); border-radius: 2px;
  animation: drop 2.4s var(--ease-out) infinite;
}
@keyframes drop {
  0% { transform: translateY(-14px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(60px); opacity: 0; }
}

/* the instrument */
.hud {
  position: absolute; left: var(--pad); right: var(--pad);
  bottom: clamp(1.25rem, 3.5vh, 2.25rem);
  display: flex; justify-content: space-between; align-items: flex-end;
  pointer-events: none;
  color: var(--bone-50);
}
.hud__chapter { display: flex; flex-direction: column; gap: 0.7rem; }
.hud__where b { font-weight: 500; color: var(--bone); }
.hud__progress { display: block; width: 120px; height: 1px; background: var(--line); }
.hud__progress i, .hud__bar i {
  display: block; height: 100%; width: 100%;
  background: var(--fire-soft);
  transform-origin: left center; transform: scaleX(0);
}
.hud__instrument { display: flex; align-items: center; gap: 1.1rem; }
.hud__ring { width: 88px; height: 88px; }
.hud__readout {
  display: grid; grid-template-columns: auto auto; gap: 0.45rem 0.9rem; align-items: center;
  margin: 0;
}
.hud__readout dt, .hud__readout dd { margin: 0; }
.hud__sym { font-family: var(--font-display); font-style: italic; text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--bone-70); }
.hud__value {
  font-size: 1.15rem; letter-spacing: 0; color: var(--bone);
  font-variant-numeric: tabular-nums;
}
.hud__bar { display: block; width: 72px; height: 1px; background: var(--line); }

/* ---------- content sections ---------- */
.section {
  position: relative; z-index: 2;
  padding: clamp(5rem, 12vh, 9rem) var(--pad);
  background: var(--bg-panel);
}
.section--first {
  padding-top: clamp(8rem, 18vh, 13rem);
  background: linear-gradient(180deg, rgba(6, 9, 7, 0) 0%, var(--bg-panel) 22%);
}
.section__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2.5rem, 6vw, 7rem);
  max-width: 84rem; margin: 0 auto;
}
.section__head { position: sticky; top: 6.5rem; align-self: start; }
.section__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.4rem, 4.4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0.6rem 0 1.3rem;
  text-wrap: balance;
}
.section__lede { color: var(--bone-70); max-width: 30rem; font-size: 1.1rem; margin: 0; text-wrap: pretty; }
.cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

.prose p { max-width: var(--measure); color: var(--bone-70); margin: 0 0 1.4rem; font-size: 1.08rem; text-wrap: pretty; }
.subhead {
  font-family: var(--font-display); font-weight: 400; font-style: italic;
  font-size: 1.7rem; letter-spacing: -0.01em;
  margin: 3.5rem 0 1.4rem;
}

/* the Kuramoto equation, set in the display face like a plate in a monograph */
.equation {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem;
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(1.7rem, 3vw, 2.7rem); line-height: 1.1;
  color: var(--bone);
  padding: 2rem 0; margin: 0.5rem 0 2.5rem;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}
.equation sub { font-size: 0.55em; line-height: 0; vertical-align: -0.2em; }
.eq__op { font-style: normal; color: var(--bone-50); }
.eq__frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; }
.eq__frac > span:last-child { border-top: 1px solid var(--bone-50); padding-top: 0.08em; margin-top: 0.05em; }
.eq__sum { font-style: normal; font-size: 1.35em; line-height: 1; }

.defs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.2rem 3rem; margin: 0 0 1rem; }
.defs dt {
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: 2rem; line-height: 1; margin: 0 0 0.5rem;
  display: flex; align-items: baseline; gap: 0.8rem;
}
.defs dt sub { font-size: 0.55em; line-height: 0; vertical-align: -0.15em; }
.def__role { font-style: normal; color: var(--fire-soft); }
.defs dd { margin: 0; color: var(--bone-70); font-size: 0.98rem; text-wrap: pretty; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.3rem; }
.history li { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1rem; align-items: baseline; }
.history time { color: var(--fire-soft); font-variant-numeric: tabular-nums; }
.history p { margin: 0; color: var(--bone-70); max-width: var(--measure); text-wrap: pretty; }

/* stat tiles: big typographic numbers, no boxes */
.stats {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3.5rem 2.5rem;
}
.stat__value {
  font-family: var(--font-display); font-weight: 300;
  font-size: clamp(3.4rem, 6.2vw, 6rem); line-height: 0.95; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.stat__value small { font-size: 0.4em; color: var(--bone-50); letter-spacing: 0; margin-left: 0.2em; font-style: italic; }
.stat__label { color: var(--bone); margin: 1rem 0 0.45rem; }
.stat__note { color: var(--sage); font-size: 0.95rem; max-width: 22rem; margin: 0; text-wrap: pretty; }

/* visit */
.timeline { list-style: none; margin: 0 0 1rem; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 0.3rem; top: 0.9rem; bottom: 0.9rem;
  width: 1px; background: var(--line);
}
.timeline li { position: relative; padding-left: 2.2rem; margin-bottom: 2.2rem; display: grid; gap: 0.35rem; }
.timeline li::before {
  content: ""; position: absolute; left: 0; top: 0.35rem;
  width: 0.65rem; height: 0.65rem; border-radius: 50%;
  background: var(--fire-hot);
  box-shadow: 0 0 12px 3px var(--fire-glow);
}
.timeline time { color: var(--fire-soft); }
.timeline h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; line-height: 1.1; margin: 0; }
.timeline p { margin: 0; color: var(--bone-70); max-width: var(--measure); text-wrap: pretty; }

.etiquette { list-style: none; margin: 0 0 2.5rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.5rem; }
.etiquette li {
  display: flex; gap: 0.9rem; align-items: flex-start;
  padding: 1.1rem 0; border-top: 1px solid var(--line-soft);
  color: var(--bone-70); font-size: 0.98rem; text-wrap: pretty;
}
.etiquette strong { display: block; color: var(--bone); font-weight: 500; }
.dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-top: 0.5rem; background: var(--bone-30); }
.dot--red { background: var(--ember); box-shadow: 0 0 10px 2px rgba(184, 67, 58, 0.45); }
.fineprint { color: var(--sage); font-size: 0.92rem; max-width: var(--measure); margin: 0; text-wrap: pretty; }

/* footer */
.footer {
  position: relative; z-index: 2;
  background: var(--bg);
  padding: 4.5rem var(--pad) 2.5rem;
  border-top: 1px solid var(--line-soft);
}
.footer__grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 3rem;
  max-width: 84rem; margin: 0 auto 3.5rem;
}
.footer p { color: var(--bone-50); font-size: 0.95rem; margin: 0; max-width: 36rem; text-wrap: pretty; }
.footer__brand { font-family: var(--font-display); font-size: 1.4rem; color: var(--bone) !important; margin: 0 0 0.6rem !important; }
.footer__brand em { color: var(--bone-70); }
.footer__label { color: var(--fire-soft) !important; margin: 0 0 0.6rem !important; }
.footer__links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.footer__links a { color: var(--bone-50); font-size: 0.95rem; text-decoration: none; border-bottom: 1px solid var(--line); transition: color 0.25s, border-color 0.25s; }
.footer__links a:hover { color: var(--bone); border-color: var(--bone-50); }
.footer__small {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem 2rem;
  max-width: 84rem; margin: 0 auto;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--bone-30);
}
.footer__small b { font-weight: 500; color: var(--bone-70); font-variant-numeric: tabular-nums; }

/* ---------- scroll-driven reveals for the content sections ----------
   Progressive: browsers without view() timelines simply show the content at rest. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 8% entry 42%;
    }
  }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .section__grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .section__head { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.75rem 2rem; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .defs { grid-template-columns: 1fr; gap: 1.8rem; }
  .etiquette { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav { padding-top: 0.9rem; padding-bottom: 0.9rem; }
  .nav__links { display: none; }
  .chapter { align-items: flex-end; padding-bottom: 3.5rem; }
  .chapter--right, .chapter--center { justify-content: flex-start; text-align: left; }
  .chapter--hero { padding-bottom: 5rem; }
  .scrollcue { display: none; }
  .eyebrow { font-size: 0.66rem; letter-spacing: 0.12em; }
  .hud {
    left: auto; right: var(--pad); bottom: auto; top: 4.4rem;
    justify-content: flex-end;
  }
  .hud__chapter { display: none; }
  .hud__ring { width: 62px; height: 62px; }
  .hud__readout { gap: 0.3rem 0.6rem; font-size: 0.64rem; }
  .hud__value { font-size: 1rem; }
  .hud__bar { width: 56px; }
}

@media (max-width: 520px) {
  body { font-size: 1rem; }
  .brand__name { font-size: 1.05rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: 2.25rem 1.25rem; }
  .stat__value { font-size: 2.9rem; }
  .footer__grid { grid-template-columns: 1fr; gap: 2rem; }
  .history li { grid-template-columns: 3.6rem 1fr; }
  .equation { font-size: 1.5rem; gap: 0.3rem 0.6rem; }
}

@media (max-height: 620px) and (min-width: 861px) {
  .chapter h2 { font-size: clamp(2rem, 4.5vw, 3.6rem); }
  .hero__title { font-size: clamp(2.6rem, 6vw, 5rem); }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scrollcue__line i, .brand__dot, .chapter--hero .chapter__inner > * { animation: none; }
  .brand__dot { opacity: 0.85; }
  .chapter { will-change: auto; }
}
