/* ═══════════════════════════════════════════════════════════════
   MERIDIAN — From Summit to Sea
   Typography: Jost (variable 100–400) + Cormorant Garamond 300
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Jost';
  src: url('fonts/jost-latin-var.woff2') format('woff2');
  font-weight: 100 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-garamond-300.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-garamond-300-italic.woff2') format('woff2');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

:root {
  /* ink shifts with the descent — driven from JS each frame */
  --ink: #efe9dd;
  --ink-dim: rgba(239, 233, 221, .62);
  --hair: rgba(239, 233, 221, .28);
  --accent: #d8b98a;
  --bg: #0b1016;
  --shadow: 0 0 24px rgba(8, 12, 18, .35);
  --nav-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* no-WebGL / context-loss: the story flows as a plain readable page */
body.fallback #story { position: relative; z-index: 2; }
body.fallback .s {
  position: relative; inset: auto; visibility: visible;
  min-height: 60vh; padding: 12vh clamp(22px, 8vw, 120px);
}
body.fallback .reveal { opacity: 1 !important; transform: none !important; filter: none !important; }
body.fallback #instrument, body.fallback #cue { display: none; }

html { scrollbar-width: thin; scrollbar-color: rgba(140, 146, 150, .5) transparent; }
/* the gutter shows page background — keep it a scene-neutral grey so
   no dark frame edges the shots (the loader covers boot anyway) */
html, body { background: #8d969c; }

body {
  font-family: 'Jost', 'Avenir Next', 'Segoe UI', sans-serif;
  font-weight: 300;
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(216, 185, 138, .35); color: #fff; }

.serif { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 300; }

/* ── skip link ─────────────────────────────────────────────── */
.skip-link {
  position: fixed; top: -48px; left: 16px; z-index: 60;
  background: #10161d; color: #efe9dd; padding: 10px 18px;
  font-size: 12px; letter-spacing: .2em; text-decoration: none;
  transition: top .2s ease;
}
.skip-link:focus-visible { top: 12px; }

/* ── canvas ────────────────────────────────────────────────── */
#stage {
  position: fixed; inset: 0; width: 100%; height: 100dvh;
  display: block; z-index: 0;
}
#fallback {
  position: fixed; inset: 0; z-index: 1;
  display: grid; place-items: center; text-align: center;
  background:
    linear-gradient(180deg, #16233a 0%, #58627a 34%, #c8cdd2 52%, #7f8d94 60%, #35434a 100%);
  color: #f0ece2; font-size: 15px; letter-spacing: .08em; line-height: 2;
  padding: 2rem;
}

/* ── loader ────────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; z-index: 50;
  background: #0b1016;
  display: grid; place-items: center;
  overflow: hidden;
  transition: opacity 1.1s cubic-bezier(.6, 0, .3, 1), visibility 1.1s;
}
#loader.done { opacity: 0; visibility: hidden; pointer-events: none; }

/* generated dawn footage breathes behind the boot sequence */
.ambient-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .34;
  filter: saturate(.85) brightness(.85);
}
#loader .loader-inner { position: relative; z-index: 1; }
#loader::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 46%, transparent 20%, rgba(8, 12, 20, .55) 78%);
  pointer-events: none;
}
#fallback .ambient-video { opacity: .3; }
#fallback p { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .ambient-video { display: none; }
}
.loader-inner { width: min(420px, 72vw); text-align: center; }
.loader-mark {
  font-weight: 120; font-size: 15px; letter-spacing: .58em; text-indent: .58em;
  color: #efe9dd; margin-bottom: 34px; opacity: .92;
}
.loader-line {
  height: 1px; background: rgba(239,233,221,.14); position: relative; overflow: hidden;
}
#loader-fill {
  position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, #b98d54, #ecd7b0);
  transition: transform .35s cubic-bezier(.3, 0, .2, 1);
}
#loader.done .loader-line { overflow: visible; }
.loader-meta {
  display: flex; justify-content: space-between; margin-top: 14px;
  font-size: 10px; letter-spacing: .34em; color: rgba(239,233,221,.5);
  font-variant-numeric: tabular-nums;
}
#loader-pct { color: #d8b98a; }

