/* scroll.css — fixed chrome: header/footer bars, edge fades, scroll
   cues, and section snapping. --head-h/--foot-h are measured live by
   the WASM scroll module; the fallbacks cover the pre-boot frame. */

:root {
  --head-h: 3.4rem;
  --foot-h: 3.4rem;
  --bar-bg: color-mix(in srgb, var(--void-2) 82%, transparent);
  --lie-glow: 0;
}

/* ---------- fixed bars (same skin, mirrored) ---------- */

.trap-head,
.site-foot {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 70;
  min-height: 3.7rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: var(--font-mono);
}
.trap-head {
  top: 0;
  max-height: 72vh;
  overflow-y: auto;
}
.site-foot {
  bottom: 0;
  padding: 0.55rem clamp(1rem, 4vw, 3rem);
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 1.1rem;
  row-gap: 0.15rem;
}
body.page-index .trap-head {
  background: var(--bar-bg);
  padding: 0.55rem clamp(1rem, 4vw, 3rem);
}

/* ---------- content clears the bars ---------- */

main {
  padding-top: calc(var(--head-h) + clamp(1.5rem, 4vw, 3rem));
  padding-bottom: calc(var(--foot-h) + clamp(2rem, 4vw, 3rem));
}

.colophon {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
  text-align: center;
}
.colophon .foot-whisper { margin: 0 0 1rem; }
.colophon .fine { margin: 0 0 0.4rem; }

/* ---------- edge fades — content dissolves before the bars ---------- */

.edge-fade {
  position: fixed;
  left: 0;
  right: 0;
  height: 4.5rem;
  z-index: 30;
  pointer-events: none;
}
.edge-top {
  top: var(--head-h);
  background: linear-gradient(to bottom, var(--void), transparent);
}
.edge-bot {
  bottom: var(--foot-h);
  background: linear-gradient(to top, var(--void), transparent);
}

/* ---------- scroll cues — stacked rail at the panel's right edge ---------- */

.cue-rail {
  position: fixed;
  right: max(0.75rem, calc(50vw - var(--max) / 2 + 0.9rem));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 75;
}
.scroll-cue {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid color-mix(in srgb, var(--accent-2) 45%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--void-2) 88%, transparent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.3s ease, border-color 0.2s ease;
}
.scroll-cue:hover { opacity: 1; border-color: var(--accent); }
.scroll-cue:focus-visible { opacity: 1; }
.scroll-cue.off { opacity: 0.15; pointer-events: none; }

/* The live rail replaces the hero's static scroll hint when WASM is up.
   scroll-bob animates opacity, so the animation must die with the fade. */
body.can-down .scroll-hint { opacity: 0; animation: none; pointer-events: none; }

@media (max-width: 40rem) {
  .cue-rail { right: 0.5rem; gap: 0.45rem; }
  .scroll-cue { width: 2rem; height: 2rem; font-size: 0.7rem; }
}

/* ---------- snapping ---------- */

html {
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
  scroll-padding-top: calc(var(--head-h) + 4.5rem);
  scroll-padding-bottom: calc(var(--foot-h) + 4.5rem);
}
main > .page-head,
main > section,
main > .entries,
.hero-viewport,
.lore-page,
.bargain-page,
.tiles,
.license-page,
.colophon {
  scroll-snap-align: start;
}

/* ---------- index pages — each stop is a full stage ---------- */
.lore-page,
.bargain-page,
.tiles,
.license-page {
  min-height: calc(100vh - var(--head-h) - var(--foot-h));
  min-height: calc(100dvh - var(--head-h) - var(--foot-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* content centers on the visible region between the bars: the page
     lands at scroll-padding-top (+4.5rem of fade), so the extra pad
     below pushes its flex-center up onto the true middle. */
  padding: 2rem clamp(1rem, 4vw, 3rem) calc(2rem + 9rem);
  box-sizing: border-box;
}
/* Centered top-to-bottom; equal space from the left edge and the
   cue rail on the right. --edge gives both sides the same breathing
   floor so the box never touches the viewport edge. */
.bargain-page {
  --edge: clamp(0.75rem, 3vw, 2rem);
  padding-left: var(--edge);
  padding-right: calc(var(--edge) + max(2.75rem, calc(50vw - var(--max) / 2 + 3.3rem)));
}

/* The bargain materializes when its page arrives. .veiled is only
   ever set by the runtime — without it the box is always shown. */
.bargain-box {
  transition: opacity 1.1s ease, transform 1.1s ease, filter 1.1s ease;
}
.bargain-box.veiled {
  opacity: 0;
  transform: translateY(1.75rem) scale(0.96);
  filter: blur(9px);
}
.bargain-box.summoned {
  opacity: 1;
  transform: none;
  filter: none;
}

/* ---------- the Bargain License page ---------- */
.license-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.5vw, 2.8rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bone);
  margin: 0 0 0.75rem;
}
.license-lead {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent);
  margin: 0 0 1.75rem;
}
.license-terms {
  max-width: 38rem;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 12px;
  padding: 1.25rem clamp(1rem, 3vw, 1.75rem);
  background: color-mix(in srgb, var(--void-2) 55%, transparent);
}
.license-terms p {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--bone-dim);
  margin: 0.55rem 0;
}
.license-terms strong { color: var(--bone); font-weight: 600; }
.license-terms .t-num { color: var(--accent); margin-right: 0.5rem; }
.license-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 1.75rem;
}
.license-link:hover { color: var(--accent-2); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; scroll-snap-type: none; }
  .scroll-cue { transition: none; }
}
