/* =============================
   CSS Custom Properties
   ============================= */
:root {
  --bg:               #0f172a;
  --surface:          #1e293b;
  --surface-2:        #263548;
  --border:           #334155;
  --text-primary:     #e2e8f0;
  --text-secondary:   #94a3b8;
  --visited:          #eab308;
  --visited-hover:    #fbbf24;
  --unvisited:        #334155;
  --unvisited-hover:  #475569;
  --ocean:            #162032;
  --graticule:        #1e3a5f;
  --border-map:       #0f172a;
  --map-bg:           #162032;
  --shadow:           0 4px 24px rgba(0,0,0,0.5);
  --toggle-bg:        #1e293b;
  --toggle-active-bg: #3b82f6;
  --toggle-active-fg: #fff;
  --counter-num:      #eab308;
  --radius-pill:      9999px;
}

[data-theme="light"] {
  --bg:               #f1f5f9;
  --surface:          #dde3ec;
  --surface-2:        #ecf0f6;
  --border:           #b8c4d2;
  --text-primary:     #1e293b;
  --text-secondary:   #64748b;
  --visited:          #eab308;
  --visited-hover:    #ca8a04;
  --unvisited:        #9eb3c7;
  --unvisited-hover:  #7a97ad;
  --ocean:            #5b9fd4;
  --graticule:        #4a87bb;
  --border-map:       #d8e4ed;
  --map-bg:           #5b9fd4;
  --shadow:           0 4px 24px rgba(0,0,0,0.12);
  --toggle-bg:        #c8d0da;
  --toggle-active-bg: #2563eb;
  --toggle-active-fg: #fff;
  --counter-num:      #eab308;
}

/* =============================
   Reset & Base
   ============================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
}

/* =============================
   Top Bar
   ============================= */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.top-bar__spacer {
  flex: 1;
}

.top-bar__right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

/* =============================
   Toggle Group (pill segmented control)
   ============================= */
.toggle-group {
  display: flex;
  background: var(--toggle-bg);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  transition: background 0.3s ease;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 22px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
  letter-spacing: 0.02em;
  user-select: none;
}

.toggle-btn:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.toggle-btn.active {
  background: var(--toggle-active-bg);
  color: var(--toggle-active-fg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.toggle-btn:active {
  transform: scale(0.97);
}

/* =============================
   Theme Toggle Button
   ============================= */
.theme-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  position: relative;
  overflow: hidden;
}

.theme-btn:hover {
  background: var(--border);
  transform: scale(1.08);
}

.theme-btn:active {
  transform: scale(0.93);
}

.theme-icon {
  position: absolute;
  line-height: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* dark mode: show moon */
.theme-icon--moon { opacity: 1;  transform: translateY(0);    }
.theme-icon--sun  { opacity: 0;  transform: translateY(10px); }

/* light mode: show sun */
[data-theme="light"] .theme-icon--moon { opacity: 0;  transform: translateY(-10px); }
[data-theme="light"] .theme-icon--sun  { opacity: 1;  transform: translateY(0);     }

/* =============================
   Map Wrapper
   ============================= */
.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  transition: background 0.3s ease;
}

.map-view {
  position: absolute;
  inset: 0;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.map-view.hidden {
  opacity: 0;
  pointer-events: none;
}

.map-view svg {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--map-bg);
  transition: background 0.3s ease;
}

/* =============================
   Map SVG Paths
   ============================= */
.land {
  stroke: var(--border-map);
  stroke-width: 0.5px;
  cursor: pointer;
  transition: fill 0.15s ease;
}

.land.visited   { fill: var(--visited); }
.land.unvisited { fill: var(--unvisited); }

.land.visited:hover   { fill: var(--visited-hover); }
.land.unvisited:hover { fill: var(--unvisited-hover); }

.ocean {
  fill: var(--ocean);
  transition: fill 0.3s ease;
}

.graticule {
  fill: none;
  stroke: var(--graticule);
  stroke-width: 0.4px;
  transition: stroke 0.3s ease;
}

.borders {
  fill: none;
  stroke: var(--border-map);
  stroke-width: 0.7px;
  pointer-events: none;
}

.state-borders {
  fill: none;
  stroke: var(--border-map);
  stroke-width: 0.5px;
  pointer-events: none;
}

/* =============================
   Tooltip
   ============================= */
.tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 100;
  letter-spacing: 0.01em;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .visited-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--visited);
  margin-right: 7px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* =============================
   Counter Bar (bottom left)
   ============================= */
.counter-bar {
  padding: 9px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.counters {
  display: flex;
  gap: 28px;
}

.counter {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.counter__num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--counter-num);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.counter__sep,
.counter__total {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.counter__label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-left: 5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* =============================
   Responsive
   ============================= */
@media (max-width: 480px) {
  .toggle-btn      { padding: 6px 14px; font-size: 0.8125rem; }
  .counter__num    { font-size: 1.05rem; }
  .counter__label  { font-size: 0.75rem; }
}
