/* ===========================================================
   Room 11 — Country
   An interactive relief map: story pinned to place.
   =========================================================== */

@font-face {
  font-family: "Fraunces Var";
  src: url("/vendor/fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk Var";
  src: url("/vendor/fonts/SpaceGrotesk-Variable.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader Italic Var";
  src: url("/vendor/fonts/Newsreader-Italic-Variable.woff2") format("woff2");
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader Var";
  src: url("/vendor/fonts/Newsreader-Variable.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #120d09;
  --panel: #1c160f;
  --panel-2: #241c14;
  --paper: #f4ead9;
  --paper-dim: #cfc0a8;
  --ochre: #dd934c;
  --ochre-deep: #a85f2e;
  --charcoal: #3c362d;
  --stone: #a89a86;
  --line: rgba(244, 234, 217, 0.16);
  --line-soft: rgba(244, 234, 217, 0.08);
  --teal: #6fa89c;
  --shadow: rgba(8, 5, 2, 0.5);

  --wash-color: 20, 15, 10;
  --wash-a: 0.08;
  --glow-color: 217, 148, 90;
  --glow-a: 0;

  --ease: cubic-bezier(0.22, 0.68, 0.1, 1);
  --dur-glide: 1400ms;
  --dur-fade: 900ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Space Grotesk Var", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

::selection { background: var(--ochre-deep); color: var(--paper); }

/* ---------------------------------------------------------- chrome */

.chrome {
  position: fixed;
  top: 18px;
  z-index: 60;
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--paper-dim);
  text-decoration: none;
}
.chrome--index {
  left: 20px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 13, 9, 0.55);
  backdrop-filter: blur(6px);
  transition: color 220ms ease, border-color 220ms ease;
}
.chrome--index:hover { color: var(--paper); border-color: var(--ochre); }
.chrome--label {
  right: 20px;
  padding: 6px 10px;
}

.sound-toggle {
  position: fixed;
  top: 18px;
  right: 130px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 13, 9, 0.55);
  backdrop-filter: blur(6px);
  color: var(--paper-dim);
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 220ms ease, border-color 220ms ease;
}
.sound-toggle:hover { color: var(--paper); border-color: var(--ochre); }
.sound-toggle__icon { width: 16px; height: 16px; overflow: visible; }
.sound-toggle__icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-toggle__body { fill: currentColor; stroke: none; }
.sound-toggle__x { opacity: 0; transition: opacity 160ms ease; }
.sound-toggle[aria-pressed="true"] .sound-toggle__x { opacity: 1; }
.sound-toggle[aria-pressed="true"] .sound-toggle__wave { opacity: 0; }
.sound-toggle__wave { transition: opacity 160ms ease; }

/* ---------------------------------------------------------- stage */

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: var(--ink);
}
.map-stage.is-dragging { cursor: grabbing; }

.map-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.map-world__relief,
.map-world__contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}
.map-world__contours {
  mix-blend-mode: soft-light;
  opacity: 0.9;
}
.map-world__pins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* pins */
.pin {
  cursor: pointer;
}
.pin__halo {
  fill: rgba(221, 147, 76, 0.0);
  stroke: none;
  transition: fill 260ms ease;
}
.pin__ring {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.6;
  opacity: 0.85;
  transform-box: fill-box;
  transform-origin: center;
  transition: r 240ms ease, opacity 240ms ease, stroke 240ms ease;
}
.pin__dot {
  fill: var(--ochre);
  stroke: rgba(18, 13, 9, 0.65);
  stroke-width: 2;
  transition: fill 240ms ease, r 240ms ease;
}
.pin__label {
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 15px;
  letter-spacing: 0.06em;
  fill: var(--paper);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 240ms ease, transform 240ms ease;
  paint-order: stroke;
  stroke: rgba(12, 8, 5, 0.75);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.pin:hover .pin__label,
.pin.is-active .pin__label { opacity: 1; transform: translateY(0); }
.pin:hover .pin__ring { r: 15; opacity: 1; }
.pin.is-active .pin__dot { fill: var(--paper); }
.pin.is-active .pin__ring { r: 17; stroke: var(--ochre); opacity: 1; }
.pin__pulse {
  fill: none;
  stroke: var(--ochre);
  stroke-width: 1.4;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.pin.is-active .pin__pulse { animation: pinPulse 2600ms ease-out infinite; }

@keyframes pinPulse {
  0% { r: 10px; opacity: 0.55; }
  100% { r: 28px; opacity: 0; }
}

/* ---------------------------------------------------------- ambience */

.ambience {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.ambience__wash {
  position: absolute;
  inset: 0;
  background: rgba(var(--wash-color), var(--wash-a));
  transition: background-color var(--dur-fade) ease, opacity var(--dur-fade) ease;
  mix-blend-mode: multiply;
}
.ambience__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 45% at var(--glow-x, 50%) var(--glow-y, 55%),
    rgba(var(--glow-color), var(--glow-a)) 0%, rgba(var(--glow-color), 0) 70%);
  transition: opacity var(--dur-fade) ease;
}
.ambience__particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1200ms ease;
}
.ambience__particles.is-on { opacity: 1; }

