/* ═══════════════════════════════════════
   AI Power DC Map — Stylesheet
   Theme: Dark tech/data visualization
   Colors: Deep navy + electric blue accents
   ═══════════════════════════════════════ */

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

:root {
  --font-display: 'Cabinet Grotesk', 'Inter', sans-serif;
  --font-body: 'General Sans', 'Inter', sans-serif;

  --text-xs:   clamp(0.7rem,  0.65rem + 0.25vw, 0.8rem);
  --text-sm:   clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-lg:   clamp(1rem, 0.95rem + 0.35vw, 1.25rem);
  --text-xl:   clamp(1.25rem, 1.1rem + 0.75vw, 1.75rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Category Colors */
  --cat-hyperscaler: #3b82f6;
  --cat-neocloud: #8b5cf6;
  --cat-independent: #f59e0b;
  --cat-sovereign: #10b981;
  --cat-stargate: #ef4444;

  --status-operational: #22c55e;
  --status-construction: #f59e0b;
  --status-planned: #818cf8;
}

/* Dark Theme (Default) */
[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-elevated: #0f1424;
  --bg-card: #141a2e;
  --bg-card-hover: #1a2240;
  --border: #1e2a4a;
  --border-light: #283556;
  --text: #e2e8f0;
  --text-muted: #8892a8;
  --text-faint: #4a5568;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --surface-glow: rgba(59, 130, 246, 0.05);
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
}

/* Light Theme */
[data-theme="light"] {
  --bg: #f0f2f7;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f8fc;
  --border: #d4d9e4;
  --border-light: #e2e6f0;
  --text: #1a202c;
  --text-muted: #5a6478;
  --text-faint: #a0a8b8;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.1);
  --surface-glow: rgba(37, 99, 235, 0.03);
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100dvh;
}

/* ═══ HEADER ═══ */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

[data-theme="dark"] .header {
  background: rgba(15, 20, 36, 0.92);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-icon {
  color: var(--text);
  flex-shrink: 0;
}

.logo-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.logo-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-stats {
  display: flex;
  gap: var(--space-6);
  font-size: var(--text-sm);
}

.header-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--accent);
}

.header-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ═══ FILTERS ═══ */
.filters-bar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) 0;
}

[data-theme="dark"] .filters-bar {
  background: rgba(15, 20, 36, 0.8);
}

.filters-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.filter-chips {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.filter-chip {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: var(--font-body);
}
.filter-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
}
.filter-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-glow);
}
.filter-chip .chip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.search-group {
  margin-left: auto;
}
.search-input {
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  width: 220px;
  font-family: var(--font-body);
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ═══ MAIN LAYOUT ═══ */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  height: calc(100vh - 140px);
  min-height: 500px;
}

/* ═══ MAP ═══ */
.map-container {
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

[data-theme="dark"] .leaflet-container {
  background: #0a0e1a;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: var(--font-body) !important;
  font-size: var(--text-sm) !important;
  line-height: 1.5 !important;
  min-width: 280px !important;
  max-width: 340px !important;
}

.popup-inner {
  padding: var(--space-4);
}

.popup-category {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.popup-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
  line-height: 1.2;
}

.popup-company {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.popup-location {
  color: #ffffff;
  font-weight: 600;
  transition: color var(--transition), text-shadow var(--transition);
}

.popup-location:hover {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

.popup-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.popup-meta-item {
  display: flex;
  flex-direction: column;
}

.popup-meta-label {
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.popup-meta-value {
  font-weight: 600;
  font-size: var(--text-sm);
}

.popup-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.popup-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  z-index: 800;
  box-shadow: var(--shadow);
  font-size: var(--text-xs);
  display: none;
}

.legend-title {
  font-weight: 700;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-size-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.legend-size-dot {
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  flex-shrink: 0;
}

.legend-size-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
}

.sidebar-count {
  font-size: var(--text-xs);
  padding: 2px 10px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all var(--transition);
  font-family: var(--font-body);
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.dc-card {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.dc-card:hover {
  background: var(--bg-card-hover);
}

.dc-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.dc-card-name {
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.3;
}

.dc-card-power {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  color: var(--accent);
}

.dc-card-company {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.dc-card-meta {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.dc-card-meta span {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.dc-card-location {
  color: #ffffff !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  transition: color var(--transition), text-shadow var(--transition);
}

.dc-card:hover .dc-card-location {
  color: #ffffff !important;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.dc-card-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.dc-card-cat {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 3px;
}

/* Semi cards */
.semi-card {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.semi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.semi-card-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.semi-card-ticker {
  font-family: monospace;
  font-size: var(--text-xs);
  color: var(--accent);
  background: var(--accent-glow);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.semi-card-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.4;
}

/* ═══ TIMELINE ═══ */
.timeline-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-10);
}

.timeline-header {
  margin-bottom: var(--space-6);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.timeline-container {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.timeline-track {
  position: relative;
  min-width: 2400px;
  height: 320px;
  padding: var(--space-8) var(--space-4) 60px;
}

.timeline-line {
  position: absolute;
  bottom: 50px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
}

.timeline-month-label {
  position: absolute;
  bottom: 20px;
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-marker {
  position: absolute;
  bottom: 44px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid;
  cursor: pointer;
  transform: translateX(-50%);
  transition: all var(--transition);
  z-index: 10;
}

.timeline-marker.high {
  width: 18px;
  height: 18px;
  bottom: 42px;
}

.timeline-marker:hover {
  transform: translateX(-50%) scale(1.4);
  z-index: 20;
  box-shadow: 0 0 12px currentColor;
}

.timeline-stem {
  position: absolute;
  bottom: 52px;
  width: 1px;
  background: var(--border-light);
  transform: translateX(-50%);
}

.timeline-bubble {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 100;
  font-size: var(--text-xs);
}

.timeline-event:hover .timeline-bubble {
  opacity: 1;
  pointer-events: auto;
}

.timeline-event {
  position: absolute;
}

.bubble-date {
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}

.bubble-title {
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  line-height: 1.3;
}

.bubble-desc {
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

.bubble-companies {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.bubble-company-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent);
  white-space: nowrap;
}

/* ═══ STATS ═══ */
.stats-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4);
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--space-1);
}

/* ═══ FOOTER ═══ */
.footer {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-align: center;
}

.footer-note {
  margin-top: var(--space-1);
}

/* ═══ CUSTOM MAP MARKERS ═══ */
.custom-marker {
  border-radius: 50%;
  border: 2px solid;
  opacity: 0.9;
  transition: all 200ms ease;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
}
.custom-marker:hover {
  opacity: 1;
  transform: scale(1.3);
  z-index: 1000 !important;
}

.custom-marker.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 12px currentColor; }
}

/* Responsive */
@media (max-width: 1100px) {
  .main-content {
    grid-template-columns: 1fr;
    height: auto;
  }
  .map-container {
    height: 50vh;
    min-height: 400px;
  }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 400px;
  }
  .header-stats {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .filters-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .search-group {
    margin-left: 0;
    width: 100%;
  }
  .search-input {
    width: 100%;
  }
  .timeline-track {
    min-width: 1800px;
  }
}

/* Leaflet attribution dark mode */
[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(10, 14, 26, 0.7) !important;
  color: #4a5568 !important;
}
[data-theme="dark"] .leaflet-control-attribution a {
  color: #5a6478 !important;
}
[data-theme="dark"] .leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
