:root {
  --ink: #f4efe8;
  --ink-dim: rgba(244, 239, 232, 0.72);
  --serif: 'Instrument Serif', 'Times New Roman', Georgia, serif;
  --sans: 'Manrope', 'Helvetica Neue', Arial, sans-serif;
  --gutter: clamp(20px, 5vw, 72px);
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  background: #0d1522;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The page is one tall scroll track; everything visible is fixed. */
#track { height: 1400vh; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- opening: three aerial stills, pushed in and cross-faded by scroll --- */
#aerial {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
#aerial img {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
  object-position: 50% 45%;
  opacity: 0;
  transform-origin: 50% 55%;
  will-change: transform, opacity;
}
#aerial::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(8, 16, 26, 0.5) 0%, rgba(8, 16, 26, 0.18) 45%, rgba(8, 16, 26, 0) 70%),
    linear-gradient(180deg, rgba(8, 16, 26, 0.3), rgba(8, 16, 26, 0) 30%);
}

/* --- final sea footage, frames cross-faded by scroll --- */
#sea {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
#sea img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 50%;
  opacity: 0;
}

/* --- film texture --- */
#grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: 0.07;
  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 values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(3) infinite;
  mix-blend-mode: soft-light;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(5, 8, 14, 0.42) 100%);
}

/* --- fixed chrome: deliberately almost nothing --- */
#wordmark {
  position: fixed;
  top: var(--gutter);
  left: var(--gutter);
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.04em;
  z-index: 5;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.25);
}
#stage {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 5;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-align: right;
}
#stage span { display: inline-block; transition: opacity 0.5s ease, transform 0.5s ease; }
#stage.swap span { opacity: 0; transform: translateY(6px); }
#stage i { font-style: normal; opacity: 0.55; margin-right: 0.8em; }

#line {
  position: fixed;
  right: calc(var(--gutter) / 2);
  top: 50%;
  width: 1px;
  height: 36vh;
  transform: translateY(-50%);
  background: rgba(244, 239, 232, 0.18);
  z-index: 5;
}
#line i {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 0%;
  background: var(--ink);
}

/* --- floating captions --- */
#captions { position: fixed; inset: 0; pointer-events: none; z-index: 4; }

.cap {
  position: absolute;
  max-width: min(560px, calc(100vw - 2 * var(--gutter)));
  opacity: 0;
  filter: blur(var(--blur, 0px));
  transform: translateY(var(--dy, 0px));
  will-change: opacity, transform, filter;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.28);
}
.cap.tl { top: calc(var(--gutter) + 56px); left: var(--gutter); }
.cap.tr { top: calc(var(--gutter) + 56px); right: var(--gutter); text-align: right; }
.cap.bl { bottom: calc(var(--gutter) + 72px); left: var(--gutter); }
.cap.br { bottom: calc(var(--gutter) + 72px); right: var(--gutter); text-align: right; }
.cap.cl { top: 50%; left: var(--gutter); transform: translateY(calc(-50% + var(--dy, 0px))); }
.cap.cr { top: 50%; right: var(--gutter); text-align: right; transform: translateY(calc(-50% + var(--dy, 0px))); }
.cap.c  { top: 50%; left: 50%; text-align: center; transform: translate(-50%, calc(-50% + var(--dy, 0px))); }

.cap .over {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 14px;
}
.cap .title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 4.4vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  white-space: pre-line;
}
.cap.hero .title { font-size: clamp(44px, 6.4vw, 96px); }
.cap .body {
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.55;
  color: var(--ink-dim);
  margin: 0;
  white-space: pre-line;
}
.cap .hint {
  margin-top: 36px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.cap .hint::after {
  content: '';
  display: inline-block;
  width: 36px;
  height: 1px;
  margin-left: 14px;
  vertical-align: middle;
  background: currentColor;
  opacity: 0.6;
}

/* closing block over the sea */
#closing {
  position: fixed;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0, 20, 40, 0.35);
}
#closing .title {
  font-family: var(--serif);
  font-size: clamp(44px, 6.4vw, 100px);
  line-height: 1.0;
  margin: 0 0 28px;
  white-space: pre-line;
  color: #eef3f6;
}
#closing .lines {
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.8;
  color: rgba(238, 243, 246, 0.8);
}
#closing a { color: inherit; text-decoration: none; pointer-events: auto; }
#closing .foot {
  margin-top: 40px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(238, 243, 246, 0.55);
}

@media (max-width: 720px) {
  .cap { max-width: calc(100vw - 2 * var(--gutter)); }
  .cap.tr, .cap.br, .cap.cr { text-align: left; right: auto; left: var(--gutter); }
  .cap .body br { display: none; }
  #line { display: none; }
  #stage { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
}

/* shown only when WebGL is unavailable */
#fallback {
  position: fixed;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  max-width: 640px;
  z-index: 7;
}
#fallback .over { font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-dim); margin: 0 0 14px; }
#fallback h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 6vw, 88px); line-height: 1.02; margin: 0 0 18px; }
#fallback p { color: var(--ink-dim); line-height: 1.55; }