/* vignette frame — the "under glass" feel */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  box-shadow: inset 0 0 min(14vw, 220px) rgba(4, 3, 2, 0.62);
}

/* ---------------------------------------------------------- intro */

.intro {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: 300px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: opacity 500ms ease, transform 500ms ease;
  pointer-events: none;
}
.intro__kicker {
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ochre);
}
.intro__body {
  font-family: "Newsreader Italic Var", serif;
  font-style: italic;
  font-size: 14px;
  line-height: 1.4;
  color: var(--paper-dim);
}
body.has-selection .intro { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------- recenter */

.recenter {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 41;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 13, 9, 0.6);
  backdrop-filter: blur(6px);
  color: var(--paper-dim);
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 320ms ease, transform 320ms ease, color 220ms ease, border-color 220ms ease;
}
.recenter svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.6; fill: none; }
body.has-selection .recenter { opacity: 1; transform: translateY(0); pointer-events: auto; }
.recenter:hover { color: var(--paper); border-color: var(--ochre); }

/* ---------------------------------------------------------- legend */

.legend {
  position: fixed;
  right: 20px;
  top: 66px;
  z-index: 40;
  width: 218px;
  font-family: "Space Grotesk Var", sans-serif;
}
.legend__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(18, 13, 9, 0.6);
  backdrop-filter: blur(6px);
  color: var(--paper-dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 220ms ease, border-color 220ms ease;
}
.legend__toggle:hover { color: var(--paper); }
.legend__toggle svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8; fill: none; transition: transform 260ms var(--ease); }
.legend__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.legend__list {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(18, 13, 9, 0.72);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.legend__item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  width: 100%;
  padding: 8px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--paper-dim);
  font-family: "Fraunces Var", serif;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.legend__item:hover { background: rgba(221, 147, 76, 0.1); color: var(--paper); }
.legend__item.is-active { background: rgba(221, 147, 76, 0.16); color: var(--ochre); }
.legend__item-mark {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--stone);
  flex: none;
}
.legend__item.is-active .legend__item-mark { background: var(--ochre); }

/* ---------------------------------------------------------- compass */

.compass {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  width: 84px;
  height: 84px;
  opacity: 0.88;
}
.compass svg { width: 100%; height: 100%; overflow: visible; }
.compass__ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.compass__ring--inner { stroke: var(--line-soft); }
.compass__needle {
  fill: var(--ochre);
  opacity: 0.85;
  transform-box: fill-box;
  transform-origin: center;
  animation: compassBreathe 14s ease-in-out infinite;
}
.compass__label {
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 9px;
  letter-spacing: 0.05em;
  fill: var(--paper-dim);
}
.compass__weather {
  font-family: "Newsreader Italic Var", serif;
  font-style: italic;
  font-size: 7px;
  fill: var(--teal);
}
@keyframes compassBreathe {
  0%, 100% { transform: rotate(-1.2deg); }
  50% { transform: rotate(1.2deg); }
}

/* ---------------------------------------------------------- scale bar */

.scale-bar {
  position: fixed;
  left: 20px;
  top: 66px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0.85;
}
.scale-bar svg { width: 118px; height: 15px; overflow: visible; }
.scale-bar path { fill: none; stroke: var(--paper-dim); stroke-width: 1.1; }
.scale-bar__label {
  font-family: "Newsreader Italic Var", serif;
  font-style: italic;
  font-size: 10.5px;
  color: var(--paper-dim);
  max-width: 150px;
}

/* ---------------------------------------------------------- card */

.card {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 22px 24px 24px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(175deg, rgba(28, 22, 15, 0.94), rgba(20, 15, 10, 0.96));
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(14px) scale(0.98);
  opacity: 0;
  transition: transform 480ms var(--ease), opacity 380ms ease;
}
.card.is-open { transform: translateY(0) scale(1); opacity: 1; }
.card:not(.is-open) { pointer-events: none; }

.card__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease, transform 200ms ease;
}
.card__close svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 1.8; }
.card__close:hover { color: var(--paper); border-color: var(--ochre); transform: rotate(90deg); }

.card__kicker {
  margin: 0 0 6px;
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ochre);
}
.card__name {
  margin: 0 0 12px;
  font-family: "Fraunces Var", serif;
  font-variation-settings: "opsz" 40, "SOFT" 20;
  font-weight: 480;
  font-size: 30px;
  line-height: 1.06;
  color: var(--paper);
  max-width: 90%;
}
.card__note {
  margin: 0 0 18px;
  font-family: "Newsreader Italic Var", serif;
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--paper-dim);
}

