/* ============================================================
   From Summit to Sea — style
   Ink / porcelain / signal orange · Marcellus + Familjen + Fragment
   ============================================================ */

@font-face {
  font-family: 'Marcellus';
  src: url('../assets/fonts/marcellus-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Familjen Grotesk';
  src: url('../assets/fonts/familjen-grotesk-var.woff2') format('woff2-variations');
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fragment Mono';
  src: url('../assets/fonts/fragment-mono-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --ink: #0a1118;
  --ink-80: rgba(10, 17, 24, 0.8);
  --porcelain: #eef3f6;
  --porcelain-60: rgba(238, 243, 246, 0.6);
  --porcelain-35: rgba(238, 243, 246, 0.35);
  --orange: #ff6b35;
  --glass: rgba(7, 14, 22, 0.46);
  --hairline: rgba(238, 243, 246, 0.22);
  --display: 'Marcellus', 'Times New Roman', serif;
  --body: 'Familjen Grotesk', 'Segoe UI', sans-serif;
  --mono: 'Fragment Mono', 'Consolas', monospace;
  --pad: clamp(20px, 4vw, 64px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scrollbar-width: thin; scrollbar-color: rgba(238,243,246,.25) transparent; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
  background: var(--ink);
  color: var(--porcelain);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--orange); color: var(--ink); }

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.display {
  font-family: var(--display);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.display em { font-style: normal; color: var(--orange); }

/* ============ fixed stage & overlays ============ */

#stage { position: fixed; inset: 0; z-index: -1; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* The vignette lives in the render pipeline now (js/post.js), applied before
   tone mapping so it darkens light rather than painting black on top. */

#grain {
  position: fixed; inset: -100px; z-index: 60; pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-38px, 24px); }
  50% { transform: translate(22px, -30px); }
  75% { transform: translate(-14px, -18px); }
  100% { transform: translate(30px, 12px); }
}

/* ============ loader ============ */

#loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--ink);
  display: grid; place-items: center;
  transition: opacity 0.55s ease 0.05s, visibility 0.55s ease 0.05s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; width: min(360px, 72vw); }
.loader-mark {
  font-family: var(--display); font-size: 54px; color: var(--orange);
  line-height: 1; margin-bottom: 10px;
  letter-spacing: 0.08em;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.loader-word {
  font-family: var(--display); font-size: 22px; letter-spacing: 0.42em;
  text-indent: 0.42em; margin-bottom: 34px;
}
.loader-bar {
  height: 1px; background: var(--hairline); margin-bottom: 14px; overflow: hidden;
}
#loader-fill {
  display: block; height: 100%; width: 0%;
  background: var(--orange); transition: width 0.3s ease;
}
.loader-status { color: var(--porcelain-60); font-size: 10px; }

/* ============ chrome ============ */

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--pad);
  mix-blend-mode: normal;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--porcelain); text-decoration: none;
}
.brand-index { color: var(--orange); font-size: 9px; }
.brand-word {
  font-family: var(--display); font-size: 15px; letter-spacing: 0.26em;
}
.topnav { display: flex; gap: clamp(16px, 3vw, 42px); }
.topnav a {
  color: var(--porcelain-60); text-decoration: none;
  transition: color 0.3s ease; position: relative; padding-bottom: 4px;
}
.topnav a::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 1px; width: 0;
  background: var(--orange); transition: width 0.35s ease;
}
.topnav a:hover, .topnav a.active { color: var(--porcelain); }
.topnav a:hover::after, .topnav a.active::after { width: 100%; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.aircraft-picker {
  display: flex; align-items: center; gap: 2px;
  padding: 3px; border: 1px solid var(--hairline); border-radius: 999px;
  background: rgba(7, 14, 22, 0.3);
  backdrop-filter: blur(12px);
}
.picker-label { color: var(--porcelain-35); padding: 0 8px 0 10px; font-size: 9px; }
.aircraft-picker button {
  border: 0; border-radius: 999px; background: transparent;
  color: var(--porcelain-60); padding: 7px 10px; cursor: pointer;
  font: inherit; font-size: 9px; letter-spacing: 0.12em;
  transition: color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}
.aircraft-picker button:hover { color: var(--porcelain); }
.aircraft-picker button.active {
  color: var(--ink); background: var(--orange); transform: translateY(-1px);
}
.aircraft-picker button:focus-visible,
#sound-toggle:focus-visible,
.cta:focus-visible,
.topnav a:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 3px;
}

