:root {
  --bg-deep: #050613;
  --bg-mid: #0b0d22;
  --bg-warm: #1b1027;
  --ink: #f5efe6;
  --ink-dim: rgba(245, 239, 230, 0.62);
  --ink-faint: rgba(245, 239, 230, 0.34);
  --accent: #f0c98a;
  --accent-cool: #8aa9f0;
  --rule: rgba(245, 239, 230, 0.16);
  --card-bg: rgba(16, 12, 28, 0.42);
  --card-stroke: rgba(245, 239, 230, 0.14);
  --serif: "Cormorant Garamond", "EB Garamond", "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --progress: 0;
}

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

html,
body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 320vh;
  overflow-x: hidden;
  background:
    radial-gradient(
      120% 90% at 50% calc(50% - var(--progress) * 18%),
      rgba(70, 38, 110, calc(0.45 - var(--progress) * 0.25)) 0%,
      rgba(10, 12, 32, 0.92) 55%,
      var(--bg-deep) 100%
    ),
    linear-gradient(
      180deg,
      var(--bg-mid) 0%,
      var(--bg-deep) 40%,
      var(--bg-warm) 100%
    );
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Three.js stage                                                      */
/* ------------------------------------------------------------------ */

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#portal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      60% 50% at 50% 50%,
      rgba(0, 0, 0, 0) 40%,
      rgba(3, 4, 14, 0.55) 100%
    );
  mix-blend-mode: multiply;
  opacity: calc(0.55 + var(--progress) * 0.2);
  transition: opacity 0.4s ease-out;
}

.stage__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      120% 120% at 50% 50%,
      rgba(0, 0, 0, 0) 55%,
      rgba(0, 0, 0, 0.75) 100%
    );
}

.stage__grain {
  position: absolute;
  inset: -10%;
  opacity: 0.08;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.6) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
  mix-blend-mode: overlay;
  animation: grain 4s steps(8) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 1%); }
  40% { transform: translate(1%, -2%); }
  60% { transform: translate(-1%, 2%); }
  80% { transform: translate(2%, -1%); }
}

/* ------------------------------------------------------------------ */
/* Top nav                                                             */
/* ------------------------------------------------------------------ */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px clamp(20px, 4vw, 56px);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  mix-blend-mode: normal;
}

.top-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(5, 6, 19, 0.85) 0%,
    rgba(5, 6, 19, 0) 100%
  );
  z-index: -1;
  opacity: calc(0.5 + var(--progress) * 0.3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  letter-spacing: 0.32em;
}

.brand__mark {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  color: var(--accent);
  font-size: 16px;
  transform: translateY(-1px);
}

.brand__word {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

.top-nav__links {
  display: inline-flex;
  gap: clamp(16px, 3vw, 36px);
  justify-self: center;
}

.top-nav__links a {
  position: relative;
  transition: color 0.25s ease;
}

.top-nav__links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s ease;
  transform: translateX(-50%);
}

.top-nav__links a:hover {
  color: var(--ink);
}

.top-nav__links a:hover::after {
  width: 100%;
}

.top-nav__cta {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink);
  letter-spacing: 0.24em;
  font-size: 11px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(245, 239, 230, 0.04);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.top-nav__cta:hover {
  border-color: var(--accent);
  background: rgba(240, 201, 138, 0.08);
  transform: translateY(-1px);
}

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */

.hero {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 80px);
  padding: clamp(96px, 12vh, 140px) clamp(20px, 5vw, 80px)
    clamp(140px, 18vh, 180px);
  pointer-events: none;
}

.hero__text > *,
.cards > * {
  pointer-events: auto;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: clamp(20px, 3vh, 30px);
  will-change: transform, opacity;
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}

.title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(48px, 9vw, 132px);
  line-height: 0.96;
  letter-spacing: -0.012em;
  margin-bottom: clamp(20px, 3.4vh, 36px);
  color: var(--ink);
}

.title__line {
  display: block;
  will-change: transform, opacity;
  transform-origin: left center;
}

.title__line em {
  font-style: italic;
  color: var(--accent);
  font-weight: 500;
  padding-right: 0.08em;
}

