/* ═══════════════════════════════════════════════════════
   Atlas — Global Styles
   Theme: Cartographic Noir
   ═══════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────── */
:root {
  /* Colours - Light Professional */
  --ocean:        #e2e8f0; /* Soft professional slate for water */
  --land:         #ffffff; /* Clean white landmasses */
  --land-stroke:  #cbd5e1; /* Soft gray borders */
  --land-hover:   #f1f5f9; /* Subtle hover effect */
  --land-active:  #2563eb; /* Corporate brand blue for active country */
  --land-dim:     #f8fafc;
  --land-dim-stroke: #e2e8f0;
  --graticule:    rgba(0, 0, 0, 0.04);
  --sphere-fill:  var(--ocean);

  /* UI Base */
  --bg:           #f8fafc; /* Very light slate for app background */
  --surface:      #ffffff;
  --surface-2:    #f1f5f9;
  --surface-3:    #e2e8f0;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;

  /* Text - High contrast */
  --text-primary: #0f172a;
  --text-secondary:#475569;
  --text-muted:   #94a3b8;

  /* Accent Colors */
  --accent:       #2563eb;
  --accent-dim:   rgba(37, 99, 235, 0.1);
  --accent-glow:  rgba(37, 99, 235, 0.2);
  --accent-hover: #1d4ed8;

  /* Danger */
  --danger:       #ef4444;

  /* Sizing, Fonts, and Transitions (Kept from your original) */
  --header-h:     56px;
  --panel-w:      380px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    5px;
  --t-fast:       150ms ease;
  --t-med:        250ms cubic-bezier(.4,0,.2,1);
  --t-slow:       400ms cubic-bezier(.4,0,.2,1);
  --font-display: 'Syne', sans-serif;
  --font-body:    'Karla', sans-serif;
  --font-mono:    'Inconsolata', monospace;
}


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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
button:disabled { opacity: .4; cursor: not-allowed; }
svg { display: block; }

/* ── Header ───────────────────────────────────────────── */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(6,12,24,.88);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

.logo-icon {
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
  animation: pulse-slow 4s ease-in-out infinite;
}
@keyframes pulse-slow {
  0%,100% { opacity:1; } 50% { opacity:.6; }
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .04em;
  color: var(--text-primary);
}

/* Continent nav */
.continent-nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}
.continent-nav::-webkit-scrollbar { display: none; }

.continent-pill {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: .02em;
  white-space: nowrap;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.continent-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-2);
  background: var(--surface-2);
}
.continent-pill.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Header actions */
.header-actions { flex-shrink: 0; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:not(:disabled):hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

/* ── Stage / Map ──────────────────────────────────────── */
.stage {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  overflow: hidden;
}

#worldMap {
  width: 100%; height: 100%;
  cursor: grab;
  touch-action: none;
}
#worldMap.dragging { cursor: grabbing; }

/* Country paths */
.country {
  fill: var(--land);
  stroke: var(--land-stroke);
  stroke-width: .4px;
  transition: fill var(--t-fast);
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}
.country:hover { fill: var(--land-hover); }
.country.active { fill: var(--land-active); stroke: var(--accent); stroke-width: .6px; }
.country.dimmed { fill: var(--land-dim); stroke: var(--land-dim-stroke); cursor: default; pointer-events: none; }
.country.dimmed:hover { fill: var(--land-dim); }

/* Graticule */
.graticule { fill: none; stroke: var(--graticule); stroke-width: .5px; }

/* Sphere background */
.sphere { fill: var(--sphere-fill); }

/* Vignette overlay */
.vignette { fill: url(#vignetteGrad); pointer-events: none; }

/* ── Tooltip ──────────────────────────────────────────── */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(6,12,24,.92);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: 300;
  backdrop-filter: blur(8px);
}
.map-tooltip.visible { opacity: 1; transform: translateY(0); }
.map-tooltip .tt-flag { margin-right: 5px; }

/* ── Zoom Controls ────────────────────────────────────── */
.zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  background: rgba(15,25,35,.9);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  z-index: 100;
}
.zoom-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  line-height: 1;
}
.zoom-btn svg { width: 15px; height: 15px; }
.zoom-btn:hover { color: var(--accent); background: var(--surface-2); }
.zoom-btn:active { transform: scale(.92); }
.zoom-btn--reset { font-size: 13px; }
.zoom-divider { height: 1px; background: var(--border); margin: 0 6px; }