#sound-toggle {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 1px solid var(--hairline); border-radius: 999px;
  color: var(--porcelain-60); padding: 8px 12px; cursor: pointer;
  backdrop-filter: blur(12px); background: rgba(7, 14, 22, 0.3);
  transition: color 0.3s, border-color 0.3s;
}
#sound-toggle:hover { color: var(--porcelain); border-color: var(--porcelain-35); }
#sound-toggle .bars { display: flex; align-items: flex-end; gap: 2px; height: 10px; }
#sound-toggle .bars i {
  width: 2px; height: 100%; background: currentColor; transform: scaleY(0.25);
  transform-origin: bottom; transition: transform 0.3s;
}
#sound-toggle[aria-pressed="true"] { color: var(--orange); border-color: var(--orange); }
#sound-toggle[aria-pressed="true"] .bars i { animation: eq 0.9s ease-in-out infinite; }
#sound-toggle[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: 0.15s; }
#sound-toggle[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: 0.3s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.25); } 50% { transform: scaleY(1); } }

#dots {
  position: fixed; right: clamp(14px, 2.4vw, 34px); top: 50%; z-index: 50;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 14px;
}
#dots button {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid var(--porcelain-35); background: transparent;
  cursor: pointer; padding: 0;
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}
#dots button:hover { border-color: var(--porcelain); }
#dots button.active {
  background: var(--orange); border-color: var(--orange); transform: scale(1.25);
}

#hud {
  position: fixed; right: var(--pad); bottom: 26px; z-index: 50;
  display: flex; flex-direction: column; gap: 5px; align-items: flex-end;
  font-size: 10px; letter-spacing: 0.14em; color: var(--porcelain-60);
  text-shadow: 0 1px 10px rgba(5, 9, 14, 0.7);
}
.hud-row { display: flex; gap: 12px; }
.hud-key { color: var(--orange); width: 34px; }
.hud-val { min-width: 72px; text-align: right; }

/* wildlife call-out, bottom left above the scroll hint */
#sighting {
  position: fixed; left: var(--pad); bottom: 72px; z-index: 50;
  max-width: 60vw;
  color: var(--porcelain); font-size: 10px;
  padding-left: 13px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}
#sighting::before {
  content: ''; position: absolute; left: 0; top: 5px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 0 0 rgba(255, 90, 31, 0.55);
  animation: ping 1.8s ease-out infinite;
}
#sighting.on { opacity: 1; transform: translateY(0); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 31, 0.5); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(255, 90, 31, 0); }
}

/* pointer-interaction hint */
#cursor-hint {
  position: fixed; left: 50%; bottom: 62px; z-index: 50;
  transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 9px;
  color: var(--porcelain-35); font-size: 10px;
  opacity: 0; transition: opacity 0.8s ease, transform 0.8s ease;
  pointer-events: none; white-space: nowrap;
}
#cursor-hint.on { opacity: 1; transform: translate(-50%, 0); }
.hint-dot {
  width: 5px; height: 5px; border-radius: 50%;
  border: 1px solid var(--porcelain-35);
  animation: hintdot 2.4s ease-in-out infinite;
}
@keyframes hintdot {
  0%, 100% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
}

#progress {
  position: fixed; left: 50%; bottom: 30px; z-index: 50;
  width: min(220px, 26vw); height: 1px; transform: translateX(-50%);
  background: var(--hairline);
}
#progress-fill {
  display: block; height: 100%; width: 0%; background: var(--orange);
}

/* ============ chapters ============ */

main { position: relative; z-index: 10; }

.chapter { position: relative; height: 240vh; }
.chapter.hero { height: 190vh; }
.chapter.footer-ch { height: 170vh; }

.pin {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--pad);
  overflow: hidden;
}