.card__audio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line-soft);
  margin-bottom: 18px;
}
.card__play {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--ochre);
  background: rgba(221, 147, 76, 0.12);
  color: var(--ochre);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 200ms ease, transform 160ms ease;
}
.card__play:hover { background: rgba(221, 147, 76, 0.22); }
.card__play:active { transform: scale(0.94); }
.card__play-icon { width: 18px; height: 18px; }
.card__play-triangle, .card__play-bars rect { fill: currentColor; }
.card__play-bars { display: none; }
.card__play.is-playing .card__play-triangle { display: none; }
.card__play.is-playing .card__play-bars { display: block; }

.card__meter {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  flex: 1;
}
.card__meter span {
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: var(--ochre-deep);
  opacity: 0.55;
  transform-origin: center;
  transition: opacity 300ms ease;
}
.card__play.is-playing ~ .card__meter span,
.card__audio:has(.card__play.is-playing) .card__meter span {
  opacity: 1;
  animation: meterBar 1100ms ease-in-out infinite;
}
.card__meter span:nth-child(1) { animation-delay: -0.9s; }
.card__meter span:nth-child(2) { animation-delay: -0.5s; }
.card__meter span:nth-child(3) { animation-delay: -1.1s; }
.card__meter span:nth-child(4) { animation-delay: -0.2s; }
.card__meter span:nth-child(5) { animation-delay: -0.7s; }
@keyframes meterBar {
  0%, 100% { height: 5px; }
  50% { height: 17px; }
}
.card__audio-label {
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-dim);
  opacity: 0.7;
}

.card__slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px 18px;
  border-radius: 12px;
  border: 1px dashed rgba(244, 234, 217, 0.28);
  background:
    repeating-linear-gradient(135deg, rgba(244,234,217,0.025) 0 2px, transparent 2px 10px);
  text-align: center;
}
.card__slot-mark { width: 20px; height: 20px; opacity: 0.6; margin-bottom: 2px; }
.card__slot-mark svg { width: 100%; height: 100%; }
.card__slot-mark circle { fill: none; stroke: var(--paper-dim); stroke-width: 1; }
.card__slot-title {
  font-family: "Fraunces Var", serif;
  font-style: italic;
  font-size: 15px;
  color: var(--paper-dim);
}
.card__slot-body {
  font-family: "Newsreader Italic Var", serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(207, 192, 168, 0.68);
  max-width: 240px;
}

/* ---------------------------------------------------------- notes footer */

.notes {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.notes__toggle {
  pointer-events: auto;
  margin: 0 0 14px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 13, 9, 0.7);
  backdrop-filter: blur(8px);
  color: var(--paper-dim);
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease;
}
.notes__toggle:hover { color: var(--paper); border-color: var(--ochre); }
.notes__panel {
  pointer-events: auto;
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  z-index: 56;
  width: min(920px, calc(100vw - 40px));
  max-height: min(64vh, 520px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px;
  padding: 26px 30px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(16, 12, 8, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.notes__panel[hidden] { display: none; }
.notes__col h2 {
  margin: 0 0 8px;
  font-family: "Space Grotesk Var", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ochre);
}
.notes__col p {
  margin: 0;
  font-family: "Newsreader Var", serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--paper-dim);
}

/* ---------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  /* opacity-only so the JS glide-substitution fades (transform stays instant —
     no animated camera glide under reduced motion; see glideTo() fade path) */
  .map-world { transition: opacity 260ms ease !important; }
  .pin.is-active .pin__pulse { animation: none; opacity: 0.3; }
  .compass__needle { animation: none; }
  .card__meter span { animation: none !important; height: 11px !important; }
  .card, .recenter, .intro { transition-duration: 220ms; }
}

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

@media (max-width: 720px) {
  .sound-toggle { right: 20px; top: 60px; }
  .chrome--label { top: 18px; }
  .legend { top: auto; bottom: 20px; left: 20px; right: 20px; width: auto; }
  .legend__toggle { width: auto; padding: 9px 14px; }
  .legend__list { position: absolute; bottom: 44px; left: 0; right: 0; max-height: 46vh; overflow-y: auto; }
  .intro { display: none; }
  .recenter { left: auto; right: 20px; bottom: 20px; }
  body.has-selection .legend { display: none; }
  .compass { width: 62px; height: 62px; right: 16px; bottom: 16px; }
  .scale-bar { display: none; }
  .card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: 62vh;
    border-radius: 16px;
  }
  .card__name { font-size: 26px; }
  .notes__panel { grid-template-columns: 1fr; padding: 22px; }
}

@media (max-width: 420px) {
  .card__name { font-size: 23px; }
  .card__note { font-size: 14px; }
}
