:root {
  --ink: #2a2438;
  --cream: #fdf6ec;
  --veil: rgba(20, 18, 30, 0.0);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

/* Readable-but-invisible content for assistive tech & crawlers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Always show a clear focus ring on keyboard navigation */
#ui button:focus-visible, #ui a:focus-visible, .sr-only a:focus-visible {
  outline: 2px solid #fff7eb;
  outline-offset: 3px;
  border-radius: 6px;
}
.rail__dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 14, 30, 0.55), 0 0 0 5px #fff7eb;
}

html { scroll-behavior: auto; }

body {
  font-family: var(--sans);
  color: var(--cream);
  background: #1a2233;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* The 3D world sits fixed behind everything */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  z-index: 0;
}

/* Tall invisible track that the scroll listener measures */
#scroll-space {
  position: relative;
  width: 1px;
  height: 760vh;
  pointer-events: none;
}

/* ───────── UI overlay ───────── */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}
#ui button, #ui a { pointer-events: auto; }

/* Loader veil */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 35%, #f4e6d4 0%, #e7d2bd 45%, #c9b6cf 100%);
  transition: opacity 1.1s ease;
}
.loader.is-hidden { opacity: 0; pointer-events: none; }
.loader__inner { text-align: center; color: #5a4e5e; }
.loader__mark {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.42em;
  font-size: clamp(1.1rem, 4vw, 1.9rem);
  margin-bottom: 1.4rem;
  padding-left: 0.42em;
  opacity: 0.9;
}
.loader__bar {
  width: min(240px, 56vw);
  height: 2px;
  background: rgba(90, 78, 94, 0.25);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}
.loader__bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: #5a4e5e;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.4s ease;
}
.loader__hint {
  margin-top: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  opacity: 0.55;
}

/* Region typography cards */
.cards { position: absolute; inset: 0; }
.card {
  position: absolute;
  top: 34%;                 /* upper third — clear of Sumi (lower-centre) & water */
  transform: translateY(0);
  width: min(620px, 86vw);
  opacity: 0;
  will-change: transform, opacity, filter;
  text-shadow: 0 2px 40px rgba(20, 14, 30, 0.55), 0 1px 4px rgba(20, 14, 30, 0.6);
}
/* soft legibility halo behind the type — fades fully to transparent on every
   side (closest-side ellipse + generous inset) so it blends into the world
   instead of being cut off with a hard edge. */
.card::before, .outro::before {
  content: '';
  position: absolute;
  inset: -60% -26%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse closest-side at center, rgba(16, 12, 24, 0.5) 0%, rgba(16, 12, 24, 0.2) 38%, transparent 80%);
}
.card--center { left: 50%; translate: -50% -50%; text-align: center; }
.card--left  { left: clamp(1.4rem, 7vw, 9rem); translate: 0 -54%; text-align: left; }
.card--right { right: clamp(1.4rem, 7vw, 9rem); translate: 0 -46%; text-align: right; }

.card__kicker {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(0.72rem, 1.4vw, 0.92rem);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}
.card__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.6rem, 9vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
  margin-bottom: 1.1rem;
}
.card__lines p {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.05rem, 2.4vw, 1.7rem);
  line-height: 1.4;
  opacity: 0.94;
  max-width: 36ch;
}
.card--right .card__lines p { margin-left: auto; }
.card--center .card__lines p { margin-left: auto; margin-right: auto; }

/* Scroll hint */
.hint {
  position: absolute;
  left: 50%;
  bottom: clamp(1.6rem, 5vh, 3rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 247, 235, 0.85);
  font-size: 0.74rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-shadow: 0 2px 18px rgba(20, 14, 30, 0.5);
  transition: opacity 0.6s ease;
}
.hint__dot { animation: hintdot 1.8s ease-in-out infinite; }
@keyframes hintdot { 0%,100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(9px); opacity: 0.3; } }

/* Journey rail */
.rail {
  position: absolute;
  right: clamp(0.9rem, 2vw, 1.8rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  padding: 0.6rem 0;
}
.rail__fill {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(rgba(255,247,235,0.65), rgba(255,247,235,0.15));
  transform-origin: top;
  transform: scaleY(0);
}
.rail::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255, 247, 235, 0.16);
}
.rail__dot {
  position: relative;
  width: 26px; height: 26px;   /* ≥24px tap target */
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
.rail__dot::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 9px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 247, 235, 0.4);
  transition: transform 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}