/* hero */
.hero .pin { align-items: flex-start; justify-content: center; width: min(48vw, 720px); }
.kicker { color: var(--orange); margin-bottom: 3.2vh; }
.hero-title {
  font-size: clamp(54px, 8.2vw, 122px);
  margin-left: -0.04em;
  max-width: 6.2em;
}
.hero-title .line { display: block; }
.hero-sub {
  margin-top: 3.6vh; max-width: 25em;
  color: var(--porcelain-60); font-size: clamp(15px, 1.4vw, 19px);
}
.hero .kicker, .hero-sub {
  padding: 8px 12px; margin-left: -12px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(5, 10, 16, 0.42), rgba(5, 10, 16, 0));
  backdrop-filter: blur(2px);
}
.scroll-hint {
  position: absolute; bottom: 34px; left: var(--pad);
  display: flex; align-items: center; gap: 14px; color: var(--porcelain-60);
}
.hint-line {
  display: block; width: 52px; height: 1px; background: var(--orange);
  animation: hint 2.2s ease-in-out infinite; transform-origin: left;
}
@keyframes hint { 0%, 100% { transform: scaleX(0.35); } 50% { transform: scaleX(1); } }

/* chapter grids */
.ch-grid {
  display: grid; grid-template-columns: repeat(12, 1fr);
  column-gap: clamp(12px, 2vw, 32px); row-gap: 4.5vh;
  align-content: center;
}
.ch-no { display: block; color: var(--orange); margin-bottom: 2.2vh; }
.ch-grid h2 { font-size: clamp(42px, 5.7vw, 88px); }
.ch-head { grid-row: 1; }
.ch-body { grid-row: 2; max-width: 23em; }
.ch-grid.right .ch-head, .ch-grid.right .ch-body { grid-column: 9 / 13; }
.ch-grid.left .ch-head, .ch-grid.left .ch-body { grid-column: 1 / 5; }
.ch-grid.center { text-align: left; }
.ch-grid.center .ch-head, .ch-grid.center .ch-body { grid-column: 1 / 5; justify-self: start; }

.lede {
  font-size: clamp(19px, 2vw, 25px); line-height: 1.4;
  margin-bottom: 2.6vh; letter-spacing: -0.01em;
}
.ch-body p:not(.lede):not(.fig) { color: rgba(238, 243, 246, 0.76); margin-bottom: 2.6vh; }
.fig { color: var(--orange); }

.ch-head, .ch-body {
  width: fit-content;
  padding: clamp(12px, 1.4vw, 18px);
  margin: clamp(-12px, -1.4vw, -18px);
  border-radius: 8px;
  background: linear-gradient(110deg, rgba(5, 10, 16, 0.42), rgba(5, 10, 16, 0.1) 72%, transparent);
  backdrop-filter: blur(2px);
}
.ch-grid.right .ch-head, .ch-grid.right .ch-body {
  background: linear-gradient(250deg, rgba(5, 10, 16, 0.42), rgba(5, 10, 16, 0.1) 72%, transparent);
}
.ch-grid.center .ch-head, .ch-grid.center .ch-body {
  background: linear-gradient(110deg, rgba(5, 10, 16, 0.42), rgba(5, 10, 16, 0.1) 72%, transparent);
}

/* readability scrim behind text columns */
.ch-grid.right::before, .ch-grid.left::before, .ch-grid.center::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
}
.ch-grid.right::before {
  background: radial-gradient(ellipse 38% 68% at 86% 50%, rgba(6, 11, 17, 0.32), transparent 74%);
}
.ch-grid.left::before {
  background: radial-gradient(ellipse 38% 68% at 14% 50%, rgba(6, 11, 17, 0.32), transparent 74%);
}
.ch-grid.center::before {
  background: radial-gradient(ellipse 38% 68% at 14% 50%, rgba(6, 11, 17, 0.32), transparent 74%);
}
.ch-grid { position: relative; }

/* The scrim alone cannot carry the copy over the sun's glitter path, which is
   the brightest thing in the frame and lands right behind chapter three. A soft
   shadow makes the type legible against anything without dimming the render. */
.ch-grid h2, .ch-grid p, .ch-no,
.hero-title, .hero-sub, .kicker,
.footer-title, .footer-meta, .scroll-hint {
  text-shadow: 0 1px 14px rgba(5, 9, 14, 0.55), 0 0 3px rgba(5, 9, 14, 0.5);
}

/* footer */
.footer-ch .pin { justify-content: center; text-align: center; align-items: center; }
/* The closing panel carries more copy than any other and it has to fit inside
   one viewport, because .pin clips at 100vh. Sized down from the chapter
   headings accordingly — and the meta line flows after the button rather than
   being pinned to the bottom, where a tall block would run straight over it. */
