/*
 * Map page styles — browse.php
 * Covers: browse page layout, SVG map, tooltip, state labels.
 */

/* ── Browse page layout ──────────────────────────────────────────────────────── */

.browse-wrap {
  padding: var(--sp-8, 3rem) var(--sp-6, 1.5rem) var(--sp-10, 5rem);
}

/* Hero text block */
.hero {
  max-width: 640px;
  margin: 0 auto var(--sp-8, 3rem);
  text-align: center;
}
.hero h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  margin-bottom: var(--sp-4, 1rem);
  line-height: 1.08;
}
.hero .sub {
  font-size: var(--text-md, 1rem);
  color: var(--muted, #888);
  max-width: 480px;
  margin: 0 auto;
}

/* Map + rail side-by-side on desktop, stacked on mobile */
.map-wrap {
  display: flex;
  gap: var(--sp-6, 1.5rem);
  align-items: flex-start;
  justify-content: center;
  margin-bottom: var(--sp-8, 3rem);
}

.map-card {
  flex: 0 0 auto;          /* don't grow or shrink — fixed by the stage size */
  min-width: 0;
}

.rail {
  flex: 0 0 260px;
  min-width: 220px;
  max-width: 300px;
}

@media (max-width: 900px) {
  .map-wrap {
    flex-direction: column;
    align-items: center;
  }
  .rail {
    flex: none;
    width: 100%;
    max-width: 80vw;
  }
}

/* ── Map toolbar (search + legend) ──────────────────────────────────────────── */

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4, 1rem);
  margin-bottom: var(--sp-3, 0.75rem);
  width: 80vw;
  max-width: 80vw;
  box-sizing: border-box;
}