.rail__dot span {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: rgba(255, 247, 235, 0.9);
  opacity: 0;
  transition: opacity 0.3s ease;
  text-shadow: 0 1px 10px rgba(20,14,30,0.6);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
}
.rail__dot:hover span { opacity: 1; }
.rail__dot.is-active::before {
  background: #fff7eb;
  transform: translate(-50%, -50%) scale(1.7);
  box-shadow: 0 0 14px rgba(255, 247, 235, 0.8);
}

/* Audio button */
.audio-btn {
  position: absolute;
  left: clamp(1rem, 2.4vw, 1.8rem);
  bottom: clamp(1rem, 2.4vw, 1.8rem);
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 247, 235, 0.3);
  background: rgba(30, 24, 40, 0.28);
  backdrop-filter: blur(8px);
  color: rgba(255, 247, 235, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, border 0.3s ease;
}
.audio-btn:hover { background: rgba(30, 24, 40, 0.45); }
.audio-btn .a-wave { opacity: 0.25; transition: opacity 0.3s ease; }
.audio-btn.is-on { border-color: rgba(255,247,235,0.7); }
.audio-btn.is-on .a-wave { opacity: 1; }

/* Skip button */
.skip-btn {
  position: absolute;
  right: clamp(1rem, 2.4vw, 1.8rem);
  bottom: clamp(1rem, 2.4vw, 1.8rem);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 247, 235, 0.3);
  background: rgba(30, 24, 40, 0.28);
  backdrop-filter: blur(8px);
  color: rgba(255, 247, 235, 0.85);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s ease, opacity 0.5s ease;
}
.skip-btn:hover { background: rgba(30, 24, 40, 0.45); }

/* Outro */
.outro {
  position: absolute;
  left: 50%;
  top: 73%;                 /* lower area — leaves the orb & floating Sumi clearly visible above */
  translate: -50% -50%;
  width: min(680px, 88vw);
  text-align: center;
  opacity: 0;
  will-change: opacity, transform;
}
.outro__title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 1.0;
  margin-bottom: 1.4rem;
  text-shadow: 0 2px 40px rgba(20,14,30,0.5);
}
.outro__lines p {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  line-height: 1.5;
  opacity: 0.92;
  margin-bottom: 0.3rem;
}
.outro__cta {
  display: inline-block;
  margin-top: 1.8rem;
  padding: 0.85rem 1.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255,247,235,0.45);
  color: #fff7eb;
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  background: rgba(30,24,40,0.25);
  backdrop-filter: blur(8px);
  transition: background 0.3s ease, transform 0.3s ease;
}
.outro__cta:hover { background: rgba(255,247,235,0.16); transform: translateY(-2px); }
.outro__sig {
  margin-top: 1.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  opacity: 0.6;
}
.outro__credit {
  margin-top: 0.8rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  opacity: 0.4;
}

/* Fallback (no WebGL) */
#fallback {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 35%, #f4e6d4 0%, #d8c2cf 100%);
  color: #4a3f50;
}
.fallback__card { text-align: center; max-width: 540px; padding: 2rem; }
.fallback__mark { font-family: var(--serif); letter-spacing: 0.4em; font-size: 1.6rem; margin-bottom: 1.2rem; padding-left: 0.4em; }
.fallback__msg { font-size: 1.1rem; margin-bottom: 0.8rem; }
.fallback__sub { opacity: 0.7; margin-bottom: 1.4rem; line-height: 1.5; }
#fallback a { color: #4a3f50; }

/* Touch: hide hover-only rail labels, ease type */
@media (max-width: 720px) {
  .rail { gap: 0.9rem; right: 0.7rem; }
  .rail__dot span { display: none; }
  .card { width: 90vw; }
  .card--left, .card--right { left: 50%; right: auto; translate: -50% -50%; text-align: center; }
  .card--left .card__lines p, .card--right .card__lines p { margin-left: auto; margin-right: auto; }
}

/* Short / landscape viewports: shrink the big type so it never clips */
@media (max-height: 540px) {
  .card { max-height: 92dvh; }
  .card__kicker { margin-bottom: 0.5rem; }
  .card__title { font-size: clamp(1.7rem, 7vh, 3.2rem); margin-bottom: 0.5rem; }
  .card__lines p { font-size: clamp(0.9rem, 3.2vh, 1.2rem); line-height: 1.3; }
  .outro__title { font-size: clamp(1.7rem, 8vh, 3rem); margin-bottom: 0.7rem; }
  .outro__lines p { font-size: clamp(0.85rem, 3vh, 1.1rem); }
}

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