/* ==========================================================================
   System Map - full-viewport graph viewer.
   Canvas occupies the entire main area below the topstrip.
   ========================================================================== */

.map-shell {
  position: fixed;
  top: var(--topstrip-h);
  left: var(--rail-w);
  right: 0;
  bottom: 0;
  /* Theme-aware backdrop. In dark mode this resolves to a deep blue-black
     radial; in light mode it becomes a soft warm-white radial so the
     filter pills and search box render with proper contrast. */
  background: radial-gradient(
    ellipse at center,
    color-mix(in oklch, var(--surface-0) 92%, transparent) 0%,
    var(--surface-0) 100%
  );
  overflow: hidden;
}
@media (max-width: 960px) {
  .map-shell { left: 0; }
}

#map-canvas-wrap {
  position: absolute;
  inset: 0;
}
#map-canvas-wrap canvas {
  display: block;
  cursor: grab;
}
#map-canvas-wrap canvas:active { cursor: grabbing; }

/* HUD: filter chips at the top of the map */
.map-hud {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}
.map-hud > * { pointer-events: auto; }
.map-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in oklch, var(--surface-1) 85%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  min-width: 280px;
  max-width: 360px;
}
.map-search-box input {
  background: transparent;
  border: 0;
  color: var(--text-1);
  font-size: var(--fs-200);
  outline: none;
  flex: 1;
  font-family: var(--font-sans);
}
.map-search-box input::placeholder { color: var(--text-4); }
.map-search-box .ico { color: var(--text-3); width: 14px; height: 14px; flex: 0 0 auto; }

.map-filter-chip {
  padding: 6px 12px;
  background: color-mix(in oklch, var(--surface-1) 85%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text-2);
  font-size: var(--fs-200);
  font-family: var(--font-sans);
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-filter-chip:hover { background: var(--surface-2); border-color: var(--border-3); }
.map-filter-chip[aria-pressed="true"] {
  background: var(--accent-faint);
  color: var(--accent);
  border-color: var(--accent);
}
.map-filter-chip .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
}

.map-module-select {
  padding: 6px 28px 6px 12px;
  background: color-mix(in oklch, var(--surface-1) 85%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text-2);
  font-size: var(--fs-200);
  font-family: var(--font-sans);
  appearance: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
  max-width: 200px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) center, calc(100% - 8px) center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

/* Hover card */
.map-hover-card {
  position: absolute;
  background: color-mix(in oklch, var(--surface-2) 96%, transparent);
  border: 1px solid var(--border-3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  max-width: 280px;
  pointer-events: none;
  z-index: 20;
  font-size: var(--fs-200);
  color: var(--text-1);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-3);
  display: none;
}
.map-hover-card[data-visible="true"] { display: block; }
.map-hover-card .name { font-weight: 600; margin: 0 0 4px; }
.map-hover-card .stub { color: var(--text-3); font-size: var(--fs-100); margin: 0 0 6px; line-height: 1.4; }
.map-hover-card .pills { display: flex; gap: 4px; flex-wrap: wrap; }
.map-hover-card .pill { font-size: 10px; padding: 1px 6px; }

/* Mini-map */
.map-mini {
  position: absolute;
  bottom: 18px;
  right: 18px;
  width: 200px;
  height: 140px;
  background: color-mix(in oklch, var(--surface-1) 90%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
  backdrop-filter: blur(6px);
}

/* Legend */
.map-legend {
  position: absolute;
  bottom: 18px;
  left: 18px;
  max-width: calc(100% - 36px);
  padding: 12px 14px;
  background: color-mix(in oklch, var(--surface-1) 90%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: .04em;
  text-transform: uppercase;
  z-index: 10;
  backdrop-filter: blur(6px);
}
.map-legend .row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.map-legend .row:last-child { margin-bottom: 0; }
.map-legend .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }

/* Concept side-sheet (slides in from the right when a node is clicked) */
.map-concept-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 92%;
  background: var(--surface-1);
  border-left: 1px solid var(--border-2);
  z-index: 30;
  transform: translateX(100%);
  transition: transform var(--dur-mid) var(--ease-out);
  overflow-y: auto;
  box-shadow: var(--shadow-3);
}
.map-concept-sheet[data-open="true"] { transform: translateX(0); }
.map-concept-sheet-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  background: var(--surface-1);
  z-index: 1;
}
.map-concept-sheet-body { padding: 18px; }

