/* ===========================================================
   VILLAVICENCIO — Base system
   Typography, palette, resets, shared primitives
   =========================================================== */

:root {
  /* Mineral palette */
  --mineral-green: #435B4D;
  --jarilla:       #7E9474;
  --stone-beige:   #CFC3AE;
  --warm-sand:     #B89D78;
  --limestone:     #F3EFE7;
  --water-blue:    #8FB8C1;
  --shadow:        #2E3A34;
  --abyss:         #161D1A;   /* deeper than shadow, for cave interior */
  --abyss-2:       #0C100E;

  /* Type */
  --display: "Cormorant Garamond", Georgia, serif;
  --body:    "Spectral", Georgia, serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  /* Rhythm */
  --measure: 34rem;
  --ease-cine: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: auto; /* JS drives the experience; no native smooth jank */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--body);
  background: var(--abyss-2);
  color: var(--limestone);
  font-weight: 300;
  line-height: 1.65;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

main {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* ---------- Typographic primitives ---------- */

.eyebrow {
  font-family: var(--mono);
  font-size: clamp(0.62rem, 0.8vw, 0.74rem);
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.72;
}

.scene-no {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.display {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2.8rem, 8vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.display em {
  font-style: italic;
  font-weight: 400;
}

.title {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2.2rem, 5.5vw, 5rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
}

.lede {
  font-family: var(--body);
  font-weight: 300;
  font-size: clamp(1.05rem, 1.6vw, 1.5rem);
  line-height: 1.62;
  max-width: var(--measure);
  text-wrap: pretty;
}

.lede em { font-style: italic; color: var(--water-blue); }

.fine {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  opacity: 0.6;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .eyebrow {
    letter-spacing: 0.26em;
    font-size: clamp(0.56rem, 2.8vw, 0.64rem);
  }
  .display {
    font-size: clamp(2.15rem, 10vw, 3.4rem);
    line-height: 1.02;
  }
  .title {
    font-size: clamp(1.85rem, 7.8vw, 2.75rem);
    line-height: 1.06;
  }
  .lede {
    font-size: clamp(1rem, 4.1vw, 1.18rem);
    line-height: 1.7;
    max-width: none;
  }
  .key-msg {
    font-size: clamp(1.35rem, 5.8vw, 1.95rem);
    line-height: 1.22;
    max-width: none;
  }
  .fine {
    letter-spacing: 0.12em;
    font-size: 0.62rem;
  }
}

/* ---------- Reveal primitives (driven by IntersectionObserver) ---------- */

.reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 1.2s var(--ease-cine), transform 1.2s var(--ease-cine);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

.reveal-slow { transition-duration: 1.8s; }
.d1 { transition-delay: 0.12s; }
.d2 { transition-delay: 0.26s; }
.d3 { transition-delay: 0.4s; }
.d4 { transition-delay: 0.56s; }
.d5 { transition-delay: 0.72s; }

.fade-only { transform: none; }

/* mask-reveal: word/line wipes upward */
.line-mask { overflow: hidden; display: block; }
.line-mask > span {
  display: block;
  transform: translateY(105%);
  transition: transform 1.3s var(--ease-cine);
}
.is-visible .line-mask > span,
.line-mask.is-visible > span { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .line-mask > span { transition: none !important; opacity: 1 !important; transform: none !important; }
  .topo-line { animation: none; stroke-dasharray: none; }
  .topo-lines { animation: none; }
  .map-locus-ring, .map-locus-dot { animation: none; }
  .ghost-bottle { opacity: 1 !important; animation: none !important; transform: translate(-50%, -50%) !important; }
}

/* ---------- Scene scaffolding ---------- */

.scene {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.scene-inner {
  position: relative;
  z-index: 5;
  width: min(1280px, 90vw);
  max-width: 100%;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 3rem);
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .scene-inner {
    width: 100%;
    padding: 0 clamp(1.15rem, 4.5vw, 1.5rem);
  }
}

/* a generic atmospheric layer container */
.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* grain overlay reused across dark scenes */
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  mix-blend-mode: overlay;
  z-index: 30;
}

/* vignette */
.vignette::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background: radial-gradient(120% 90% at 50% 45%, transparent 40%, rgba(0,0,0,0.55) 100%);
}
