/* ============================================================
   THE CAVE — cave.css (Cave-002 Threshold build)
   ------------------------------------------------------------
   Reconstructed from the approved Cave-002 screenshot since the
   original v0.5.1 working files were lost. Positions and the
   display font are matched by eye against that screenshot, not
   measured from source — nudge freely if anything sits off.

   v0.5.2 — replaced placeholder .journey-guide circle with a
   built (CSS/SVG, no raster asset) leather-pocket Wayfinder:
   coin peeks from the opening, flap + snap sit in front, coin
   carries the slow "heartbeat" glow per the Wayfinder concept.

   v0.5.3 — balance pass: pocket enlarged + given an ambient
   halo so it reads clearly against the backdrop; removed the
   now-redundant "YOUR WAYFINDER AWAITS" label; mid-block
   re-centered in the open band between title and nav via
   top/bottom + flex instead of a fixed top%; added a soft
   radial scrim behind mid-block for legibility.

   v0.5.4 — fixed the v0.5.3 scrim (it was sized to the tall
   positioning band, not the actual text, so it did nothing
   useful): now wraps a snug .mid-inner content box instead.
   Gave the pocket a gold trim/rim-glow so it reads against
   the dark corner of the art. Added the Wayfinder arrival
   ritual: a representative coin graphic travels from the
   doorway into the pocket once per visitor (localStorage-
   gated, reduced-motion aware) — separate from the eventual
   functional nav medallion, which will live in the pocket.

   v0.5.5 — REGRESSION FIX: v0.5.4's mid-block re-centering
   pushed the text into the brightest part of the waterfall,
   and the plaque backgrounds turned it into a muddy block.
   Reverted to a fixed, vertically-centered position matching
   the approved Cave-002 reference; dropped the plaques for
   clean layered text-shadow only (mid-final now cream/white
   like the title, matching the reference). Added the "Every
   explorer has a Wayfinder. This one is yours." caption,
   fading in only while the coin holds still mid-flight. Gave
   both coins eight compass tick marks (echoes the eight-
   destination-segment design). Made the Wayfinder pocket
   functional: clicking it now steps through the three preview
   destinations (Hall of Echoes → Sanctuary Basin → Ancient
   Door) — scoped first pass, not the full eight-path site nav.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;900&family=EB+Garamond:ital,wght@0,400;1,400;1,500&family=Cinzel:wght@400;600&display=swap');

:root {
  --ink: #07060a;
  --ember: #d69a4d;
  --ember-deep: #8a5a22;
  --parchment: #f1e6c9;
  --gold: #e8c77a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--ink);
  overflow: hidden;
  font-family: 'EB Garamond', serif;
}

.stage-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: var(--ink);
}

/* ---------- Artwork ---------- */
.stage {
  position: absolute;
  inset: 0;
  /* background-image is set inline by page-threshold.php with the correct
     WordPress asset URL — this rule intentionally has no url() of its own
     so there's nothing here that could silently go stale or 404. */
  background-size: cover;
  background-position: center;
  opacity: 1; /* Cave-002 shows it already settled/steady, no long fade needed on reload */
  filter: saturate(1.03) contrast(1.02);
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 60% 55%,
    rgba(0,0,0,0) 35%,
    rgba(4,3,2,0.30) 80%,
    rgba(2,1,1,0.55) 100%);
}

/* ---------- Torchlight ---------- */
.torch-glow {
  position: absolute;
  width: 9vw; height: 9vw;
  max-width: 140px; max-height: 140px;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255,170,70,0.85) 0%, rgba(255,120,40,0.35) 40%, rgba(255,120,40,0) 72%);
  animation: flicker 3.4s ease-in-out infinite;
}
.torch-left  { left: 1.5%;  bottom: 26%; animation-delay: 0.2s; }
.torch-right { right: 2.5%; bottom: 30%; animation-delay: 1.1s; }

@keyframes flicker {
  0%, 100% { opacity: 0.42; transform: scale(1); }
  22%      { opacity: 0.62; transform: scale(1.05); }
  38%      { opacity: 0.38; transform: scale(0.97); }
  55%      { opacity: 0.58; transform: scale(1.03); }
  70%      { opacity: 0.46; transform: scale(1); }
  85%      { opacity: 0.60; transform: scale(1.04); }
}