/* ── Loading ──────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 500;
  transition: opacity var(--t-slow);
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loading-ring {
  width: 40px; height: 40px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Error */
.error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 500;
}
.error-icon { font-size: 32px; }
.error-text { color: var(--text-secondary); font-size: 14px; }
.btn-retry {
  padding: 8px 20px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 13px;
  transition: background var(--t-fast);
}
.btn-retry:hover { background: var(--accent-hover); }

/* ── Info Panel ───────────────────────────────────────── */
.info-panel {
  position: fixed;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);

  /* Mobile: bottom sheet */
  inset: auto 0 0 0;
  border-radius: 20px 20px 0 0;
  max-height: 70vh;
  transform: translateY(100%);
  transition: transform var(--t-slow);
  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
}
.info-panel.open {
  transform: translateY(0);
}

/* Desktop: right sidebar */
@media (min-width: 768px) {
  .info-panel {
    inset: var(--header-h) 0 0 auto;
    width: var(--panel-w);
    border-radius: 0;
    max-height: none;
    transform: translateX(100%);
    border-left: 1px solid var(--border);
    border-top: none;
    border-right: none;
    border-bottom: none;
    box-shadow: -8px 0 40px rgba(0,0,0,.4);
  }
  .info-panel.open { transform: translateX(0); }
  .panel-drag-handle { display: none; }
}

.panel-drag-handle {
  width: 40px; height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  margin: 12px auto 8px;
}

.panel-close-btn {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  z-index: 1;
}
.panel-close-btn svg { width: 12px; height: 12px; }
.panel-close-btn:hover { background: var(--surface-3); color: var(--text-primary); }

.panel-scroll {
  overflow-y: auto;
  height: 100%;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* Skeleton loader */
.panel-skeleton { padding: 20px 20px 32px; display: flex; flex-direction: column; gap: 12px; }
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel--flag  { width: 52px; height: 40px; border-radius: var(--radius-xs); }
.skel--title { width: 65%; height: 26px; }
.skel--sub   { width: 40%; height: 14px; }
.skel--block { width: 100%; height: 72px; border-radius: var(--radius-sm); }

/* Panel body */
.panel-body { padding: 20px 20px 32px; }

/* Country header */
.p-hero {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.p-flag {
  font-size: 44px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
}
.p-titles { flex: 1; min-width: 0; }
.p-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}
.p-alpha {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--accent);
  text-transform: uppercase;
  background: var(--accent-dim);
  padding: 2px 7px;
  border-radius: 99px;
  display: inline-block;
}

/* Stat grid */
.p-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.p-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.p-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.p-stat-value {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.p-stat-value.large { font-size: 13px; }

/* Info rows */
.p-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
}
.p-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.p-row:last-child { border-bottom: none; }
.p-row-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
  text-transform: uppercase;
  min-width: 80px;
  padding-top: 1px;
}
.p-row-value {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  word-break: break-word;
}

/* Tags */
.p-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.p-tag {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Scrim */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 350;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
  backdrop-filter: blur(2px);
}
.scrim.visible { opacity: 1; pointer-events: all; }

/* Hide scrim on desktop (no need with side panel) */
@media (min-width: 768px) {
  .scrim { display: none; }
}

/* ── Responsive tweaks ────────────────────────────────── */
@media (max-width: 480px) {
  .logo-text { display: none; }
  .header { padding: 0 12px; gap: 8px; }
  .continent-pill { height: 28px; padding: 0 10px; font-size: 12px; }
}

@media (min-width: 768px) {
  /* Shift map when panel is open to keep map centred */
  .stage.panel-open { padding-right: var(--panel-w); }
  .zoom-controls { right: 20px; bottom: 32px; }
}

/* ── Focus styles ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ── Selection colour ─────────────────────────────────── */
::selection { background: var(--accent-dim); color: var(--accent); }

/* --- LIGHT THEME OVERRIDES --- */

/* Hide the dark vignette overlay */
.vignette { 
  display: none; 
}

/* Brighten the header transparency */
.header {
  background: rgba(255, 255, 255, 0.85);
}

/* Ensure the logo icon doesn't look washed out */
.logo-icon {
  color: var(--accent);
}

/* Lighten tooltips and zoom controls */
.map-tooltip {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.zoom-controls {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Darken the mobile scrim overlay for contrast against light panels */
.scrim {
  background: rgba(15, 23, 42, 0.4);
}
