/* Andrews & Sons · The Cartographer's Folio (Production)
   Tolkien-Inspired Copperplate Cartography × Custom GLSL Parchment & Moon-Letter Shader */

@font-face {
  font-family: "Source Serif 4";
  src: url("./assets/source-serif-4-variable.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("./assets/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #efeae0;
  --fg: #0d2417;
  --fg-soft: #314237;
  --fg-muted: #56665c;
  --rule: rgba(13, 36, 23, 0.17);
  --rule-strong: rgba(13, 36, 23, 0.32);
  --gold: #9a6516;
  --gold-bright: #c58826;
  --glass: rgba(246, 242, 233, 0.86);
  --cta-bg: #0e2c1b;
  --cta-fg: #faf6ee;
  --pill-active-bg: #0e2c1b;
  --pill-active-fg: #faf6ee;
  --map-label-fg: #0b2215;
  --map-sub-fg: #443b2c;
  --map-sea-fg: rgba(18, 44, 29, 0.54);
  --trail-color: #a66c14;
  --trail-glow: #d89b3c;
  --trail-ghost: rgba(19, 43, 27, 0.24);
  --veil-rgb: 239, 234, 224;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-mood="obsidian"] {
  --bg: #06120b;
  --fg: #f7f3eb;
  --fg-soft: rgba(247, 243, 235, 0.8);
  --fg-muted: rgba(247, 243, 235, 0.56);
  --rule: rgba(247, 243, 235, 0.17);
  --rule-strong: rgba(247, 243, 235, 0.34);
  --gold: #e6a844;
  --gold-bright: #f7cf80;
  --glass: rgba(7, 21, 13, 0.84);
  --cta-bg: #f7f3eb;
  --cta-fg: #06120b;
  --pill-active-bg: #e6a844;
  --pill-active-fg: #06120b;
  --map-label-fg: #f7d996;
  --map-sub-fg: rgba(245, 226, 182, 0.72);
  --map-sea-fg: rgba(230, 178, 88, 0.36);
  --trail-color: #f6c96c;
  --trail-glow: #ffda88;
  --trail-ghost: rgba(235, 184, 92, 0.22);
  --veil-rgb: 6, 18, 11;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.55s var(--ease), color 0.55s var(--ease);
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, a, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.mono {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ============================================================
   FULL-VIEWPORT GLSL CARTOGRAPHY STAGE & PIXEL-LOCKED OVERLAY
   ============================================================ */

#map-gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100lvh;
  z-index: 1;
}

#map-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100lvh;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

/* Soft Left Atmospheric Vignette so Copy Always Reads Effortlessly */
.reading-veil {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(var(--veil-rgb), 0.94) 0%,
    rgba(var(--veil-rgb), 0.86) 27%,
    rgba(var(--veil-rgb), 0.52) 41%,
    rgba(var(--veil-rgb), 0.0) 56%
  );
  transition: background 0.55s var(--ease);
}

.scroll-runway {
  position: relative;
  height: 560vh;
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   LIVE VECTOR CARTOGRAPHY ELEMENTS (TRAIL, BEACONS, LABELS)
   ============================================================ */

.map-sea-label {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.44em;
  font-weight: 500;
  fill: var(--map-sea-fg);
  text-anchor: middle;
}

.map-cartouche {
  opacity: 0.84;
  transition: opacity 0.55s var(--ease);
}

.map-cartouche.is-active {
  opacity: 1;
}

.cartouche-bg {
  fill: rgba(var(--veil-rgb), 0.92);
  stroke: var(--rule-strong);
  stroke-width: 1.25;
  transition: fill 0.5s var(--ease), stroke 0.5s var(--ease);
}

.map-cartouche.is-active .cartouche-bg {
  stroke: var(--gold-bright);
  stroke-width: 1.5;
}

.cartouche-inner {
  fill: none;
  stroke: var(--gold);
  stroke-width: 0.65;
  opacity: 0.55;
  transition: opacity 0.5s var(--ease), stroke 0.5s var(--ease);
}

.map-cartouche.is-active .cartouche-inner {
  opacity: 0.92;
}

.map-region-label {
  font-family: var(--serif);
  font-size: 13.5px;
  letter-spacing: 0.24em;
  font-weight: 650;
  fill: var(--map-label-fg);
  text-anchor: middle;
  transition: fill 0.5s var(--ease);
}

.map-colophon-label {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.32em;
  font-weight: 650;
  fill: var(--gold);
  text-anchor: middle;
  transition: fill 0.5s var(--ease);
}

.map-sub-label {
  font-family: var(--sans);
  font-size: 9.8px;
  letter-spacing: 0.06em;
  font-weight: 500;
  fill: var(--map-sub-fg);
  text-anchor: middle;
  transition: fill 0.5s var(--ease);
}

.journey-ghost {
  stroke: var(--trail-ghost);
  stroke-width: 1.8;
  stroke-dasharray: 4 7;
  stroke-linecap: round;
}

.journey-trail-glow {
  stroke: var(--trail-glow);
  stroke-width: 5.5;
  stroke-linecap: round;
  opacity: 0.42;
}

.journey-trail {
  stroke: var(--trail-color);
  stroke-width: 2.3;
  stroke-dasharray: 8 5;
  stroke-linecap: round;
}

.waypoint-node {
  opacity: 0.42;
  transition: opacity 0.5s var(--ease);
}

.waypoint-node.is-lit {
  opacity: 1;
}

.wp-pulse {
  fill: none;
  stroke: var(--trail-glow);
  stroke-width: 1.2;
  opacity: 0;
}

.waypoint-node.is-lit .wp-pulse {
  animation: wpRipple 2.8s var(--ease) infinite;
}

.wp-ring {
  fill: rgba(var(--veil-rgb), 0.72);
  stroke: var(--trail-color);
  stroke-width: 1.6;
}

.wp-core {
  fill: var(--trail-color);
}

@keyframes wpRipple {
  0% { r: 9; opacity: 0.75; }
  100% { r: 24; opacity: 0; }
}

.mill-wheel-spin {
  transform-box: fill-box;
  transform-origin: center;
}

.mill-node.is-lit .mill-wheel-spin {
  animation: millRotate 14s linear infinite;
}

@keyframes millRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.beacon {
  opacity: 0.14;
  transition: opacity 0.55s var(--ease);
}

.beacon.is-lit {
  opacity: 1;
}

.beacon.is-blazing .beacon-halo {
  animation: fireBlaze 1.1s ease-in-out infinite alternate;
}

@keyframes fireBlaze {
  0% { opacity: 0.92; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1.42); }
}

.beacon-halo {
  transform-box: fill-box;
  transform-origin: center;
}

.beacon.is-lit .beacon-halo {
  animation: fireFlicker 1.9s ease-in-out infinite alternate;
}

.beacon-spark {
  fill: #fff4d1;
  stroke: #d4891e;
  stroke-width: 1.2;
}

@keyframes fireFlicker {
  0% { opacity: 0.78; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1.16); }
}

