/* ============================================================
   Been There — night atlas theme
   Palette:
     --ink    #0d1321  deep night background
     --panel  #151d31  raised surfaces
     --line   #26304a  hairline borders
     --land   #2b3854  unvisited country fill
     --gold   #e6b34d  visited country fill (the signature)
     --paper  #f2ead8  headline text
     --mist   #9aa7bd  secondary text
   ============================================================ */

:root {
  --ink: #0d1321;
  --panel: #151d31;
  --line: #26304a;
  --land: #2b3854;
  --land-hover: #40507a;
  --gold: #e6b34d;
  --gold-bright: #f4cd77;
  --paper: #f2ead8;
  --mist: #9aa7bd;
  --font-display: "DM Serif Display", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.5;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2.5rem clamp(1rem, 4vw, 3rem) 1.5rem;
}

.wordmark h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  margin: 0;
  letter-spacing: 0.01em;
}

.tagline {
  color: var(--mist);
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

.stats {
  display: flex;
  gap: 2.5rem;
}

.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  color: var(--gold);
  line-height: 1.1;
}

.stat-label {
  color: var(--mist);
  font-size: 0.8rem;
  max-width: 12rem;
  display: block;
}

/* ---------- Onboarding hint ---------- */

.onboarding-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.onboarding-hint p { margin: 0; font-size: 0.9rem; color: var(--paper); }

.onboarding-dismiss {
  flex-shrink: 0;
  background: var(--gold);
  color: #241a05;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.onboarding-dismiss:hover { background: var(--gold-bright); }
.onboarding-dismiss:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

/* ---------- Toolbar (search + zoom) ---------- */

main {
  padding: 0 clamp(1rem, 4vw, 3rem) 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.search-wrap { flex: 1 1 320px; max-width: 480px; }

#country-search {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--paper);
  font: inherit;
  font-size: 0.95rem;
}

#country-search::placeholder { color: var(--mist); opacity: 0.7; }
#country-search:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.map-controls { display: flex; gap: 0.4rem; }

.control-btn {
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--paper);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.control-btn--text { font-size: 0.85rem; padding: 0 0.8rem; }
.control-btn:hover { border-color: var(--gold); }
.control-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Map ---------- */

.map-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 50% 10%, #131c33 0%, var(--ink) 70%);
  overflow: hidden;
}

.map-viewport {
  cursor: grab;
  touch-action: none; /* we handle panning ourselves */
}

.map-viewport.dragging { cursor: grabbing; }

.map-viewport svg {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 0 0; /* pan/zoom math assumes top-left origin */
}

.map-loading {
  text-align: center;
  color: var(--mist);
  padding: 6rem 1rem;
}

/* Country states — the heart of the app */

.map-viewport svg path {
  fill: var(--land);
  stroke: var(--ink);
  stroke-width: 0.4;
  cursor: pointer;
  transition: fill 220ms ease;
}

.map-viewport svg path:hover { fill: var(--land-hover); }

.map-viewport svg path:focus-visible {
  fill: var(--land-hover);
  stroke: var(--gold-bright);
  stroke-width: 2;
  outline: none;
}

.map-viewport svg path.visited { fill: var(--gold); }
.map-viewport svg path.visited:hover { fill: var(--gold-bright); }
.map-viewport svg path.visited:focus-visible { fill: var(--gold-bright); }

/* Brief glow when a country is found via search */
.map-viewport svg path.flash {
  fill: var(--gold-bright);
  filter: drop-shadow(0 0 6px var(--gold));
}

/* Floating tooltip that follows the cursor */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  z-index: 10;
}

/* ---------- Continents ---------- */

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 2.5rem 0 1rem;
}

.continent-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem 2rem;
}

.continent-row .continent-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.continent-row .continent-count { color: var(--mist); }

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 99px;
  width: 0%;
  transition: width 400ms ease;
}

/* ---------- Visited chips ---------- */

.empty-note { color: var(--mist); font-size: 0.95rem; }

.chip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--paper);
  font-family: var(--font-body);
}

.chip:hover { border-color: var(--gold); }
.chip::after { content: " ×"; color: var(--mist); }

/* ---------- Actions ---------- */

.actions {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 1.3rem;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn--primary { background: var(--gold); color: #241a05; font-weight: 700; }
.btn--primary:hover { background: var(--gold-bright); }

.btn--ghost { background: transparent; color: var(--mist); border-color: var(--line); }
.btn--ghost:hover { color: var(--paper); border-color: var(--mist); }

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

.action-feedback { color: var(--gold); font-size: 0.9rem; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--mist);
  font-size: 0.85rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
}

.site-footer p { margin: 0.2rem 0; }

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 640px) {
  .site-header { padding-top: 1.5rem; }
  .stats { gap: 1.5rem; }
}