/* ── chrome: nav ───────────────────────────────────────────── */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 56px);
  opacity: 0; transform: translateY(-8px);
  transition: opacity 1.4s ease .2s, transform 1.4s ease .2s;
  pointer-events: none;
}
body.live #nav { opacity: 1; transform: none; pointer-events: auto; }

.nav-mark {
  font-weight: 200; font-size: 15px; letter-spacing: .5em;
  color: var(--ink); text-decoration: none; text-shadow: var(--shadow);
  display: flex; align-items: baseline; gap: 10px;
}
.nav-mark-sub { font-size: 8px; letter-spacing: .5em; color: var(--ink-dim); }

.nav-links { display: flex; gap: clamp(18px, 2.6vw, 40px); }
.nav-links a {
  font-size: 11px; font-weight: 300; letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-dim); text-decoration: none; text-shadow: var(--shadow);
  padding: 6px 2px; position: relative; transition: color .35s ease;
}
.nav-links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: 0;
  height: 1px; background: var(--accent); transition: right .4s cubic-bezier(.3,0,.2,1);
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--ink); }
.nav-links a:hover::after, .nav-links a:focus-visible::after { right: 0; }

.nav-right { display: flex; align-items: center; gap: 22px; }
#sound-toggle, #menu-toggle {
  background: none; border: 0; cursor: pointer; color: var(--ink-dim);
  font: inherit; font-size: 11px; letter-spacing: .3em;
  display: flex; align-items: center; gap: 9px;
  min-height: 44px; padding: 8px 6px;
  transition: color .35s ease; text-shadow: var(--shadow);
}
#sound-toggle:hover, #menu-toggle:hover,
#sound-toggle:focus-visible, #menu-toggle:focus-visible { color: var(--ink); }
.st-bars { display: flex; align-items: flex-end; gap: 2px; height: 10px; }
.st-bars i {
  width: 1.5px; height: 3px; background: currentColor; opacity: .85;
  transition: height .3s ease;
}
#sound-toggle[aria-pressed="true"] .st-bars i { animation: eq 1.1s ease-in-out infinite; }
#sound-toggle[aria-pressed="true"] .st-bars i:nth-child(2) { animation-delay: .18s; }
#sound-toggle[aria-pressed="true"] .st-bars i:nth-child(3) { animation-delay: .36s; }
#sound-toggle[aria-pressed="true"] .st-bars i:nth-child(4) { animation-delay: .54s; }
@keyframes eq { 0%, 100% { height: 3px } 50% { height: 10px } }
#menu-toggle { display: none; }

/* ── mobile menu ───────────────────────────────────────────── */
#menu {
  position: fixed; inset: 0; z-index: 28;
  background: rgba(9, 13, 18, .92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility .5s;
}
#menu.open { opacity: 1; visibility: visible; }
#menu nav { display: grid; gap: 6vh; text-align: center; }
#menu a {
  font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic;
  font-size: clamp(28px, 7vw, 44px); color: #efe9dd; text-decoration: none;
  display: flex; align-items: baseline; gap: 18px; justify-content: center;
}
#menu a i { font-family: 'Jost', sans-serif; font-style: normal; font-size: 11px; letter-spacing: .3em; color: rgba(239,233,221,.45); }

/* ── instrument (altimeter) ────────────────────────────────── */
#instrument {
  position: fixed; right: clamp(18px, 3.4vw, 48px); top: 50%; z-index: 26;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  opacity: 0; transition: opacity 1.2s ease .6s;
  text-shadow: 0 1px 22px rgba(10, 14, 20, .55), 0 0 6px rgba(10, 14, 20, .25);
}
body.live #instrument { opacity: 1; }
.inst-ruler {
  width: 22px; height: 34vh; max-height: 300px;
  background-image:
    repeating-linear-gradient(to bottom, var(--hair) 0 1px, transparent 1px 14px),
    linear-gradient(to right, transparent 12px, transparent 12px);
  background-position: 0 var(--ruler-y, 0px);
  mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
  position: relative;
}
.inst-ruler::after {
  content: ''; position: absolute; top: 50%; right: 0; width: 30px; height: 1px;
  background: var(--accent);
}
.inst-read {
  display: flex; align-items: baseline; gap: 6px;
  font-variant-numeric: tabular-nums;
}
#inst-value { font-size: 21px; font-weight: 200; letter-spacing: .14em; }
#inst-unit { font-size: 10px; letter-spacing: .3em; color: var(--ink-dim); }
.inst-tag { font-size: 8.5px; letter-spacing: .42em; color: var(--ink-dim); }
#instrument.static { animation: static-flicker .32s steps(2) infinite; }
@keyframes static-flicker { 0% { opacity: .55 } 50% { opacity: .9 } 100% { opacity: .62 } }