.footer-title { font-size: clamp(40px, 7.2vw, 104px); line-height: 0.94; }

/* The chapters each get a scrim on the side their column sits on. The footer is
   centred, and it lands on the last frame of the route — low sun, full glitter
   path, the brightest thing in the whole piece directly behind centred body
   copy. It needs its own scrim, and a stronger one. */
.footer-inner { position: relative; }
.footer-inner::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  inset: -14vh -8vw;
  background: radial-gradient(ellipse 62% 58% at 50% 48%,
    rgba(4, 8, 13, 0.80), rgba(4, 8, 13, 0.52) 46%, rgba(4, 8, 13, 0.16) 72%, transparent 88%);
}
.footer-about {
  max-width: 46em; margin: 2.2vh auto 0;
  padding: clamp(9px, 1vw, 14px) clamp(14px, 1.6vw, 24px);
  border-radius: 8px;
  background: rgba(5, 10, 16, 0.46);
  backdrop-filter: blur(3px);
  color: rgba(240, 245, 248, 0.88);
  font-size: clamp(13px, 1.12vw, 17px); line-height: 1.5;
}
.footer-about + .footer-about { margin-top: 1.2vh; }
.footer-ch .kicker {
  padding: 8px 14px; border-radius: 4px;
  background: rgba(5, 10, 16, 0.42); backdrop-filter: blur(3px);
}
.footer-about, .cta, .footer-ch .kicker {
  text-shadow: 0 1px 14px rgba(5, 9, 14, 0.55), 0 0 3px rgba(5, 9, 14, 0.5);
}
.cta { background: rgba(5, 10, 16, 0.42); backdrop-filter: blur(3px); }
.cta {
  display: inline-block; margin-top: 2.8vh;
  font-family: var(--mono); font-size: clamp(11px, 1.15vw, 14px); letter-spacing: 0.22em;
  color: var(--porcelain); text-decoration: none;
  border: 1px solid var(--porcelain-35); border-radius: 999px;
  padding: 14px 28px;
  transition: background 0.35s, color 0.35s, border-color 0.35s;
}
.cta:hover { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.footer-meta {
  margin-top: 2.8vh;
  display: flex; justify-content: center; gap: clamp(8px, 1.4vw, 18px); flex-wrap: wrap;
  color: rgba(238, 243, 246, 0.72); font-size: 10px;
}
.footer-meta span {
  padding: 6px 12px; border-radius: 999px;
  background: rgba(5, 10, 16, 0.46); backdrop-filter: blur(3px);
}

/* ============ responsive ============ */

@media (max-width: 860px) {
  .hero .pin { width: 100%; }
  .topnav { display: none; }
  #dots { display: none; }
  .ch-grid.right .ch-head, .ch-grid.right .ch-body,
  .ch-grid.left .ch-head, .ch-grid.left .ch-body,
  .ch-grid.center .ch-head, .ch-grid.center .ch-body { grid-column: 1 / 13; }
  .ch-grid.center { text-align: left; }
  .ch-grid::before { background: radial-gradient(ellipse 90% 80% at 50% 50%, rgba(6,11,17,.5), transparent 75%) !important; }
  #hud, #cursor-hint, .picker-label, .sound-label { display: none; }
  #topbar { padding-top: 14px; }
  .brand-index { display: none; }
  .brand-word { font-size: 13px; letter-spacing: 0.18em; }
  .top-actions { gap: 6px; }
  .aircraft-picker button { padding: 7px 8px; font-size: 8px; }
  #sound-toggle { padding: 9px; }
  #sighting { bottom: 66px; max-width: 78vw; }
  .chapter { height: 200vh; }
}

@media (max-width: 520px) {
  .brand-word { width: 58px; line-height: 1.15; }
  .hero-title { font-size: clamp(54px, 19vw, 88px); }
  .hero-sub br { display: none; }
  .ch-head, .ch-body { padding: 12px; margin: -12px; }
  .footer-about { font-size: 15px; }
}

/* ============ reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .hint-line { animation: none; }
  .loader-mark { animation: none; }
  html { scroll-behavior: auto; }
}
