/* ============================================================
   Costa Rica — Max Motif concept study
   Palette (locked):
     bg #171412 · text #E4DAC8 · muted #9A9284
     accent #5F7A63 (shaft green — the only accent)
     hairline #3A332C · hover fill #1F2B23
   Law: zero border-radius, one accent, no gradients
   (single exception: functional top scrim for chrome legibility).
   ============================================================ */

:root {
  --bg: #171412;
  --ink: #E4DAC8;
  --muted: #9A9284;
  --accent: #5F7A63;
  /* Same accent hue lifted to a value that survives being laid over a
     photograph. The base accent is only legible against --bg; on wet
     foliage and black volcanic stone it disappears entirely. */
  --accent-lit: #A3BCA7;
  --shadow-ink: rgba(12, 10, 9, 0.72);
  --hairline: #3A332C;
  --hover-fill: #1F2B23;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Inter", "Helvetica Neue", Arial, sans-serif;
  --label: 0.12em;
  --chrome-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 300; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent-lit);
  outline-offset: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.kicker {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--muted);
}

.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 300;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--hairline);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: var(--label);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Fixed chrome ---------- */

.chrome {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 0;
  pointer-events: none;
}
.chrome > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--ink);
}
.wordmark { font-weight: 500; }
.brand a { color: inherit; text-decoration: none; }
.brand-rule {
  display: inline-block;
  width: 28px; height: 1px;
  background: var(--hairline);
}
.piece { color: var(--muted); }

.site-nav,
.site-nav-wide {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
}
.site-nav a,
.site-nav summary {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--label);
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 0 1px 6px var(--shadow-ink);
}
.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav summary:hover,
.site-nav summary:focus-visible,
.site-nav .portfolio-link { color: var(--ink); }
.site-nav-menu { display: none; position: relative; }
.site-nav-menu summary { cursor: pointer; list-style: none; }
.site-nav-menu summary::-webkit-details-marker { display: none; }
.site-nav-panel {
  position: absolute;
  top: 28px;
  right: 0;
  display: grid;
  min-width: 148px;
  border: 1px solid var(--hairline);
  background: rgba(23, 20, 18, 0.94);
}
.site-nav-panel a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--hairline);
}
.site-nav-panel a:last-child { border-bottom: 0; }

/* The only gradient on the site: functional scrim so the fixed
   chrome stays legible over any photograph. */
.top-scrim {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 120px;
  z-index: 110;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(23, 20, 18, 0.72), rgba(23, 20, 18, 0));
}

/* ============================================================
   BASE LAYOUT = calm stacked editorial
   (no-JS and prefers-reduced-motion reading experience)
   ============================================================ */

.hero {
  padding: 28vh 24px 18vh;
  max-width: 720px;
  margin: 0 auto;
}
.hero-name {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1.04;
  margin: 18px 0 22px;
}
.hero-premise {
  color: var(--ink);
  opacity: 0.85;
  font-size: 16px;
  max-width: 34ch;
}
.scroll-cue { display: none; }

.beat {
  padding: 6vh 24px;
  max-width: 1080px;
  margin: 0 auto;
}
.beat-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  background: var(--hairline);
}
.beat-text { padding-top: 28px; max-width: 34ch; }
.beat-no {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--accent);
  margin-bottom: 12px;
}
.beat-text h2 {
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  line-height: 1.08;
  margin-bottom: 16px;
}
.beat-body {
  font-size: 15px;
  color: var(--ink);
  opacity: 0.85;
  max-width: 34ch;
}

.hotspot-dot { display: none; }

.hotspot-detail {
  margin-top: 28px;
  border-top: 1px solid var(--hairline);
  padding-top: 4px;
  max-width: 560px;
}
.hotspot-detail summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hotspot-detail summary::-webkit-details-marker { display: none; }
.hotspot-detail summary .kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
}
.hotspot-detail summary::after {
  content: "+";
  float: right;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
}
.hotspot-detail[open] summary::after { content: "–"; }
.hotspot-detail figure { margin: 8px 0 16px; }
.hotspot-detail figure img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--hairline); }
.hotspot-detail p { font-size: 15px; opacity: 0.85; max-width: 52ch; padding-bottom: 18px; }

.rail { display: none; }

/* ---------- CTA + footer (shared by both modes) ---------- */

