/* ============================================================
   STELLARIUM — art direction
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Grotesk";
  src: url("../fonts/space-grotesk-latin-300-normal.woff2") format("woff2");
  font-weight: 300; font-display: swap;
}
@font-face {
  font-family: "Grotesk";
  src: url("../fonts/space-grotesk-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "Grotesk";
  src: url("../fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "Mono";
  src: url("../fonts/space-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Mono";
  src: url("../fonts/space-mono-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  --ink: #05060b;
  --paper: #f4f0e6;
  --dim: rgba(244, 240, 230, 0.42);
  --dimmer: rgba(244, 240, 230, 0.22);
  --line: rgba(244, 240, 230, 0.14);
  /* accent is driven live by JS to match the star's phase */
  --accent: #7fb2ff;
  --edge: 34px;
}

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

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Grotesk", system-ui, sans-serif;
  overflow: hidden;
  cursor: none;
}

#app { position: fixed; inset: 0; }

/* WebGL canvas host ---------------------------------------- */
#gl {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* scroll driver — an invisible tall element that owns the scrollbar.
   Must sit ABOVE the overlay + poster so the wheel/trackpad actually reaches it. */
#scroller {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: none;
}
#scroller::-webkit-scrollbar { display: none; }
#spacer { width: 1px; }

/* overlay UI ---------------------------------------------- */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease 0.2s;
}
#ui.ready { opacity: 1; }

/* corner frame */
.frame span {
  position: fixed;
  width: 18px; height: 18px;
  border: 1px solid var(--line);
  z-index: 11;
}
.frame .tl { top: var(--edge); left: var(--edge); border-right: 0; border-bottom: 0; }
.frame .tr { top: var(--edge); right: var(--edge); border-left: 0; border-bottom: 0; }
.frame .bl { bottom: var(--edge); left: var(--edge); border-right: 0; border-top: 0; }
.frame .br { bottom: var(--edge); right: var(--edge); border-left: 0; border-top: 0; }

/* HUD labels */
.hud {
  position: fixed;
  font-family: "Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  z-index: 11;
}
.hud .accent { color: var(--accent); transition: color 0.6s ease; }

#hud-brand   { top: calc(var(--edge) + 2px); left: calc(var(--edge) + 34px); }
#hud-brand b { font-weight: 700; color: var(--paper); letter-spacing: 0.34em; }
#hud-stardate{ top: calc(var(--edge) + 2px); right: calc(var(--edge) + 34px); text-align: right; }

/* live readout panel bottom-left */
#readout {
  bottom: calc(var(--edge) + 30px);
  left: calc(var(--edge) + 34px);
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 18px;
  align-items: baseline;
}
#readout .k { color: var(--dimmer); }
#readout .v { color: var(--paper); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
#readout .v em { font-style: normal; color: var(--accent); transition: color 0.6s ease; }

/* scroll hint bottom-right */
#hint {
  bottom: calc(var(--edge) + 30px);
  right: calc(var(--edge) + 34px);
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
#hint .bar {
  width: 120px; height: 1px; background: var(--line); position: relative; overflow: hidden;
}
#hint .bar i {
  position: absolute; inset: 0; width: 0%; background: var(--accent);
  transition: background 0.6s ease;
}
#hint .cue { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.3 } 50% { opacity: 1 } }

/* phase timeline — right edge */
#timeline {
  position: fixed;
  right: var(--edge);
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: flex-end;
}
#timeline .node {
  display: flex; align-items: center; gap: 10px;
  font-family: "Mono", monospace; font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--dimmer);
  transition: color 0.4s ease;
}
#timeline .node .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--dimmer); transition: all 0.4s ease;
}
#timeline .node.on { color: var(--paper); }
#timeline .node.on .dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); transform: scale(1.6); }