.map-search {
  display: flex;
  align-items: center;
  gap: var(--sp-2, 0.5rem);
  background: var(--bone-2, #f5f5f0);
  border: 1px solid var(--line, #e0e0da);
  border-radius: var(--rad-full, 999px);
  padding: 7px 14px;
  flex: 1;
  max-width: 320px;
}
.map-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--text-sm, 0.875rem);
  color: var(--ink, #111);
  width: 100%;
}
.map-search svg { flex-shrink: 0; color: var(--muted, #888); }

.map-meta {
  display: flex;
  gap: var(--sp-4, 1rem);
}
.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs, 0.75rem);
  color: var(--muted, #888);
}
.swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  background: var(--bone-3, #e8e8e2);
  border: 1px solid var(--line, #e0e0da);
  flex-shrink: 0;
}
.swatch.acc { background: var(--accent, #6c47ff); border-color: var(--accent, #6c47ff); }

/* ── Map stage — always 80% of viewport width ────────────────────────────────── */

.map-stage {
  position: relative;
  width: 80vw;
  max-width: 80vw;
  aspect-ratio: 975 / 610;        /* exact SVG viewBox ratio */
  background-image:
    radial-gradient(circle at 1px 1px, color-mix(in oklab, var(--ink, #111) 8%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  border-radius: var(--rad-md, 12px);
  overflow: hidden;
}
.map-stage svg { display: block; width: 100%; height: 100%; }

/* ── State paths ─────────────────────────────────────────────────────────────── */

.state {
  fill: var(--bone-3, #e8e8e2);
  stroke: var(--bone, #f5f5f0);
  stroke-width: 1;
  stroke-linejoin: round;
  transition: fill 180ms ease, filter 200ms ease;
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  outline: none;
}
.state:hover { fill: color-mix(in oklab, var(--accent, #6c47ff) 35%, var(--bone-3, #e8e8e2)); }
.state:hover.zoom { filter: drop-shadow(0 6px 14px color-mix(in oklab, var(--accent, #6c47ff) 50%, transparent)); }
.state.selected { fill: var(--accent, #6c47ff); }
.state:focus-visible { stroke: var(--ink, #111); stroke-width: 1.5; }

/* ── State labels ────────────────────────────────────────────────────────────── */

.state-label {
  pointer-events: none;
  font: 500 9.5px/1 var(--font-sans, sans-serif);
  fill: color-mix(in oklab, var(--ink, #111) 72%, transparent);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bone-2, #efefea);
  stroke-width: 2.2;
}
.state-label.on-selected { fill: var(--accent-ink, #fff); stroke: var(--accent, #6c47ff); }

/* ── Inset map decorations ───────────────────────────────────────────────────── */

.state-divider {
  fill: none;
  stroke: var(--line-2, #d0d0ca);
  stroke-width: .5;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.inset-cap {
  font: 500 9.5px/1 var(--font-sans, sans-serif);
  fill: var(--muted, #888);
  text-anchor: start;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────────── */

.tip {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -130%);
  background: var(--ink, #111);
  color: var(--bone, #faf9f6);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .005em;
  padding: 7px 10px;
  border-radius: var(--rad-sm, 6px);
  white-space: nowrap;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity 120ms ease;
  z-index: 10;
}
.tip.show { opacity: 1; }
.tip::after {
  content: "";
  position: absolute;
  left: 50%; top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink, #111);
}
.tip .count { margin-left: 8px; opacity: .65; font-variant-numeric: tabular-nums; }

/* ── State detail rail (right panel) ─────────────────────────────────────────── */

.panel {
  background: var(--bone-2, #f5f5f0);
  border: 1px solid var(--line, #e0e0da);
  border-radius: var(--rad-lg, 16px);
  padding: var(--sp-5, 1.25rem);
}
.panel h3 {
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted, #888);
  margin-bottom: var(--sp-4, 1rem);
}
.display {
  font-family: var(--font-serif, serif);
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.1;
  margin-bottom: var(--sp-3, 0.75rem);
}
.empty {
  font-size: var(--text-sm, 0.875rem);
  color: var(--muted, #888);
  margin-bottom: var(--sp-4, 1rem);
}
.hint {
  font-size: var(--text-xs, 0.75rem);
  color: var(--muted, #888);
}
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--bone-3, #e8e8e2);
  border: 1px solid var(--line-2, #d0d0ca);
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}
.meta-row {
  display: flex;
  gap: var(--sp-4, 1rem);
  margin-bottom: var(--sp-4, 1rem);
}
.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta span { font-size: var(--text-xs, 0.75rem); color: var(--muted, #888); text-transform: uppercase; letter-spacing: .08em; }
.meta b { font-size: var(--text-lg, 1.125rem); font-weight: 600; }
.route {
  display: flex;
  align-items: center;
  gap: var(--sp-2, 0.5rem);
  padding: 8px 12px;
  background: var(--bone-3, #e8e8e2);
  border-radius: var(--rad-sm, 6px);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  margin-bottom: var(--sp-4, 1rem);
  overflow: hidden;
}
.verb { color: var(--accent, #6c47ff); font-weight: 600; }
.arrow { color: var(--muted, #888); }
.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--accent, #6c47ff);
  color: var(--accent-ink, #fff);
  border-radius: var(--rad-md, 12px);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm, 0.875rem);
  transition: opacity 150ms ease;
}
.cta:hover { opacity: .9; }

/* ── A–Z state grid ──────────────────────────────────────────────────────────── */

.state-grid {
  margin: 0 auto;
  max-width: 80vw;
}
.state-grid h3 {
  font-size: var(--text-xs, 0.75rem);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted, #888);
  margin-bottom: var(--sp-4, 1rem);
}
.state-grid ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-1, 0.25rem) var(--sp-4, 1rem);
}
.state-grid li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2, 0.5rem) 0;
  border-bottom: 1px solid var(--line, #e0e0da);
}
.state-grid a {
  font-size: var(--text-sm, 0.875rem);
  text-decoration: none;
  color: var(--ink, #111);
  transition: color 120ms ease;
}
.state-grid a:hover { color: var(--accent, #6c47ff); }
.state-grid .ct {
  font-size: var(--text-xs, 0.75rem);
  color: var(--muted, #888);
  font-variant-numeric: tabular-nums;
}

/* ── Loading state ───────────────────────────────────────────────────────────── */

.map-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80vw;
  aspect-ratio: 975 / 610;
  color: var(--muted, #888);
  background: var(--bone-2, #f5f5f0);
  border-radius: var(--rad-md, 12px);
}