.cursor-diamond {
  fill: #fff3cf;
  stroke: #b57618;
  stroke-width: 1.3;
}

/* ============================================================
   TOP CHROME
   ============================================================ */

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.45rem clamp(1.25rem, 3.8vw, 3.25rem);
  pointer-events: none;
}

.hud-top > * { pointer-events: auto; }

.hud-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.hud-brand img { width: 5.9rem; height: auto; display: block; }
.hud-brand .logo-dark { display: block; }
.hud-brand .logo-light { display: none; }
[data-mood="obsidian"] .hud-brand .logo-dark { display: none; }
[data-mood="obsidian"] .hud-brand .logo-light { display: block; }

.hud-right { display: flex; align-items: center; gap: 0.7rem; }

.mood-toggle {
  display: inline-flex;
  padding: 0.22rem;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.mood-btn {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.36rem 0.82rem;
  border-radius: 999px;
  color: var(--fg-soft);
  font-weight: 500;
  transition: all 0.25s var(--ease);
}

[data-mood="obsidian"] .mood-btn { color: rgba(247, 243, 235, 0.82); }

.mood-btn[aria-pressed="true"] {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg) !important;
  font-weight: 600;
}

.hud-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.62rem 1.24rem;
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  font-size: 0.83rem;
  font-weight: 560;
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease);
}

.hud-cta:hover {
  transform: translateY(-1px);
  background: #c58826;
  color: #faf6ee;
}

