/* ============================================================
   world.css — immersive overlay UI over a fixed 3D canvas
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
:root {
  --bg: #07080c;
  --ink: #f4f1ec;
  --ink-soft: #b7b2ab;
  --ink-mute: #7c7770;
  --accent: #c21f3a;
  --accent-hi: #e63552;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-text: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --edge: clamp(1.25rem, 0.5rem + 4vw, 4.5rem);
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-text);
  overflow: hidden;                 /* NO document scroll — the world is the scroll */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Fixed canvas fills the viewport */
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; touch-action: none; }
.scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 55%, rgba(0,0,0,0.45) 100%),
    linear-gradient(0deg, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.15) 26%, transparent 46%);
}
.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; }

/* ---- Top HUD ---- */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(1rem,0.5rem+1.5vw,1.75rem) var(--edge);
  mix-blend-mode: difference;
}
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand b { color: var(--accent); }
.sound-hint {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--ink-soft); background: none; border: 1px solid rgba(255,255,255,0.18);
  padding: 0.45rem 0.8rem; border-radius: 999px; cursor: pointer; transition: border-color .3s, color .3s;
}
.sound-hint:hover { border-color: var(--accent); color: var(--ink); }

/* ---- Game dialogue box ---- */
.stage { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.dialogue {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: clamp(1.5rem, 1rem + 3vw, 3rem);
  width: min(52rem, calc(100vw - 2 * var(--edge)));
  display: grid; grid-template-columns: auto 1fr auto; gap: clamp(0.8rem, 0.5rem + 1vw, 1.3rem);
  align-items: center; pointer-events: auto;
  padding: clamp(0.9rem, 0.7rem + 0.8vw, 1.3rem) clamp(1rem, 0.8rem + 1vw, 1.5rem);
  background: linear-gradient(180deg, rgba(16,18,24,0.72), rgba(9,10,14,0.82));
  border: 1px solid rgba(255,255,255,0.12); border-radius: 16px;
  backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: dialogueIn .6s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes dialogueIn { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }

.dialogue__avatar {
  width: clamp(2.4rem, 2rem + 1.5vw, 3.2rem); aspect-ratio: 1; border-radius: 12px;
  display: grid; place-items: center; align-self: start;
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em;
  color: #fff; background: linear-gradient(140deg, var(--accent), #7a1020);
  box-shadow: 0 4px 18px rgba(194,31,58,0.4);
}
.dialogue__body { min-width: 0; }
.dialogue__who {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); display: inline-block; margin-bottom: 0.35rem;
}
.dialogue__line {
  font-size: clamp(0.98rem, 0.92rem + 0.4vw, 1.22rem); line-height: 1.4; color: var(--ink);
  font-weight: 400; min-height: 2.6em; cursor: text;
}
.dialogue__line::after { content: "▌"; color: var(--accent); margin-left: 2px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.dialogue__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.dialogue__tags li {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.02em;
  padding: 0.28rem 0.6rem; border: 1px solid rgba(194,31,58,0.35); border-radius: 999px;
  color: var(--ink-soft); background: rgba(194,31,58,0.08);
  opacity: 0; transform: translateY(6px); animation: tagIn .4s ease forwards;
}
@keyframes tagIn { to { opacity: 1; transform: none; } }

.dialogue__next {
  align-self: center; display: inline-flex; flex-direction: column; align-items: center; gap: 0.1rem;
  padding: 0.55rem 0.7rem; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.03);
  color: var(--ink-soft); font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase;
  transition: border-color .3s, color .3s, background .3s;
}
.dialogue__next:hover { border-color: var(--accent); color: var(--ink); background: rgba(194,31,58,0.12); }
.dialogue__chev { font-size: 1rem; line-height: 1; animation: bob 1.6s ease-in-out infinite; }
.dialogue__next.is-final { background: var(--accent); color: #fff; border-color: var(--accent); }
.dialogue__next.is-final .dialogue__chev { transform: rotate(-90deg); animation: none; }
@keyframes bob { 0%,100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(3px); opacity: 1; } }
@media (max-width: 560px) { .dialogue { grid-template-columns: auto 1fr; } .dialogue__next { grid-column: 2; justify-self: end; flex-direction: row; margin-top: 0.2rem; } }

/* ---- Progress rail (right side) ---- */
.rail {
  position: fixed; right: clamp(1rem,0.5rem+1.5vw,2.2rem); top: 50%; transform: translateY(-50%);
  z-index: 10; display: flex; align-items: center; gap: 1rem;
}
.rail__track { position: relative; width: 2px; height: 42vh; background: rgba(255,255,255,0.12); border-radius: 2px; cursor: pointer; }
.rail__fill { position: absolute; left: 0; top: 0; width: 100%; height: 0%; background: var(--accent); border-radius: 2px; }
.rail__dots { position: absolute; right: 0; top: 50%; transform: translateY(-50%); height: 42vh; display: flex; flex-direction: column; justify-content: space-between; }
.rail__dots button {
  display: block; width: 10px; height: 10px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.3); background: transparent; transition: all .3s;
}
.rail__dots button:hover { border-color: var(--accent); }
.rail__dots button.is-on { background: var(--accent); border-color: var(--accent); transform: scale(1.25); }
@media (max-width: 720px) { .rail__track { height: 30vh; } .rail__dots { height: 30vh; } }

/* ---- Loader ---- */
.loader {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 0.8rem;
  background: var(--bg); color: var(--ink-mute); font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.1em;
  transition: opacity .8s ease; text-transform: lowercase;
}
.loader.is-hidden { opacity: 0; pointer-events: none; }
.loader span { width: 10px; height: 10px; border-radius: 999px; background: var(--accent); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: .2; } 50% { opacity: 1; } }

/* ---- noscript fallback ---- */
.fallback { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--bg); padding: var(--edge); }
.fallback__inner { max-width: 40rem; }
.fallback h1 { font-family: var(--font-display); font-size: clamp(2.5rem,6vw,5rem); }
.fallback p { color: var(--ink-soft); margin-top: 1rem; line-height: 1.6; }
.fallback a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .dialogue { animation: none; }
  .dialogue__line::after, .dialogue__chev, .dialogue__tags li { animation: none; opacity: 1; transform: none; }
}
