/* ============================================================
   Ainmeer — Dungeon Hall mechanic
   First-person CSS-3D corridor. Scroll scrubs an anime.js
   camera timeline (see dungeon.js). Pure CSS/SVG, no images,
   no network — CSP-safe on free Neocities.

   Geometry constants are mirrored in dungeon.js (GEO). If you
   change W/H/SEG here, change them there too.
   ============================================================ */

:root {
  --dgn-w: 900px;     /* corridor inner width  (X) */
  --dgn-h: 680px;     /* corridor inner height (Y) */
  --dgn-seg: 620px;   /* segment depth         (Z) */
  --stone-a: #221d28;
  --stone-b: #2c2533;
  --stone-mortar: #15121b;
  --torch: #ffb347;
}

html, body { margin: 0; }

/* the corridor takes over the screen; the page itself only
   provides scroll *range* via #track. */
body.dungeon-mode {
  background: #0c0a10;
  color: var(--ink, #e9e4f0);
  overflow-x: hidden;
}

/* CRITICAL: style.css sets html{scroll-behavior:smooth}. The engine
   drives the camera with per-frame window.scrollTo(); browser smooth
   scrolling fights those calls and stalls keyboard/button movement
   (and makes the loop recentre visibly jump). Force instant here. */
html { scroll-behavior: auto !important; }

/* invisible spacer that creates the scrollable distance.
   height is set by JS from segment count. */
#track { width: 1px; pointer-events: none; }

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  perspective: 760px;
  perspective-origin: 50% 50%;
  background:
    radial-gradient(ellipse at 50% 44%, #1a1622 0%, #0c0a10 70%);
  z-index: 0;
}

.scene {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
  /* transform (translateZ + bob) applied by JS each frame */
}

/* ---- a corridor segment: 4 inward-facing planes ---- */
.seg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0; height: 0;
  transform-style: preserve-3d;
  /* translate3d(-50%,-50%, --z) applied inline by JS */
}
.seg .face {
  position: absolute;
  left: 50%; top: 50%;
  backface-visibility: hidden;
}

/* brick / flagstone surfacing built from layered gradients */
.face.wall {
  width: var(--dgn-seg); height: var(--dgn-h);
  background:
    repeating-linear-gradient(  /* mortar courses */
      0deg, transparent 0 54px, var(--stone-mortar) 54px 60px),
    repeating-linear-gradient(  /* vertical joints, offset feel */
      90deg, transparent 0 92px, var(--stone-mortar) 92px 98px),
    linear-gradient(var(--stone-b), var(--stone-a));
  box-shadow: inset 0 0 120px rgba(0,0,0,.65);
}
.face.left  { transform: translate(-50%,-50%) rotateY(90deg)  translateZ(calc(var(--dgn-w) / -2)); }
.face.right { transform: translate(-50%,-50%) rotateY(-90deg) translateZ(calc(var(--dgn-w) / -2)); }