/* ============================================================
   UNOBSTRUCTED LEFT NARRATIVE COLUMN
   ============================================================ */

.stages-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.stage-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 6rem clamp(1.5rem, 4.8vw, 4.75rem) 6rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.48s var(--ease), transform 0.6s var(--ease);
  pointer-events: none;
}

.stage-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.stage-content {
  width: 100%;
  max-width: 30.5rem;
  pointer-events: auto;
}

.stage-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--gold);
  margin-bottom: 1.05rem;
}

.stage-kicker::before {
  content: "";
  width: 1.85rem;
  height: 1px;
  background: currentColor;
}

.stage-title {
  font-family: var(--serif);
  font-weight: 340;
  font-size: clamp(2.55rem, 4.55vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--fg);
  margin-bottom: 1.2rem;
  text-wrap: balance;
}

.stage-title .gold { color: var(--gold); font-weight: 280; }

.stage-copy {
  font-size: clamp(0.97rem, 1.16vw, 1.07rem);
  line-height: 1.66;
  color: var(--fg-soft);
  max-width: 28.5rem;
  margin-bottom: 1.55rem;
}

.stage-specs {
  border-top: 1px solid var(--rule);
  max-width: 28rem;
  margin-bottom: 1.5rem;
}

.stage-specs li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.62rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.84rem;
}

.stage-specs .k { color: var(--fg-muted); }
.stage-specs .v { color: var(--fg); font-weight: 500; text-align: right; }

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.4rem;
}

.btn-solid {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.86rem 1.58rem;
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  font-size: 0.88rem;
  font-weight: 560;
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease);
}

.btn-solid:hover {
  transform: translateY(-2px);
  background: #c58826;
  color: #faf6ee;
}

.btn-line {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--fg);
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--rule-strong);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.btn-line:hover { color: var(--gold); border-color: var(--gold); }

.sdg-mark {
  display: inline-block;
  margin-bottom: 1.35rem;
  color: var(--gold);
  letter-spacing: 0.24em;
}

/* ============================================================
   BOTTOM RAIL & COMPASS TELEMETRY
   ============================================================ */

.hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1.25rem, 3.8vw, 3.25rem);
  pointer-events: none;
}

.hud-bottom > * { pointer-events: auto; }

.stage-rail {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-soft);
  font-weight: 500;
  transition: all 0.25s var(--ease);
}

.rail-btn:hover { color: var(--fg); }

.rail-btn[aria-current="true"] {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg);
  font-weight: 600;
}

.hud-telemetry {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--fg-soft);
  padding: 0.42rem 0.92rem;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
}

.mini-compass {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--fg);
}

.coord-readout {
  color: var(--gold);
  font-weight: 600;
}

.progress-bar {
  width: 4.5rem;
  height: 2.5px;
  background: var(--rule-strong);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
}