/* ---------- Interior glow ---------- */
.interior-glow {
  position: absolute;
  left: 15%; top: 44%;
  width: 16%; height: 30%;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(ellipse at 40% 50%, rgba(255,207,138,0.55) 0%, rgba(255,180,100,0.18) 45%, rgba(255,180,100,0) 75%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}

/* ---------- Vine shimmer (SVG displacement, driven by cave.js) ---------- */
.breeze {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* background-image is set inline by page-threshold.php (same asset,
     same WordPress-correct URL as .stage) — see note on .stage above. */
  background-size: cover;
  background-position: center;
  filter: url(#vineWarp);
}
.breeze-left  { clip-path: inset(0 62% 78% 0); }
.breeze-right { clip-path: inset(0 0 78% 55%); }

/* ---------- Dust ---------- */
#dust-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ---------- Pterodactyl ---------- */
#pterodactyl {
  position: absolute;
  width: 90px;
  height: 45px;
  top: 12%;
  left: -12%;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
#pterodactyl.flying {
  animation: ptero-flight 9s ease-in-out 1, ptero-fade 9s ease-in-out 1;
}
#ptero-body {
  transform-origin: 100px 50px;
  animation: ptero-flap 0.55s ease-in-out infinite;
}
@keyframes ptero-flap {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.55); }
}
@keyframes ptero-flight {
  0%   { left: -12%; top: 14%; }
  25%  { left: 20%;  top: 8%; }
  50%  { left: 48%;  top: 15%; }
  75%  { left: 74%;  top: 9%; }
  100% { left: 108%; top: 16%; }
}
@keyframes ptero-fade {
  0%   { opacity: 0; }
  8%   { opacity: 0.92; }
  92%  { opacity: 0.92; }
  100% { opacity: 0; }
}

/* ---------- Threshold copy (matched to Cave-002) ---------- */
.title-block {
  position: absolute;
  top: 9%;
  left: 52%;
  width: 36%;
  text-align: center;
  color: #fdf9ef;
  pointer-events: none;
}
.title-sub {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 1.9vw, 1.6rem);
  letter-spacing: 0.1em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6), 0 0 10px rgba(0,0,0,0.4);
}
.title-main {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(3rem, 6.6vw, 5.7rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 16px rgba(0,0,0,0.65), 0 0 20px rgba(0,0,0,0.4);
}
.title-sub2 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 1.9vw, 1.6rem);
  letter-spacing: 0.1em;
  margin-bottom: 0.6em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6), 0 0 10px rgba(0,0,0,0.4);
}
.title-tag {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  text-shadow: 0 2px 8px rgba(0,0,0,0.65), 0 0 8px rgba(0,0,0,0.4);
}

.mid-block {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 52%;
  width: 36%;
  text-align: center;
  color: var(--gold);
  pointer-events: none;
}
.mid-inner {
  position: relative;
}
.mid-head {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: clamp(0.95rem, 1.7vw, 1.4rem);
  letter-spacing: 0.05em;
  margin-bottom: 0.6em;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.7), 0 0 16px rgba(0,0,0,0.5);
}
.mid-tag {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-weight: 600;
  color: #f4e6bd;
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  line-height: 1.6;
  text-shadow: 0 2px 8px rgba(0,0,0,0.65), 0 0 8px rgba(0,0,0,0.4);
  margin-bottom: 0.7em;
}
.mid-final {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: clamp(0.85rem, 1.35vw, 1.05rem);
  color: #fdf9ef;
  text-shadow: 0 2px 4px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.7), 0 0 16px rgba(0,0,0,0.5);
}

.nav-strip {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 11%;
  background: linear-gradient(to top,
    rgba(8,6,3,0.6) 0%,
    rgba(8,6,3,0.32) 55%,
    rgba(8,6,3,0) 100%);
  pointer-events: none;
}

.nav-row {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  color: #f7e4ac;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  letter-spacing: 0.24em;
  text-shadow: 0 2px 5px rgba(0,0,0,0.9), 0 0 16px rgba(0,0,0,0.6);
  white-space: nowrap;
  pointer-events: none;
}
.nav-row .dot {
  margin: 0 1.1em;
  font-size: 0.65em;
  opacity: 0.9;
}


@media (prefers-reduced-motion: reduce) {
  .torch-glow, .interior-glow, #ptero-body {
    animation: none !important;
  }
  #pterodactyl { display: none; }
}

@media (max-width: 640px) {
  .title-block { width: 80%; left: 10%; right: auto; top: 8%; }
  .mid-block { width: 80%; left: 10%; top: 55%; }
  .nav-row { font-size: 0.6rem; letter-spacing: 0.1em; }
}