.face.floor, .face.ceil {
  width: var(--dgn-w); height: var(--dgn-seg);
  background:
    repeating-linear-gradient(0deg,  transparent 0 92px, var(--stone-mortar) 92px 98px),
    repeating-linear-gradient(90deg, transparent 0 92px, var(--stone-mortar) 92px 98px),
    linear-gradient(var(--stone-a), var(--stone-b));
}
.face.floor {
  transform: translate(-50%,-50%) rotateX(90deg)  translateZ(calc(var(--dgn-h) / -2));
  box-shadow: inset 0 0 140px rgba(0,0,0,.75);
}
.face.ceil {
  transform: translate(-50%,-50%) rotateX(-90deg) translateZ(calc(var(--dgn-h) / -2));
  background: linear-gradient(#1a1622, #0e0b13);
  box-shadow: inset 0 0 160px rgba(0,0,0,.85);
}

/* far end cap */
.endwall {
  position: absolute; left: 50%; top: 50%;
  width: var(--dgn-w); height: var(--dgn-h);
  transform: translate(-50%,-50%);   /* translateZ set inline */
  background:
    repeating-linear-gradient(0deg, transparent 0 54px, var(--stone-mortar) 54px 60px),
    linear-gradient(var(--stone-b), var(--stone-a));
  box-shadow: inset 0 0 120px rgba(0,0,0,.8);
  display: grid; place-items: center;
}

/* ---- stations: doors (nav) + panels (content) ---- */
.station {
  position: absolute; left: 50%; top: 50%;
  transform-style: preserve-3d;
  /* translate3d(-50%,-50%,z) + wall rotation applied inline by JS */
}

/* a doorway / portal = category link. Text sits at the TOP. */
.door {
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  width: 340px; height: 500px;
  text-decoration: none;
  color: var(--ink, #e9e4f0);
  border: 8px solid #0c0a10;
  border-radius: 170px 170px 10px 10px;   /* arched top */
  background:
    radial-gradient(ellipse at 50% 62%, #2a2233 0%, #110e16 62%, #050406 100%);
  box-shadow:
    0 0 0 3px #3b3348,
    inset 0 0 60px rgba(0,0,0,.9);
  padding: 64px 26px 22px;                 /* clears the arch curve */
  transition: box-shadow .25s ease, color .25s ease;
}
.door .door-top { display: block; text-align: center; }
.door .door-label {
  display: block;
  font-family: var(--serif, Georgia, serif);
  font-size: 2.1rem;
  letter-spacing: .05em;
  color: #f3ead8;
  text-shadow: 0 0 14px rgba(255,179,71,.55), 0 2px 10px #000;
}
.door .door-desc {
  display: block;
  margin-top: .7rem;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: .98rem;
  line-height: 1.42;
  color: #c4bcd6;
}
.door .door-state {
  display: block;
  margin-top: 1rem;
  font-family: var(--mono, monospace);
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent-2, #7f6fb0);
}
.door:hover, .door:focus-visible,
.station.is-near .door {
  outline: none;
  color: var(--torch);
  box-shadow:
    0 0 0 3px var(--accent, #c9a86a),
    0 0 38px rgba(201,168,106,.5),
    inset 0 0 70px rgba(0,0,0,.85);
}

/* a wall plaque = placed content */
.panel {
  width: 320px; min-height: 200px;
  background: linear-gradient(#241f2d, #15121b);
  border: 3px solid #3b3348;
  border-radius: 4px;
  box-shadow: 0 0 0 5px #0c0a10, inset 0 0 40px rgba(0,0,0,.7);
  padding: 1.2rem 1.3rem;
  color: #d8d0e4;
  font-size: 1.15rem;
  line-height: 1.5;
  cursor: pointer;
}
.panel:focus-visible { outline: 2px solid var(--accent, #c9a86a); outline-offset: 4px; }
.panel h3 {
  margin: 0 0 .5rem;
  font-family: var(--serif, Georgia, serif);
  color: var(--accent, #c9a86a);
  font-size: 1.15rem;
}
.panel a { color: var(--accent, #c9a86a); }

/* the station we've turned to face — bright and steady to read */
.station.is-focused .door,
.station.is-focused .panel {
  color: #fff;
  border-color: var(--accent, #c9a86a);
  box-shadow:
    0 0 0 3px var(--accent, #c9a86a),
    0 0 60px rgba(201,168,106,.6),
    inset 0 0 70px rgba(0,0,0,.55);
}
.station.is-focused .door-state {
  color: var(--torch);
  text-shadow: 0 0 12px rgba(255,179,71,.7);
}

/* contextual hint pill (created in dungeon.js) */
.look-hint {
  position: absolute; left: 50%; bottom: 4.4rem;
  transform: translateX(-50%) translateY(8px);
  max-width: 90vw;
  background: rgba(12,10,16,.86);
  border: 1px solid var(--line, #38324a);
  border-radius: 999px;
  padding: .5rem 1.1rem;
  font-family: var(--mono, monospace);
  font-size: .76rem;
  color: var(--ink-soft, #b3aac4);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.look-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.look-hint b  { color: #fff; }
.look-hint kbd {
  font-family: var(--mono, monospace);
  background: var(--panel, #221e2e);
  border: 1px solid var(--line, #38324a);
  border-radius: 3px; padding: .05rem .35rem; color: var(--accent, #c9a86a);
}

/* ---- torches: CSS flame, anime.js flicker (dungeon.js) ---- */
.torch {
  position: absolute; left: 50%; top: 50%;
  transform-style: preserve-3d;
  /* placement inline by JS */
}
.torch .bracket {
  width: 10px; height: 46px; margin: 0 auto;
  background: linear-gradient(#3a3340, #1c1822);
  border-radius: 3px;
}
.torch .flame {
  width: 26px; height: 46px; margin: -6px auto 0;
  border-radius: 50% 50% 50% 50% / 64% 64% 36% 36%;
  background: radial-gradient(circle at 50% 70%,
    #fff3c4 0%, var(--torch) 38%, #e0561a 70%, transparent 78%);
  transform-origin: 50% 100%;
  filter: blur(.5px);
  will-change: transform, opacity;
}
.torch .glow {
  position: absolute; left: 50%; top: 30%;
  width: 320px; height: 320px;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle,
    rgba(255,160,60,.34) 0%, rgba(255,140,40,.12) 35%, transparent 70%);
  pointer-events: none;
  will-change: opacity;
}

/* ---- atmospheric fog: hides far clip, sells depth ---- */
.fog {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(ellipse at 50% 46%,
      transparent 0%, transparent 30%,
      rgba(12,10,16,.55) 58%, rgba(12,10,16,.96) 80%),
    radial-gradient(ellipse at 50% 50%,
      transparent 55%, rgba(0,0,0,.55) 100%); /* vignette */
}

/* ---- HUD: controls, progress, fallback nav ---- */
.hud {
  position: fixed; inset: 0; z-index: 3;
  pointer-events: none;
  font-family: var(--mono, monospace);
}
.hud .bar {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1.2rem;
  font-size: .8rem; color: var(--ink-soft, #b3aac4);
}
.hud a, .hud button { pointer-events: auto; }
.hud .exit {
  color: var(--accent, #c9a86a); text-decoration: none;
  border: 1px solid var(--line, #38324a); padding: .35rem .7rem;
  border-radius: 3px; background: rgba(12,10,16,.6);
}
.hud .exit:hover { color: #fff; border-color: var(--accent, #c9a86a); }

.bar-left  { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.bar-right { display: flex; align-items: center; gap: .6rem; }

.dg-back {
  font-family: var(--mono, monospace);
  font-size: .8rem;
  color: var(--accent, #c9a86a);
  background: rgba(12,10,16,.6);
  border: 1px solid var(--line, #38324a);
  padding: .35rem .7rem;
  border-radius: 3px;
  cursor: pointer;
}
.dg-back:hover { color: #fff; border-color: var(--accent, #c9a86a); }
.dg-back[hidden] { display: none; }

.dg-crumb {
  font-family: var(--mono, monospace);
  font-size: .75rem;
  letter-spacing: .08em;
  color: var(--ink-soft, #b3aac4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .dg-crumb { display: none; }
}

.cine-toggle {
  font-family: var(--mono, monospace);
  font-size: .8rem;
  color: var(--ink-soft, #b3aac4);
  background: rgba(12,10,16,.6);
  border: 1px solid var(--line, #38324a);
  padding: .35rem .7rem; border-radius: 3px;
  cursor: pointer;
  letter-spacing: .08em;
}
.cine-toggle:hover { color: #fff; border-color: var(--accent, #c9a86a); }
.cine-toggle[aria-pressed="true"] {
  color: var(--torch);
  border-color: var(--accent, #c9a86a);
  box-shadow: 0 0 14px rgba(201,168,106,.35);
}
.cine-toggle #cine-state { color: var(--accent, #c9a86a); }

.depth-meter {
  background: rgba(12,10,16,.6);
  border: 1px solid var(--line, #38324a);
  padding: .35rem .7rem; border-radius: 3px;
  letter-spacing: .12em;
}

@media (max-width: 640px) {
  .cine-toggle { font-size: .7rem; padding: .3rem .5rem; }
}

.move-pad {
  position: absolute; right: 1.2rem; bottom: 1.4rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.move-pad button {
  pointer-events: auto;
  width: 50px; height: 44px;
  font-size: 1.1rem; cursor: pointer;
  color: var(--ink, #e9e4f0);
  background: rgba(34,30,46,.85);
  border: 1px solid var(--line, #38324a);
  border-radius: 4px;
}
.move-pad button:hover { border-color: var(--accent, #c9a86a); color: var(--torch); }

.hall-legend {
  position: absolute; left: 1.2rem; bottom: 1.4rem;
  max-width: 230px;
  background: rgba(12,10,16,.7);
  border: 1px solid var(--line, #38324a);
  border-radius: 4px; padding: .7rem .85rem;
  font-size: .74rem; color: var(--ink-soft, #b3aac4);
  pointer-events: auto;
}
.hall-legend h2 {
  margin: 0 0 .45rem; font-size: .7rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent-2, #7f6fb0);
  border: 0; padding: 0;
}
.hall-legend ul { margin: 0; padding: 0; list-style: none;
  display: flex; flex-wrap: wrap; gap: .3rem .8rem; }
.hall-legend a { color: var(--accent, #c9a86a); text-decoration: none; }
.hall-legend a:hover { color: #fff; text-decoration: underline; }

.scroll-hint {
  position: absolute; left: 50%; bottom: 1.4rem;
  transform: translateX(-50%);
  font-size: .72rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-soft, #b3aac4); opacity: .8;
}

/* ---- progressive enhancement / fallbacks ---- */
.no-js .viewport, .no-js .fog, .no-js .hud .move-pad,
.no-js .scroll-hint, .no-js #track { display: none; }
.fallback {
  display: none;
  max-width: 620px; margin: 4rem auto; padding: 0 1.5rem;
}
.no-js .fallback { display: block; }   /* shown only if JS/anime absent */

@media (max-width: 640px) {
  .viewport { perspective: 600px; }
  .hall-legend { max-width: 160px; font-size: .68rem; }
  .scroll-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .torch .flame, .torch .glow { animation: none !important; }
  html, body { scroll-behavior: auto; }
}
