:root {
  --scrolly-length: 620vh; /* scroll travel for the pinned stage */

  --ink: #f4f1ec;
  --ink-dim: #a49e95;
  --bg: #0d0d0f;
  --bg-soft: #16161a;
  --line: rgba(244, 241, 236, 0.14);
  --accent: #d8b06a;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.06;
  margin: 0;
}

a {
  color: inherit;
}

/* ------------------------------------------------------- pinned scrubber */

.scrolly {
  position: relative;
  height: var(--scrolly-length);
}

.stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #000 url("../media/poster.jpg") center / cover no-repeat;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.stage.is-live canvas {
  opacity: 1;
}

.stage__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 22% 72%, rgba(0, 0, 0, 0.65)),
    radial-gradient(120% 80% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.4));
}

/* loader / error */

.stage__loader {
  position: absolute;
  inset: auto 0 50% 0;
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.stage.is-live .stage__loader,
.stage.is-error .stage__loader {
  display: none;
}

.stage__loader i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--ink);
  animation: blink 1.1s ease-in-out infinite;
}

.stage__loader i:nth-child(2) { animation-delay: 0.15s; }
.stage__loader i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.stage__error {
  display: none;
  position: absolute;
  inset: 50% 1.5rem auto;
  transform: translateY(-50%);
  text-align: center;
  color: var(--ink-dim);
}

.stage.is-error .stage__error {
  display: block;
}

/* hud */

.stage__hud {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0 clamp(1.1rem, 4vw, 3rem) clamp(1.4rem, 3vw, 2.4rem);
  pointer-events: none;
}

.stage__hint {
  margin: 0 0 0.9rem;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244, 241, 236, 0.55);
}

.stage__progress {
  height: 2px;
  background: rgba(244, 241, 236, 0.18);
  overflow: hidden;
}

.stage__progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* -------------------------------------------------------------- POI pins */

.poi-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.poi {
  /* transform + opacity are written every frame by poi-layer.js, so nothing
     here may transition them — CSS would fight the scrub. */
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: transform, opacity;
}

.poi.is-visible {
  visibility: visible;
  pointer-events: auto;
}

.poi__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(244, 241, 236, 0.5);
  background: rgba(14, 14, 16, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.poi__dot svg {
  width: 1.35rem;
  height: 1.35rem;
}

.poi__pulse {
  position: absolute;
  left: 1.45rem;
  top: 50%;
  width: 2.9rem;
  height: 2.9rem;
  margin: -1.45rem 0 0 -1.45rem;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse 2.8s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.75; }
  70%, 100% { transform: scale(2.1); opacity: 0; }
}

.poi__tag {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  background: rgba(14, 14, 16, 0.52);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  transition: background 0.3s;
}

.poi__kicker {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.poi__label {
  font-size: 0.88rem;
  font-weight: 500;
}

.poi:hover .poi__dot,
.poi:focus-visible .poi__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #17130b;
  box-shadow: 0 10px 32px rgba(216, 176, 106, 0.4);
}

.poi:hover .poi__tag,
.poi:focus-visible .poi__tag {
  background: rgba(14, 14, 16, 0.8);
}

.poi:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- popup */

.popup {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
}

.popup.is-open {
  display: flex;
}

.popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 6, 8, 0.66);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.popup__card {
  position: relative;
  width: min(34rem, 100%);
  max-height: 85svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.6rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: linear-gradient(160deg, #1b1b20, #121215);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  will-change: transform, opacity;
}

.popup__close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.popup__close:hover {
  background: rgba(244, 241, 236, 0.1);
}

.popup__close svg {
  width: 1rem;
  height: 1rem;
}

.popup__kicker {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.popup__title {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  margin-bottom: 0.9rem;
}

.popup__body {
  margin: 0;
  color: var(--ink-dim);
  line-height: 1.65;
}

.popup__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 1rem;
  margin: 1.8rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.popup__meta dt {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.popup__meta dd {
  margin: 0.3rem 0 0;
  font-size: 1rem;
}

.popup__cta {
  display: inline-block;
  margin-top: 1.8rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #17130b;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.25s;
}

.popup__cta:hover {
  filter: brightness(1.08);
}

/* -------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  :root {
    --scrolly-length: 520vh;
  }

  .poi__tag {
    display: none; /* the pin alone; labels would crowd a phone screen */
  }

  .poi__dot {
    width: 2.5rem;
    height: 2.5rem;
  }

  .poi__pulse {
    left: 1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    margin: -1.25rem 0 0 -1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .poi__pulse,
  .stage__loader i {
    animation: none;
  }

  .stage canvas {
    transition: none;
  }
}