/* ============================================================
   CONVERSATION DRAWER
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(6, 18, 11, 0.24);
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease);
}

.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.inquiry-sheet {
  width: min(32rem, 100%);
  height: 100%;
  background: #091b11;
  color: #f7f3eb;
  border-left: 1px solid rgba(230, 168, 68, 0.35);
  padding: clamp(1.75rem, 4vw, 2.75rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateX(36px);
  transition: transform 0.45s var(--ease);
  overflow-y: auto;
}

.drawer-backdrop.is-open .inquiry-sheet { transform: translateX(0); }

.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(247, 243, 235, 0.16);
  margin-bottom: 1.75rem;
}

.sheet-close {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(247, 243, 235, 0.28);
  color: rgba(247, 243, 235, 0.86);
}

.sheet-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 350;
  line-height: 1.06;
  margin-bottom: 0.65rem;
}

.sheet-sub {
  font-size: 0.9rem;
  line-height: 1.6;
  color: rgba(247, 243, 235, 0.74);
  margin-bottom: 1.75rem;
}

.sheet-field { margin-bottom: 1.25rem; }

.sheet-field label,
.sheet-field .field-label {
  display: block;
  margin-bottom: 0.42rem;
  color: rgba(247, 243, 235, 0.58);
}

.scope-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.scope-chip {
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(247, 243, 235, 0.24);
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(247, 243, 235, 0.82);
  transition: all 0.22s var(--ease);
}

.scope-chip:hover {
  border-color: #e6a844;
}

.scope-chip.is-selected {
  background: #e6a844;
  border-color: #e6a844;
  color: #06120b;
  font-weight: 600;
}

.beacon-relay {
  padding: 1.35rem 1.4rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(230, 168, 68, 0.42);
  background: rgba(230, 168, 68, 0.08);
}

.relay-head {
  color: #f6c96c;
  margin-bottom: 0.9rem;
}

.relay-steps {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.relay-steps li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.86rem;
  color: rgba(247, 243, 235, 0.36);
  transition: color 0.35s var(--ease), transform 0.35s var(--ease);
}

.relay-steps li span {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: rgba(230, 168, 68, 0.45);
}

.relay-steps li.is-done {
  color: #f7f3eb;
}

.relay-steps li.is-done span {
  color: #f6c96c;
}

.relay-steps li.is-done::after {
  content: "✓";
  margin-left: auto;
  color: #f6c96c;
  font-weight: 600;
}

.relay-note {
  color: rgba(247, 243, 235, 0.58);
  line-height: 1.5;
}

.sheet-field input,
.sheet-field textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(247, 243, 235, 0.26);
  padding: 0.55rem 0;
  color: #f7f3eb;
  font-size: 0.94rem;
}

.sheet-field input:focus,
.sheet-field textarea:focus {
  outline: none;
  border-bottom-color: #e6a844;
}

.sheet-field textarea { min-height: 5rem; resize: vertical; }

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  margin: 0 0 0.85rem;
  font-size: 0.84rem;
  color: #f6b36c;
}

.sheet-submit {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  background: #e6a844;
  color: #06120b;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.sheet-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.sheet-foot {
  padding-top: 1.5rem;
  border-top: 1px solid rgba(247, 243, 235, 0.16);
  margin-top: 2rem;
  color: rgba(247, 243, 235, 0.64);
  font-size: 0.8rem;
  line-height: 1.55;
}

@media (max-width: 960px) {
  .mood-toggle,
  .hud-telemetry { display: none; }

  .hud-top {
    padding: calc(0.95rem + env(safe-area-inset-top, 0px)) 1.1rem 0.9rem;
    background: linear-gradient(180deg, rgba(var(--veil-rgb), 0.86) 0%, rgba(var(--veil-rgb), 0.45) 68%, rgba(var(--veil-rgb), 0) 100%);
  }

  .hud-brand img {
    width: 4.85rem;
  }

  .hud-cta {
    padding: 0.52rem 0.98rem;
    font-size: 0.78rem;
  }

  .reading-veil {
    background: linear-gradient(
      0deg,
      rgba(var(--veil-rgb), 0.99) 0%,
      rgba(var(--veil-rgb), 0.96) 44%,
      rgba(var(--veil-rgb), 0.82) 56%,
      rgba(var(--veil-rgb), 0.0) 70%
    );
  }

  .stage-panel {
    justify-content: flex-end;
    padding: 5rem 1.25rem calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }

  .stage-content {
    max-width: 100%;
  }

  .stage-kicker {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    margin-bottom: 0.65rem;
  }

  .stage-title {
    font-size: clamp(1.95rem, 8.2vw, 2.55rem);
    line-height: 0.98;
    margin-bottom: 0.72rem;
  }

  .stage-copy {
    font-size: 0.9rem;
    line-height: 1.54;
    margin-bottom: 0.95rem;
  }

  .stage-specs {
    margin-bottom: 0.5rem;
  }

  .stage-specs li {
    padding-block: 0.44rem;
    font-size: 0.79rem;
  }

  .sdg-mark {
    margin-bottom: 0.85rem;
    font-size: 0.62rem;
  }

  .btn-solid {
    padding: 0.72rem 1.28rem;
    font-size: 0.83rem;
  }

  .btn-line {
    font-size: 0.82rem;
  }

  .hud-bottom {
    padding: 0.6rem 1.1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(0deg, rgba(var(--veil-rgb), 0.98) 55%, rgba(var(--veil-rgb), 0) 100%);
  }

  .stage-rail {
    width: 100%;
    justify-content: space-between;
  }

  .rail-btn {
    padding: 0.36rem 0.62rem;
  }

  .rail-btn .rail-label { display: none; }
}