/* narrative captions — center-left, one per phase */
#captions { position: fixed; inset: 0; z-index: 11; }
.cap {
  position: absolute;
  left: clamp(34px, 9vw, 150px);
  top: 50%;
  max-width: min(46vw, 620px);
  transform: translateY(-42%);
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.2,0.8,0.2,1), filter 0.7s ease;
  filter: blur(6px);
  will-change: opacity, transform;
}
.cap.show { opacity: 1; transform: translateY(-50%); filter: blur(0); }
.cap .eyebrow {
  font-family: "Mono", monospace; font-size: 12px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 22px;
  transition: color 0.6s ease;
}
.cap h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(38px, 6vw, 88px);
  line-height: 0.96;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
}
.cap h2 i { font-style: italic; color: var(--accent); transition: color 0.6s ease; }
.cap p {
  font-size: clamp(15px, 1.25vw, 18px);
  font-weight: 300;
  line-height: 1.6;
  color: var(--dim);
  max-width: 42ch;
}

/* opening poster */
#poster {
  position: fixed; inset: 0; z-index: 11;
  pointer-events: none;                 /* never intercept the scroll */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  transition: opacity 0.8s ease, transform 1.1s cubic-bezier(0.2,0.8,0.2,1);
}
#poster.gone { opacity: 0; transform: scale(1.06); pointer-events: none; }
#poster .kicker {
  font-family: "Mono", monospace; font-size: 12px; letter-spacing: 0.4em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 26px;
}
#poster h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(56px, 13vw, 200px);
  letter-spacing: -0.03em;
  line-height: 0.9;
  background: linear-gradient(180deg, #fff 0%, #ffe6b8 55%, #ff9a5c 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 40px rgba(255, 180, 120, 0.25));
}
#poster .sub {
  margin-top: 30px;
  font-family: "Grotesk", sans-serif; font-weight: 300;
  font-size: clamp(14px, 1.5vw, 19px); color: var(--dim);
  max-width: 34ch; line-height: 1.6;
}

/* custom cursor */
#cursor {
  position: fixed; top: 0; left: 0; z-index: 30;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border: 1px solid rgba(244,240,230,0.5);
  border-radius: 50%;
  pointer-events: none;
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  mix-blend-mode: difference;
}
#cursor.hot { width: 46px; height: 46px; margin: -23px 0 0 -23px; border-color: var(--accent); background: rgba(255,255,255,0.04); }
#cursor .dot {
  position: absolute; top: 50%; left: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  background: var(--paper); border-radius: 50%;
}

/* loader */
#loader {
  position: fixed; inset: 0; z-index: 50; background: var(--ink);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  transition: opacity 0.8s ease;
}
#loader.gone { opacity: 0; pointer-events: none; }
#loader .num {
  font-family: "Fraunces", serif; font-weight: 600;
  font-size: clamp(48px, 9vw, 120px);
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  letter-spacing: -0.02em;
}
#loader .lbl {
  margin-top: 18px; font-family: "Mono", monospace; font-size: 11px;
  letter-spacing: 0.34em; text-transform: uppercase; color: var(--dim);
}

/* end note */
#coda {
  position: fixed; left: 50%; bottom: calc(var(--edge) + 80px);
  transform: translateX(-50%); z-index: 11; text-align: center;
  opacity: 0; transition: opacity 1s ease;
  max-width: 40ch;
}
#coda.show { opacity: 1; }
#coda .q {
  font-family: "Fraunces", serif; font-style: italic; font-weight: 400;
  font-size: clamp(18px, 2vw, 26px); line-height: 1.4; color: var(--paper);
}
#coda .by {
  margin-top: 16px; font-family: "Mono", monospace; font-size: 11px;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--dim);
}

/* mobile fallback note */
#rotate {
  display: none;
  position: fixed; inset: 0; z-index: 60; background: var(--ink);
  align-items: center; justify-content: center; text-align: center; padding: 40px;
  font-family: "Mono", monospace; font-size: 13px; letter-spacing: 0.1em; color: var(--dim);
}

@media (max-width: 760px) {
  #timeline { display: none; }
  .cap { max-width: 82vw; left: 24px; }
  #readout { display: none; }
  :root { --edge: 20px; }
}