.cta {
  background: var(--bg);
  border-top: 1px solid var(--hairline);
  padding: 16vh 24px 10vh;
  text-align: left;
}
.cta > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.cta h2 {
  font-size: clamp(2rem, 4.5vw, 3.5rem);
  line-height: 1.08;
  margin-bottom: 20px;
}
.cta-support {
  color: var(--ink);
  opacity: 0.85;
  font-size: 16px;
  max-width: 34ch;
  margin-bottom: 36px;
}
.cta-action { margin-bottom: 0; }
.cta-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--hairline);
  padding: 16px 24px;
  min-height: 44px;
}
.cta-link::after { content: " →"; }
.cta-link:hover { background: var(--hover-fill); }
.cta-rule {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 10vh auto 28px;
}
.footnote {
  font-size: 12px;
  color: var(--muted);
  max-width: 52ch;
}

.footer {
  padding: 28px 24px 40px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--muted);
}
.footer p {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer .wordmark { color: var(--ink); }

/* ---------- Detail card (JS-only) ---------- */

.detail-card {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 200;
  width: min(380px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--hairline);
  padding: 72px 28px 32px;
  overflow-y: auto;
  transform: translateX(102%);
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
}
.detail-card.is-open { transform: translateX(0); }
.detail-card[hidden] { display: none; }
.dc-media { margin: 0 0 20px; }
.dc-media img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--hairline); }
.detail-card .kicker { color: var(--accent); margin-bottom: 10px; }
.detail-card h2 {
  font-size: 1.7rem;
  line-height: 1.15;
  margin-bottom: 14px;
}
.dc-body { font-size: 15px; opacity: 0.85; }
.dc-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 44px; height: 44px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid transparent;
}
.dc-close:hover { color: var(--ink); border-color: var(--hairline); background: var(--hover-fill); }

@media (max-width: 640px) {
  .detail-card {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 74vh;
    border-left: 0;
    border-top: 1px solid var(--hairline);
    padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
    transform: translateY(102%);
  }
  .detail-card.is-open { transform: translateY(0); }
  .dc-close { top: 8px; right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .detail-card { transition: none; }
}

/* ============================================================
   ENHANCED LAYOUT = scroll-scrub walk
   Applied only when JS runs AND motion is allowed.
   ============================================================ */

html.enhanced .walk { height: 2200vh; }

html.enhanced .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Hero overlays beat-01 and fades out as the walk begins */
html.enhanced .hero {
  position: absolute;
  inset: 0;
  z-index: 40;
  max-width: none;
  margin: 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  will-change: opacity;
}
html.enhanced .hero-inner { max-width: 720px; }
html.enhanced .hero.is-gone { pointer-events: none; visibility: hidden; }

html.enhanced .scroll-cue {
  display: block;
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  text-align: center;
}
.cue-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--muted);
  margin-bottom: 12px;
}
.cue-line {
  display: block;
  width: 1px;
  height: 56px;
  margin: 0 auto;
  background: var(--accent-lit);
  transform-origin: top center;
  animation: cue-draw 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes cue-draw {
  0% { transform: scaleY(0); opacity: 0; }
  30% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* Beat layers */
html.enhanced .layers { position: absolute; inset: 0; }
html.enhanced .beat {
  position: absolute;
  inset: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  will-change: opacity;
}
html.enhanced .beat-media,
html.enhanced .beat-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
html.enhanced .beat-media img {
  object-fit: cover;
  object-position: center;
  aspect-ratio: auto;
  will-change: transform;
}

html.enhanced .beat-text {
  position: absolute;
  left: 24px;
  bottom: 48px;
  z-index: 5;
  padding: 20px 22px;
  background: rgba(23, 20, 18, 0.66);
  max-width: min(34ch, calc(100vw - 120px));
  will-change: opacity, transform;
}

/* On a photograph the base accent falls to roughly the value of wet
   foliage, so the beat number reads as dark-on-dark. Lifted variant. */
html.enhanced .beat-no { color: var(--accent-lit); }

html.enhanced .hotspot-detail { display: none; }


/* Hotspot markers.
   These sit directly on photographs, so they carry their own contrast:
   a cream core against a dark halo, which reads on black stone and on
   sunlit foliage alike. The accent is used for the open state only —
   at rest it is never the thing doing the work of being visible. */
html.enhanced .hotspot-dot {
  display: block;
  position: absolute;
  z-index: 6;
  width: 44px; height: 44px;
  left: var(--x, 50%);
  top: var(--y, 50%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  visibility: hidden;
}
html.enhanced .beat.is-current .hotspot-dot {
  pointer-events: auto;
  visibility: visible;
}
.dot-core {
  position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 9px;
  transform: translate(-50%, -50%);
  background: var(--ink);
  box-shadow:
    0 0 0 1px var(--shadow-ink),
    0 0 12px 3px var(--shadow-ink);
}
.hotspot-dot::before,
.hotspot-dot::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
/* Static bracket: always there, so the marker never fully disappears
   between pulses. */
.hotspot-dot::before {
  width: 22px; height: 22px;
  border: 1px solid rgba(228, 218, 200, 0.85);
  box-shadow:
    0 0 0 1px rgba(12, 10, 9, 0.45),
    inset 0 0 0 1px rgba(12, 10, 9, 0.45);
}
.hotspot-dot::after {
  width: 22px; height: 22px;
  border: 1px solid rgba(228, 218, 200, 0.9);
  animation: ring-pulse 2.8s ease-out infinite;
}
@keyframes ring-pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
  70% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}
.hotspot-dot:hover .dot-core,
.hotspot-dot:focus-visible .dot-core { background: var(--accent-lit); }
.hotspot-dot:hover::before,
.hotspot-dot:focus-visible::before { border-color: var(--accent-lit); }
.hotspot-dot[aria-expanded="true"] .dot-core { background: var(--accent-lit); }
.hotspot-dot[aria-expanded="true"]::before {
  border-color: var(--accent-lit);
  width: 28px; height: 28px;
}
.hotspot-dot[aria-expanded="true"]::after { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .hotspot-dot::after { animation: none; opacity: 0; }
}

/* Progress rail */
html.enhanced .rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
}
.rail-stop {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 24px;
  padding: 2px 4px;
}
.rail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--label);
  color: var(--ink);
  text-shadow: 0 1px 6px rgba(12, 10, 9, 0.9), 0 0 3px rgba(12, 10, 9, 0.7);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.rail-stop:hover .rail-label,
