/* ==========================================
   You Should Know — Global Styles
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #06060f;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.06);
  --text: #e8e8f0;
  --text-dim: rgba(232, 232, 240, 0.5);
  --text-muted: rgba(232, 232, 240, 0.3);
  --accent: #4488cc;
  --panel-width: 480px;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
   Background gradient
   ========================================== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(30, 50, 100, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(20, 40, 80, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(10, 10, 30, 1) 0%, rgba(6, 6, 15, 1) 100%);
  z-index: -1;
}

/* Vignette overlay + subtle noise */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Subtle film grain overlay for depth */
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2%, -2%); }
  30% { transform: translate(1%, -3%); }
  50% { transform: translate(-1%, 2%); }
  70% { transform: translate(3%, 1%); }
  90% { transform: translate(-3%, 3%); }
}

#globe-container::after {
  content: '';
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  background-repeat: repeat;
  pointer-events: none;
  z-index: 2;
  opacity: 0.4;
  animation: grain 0.5s steps(6) infinite;
  mix-blend-mode: overlay;
}

/* ==========================================
   Globe Container
   ========================================== */
#globe-container {
  position: fixed;
  inset: 0;
  cursor: grab;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#globe-container:active {
  cursor: grabbing;
}

#globe-container.shifted {
  transform: translateX(calc(var(--panel-width) / -2));
}

#globe-container canvas {
  display: block;
}

/* ==========================================
   Loading Screen
   ========================================== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.loader-text {
  margin-top: 24px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   UI Overlay
   ========================================== */
#ui-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#ui-overlay.visible {
  opacity: 1;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* ==========================================
   Title Bar
   ========================================== */
#title-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 32px 40px;
  pointer-events: none;
}

.site-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #88aadd 50%, #ffffff 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  animation: titleShimmer 8s ease infinite;
}

@keyframes titleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.site-subtitle {
  font-size: clamp(13px, 1.5vw, 16px);
  color: var(--text-dim);
  margin-top: 8px;
  font-weight: 300;
  letter-spacing: 0.02em;
}

/* Global Stats Counter */
#global-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 10px 18px;
  background: rgba(12, 12, 30, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 30px;
  width: fit-content;
  pointer-events: auto;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stat-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ==========================================
   Interaction Hint
   ========================================== */
#interaction-hint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-align: center;
  transition: opacity 1s ease;
  pointer-events: none;
  animation: hintPulse 3s ease-in-out infinite;
}

#interaction-hint.fade-out {
  opacity: 0;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* ==========================================
   Featured Fact Ticker
   ========================================== */
#fact-ticker {
  position: absolute;
  top: 100px;
  right: 40px;
  max-width: 340px;
  padding: 16px 20px;
  background: rgba(12, 12, 30, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#fact-ticker.visible {
  opacity: 1;
  transform: translateY(0);
}

#fact-ticker.transitioning {
  opacity: 0;
  transform: translateY(-8px);
}

#ticker-region {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

#ticker-fact {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* ==========================================
   Tooltip
   ========================================== */
#region-tooltip {
  position: fixed;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(12, 12, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

#region-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.tooltip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tooltip-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.tooltip-detail {
  font-size: 12px;
  color: var(--text-dim);
}

/* ==========================================
   Info Panel
   ========================================== */
#info-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-width);
  background: rgba(8, 8, 20, 0.92);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#info-panel.open {
  transform: translateX(0);
}

#info-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg,
    transparent 0%,
    var(--accent) 20%,
    transparent 40%,
    var(--accent) 60%,
    transparent 80%,
    var(--accent) 100%
  );
  background-size: 100% 200%;
  animation: panelGlow 4s linear infinite;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#info-panel.open::before {
  opacity: 0.5;
}

@keyframes panelGlow {
  0% { background-position: 0 0; }
  100% { background-position: 0 200%; }
}

.panel-header {
  padding: 32px 28px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

#panel-close {
  position: absolute;
  top: 28px;
  right: 24px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#panel-close:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

#panel-region-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-right: 48px;
}

#panel-region-summary {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 10px;
}

#panel-region-pop {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: inline-block;
  letter-spacing: 0.03em;
}

#panel-search-wrap {
  margin-top: 14px;
}

#panel-search {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

#panel-search::placeholder {
  color: var(--text-muted);
}

#panel-search:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

/* Region Navigator */
#region-nav {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.region-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s ease;
  padding: 0;
}

.region-dot:hover {
  opacity: 0.8;
  transform: scale(1.15);
}

.region-dot.active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.2);
  box-shadow: 0 0 10px currentColor;
}

/* Panel scrollable content */
#panel-facts {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 100px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

#panel-facts::-webkit-scrollbar {
  width: 6px;
}

#panel-facts::-webkit-scrollbar-track {
  background: transparent;
}

#panel-facts::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

/* ==========================================
   Fact Cards
   ========================================== */
.fact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  animation: factSlideIn 0.4s ease forwards;
  opacity: 0;
  transform: translateY(12px);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.fact-card:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

@keyframes factSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fact-category {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.fact-cat-icon {
  font-size: 14px;
}

.fact-importance {
  margin-left: auto;
  display: flex;
  gap: 3px;
}

.imp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.imp-dot.filled {
  box-shadow: 0 0 4px currentColor;
}

.fact-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--text);
}

.fact-description {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.fact-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.fact-source {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  flex: 1;
}

.fact-share {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.fact-share:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.no-facts {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-facts p {
  margin-bottom: 8px;
  font-size: 14px;
}

/* ==========================================
   Category Filters
   ========================================== */
#category-filters {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(12, 12, 30, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 30px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  scrollbar-width: none;
}

#category-filters::-webkit-scrollbar {
  display: none;
}

.category-pill {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: transparent;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.category-pill:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.category-pill.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 768px) {
  :root {
    --panel-width: 100vw;
  }

  #fact-ticker {
    position: absolute;
    top: auto;
    right: auto;
    bottom: 80px;
    left: 24px;
    right: 24px;
    max-width: none;
  }

  #title-bar {
    padding: 20px 24px;
  }

  #globe-container.shifted {
    transform: none;
  }

  #info-panel {
    width: 100%;
    top: 30vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
  }

  #info-panel.open {
    transform: translateY(0);
  }

  .panel-header {
    padding: 20px 20px 16px;
  }

  #panel-region-name {
    font-size: 22px;
  }

  #panel-facts {
    padding: 16px 20px 100px;
  }

  .fact-card {
    padding: 16px;
  }

  #category-filters {
    bottom: 16px;
    gap: 4px;
    padding: 4px;
  }

  .category-pill {
    padding: 6px 12px;
    font-size: 11px;
  }

  #interaction-hint {
    bottom: 80px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .site-title {
    font-size: 24px;
  }

  .site-subtitle {
    font-size: 12px;
  }

  .fact-title {
    font-size: 15px;
  }

  .fact-description {
    font-size: 13px;
  }
}

/* ==========================================
   Selection / Focus
   ========================================== */
::selection {
  background: rgba(68, 136, 204, 0.3);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