/* ── scroll cue ────────────────────────────────────────────── */
#cue {
  position: fixed; left: 50%; bottom: 34px; z-index: 26;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  opacity: 0; transition: opacity 1.4s ease 1s;
  text-shadow: var(--shadow);
}
body.live #cue { opacity: 1; }
body.live #cue.gone { opacity: 0; transition: opacity .6s ease; }
.cue-text { font-size: 9.5px; letter-spacing: .5em; text-indent: .5em; color: var(--ink-dim); }
.cue-line { width: 1px; height: 52px; background: var(--hair); overflow: hidden; display: block; }
.cue-line i { display: block; width: 100%; height: 40%; background: var(--accent); animation: cue-drop 2.2s cubic-bezier(.6, 0, .3, 1) infinite; }
@keyframes cue-drop { 0% { transform: translateY(-120%) } 60%, 100% { transform: translateY(280%) } }

/* ── story sections ────────────────────────────────────────── */
#story { position: relative; z-index: 10; pointer-events: none; }
#story a, #story button { pointer-events: auto; }

.s {
  position: fixed; inset: 0; padding: calc(var(--nav-h) + 2vh) clamp(22px, 6vw, 96px) 8vh;
  display: flex; flex-direction: column; justify-content: center;
  visibility: hidden;
}
.s.on { visibility: visible; }

.reveal { opacity: 0; will-change: opacity, transform, filter; }

/* hero — type lives in the sky, the peak owns the lower frame */
#top { align-items: center; text-align: center; justify-content: flex-start; padding-top: calc(var(--nav-h) + 7vh); }
#top .over { order: 1; }
#top .wordmark { order: 2; }
#top .tagline { order: 3; }

.over {
  font-size: clamp(8.5px, 1vw, 10.5px); letter-spacing: .46em; text-indent: .46em;
  color: var(--ink-dim); text-shadow: var(--shadow);
}
.wordmark {
  margin: 4vh 0 2.5vh;
  font-size: clamp(34px, 11.5vw, 158px);
  font-weight: 108;
  letter-spacing: .3em; text-indent: .3em;
  line-height: 1;
  color: var(--ink); text-shadow: 0 2px 44px rgba(10, 14, 20, .4);
  display: flex; justify-content: center;
}
.wordmark span { display: inline-block; }
.tagline {
  font-style: italic; font-size: clamp(21px, 2.6vw, 30px);
  color: #fdfaf3;
  text-shadow: 0 1px 10px rgba(28, 24, 36, .5), 0 1px 3px rgba(28, 24, 36, .35);
}
#top .over {
  color: #f6f1e6;
  text-shadow: 0 1px 8px rgba(28, 24, 36, .5), 0 1px 3px rgba(28, 24, 36, .35);
}

/* per-word entrance: the line assembles itself out of the air.
   --lp (local progress) is written once per frame by JS; each word
   computes its own lag in CSS. */
.statement .w {
  display: inline-block;
  opacity: clamp(0, calc((var(--lp, 0) - var(--wi, 0) * 0.05) * 4), 1);
  transform: translateY(calc((1 - clamp(0, calc((var(--lp, 0) - var(--wi, 0) * 0.05) * 4), 1)) * 0.32em));
}
@media (prefers-reduced-motion: reduce) {
  .statement .w { opacity: 1; transform: none; }
}

/* magnetic controls drift toward the hand */
.mag { transition: transform .45s cubic-bezier(.22, .9, .3, 1); will-change: transform; }
.mag.mag-live { transition: transform .06s linear; }

/* statements */
.statement {
  font-style: italic; font-weight: 300;
  font-size: clamp(34px, 5.4vw, 66px);
  line-height: 1.18; letter-spacing: .01em;
  text-shadow: 0 2px 34px rgba(10, 14, 20, .35);
  max-width: 14em;
}
.sub {
  margin-top: 3.2vh; font-size: clamp(12px, 1.25vw, 15px); font-weight: 300;
  letter-spacing: .12em; line-height: 2.1; color: var(--ink-dim);
  text-shadow: var(--shadow); max-width: 44em;
}

