/**
 * Landing Page Styles
 * 着陆页样式
 *
 * 包含：
 * - 加载动画
 * - 地球/地图容器
 * - UI 覆盖层
 * - 城市卡片（经典视图）
 * - 响应式设计
 */

/* ===== CSS Variables ===== */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --bg-dark: #0a0a1a;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-dark);
}

/* ===== Loading Overlay ===== */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity var(--transition-slow);
}

#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-globe {
  font-size: 4rem;
  animation: pulse 2s ease-in-out infinite;
}

.loading-text {
  margin-top: 1rem;
  font-size: 1.2rem;
  opacity: 0.8;
}

.loading-spinner {
  margin-top: 1.5rem;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: auto;
  margin-right: auto;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

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

/* Loading status text */
.loading-status {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
  min-height: 1.25rem;
}

/* Slow loading hint */
.loading-timeout-hint {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 0.5rem;
  color: #ffc107;
  font-size: 0.875rem;
}

/* Loading error */
.loading-error {
  display: none;
  margin-top: 1rem;
  text-align: center;
}

.loading-error span {
  display: block;
  color: #ef4444;
  margin-bottom: 1rem;
}

.loading-error button {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  transition: background var(--transition-fast);
}

.loading-error button:hover {
  background: var(--secondary-color);
}

/* ===== Scene Containers ===== */
#earth-container,
#map-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#earth-container {
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a1a 100%);
}

#map-container {
  display: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

#map-container.visible {
  display: block;
  opacity: 1;
}

/* ===== City Cards Container (Classic View) ===== */
#city-cards-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow-y: auto;
  padding: 100px 20px 80px;
}

#city-cards-container.visible {
  display: block;
}

body.classic-view {
  background: var(--primary-gradient);
}

body.classic-view #city-cards-container {
  display: block;
}

/* City Cards Grid */
.city-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Individual City Card */
.city-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  opacity: 0;
  transform: translateY(20px);
}

.city-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.city-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.city-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.city-card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.city-card-title {
  flex: 1;
}

.city-card-name {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.city-card-fullname {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 2px;
}

.city-card-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.city-card-status.yellow {
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.city-card-status.red {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.city-card-status.gray {
  background-color: #9ca3af;
  box-shadow: none;
}

.city-card-providers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.provider-badge {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #4338ca;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 20px;
}

.city-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ===== UI Overlay ===== */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

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

/* ===== Header ===== */
.landing-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}

.nav-link:hover {
  color: white;
}

/* Language Toggle */
.language-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  overflow: hidden;
}

.lang-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lang-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  font-weight: 500;
}

/* ===== Zoom Hint ===== */
.zoom-hint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 25px;
  color: white;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.zoom-hint.visible {
  opacity: 1;
}

.hint-icon {
  font-size: 1.2rem;
}

/* ===== View Toggle ===== */
.view-toggle {
  position: absolute;
  bottom: 100px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  padding: 8px;
}

.view-toggle.hidden {
  display: none;
}

.toggle-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  opacity: 0.7;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

.toggle-btn.active {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

/* ===== Footer ===== */
.landing-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-link {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: white;
}

.footer-divider {
  color: rgba(255, 255, 255, 0.3);
}

.footer-version {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
}

/* ===== Map Markers (injected by map-scene.js) ===== */
.city-marker {
  width: 24px;
  height: 24px;
  cursor: pointer;
  position: relative;
}

.marker-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--primary-color);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
}

.marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  border-radius: 50%;
  opacity: 0.4;
  animation: marker-pulse 2s ease-out infinite;
}

@keyframes marker-pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

/* Map Popup */
.maplibregl-popup-content {
  padding: 0 !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
}

.maplibregl-popup-close-button {
  font-size: 1.2rem;
  padding: 4px 8px;
  color: #6b7280;
}

.city-popup {
  min-width: 250px;
}

.city-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--primary-gradient);
  color: white;
}

.popup-icon {
  font-size: 2rem;
}

.popup-title h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.popup-title p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.city-popup-body {
  padding: 16px;
}

.popup-providers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.popup-btn {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--primary-gradient);
  color: white;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.popup-btn:hover {
  opacity: 0.9;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .landing-header {
    padding: 12px 16px;
  }

  .logo-text {
    font-size: 1.1rem;
  }

  .nav-link {
    display: none;
  }

  .zoom-hint {
    bottom: 80px;
    font-size: 0.85rem;
    padding: 8px 16px;
  }

  .view-toggle {
    bottom: 80px;
    right: 16px;
  }

  .toggle-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .landing-footer {
    padding: 12px 16px;
  }

  .footer-link {
    font-size: 0.8rem;
  }

  #city-cards-container {
    padding: 80px 16px 70px;
  }

  .city-cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 10px;
  }

  .city-card {
    padding: 20px;
  }

  .city-card-icon {
    font-size: 2rem;
  }

  .city-card-name {
    font-size: 1.2rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .language-toggle {
    display: none;
  }

  .city-card-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }
}

/* ===== High DPI Support ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .marker-dot {
    border-width: 1.5px;
  }
}

/* ===== Dark Mode Preference ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --card-bg: rgba(30, 30, 40, 0.95);
    --text-color: #f3f4f6;
    --text-light: #9ca3af;
  }

  /* Classic View Dark Mode */
  body.classic-view {
    background: #0a0a1a;
  }

  .landing-header {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
  }

  .landing-footer {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
  }

  .city-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .city-card-stats {
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  .provider-badge {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    color: #c7d2fe;
  }

  /* City Card Status */
  .city-card-status {
    background: rgba(40, 40, 50, 0.8);
  }

  .city-card-title {
    color: var(--text-color);
  }

  .city-card-subtitle {
    color: var(--text-light);
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .loading-globe,
  .marker-pulse {
    animation: none;
  }

  /* 保留 loading-spinner 动画 - 加载指示器是必要的用户反馈 */

  .city-card,
  #loading-overlay,
  #map-container {
    transition: none;
  }
}

/* ===== Print Styles ===== */
@media print {
  #earth-container,
  #map-container,
  #loading-overlay,
  .view-toggle,
  .zoom-hint {
    display: none !important;
  }

  body.classic-view {
    background: white;
  }

  .city-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