.lede {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 1.6vw, 19px);
  line-height: 1.55;
  color: var(--ink-dim);
  max-width: 32ch;
  margin-bottom: clamp(20px, 3vh, 32px);
  will-change: opacity, transform;
}

.meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-faint);
  will-change: opacity, transform;
}

.meta__sep {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */

.cards {
  position: relative;
  height: 100%;
  min-height: 0;
}

.card {
  position: absolute;
  width: clamp(220px, 26vw, 320px);
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid var(--card-stroke);
  background: var(--card-bg);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--ink);
  will-change: transform, opacity;
  transition: box-shadow 0.4s ease;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(245, 239, 230, 0.5),
    transparent
  );
  opacity: 0.7;
}

.card--a {
  top: 6%;
  right: 4%;
  transform-origin: top right;
}

.card--b {
  top: 38%;
  right: 22%;
  transform-origin: center right;
}

.card--c {
  top: 70%;
  right: 0%;
  transform-origin: bottom right;
}

.card__tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.card__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.15;
  margin-bottom: 8px;
}

.card__body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin-bottom: 14px;
}

.card__coord {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* HUD                                                                 */
/* ------------------------------------------------------------------ */

.hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(20px, 5vw, 80px) clamp(20px, 3vh, 32px);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  pointer-events: none;
}

.hud__chapter {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.hud__num {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 26px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.hud__rule {
  display: inline-block;
  width: 48px;
  height: 1px;
  background: var(--rule);
}

.hud__name {
  color: var(--ink-dim);
}

.hud__scroll {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.hud__label {
  color: var(--ink-faint);
}

.hud__track {
  position: relative;
  display: inline-block;
  width: 1px;
  height: 64px;
  background: var(--rule);
  overflow: hidden;
}

.hud__thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: top center;
  transform: scaleY(0.05);
  transition: background 0.4s ease;
}

.hud__state {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.scroll-spacer {
  height: 320vh;
  width: 100%;
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Tablet                                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
    padding-top: clamp(96px, 14vh, 140px);
    padding-bottom: clamp(120px, 18vh, 180px);
    gap: 36px;
  }

  .cards {
    height: auto;
    min-height: 280px;
  }

  .card {
    position: absolute;
    width: min(70vw, 280px);
  }

  .card--a { top: -10px; right: 4%; }
  .card--b { top: 110px; right: 32%; }
  .card--c { top: 220px; right: 8%; }
}

/* ------------------------------------------------------------------ */
/* Mobile                                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
  .top-nav {
    grid-template-columns: 1fr auto;
    padding: 16px 20px;
    gap: 10px;
  }

  .top-nav__links {
    display: none;
  }

  .top-nav__cta {
    padding: 8px 14px;
    font-size: 10px;
  }

  .brand__word {
    font-size: 13px;
  }

  .hero {
    padding: 92px 22px 160px;
    grid-template-rows: auto 1fr;
    gap: 28px;
  }

  .title {
    font-size: clamp(40px, 13vw, 64px);
    line-height: 0.98;
  }

  .lede {
    font-size: 14px;
    max-width: 28ch;
  }

  .meta {
    font-size: 10px;
    gap: 8px;
  }

  .cards {
    position: relative;
    height: 240px;
    min-height: 240px;
  }

  .card {
    width: 74vw;
    padding: 16px 18px 14px;
    border-radius: 14px;
  }

  .card__body { font-size: 12px; }

  .card--a { top: 0; right: -8px; }
  .card--b { top: 84px; right: 22%; }
  .card--c { top: 168px; right: -4px; }

  .hud {
    padding: 0 20px 18px;
    font-size: 10px;
    letter-spacing: 0.2em;
  }

  .hud__num { font-size: 22px; }
  .hud__rule { width: 28px; }
  .hud__track { height: 48px; }
  .hud__label { display: none; }
}

@media (max-height: 760px) and (min-width: 641px) {
  .hero {
    padding-top: 96px;
    padding-bottom: 120px;
  }
  .title { font-size: clamp(44px, 7.5vw, 96px); }
}

@media (prefers-reduced-motion: reduce) {
  .stage__grain { animation: none; }
  .eyebrow__dot { animation: none; }
}