#mission, #below { align-items: flex-start; text-align: left; }
#closing { align-items: center; text-align: center; }

/* divisions */
.div-s { align-items: flex-start; justify-content: center; }
.div-s:nth-of-type(even) { align-items: flex-end; text-align: right; }
.div-no {
  font-size: 11px; letter-spacing: .5em; color: var(--accent);
  margin-bottom: 2.2vh; text-shadow: var(--shadow);
}
.div-name {
  font-size: clamp(38px, 7vw, 92px); font-weight: 130;
  letter-spacing: .24em; text-indent: .24em; line-height: 1;
  text-shadow: 0 2px 40px rgba(10, 14, 20, .4);
}
.div-line {
  font-style: italic; font-size: clamp(17px, 2vw, 24px);
  margin-top: 2.4vh; color: var(--ink); opacity: .9; text-shadow: var(--shadow);
}
.div-stat {
  margin-top: 4vh; font-size: 11px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--ink-dim); text-shadow: var(--shadow);
  display: inline-flex; align-items: baseline; gap: 12px;
}
.div-stat b { font-weight: 300; font-size: 21px; letter-spacing: .14em; color: var(--ink); font-variant-numeric: tabular-nums; text-transform: none; }
.div-stat::before { content: ''; width: 44px; height: 1px; background: var(--hair); align-self: center; }

/* seam */
#seam { align-items: center; text-align: center; }
.seam-line {
  font-size: clamp(10px, 1.3vw, 13px); font-weight: 300;
  letter-spacing: .62em; text-indent: .62em; color: var(--ink);
  text-shadow: none;
}

/* contact */
#contact { align-items: center; text-align: center; }
.cta {
  margin-top: 5.5vh; pointer-events: auto;
  font-size: 11.5px; letter-spacing: .42em; text-indent: .42em;
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--hair); padding: 19px 34px 17px;
  position: relative; overflow: hidden; transition: color .45s ease, border-color .45s ease;
}
.cta::before {
  content: ''; position: absolute; inset: 0; transform: scaleX(0); transform-origin: 0 50%;
  background: rgba(239, 233, 221, .96); transition: transform .5s cubic-bezier(.3, 0, .2, 1);
  z-index: -1;
}
.cta:hover, .cta:focus-visible { color: #10161d; border-color: rgba(239,233,221,.8); }
.cta:hover::before, .cta:focus-visible::before { transform: scaleX(1); }

/* footer */
#footer { justify-content: flex-end; padding-bottom: 4.5vh; gap: 5vh; }
#footer::before {
  content: ''; position: absolute; inset: 30% 0 0 0; z-index: -1;
  background: linear-gradient(180deg, transparent, rgba(14, 24, 30, .42) 70%, rgba(12, 20, 26, .58));
}
.foot-top { display: flex; flex-direction: column; gap: 8px; }
body.live #instrument.retired { opacity: 0; transition: opacity .8s ease; }
.foot-mark { font-size: clamp(30px, 4.6vw, 58px); font-weight: 120; letter-spacing: .4em; text-shadow: var(--shadow); }
.foot-tag { font-style: italic; font-size: clamp(15px, 1.7vw, 21px); color: var(--ink-dim); }
.foot-cols {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4vw; padding-top: 4vh; border-top: 1px solid var(--hair);
  max-width: 760px;
}
.foot-cols h3 { font-size: 9px; font-weight: 400; letter-spacing: .4em; color: var(--ink-dim); margin-bottom: 16px; }
.foot-cols a, .foot-cols span {
  display: block; font-size: 12.5px; font-weight: 300; letter-spacing: .14em;
  color: var(--ink); text-decoration: none; padding: 6px 0; opacity: .8;
}
.foot-cols a:hover, .foot-cols a:focus-visible { opacity: 1; color: var(--accent); }
.foot-base {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px;
  font-size: 9px; letter-spacing: .3em; color: var(--ink-dim);
}
#to-top {
  background: none; border: 0; cursor: pointer; color: var(--ink-dim);
  font: inherit; font-size: 9px; letter-spacing: .3em;
  min-height: 44px; padding: 8px 0;
  transition: color .3s ease;
}
#to-top:hover, #to-top:focus-visible { color: var(--ink); }