/* Hidden parallel list for keyboard / screen readers */
.map-a11y-list {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

/* Help overlay */
.map-help {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: color-mix(in oklch, var(--surface-1) 90%, transparent);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-3);
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.map-help kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--border-3);
  border-radius: 3px;
  margin: 0 2px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* On mobile, the legend was removed in favor of the intuitive dot
   coloring, and the help text (keyboard shortcuts) is hidden because
   touch users navigate by gesture. The mini-map only renders on
   desktop today, but if it ever shows on mobile push it above the
   bottom-tab nav. */
@media (max-width: 767px) {
  .map-help { display: none; }
  .map-mini { bottom: calc(80px + env(safe-area-inset-bottom, 0)); }
}

/* ==========================================================================
   Reveal overlay (shown on first ever visit).
   ========================================================================== */
#reveal-overlay {
  position: fixed;
  inset: 0;
  background: #06060A;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  /*
   * Scope dark-mode tokens locally so the cinematic stays readable even
   * when the parent page is set to a light theme (the canvas background
   * is intentionally always dark). Without this, .reveal-title rendered
   * as #0A0A0B (near-black) on the dark canvas in light-theme sessions.
   */
  --surface-0: #08080A;
  --surface-1: #1A1A22;
  --surface-2: #25252E;
  --surface-3: #2E2E38;
  --text-1: #F4F4F5;
  --text-2: #C5C5CD;
  --text-3: #93939D;
  --text-4: #6B6B73;
  --border-1: #25252E;
  --border-2: #34343E;
  --border-3: #45454F;
  --accent: #B4A0FF;
  --accent-strong: #8B5CF6;
  --accent-soft: #C9B8FF;
  color: var(--text-1);
}
#reveal-overlay.is-leaving {
  opacity: 0;
  transform: scale(1.02);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  pointer-events: none;
}
#reveal-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/*
 * Grid-stack the welcome card and wizard at the same cell so they
 * crossfade in place instead of squishing into a shared flex row.
 */
#reveal-foreground {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}
#reveal-content,
#reveal-wizard {
  grid-area: 1 / 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#reveal-content {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  transition: opacity 360ms var(--ease-out), transform 360ms var(--ease-out);
}
#reveal-content.is-leaving {
  opacity: 0;
  transform: translateY(-6px) scale(0.985);
  pointer-events: none;
}

/* ----- Wizard mounted inside the reveal ----- */
#reveal-wizard {
  max-width: 560px;
  opacity: 0;
  transform: translateY(8px) scale(0.985);
  transition: opacity 420ms var(--ease-out) 120ms, transform 420ms var(--ease-out) 120ms;
}
#reveal-wizard.is-entering {
  opacity: 1;
  transform: none;
}
#reveal-wizard .onboarding {
  margin: 0;
  width: 100%;
  background: color-mix(in oklch, #16161E 78%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid color-mix(in oklch, #45454F 60%, transparent);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.6);
}
.reveal-logo {
  display: block;
  margin: 0 auto 18px;
  width: 72px;
  height: 72px;
  /* Subtle glow so the logo doesn't sit flat against the dark canvas. */
  filter: drop-shadow(0 0 24px rgba(180, 160, 255, 0.35));
  animation: fade-up var(--dur-slow) var(--ease-out) 50ms both;
}
@media (max-width: 420px) {
  .reveal-logo { width: 56px; height: 56px; }
}
.reveal-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 16px;
  animation: fade-up var(--dur-slow) var(--ease-out) 200ms both;
  /* Allow controlled wrapping so the eyebrow breaks between phrases on
     narrow screens rather than orphaning the trailing "2026". */
  text-wrap: balance;
  line-height: 1.5;
}
.reveal-eyebrow-line { display: inline-block; white-space: nowrap; }
@media (max-width: 420px) {
  .reveal-eyebrow {
    font-size: var(--fs-100);
    letter-spacing: .1em;
  }
}
.reveal-title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 650;
  letter-spacing: -.026em;
  line-height: 1.04;
  margin: 0 0 18px;
  color: var(--text-1);
  animation: fade-up var(--dur-slow) var(--ease-out) 400ms both;
  text-wrap: balance;
}
.reveal-tagline {
  color: var(--text-3);
  font-size: var(--fs-400);
  max-width: 50ch;
  margin: 0 auto 32px;
  animation: fade-up var(--dur-slow) var(--ease-out) 700ms both;
}
#reveal-skip {
  animation: fade-up var(--dur-slow) var(--ease-out) 1100ms both;
}

/* Tier-up toast extras */
.toast-tier .tier-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 6px;
}