.rail-stop:focus-visible .rail-label,
.rail-stop.is-active .rail-label { opacity: 1; }
/* The rail also lies on photographs — ticks carry a dark halo so the
   inactive ones stay countable over a bright frame. */
.tick {
  width: 2px;
  height: 18px;
  background: rgba(228, 218, 200, 0.45);
  box-shadow: 0 0 6px 1px var(--shadow-ink);
}
.rail-stop.is-active .tick { background: var(--accent-lit); }
.rail-stop.is-active .rail-label { color: var(--accent-lit); }
.rail-stop:hover .tick { background: var(--ink); }
.rail-stop.is-active:hover .tick { background: var(--accent-lit); }

/* ---------- Mobile (390×844 primary) ---------- */

@media (max-width: 640px) {
  .chrome { align-items: center; padding: 0 16px; }
  .brand,
  .site-nav > a,
  .site-nav-menu > summary { min-height: 44px; display: flex; align-items: center; }
  .brand { gap: 8px; }
  .brand-rule { width: 16px; }
  .piece { display: none; }
  .site-nav { gap: 16px; }
  .site-nav-wide { display: none; }
  .site-nav-menu { display: block; }
  .site-nav-panel { top: 44px; }

  html.enhanced .hero-name { font-size: clamp(2.25rem, 10vw, 2.6rem); }

  html.enhanced .beat-text {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
    background: rgba(23, 20, 18, 0.78);
  }
  html.enhanced .beat-text h2 { font-size: clamp(1.7rem, 7vw, 2.2rem); }

  html.enhanced .rail { right: 10px; gap: 2px; }
  html.enhanced .rail-label { display: none; }
  html.enhanced .rail-stop { min-height: 44px; min-width: 44px; justify-content: center; padding: 0; }
  html.enhanced .tick { width: 6px; height: 6px; }



  .hero { padding: 24vh 20px 14vh; }
  html.enhanced .hero { padding: 0 20px; }
}

/* ---------------- Immersion layer: vignette ---------------- */

html.enhanced #stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 115% 88% at 50% 46%, transparent 56%, rgba(9, 8, 7, 0.34) 100%);
}

/* ---------------- Ambient motion clips (generated loops over stills) ---------------- */

.beat-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.beat-video.is-ready { opacity: 1; }

/* ---------------- Morph legs (scroll-scrubbed transition clips) ---------------- */

.morphs { display: none; }
html.enhanced .morphs {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.morph-vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
}