/* ── division deep-dives ───────────────────────────────────── */
.div-more {
  margin-top: 3vh; pointer-events: auto;
  background: none; border: 0; cursor: pointer; color: var(--ink-dim);
  font: inherit; font-size: 10px; letter-spacing: .34em;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 8px 0;
  transition: color .3s ease;
}
.div-more span { transition: transform .3s cubic-bezier(.3, 0, .2, 1); }
.div-more:hover, .div-more:focus-visible { color: var(--ink); }
.div-more:hover span { transform: translateX(6px); }

#panel {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(9, 14, 19, .93);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: opacity .55s cubic-bezier(.3, 0, .2, 1), visibility .55s;
}
#panel.open { opacity: 1; visibility: visible; }
#panel article {
  width: min(720px, 86vw); color: #efe9dd;
}
#panel .pn {
  font-size: 10px; letter-spacing: .5em; color: #d8b98a; margin-bottom: 3.5vh;
}
#panel h2 {
  font-style: italic; font-weight: 300;
  font-size: clamp(30px, 4.6vw, 54px); line-height: 1.16;
  margin-bottom: 3.5vh;
}
#panel .pl {
  font-size: clamp(13px, 1.3vw, 15.5px); font-weight: 300;
  letter-spacing: .06em; line-height: 2; color: rgba(239, 233, 221, .78);
  max-width: 54ch; margin-bottom: 5vh;
}
#panel dl {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3vw;
  border-top: 1px solid rgba(239, 233, 221, .2); padding-top: 3.5vh;
}
#panel dt {
  font-size: clamp(20px, 2.2vw, 27px); font-weight: 200;
  letter-spacing: .1em; font-variant-numeric: tabular-nums;
}
#panel dd {
  margin-top: 8px; font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: rgba(239, 233, 221, .55); line-height: 1.7;
}
#panel-close {
  position: absolute; top: 26px; right: clamp(22px, 4vw, 54px);
  background: none; border: 0; cursor: pointer; color: rgba(239, 233, 221, .6);
  font: inherit; font-size: 11px; letter-spacing: .32em;
  min-height: 44px; padding: 8px;
  transition: color .3s ease;
}
#panel-close:hover, #panel-close:focus-visible { color: #efe9dd; }
#panel article { animation: panel-in .7s cubic-bezier(.22, .9, .28, 1) both; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  #panel dl { grid-template-columns: 1fr; gap: 3vh; }
}
@media (prefers-reduced-motion: reduce) {
  #panel article { animation: none; }
}

/* ── cursor ────────────────────────────────────────────────── */
#cursor {
  position: fixed; z-index: 70; width: 7px; height: 7px; border-radius: 50%;
  background: #efe9dd; mix-blend-mode: difference;
  pointer-events: none; top: 0; left: 0; opacity: 0;
  transition: opacity .4s ease, width .25s ease, height .25s ease;
  transform: translate(-50%, -50%);
}
body.has-cursor #cursor { opacity: .9; }
body.has-cursor.cursor-link #cursor { width: 30px; height: 30px; background: transparent; border: 1px solid #efe9dd; }
@media (hover: none) { #cursor { display: none; } }

/* ── focus ─────────────────────────────────────────────────── */
:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
:focus:not(:focus-visible) { outline: none; }

/* ── responsive ────────────────────────────────────────────── */
@media (max-width: 860px) {
  :root { --nav-h: 60px; }
  .nav-links { display: none; }
  #menu-toggle { display: flex; }
  .nav-mark-sub { display: none; }
  .st-label { display: none; }
  #instrument { right: max(12px, env(safe-area-inset-right)); padding-right: 2px; }
  .inst-ruler { height: 22vh; width: 14px; }
  #inst-value { font-size: 16px; }
  .wordmark { letter-spacing: .22em; text-indent: .22em; }
  .bp { display: none; }
  .sub { line-height: 1.9; padding-right: 76px; }
  .statement { padding-right: 34px; }
  .div-stat { padding-right: 60px; }
  .div-s, .div-s:nth-of-type(even) { align-items: flex-start; text-align: left; }
  .foot-cols { grid-template-columns: 1fr 1fr; }
  .foot-base { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .cue-line i { animation: none; transform: translateY(60%); }
  #instrument.static { animation: none; opacity: .7; }
  html { scroll-behavior: auto; }
}
