/* =========================================================
   Atmosphere — Dynamic weather themes + day/night mode
   ========================================================= */

body {
  transition: color 0.5s var(--ease), background-color 0.5s var(--ease);
}

.fx-gradient {
  transition: background 0.8s var(--ease);
}

/* ---------- Light mode (high contrast UI) ---------- */

/* Variables on <html> so html { background: var(--bg) } and inheritance work */
html[data-mode="light"] {
  color-scheme: light;
  --bg: #e4ebf4;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-2: #eef3f9;
  --stroke: rgba(15, 23, 42, 0.16);
  --stroke-strong: rgba(15, 23, 42, 0.28);
  --text: #0b1220;
  --text-dim: #1e293b;
  --text-mute: #3f4b5c;
  /* Keep accents readable on white — never pale */
  --blue: #155dcf;
  --accent: #155dcf;
  --accent-strong: #0f4aa8;
  --accent-soft: rgba(21, 93, 207, 0.12);
  --blue-glow: rgba(21, 93, 207, 0.22);
  --shadow-neu:
    0 10px 28px rgba(15, 23, 42, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 1);
  --glow-blue: 0 0 0 1px rgba(21, 93, 207, 0.35), 0 8px 24px rgba(21, 93, 207, 0.18);
}

html[data-mode="dark"],
html:not([data-mode]) {
  color-scheme: dark;
}

body[data-mode="light"] {
  color: var(--text);
  background: var(--bg);
}

/* Lock accent tokens in light mode even when weather themes try to override */
html[data-mode="light"] body[data-theme="sunny"],
html[data-mode="light"] body[data-theme="cloudy"],
html[data-mode="light"] body[data-theme="rainy"],
html[data-mode="light"] body[data-theme="thunderstorm"],
html[data-mode="light"] body[data-theme="snowy"],
html[data-mode="light"] body[data-theme="foggy"],
html[data-mode="light"] body[data-theme="night"],
html[data-mode="light"] body[data-theme="default"] {
  --blue: #155dcf;
  --accent: #155dcf;
  --accent-strong: #0f4aa8;
  --accent-soft: rgba(21, 93, 207, 0.12);
  --blue-glow: rgba(21, 93, 207, 0.22);
  --text: #0b1220;
  --text-dim: #1e293b;
  --text-mute: #3f4b5c;
}

html[data-mode="light"] body[data-theme="sunny"] {
  --blue: #b45309;
  --accent: #b45309;
  --accent-strong: #92400e;
  --accent-soft: rgba(180, 83, 9, 0.12);
  --blue-glow: rgba(180, 83, 9, 0.2);
}

body[data-mode="light"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(21, 93, 207, 0.14), transparent 55%),
    linear-gradient(180deg, #d5e0ef 0%, #e4ebf4 50%, #eef3f8 100%) !important;
}

body[data-mode="light"] .navbar {
  border-bottom-color: rgba(15, 23, 42, 0.1);
}
body[data-mode="light"] .nav-link:hover {
  background: rgba(15, 23, 42, 0.05);
}
body[data-mode="light"] .nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
body[data-mode="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  border-top-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
}
body[data-mode="light"] .bottom-link:hover {
  background: rgba(15, 23, 42, 0.04);
}
@media (min-width: 960px) {
  body[data-mode="light"] .navbar-menu {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(15, 23, 42, 0.1);
  }
}

body[data-mode="light"] .neu,
body[data-mode="light"] .topbar-btn,
body[data-mode="light"] .search-field,
body[data-mode="light"] .hourly-item,
body[data-mode="light"] .daily-item,
body[data-mode="light"] .quick-chip,
body[data-mode="light"] .more-menu,
body[data-mode="light"] .modal-card,
body[data-mode="light"] .search-suggestions,
body[data-mode="light"] .compare-card,
body[data-mode="light"] .api-key-form {
  background: #ffffff;
  color: var(--text);
  border-color: var(--stroke);
  box-shadow: var(--shadow-neu);
}

body[data-mode="light"] .page .panel,
body[data-mode="light"] .tomorrow-card {
  background: #ffffff;
}

body[data-mode="light"] .empty-card {
  background: #ffffff;
  color: var(--text);
}

body[data-mode="light"] .location-name,
body[data-mode="light"] .hero-temp,
body[data-mode="light"] .panel-title,
body[data-mode="light"] .section-head h2,
body[data-mode="light"] .forecast-title,
body[data-mode="light"] .tomorrow-label,
body[data-mode="light"] .tomorrow-temps,
body[data-mode="light"] .metric strong,
body[data-mode="light"] .stat-item dd,
body[data-mode="light"] .sun-value,
body[data-mode="light"] .aqi-value,
body[data-mode="light"] .hourly-temp,
body[data-mode="light"] .daily-day,
body[data-mode="light"] .daily-temps {
  color: var(--text);
}

body[data-mode="light"] .hero-desc,
body[data-mode="light"] .hero-feels,
body[data-mode="light"] .country-line,
body[data-mode="light"] .tomorrow-desc,
body[data-mode="light"] .daily-desc,
body[data-mode="light"] .metric span:last-child,
body[data-mode="light"] .panel-empty,
body[data-mode="light"] .insight-text,
body[data-mode="light"] .aqi-explain,
body[data-mode="light"] .search-status,
body[data-mode="light"] .topbar-time,
body[data-mode="light"] .last-updated,
body[data-mode="light"] .site-footer {
  color: var(--text-dim);
}

body[data-mode="light"] .hero-day-label {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

body[data-mode="light"] .hourly-item.is-active {
  background: linear-gradient(180deg, #1b6fd4 0%, #155dcf 100%);
  color: #ffffff;
  border-color: transparent;
}
body[data-mode="light"] .hourly-item.is-active .hourly-temp,
body[data-mode="light"] .hourly-item.is-active .hourly-time {
  color: #ffffff;
}
body[data-mode="light"] .hourly-item.is-active .hourly-pop {
  color: #dbeafe;
}

body[data-mode="light"] .daily-item.is-active {
  background: rgba(21, 93, 207, 0.1);
  border-color: rgba(21, 93, 207, 0.45);
}

body[data-mode="light"] .btn-glow {
  background: linear-gradient(135deg, #2d7ff0, #155dcf);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(21, 93, 207, 0.28);
}
body[data-mode="light"][data-theme="sunny"] .btn-glow {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(180, 83, 9, 0.28);
}

body[data-mode="light"] .btn-soft {
  background: #ffffff;
  color: var(--text);
  border: 1px solid rgba(15, 23, 42, 0.28);
}
body[data-mode="light"] .btn-soft:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #f8fafc;
}

body[data-mode="light"] .btn-text {
  color: var(--text-dim);
}
body[data-mode="light"] .btn-text:hover {
  color: var(--accent-strong);
}

body[data-mode="light"] .unit-btn.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

body[data-mode="light"] .chip,
body[data-mode="light"] .chip-select {
  background: var(--accent-soft);
  border-color: rgba(21, 93, 207, 0.25);
  color: var(--text);
}

body[data-mode="light"] .alert-region {
  background: #fef2f2 !important;
  border: 1px solid #f87171 !important;
  color: #7f1d1d !important;
}
body[data-mode="light"] .alert-region .btn,
body[data-mode="light"] .alert-region .retry-btn {
  color: #7f1d1d;
  border-color: #f87171;
  background: #ffffff;
}

body[data-mode="light"] .topbar-btn {
  background: #ffffff !important;
  border: 1px solid rgba(15, 23, 42, 0.16) !important;
  color: #0b1220 !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

body[data-mode="light"] a {
  color: #0f4aa8;
  text-decoration-thickness: 1px;
}
body[data-mode="light"] a:hover {
  color: #08357a;
}
body[data-mode="light"] .navbar-brand,
body[data-mode="light"] .navbar-brand:hover {
  color: var(--text) !important;
  text-decoration: none !important;
}
body[data-mode="light"] .nav-link,
body[data-mode="light"] .bottom-link {
  color: var(--text-dim);
  text-decoration: none;
}
body[data-mode="light"] .nav-link.is-active,
body[data-mode="light"] .bottom-link.is-active {
  color: var(--accent-strong);
}

body[data-mode="light"][data-theme="sunny"] a {
  color: #92400e;
}

body[data-mode="light"] .api-key-hint,
body[data-mode="light"] .insights-disclaimer {
  color: var(--text-mute);
}

body[data-mode="light"] .api-key-form {
  background: #f8fafc !important;
  border: 1px solid rgba(15, 23, 42, 0.18) !important;
}

body[data-mode="light"] .api-key-form label {
  color: var(--text-dim);
}

body[data-mode="light"] .api-key-status {
  color: #047857;
}
body[data-mode="light"] .api-key-status.is-error {
  color: #b91c1c;
}

body[data-mode="light"] .stat-item,
body[data-mode="light"] .sun-item,
body[data-mode="light"] .insight-item,
body[data-mode="light"] .metrics-mini {
  background: #eef3f9;
  border-color: var(--stroke);
}

body[data-mode="light"] .metric-icon,
body[data-mode="light"] .search-icon,
body[data-mode="light"] .cal-icon {
  color: var(--text-dim);
}

body[data-mode="light"] .pin-icon {
  color: var(--accent);
}

body[data-mode="light"] input,
body[data-mode="light"] #searchInput,
body[data-mode="light"] .compare-fields input,
body[data-mode="light"] .api-key-row input {
  color: var(--text);
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.28);
}
body[data-mode="light"] input::placeholder,
body[data-mode="light"] #searchInput::placeholder,
body[data-mode="light"] .api-key-row input::placeholder {
  color: #3f4b5c;
  opacity: 1;
  -webkit-text-fill-color: #3f4b5c;
}

body[data-mode="light"] .search-field {
  border: 1px solid rgba(15, 23, 42, 0.22) !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

body[data-mode="light"] .api-key-form a {
  color: #0f4aa8;
  font-weight: 600;
}
body[data-mode="light"][data-theme="sunny"] .api-key-form a {
  color: #92400e;
}

body[data-mode="light"] .suggestion-country,
body[data-mode="light"] .city-option-meta,
body[data-mode="light"] .compare-cond,
body[data-mode="light"] .compare-coords,
body[data-mode="light"] .compare-range {
  color: var(--text-dim);
}
body[data-mode="light"] .compare-table-wrap {
  background: #f3f6fb;
}
body[data-mode="light"] .compare-insights {
  background: linear-gradient(145deg, rgba(45, 140, 255, 0.1), #ffffff 60%);
}

/* Soften active FX only — never force inactive layers visible */
body[data-mode="light"][data-theme="rainy"] .fx-particles,
body[data-mode="light"][data-theme="rainy"] .fx-clouds,
body[data-mode="light"][data-theme="thunderstorm"] .fx-particles,
body[data-mode="light"][data-theme="thunderstorm"] .fx-clouds,
body[data-mode="light"][data-theme="snowy"] .fx-particles,
body[data-mode="light"][data-theme="snowy"] .fx-clouds,
body[data-mode="light"][data-theme="cloudy"] .fx-clouds,
body[data-mode="light"][data-theme="cloudy"] .fx-particles,
body[data-mode="light"][data-theme="foggy"] .fx-fog,
body[data-mode="light"][data-theme="foggy"] .fx-clouds,
body[data-mode="light"][data-theme="foggy"] .fx-particles {
  opacity: 0.85;
}
body[data-mode="light"][data-theme="sunny"] .fx-sun {
  opacity: 0.95;
}
body[data-mode="light"][data-theme="night"] .fx-stars {
  opacity: 0.6;
}
body[data-mode="light"] .navbar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(228, 235, 244, 0.88)),
    radial-gradient(ellipse 60% 120% at 8% 0%, rgba(45, 140, 255, 0.12), transparent 55%);
  box-shadow: 0 8px 28px rgba(15, 40, 80, 0.08);
  color: var(--text);
}

body[data-mode="light"] .anim-settings-panel,
body[data-mode="light"] .more-menu,
body[data-mode="light"] .assistant-sheet {
  background: #ffffff;
  color: var(--text);
  border-color: var(--stroke);
  box-shadow: 0 16px 40px rgba(15, 40, 80, 0.14);
}

body[data-mode="light"] .anim-field select {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.2);
  color: var(--text);
}

body[data-mode="light"] .bottom-nav {
  color: var(--text);
}

/* Light-mode weather skies — brighter, less muddy */
body[data-mode="light"][data-theme="sunny"] .fx-gradient {
  background:
    radial-gradient(ellipse 65% 50% at 92% -8%, rgba(255, 210, 80, 0.55), transparent 60%),
    radial-gradient(ellipse 45% 35% at 75% 8%, rgba(255, 196, 60, 0.28), transparent 55%),
    linear-gradient(165deg, #cfe8ff 0%, #e8f3fb 48%, #f8fafc 100%) !important;
}
body[data-mode="light"][data-theme="rainy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 30% 0%, rgba(70, 120, 190, 0.18), transparent 55%),
    linear-gradient(170deg, #c5d5e8 0%, #e8eef6 55%, #f3f6fa 100%) !important;
}
body[data-mode="light"][data-theme="thunderstorm"] .fx-gradient {
  background:
    radial-gradient(ellipse 50% 40% at 55% 8%, rgba(90, 105, 150, 0.22), transparent 50%),
    linear-gradient(170deg, #b8c0d0 0%, #d5dbe6 50%, #e8ecf3 100%) !important;
}
body[data-mode="light"][data-theme="snowy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(200, 225, 255, 0.45), transparent 55%),
    linear-gradient(165deg, #dceaf8 0%, #eef4fb 55%, #f8fafc 100%) !important;
}
body[data-mode="light"][data-theme="cloudy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 40% at 40% 15%, rgba(148, 163, 184, 0.22), transparent 55%),
    linear-gradient(165deg, #d2d9e3 0%, #e6ebf2 55%, #f3f5f8 100%) !important;
}
body[data-mode="light"][data-theme="foggy"] .fx-gradient {
  background:
    radial-gradient(ellipse 90% 50% at 50% 40%, rgba(160, 170, 185, 0.28), transparent 60%),
    linear-gradient(180deg, #d8dde5 0%, #eaedf2 100%) !important;
}
/*
 * Light mode + night weather: keep the UI visually light.
 * Soft evening sky (not a black starfield) so chrome and cards still match.
 */
body[data-mode="light"][data-theme="night"] .fx-gradient {
  background:
    radial-gradient(ellipse 40% 32% at 82% 8%, rgba(255, 244, 220, 0.55), transparent 58%),
    radial-gradient(ellipse 55% 40% at 18% 0%, rgba(120, 150, 220, 0.22), transparent 55%),
    linear-gradient(170deg, #c5d3ef 0%, #dde5f4 42%, #eef2f8 100%) !important;
}

/* Soften night FX layers in light UI — moon stays, stars become subtle */
body[data-mode="light"][data-theme="night"] .wa-stars {
  opacity: 0.22;
}
body[data-mode="light"][data-theme="night"] .wa-moon {
  filter: drop-shadow(0 8px 20px rgba(80, 110, 170, 0.25));
}
body[data-mode="light"][data-theme="night"] .fx-stars {
  opacity: 0.15;
}

/* Dark-mode night only: light hero type on dark sky */
body:not([data-mode="light"])[data-theme="night"] .hero-temp,
body:not([data-mode="light"])[data-theme="night"] .hero-desc,
body:not([data-mode="light"])[data-theme="night"] .hero-feels,
body:not([data-mode="light"])[data-theme="night"] .country-line,
body:not([data-mode="light"])[data-theme="night"] .hero-day-label {
  color: #f4f7ff;
}
body:not([data-mode="light"])[data-theme="night"] .hero-day-label {
  background: rgba(90, 130, 220, 0.28);
  color: #dce7ff;
}
body:not([data-mode="light"])[data-theme="night"] .hero-temp .deg {
  color: rgba(244, 247, 255, 0.7);
}

/* Light-mode night: keep normal dark text on the pale evening sky */
body[data-mode="light"][data-theme="night"] .hero-temp,
body[data-mode="light"][data-theme="night"] .hero-desc,
body[data-mode="light"][data-theme="night"] .hero-feels,
body[data-mode="light"][data-theme="night"] .country-line {
  color: var(--text);
}
body[data-mode="light"][data-theme="night"] .hero-day-label {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
body[data-mode="light"][data-theme="night"] .hero-temp .deg {
  color: var(--text-dim);
}
body[data-mode="light"][data-theme="night"] .hero-icon {
  filter: drop-shadow(0 12px 22px rgba(40, 70, 140, 0.2));
}

/* ---------- Dark mode weather accents (do not apply in light) ---------- */

body:not([data-mode="light"])[data-theme="default"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(45, 140, 255, 0.14), transparent 55%),
    linear-gradient(180deg, #0a0a0e 0%, #070708 55%, #050506 100%);
}

body:not([data-mode="light"])[data-theme="sunny"] {
  --accent: #f5c518;
  --accent-strong: #e0a800;
  --accent-soft: rgba(245, 197, 24, 0.16);
  --blue: #f5c518;
  --blue-glow: rgba(245, 197, 24, 0.4);
}
body:not([data-mode="light"])[data-theme="sunny"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 55% at 88% -5%, rgba(255, 214, 90, 0.42), transparent 58%),
    radial-gradient(ellipse 45% 40% at 70% 12%, rgba(245, 197, 24, 0.22), transparent 55%),
    radial-gradient(ellipse 40% 35% at 18% 78%, rgba(251, 146, 60, 0.14), transparent 52%),
    linear-gradient(165deg, #151008 0%, #0a0806 100%);
}
body:not([data-mode="light"])[data-theme="sunny"] .btn-glow {
  background: linear-gradient(135deg, #f5c518, #e0a800);
  color: #1a1408;
  box-shadow: 0 8px 24px rgba(245, 197, 24, 0.35);
}

body:not([data-mode="light"])[data-theme="cloudy"] {
  --accent: #9aa3b2;
  --accent-strong: #7b8494;
  --accent-soft: rgba(154, 163, 178, 0.16);
  --blue: #8b9bb4;
  --blue-glow: rgba(139, 155, 180, 0.35);
}
body:not([data-mode="light"])[data-theme="cloudy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 40% at 40% 15%, rgba(148, 163, 184, 0.16), transparent 55%),
    linear-gradient(165deg, #0c0e12 0%, #08090c 100%);
}

body:not([data-mode="light"])[data-theme="rainy"] {
  --accent: #4da3ff;
  --accent-strong: #2d8cff;
  --accent-soft: rgba(77, 163, 255, 0.16);
}
body:not([data-mode="light"])[data-theme="rainy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 30% 0%, rgba(45, 140, 255, 0.22), transparent 55%),
    linear-gradient(170deg, #060912 0%, #05070e 100%);
}

body:not([data-mode="light"])[data-theme="thunderstorm"] {
  --accent: #7c9cff;
  --accent-strong: #5b7cfa;
  --accent-soft: rgba(124, 156, 255, 0.16);
  --blue: #7c9cff;
  --blue-glow: rgba(124, 156, 255, 0.5);
}
body:not([data-mode="light"])[data-theme="thunderstorm"] .fx-gradient {
  background:
    radial-gradient(ellipse 50% 40% at 55% 8%, rgba(124, 156, 255, 0.2), transparent 50%),
    radial-gradient(ellipse 40% 35% at 20% 80%, rgba(245, 197, 24, 0.08), transparent 50%),
    linear-gradient(170deg, #04050c 0%, #06070f 100%);
}

body:not([data-mode="light"])[data-theme="snowy"] {
  --accent: #e8f4ff;
  --accent-strong: #a8d4ff;
  --accent-soft: rgba(232, 244, 255, 0.12);
  --blue: #a8d4ff;
  --blue-glow: rgba(168, 212, 255, 0.4);
}
body:not([data-mode="light"])[data-theme="snowy"] .fx-gradient {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(232, 244, 255, 0.16), transparent 55%),
    linear-gradient(165deg, #0a1018 0%, #070b10 100%);
}
body:not([data-mode="light"])[data-theme="snowy"] .btn-glow {
  background: linear-gradient(135deg, #e8f4ff, #a8d4ff);
  color: #0a1018;
}

body:not([data-mode="light"])[data-theme="foggy"] {
  --accent: #c5c9d1;
  --accent-strong: #9aa0ab;
  --accent-soft: rgba(197, 201, 209, 0.14);
  --blue: #b0b6c2;
  --blue-glow: rgba(176, 182, 194, 0.3);
}
body:not([data-mode="light"])[data-theme="foggy"] .fx-gradient {
  background:
    radial-gradient(ellipse 90% 50% at 50% 40%, rgba(148, 163, 184, 0.18), transparent 60%),
    linear-gradient(180deg, #121418 0%, #0a0b0e 100%);
}

body:not([data-mode="light"])[data-theme="night"] {
  --accent: #7b8cff;
  --accent-strong: #5c6bf0;
  --accent-soft: rgba(123, 140, 255, 0.16);
  --blue: #7b8cff;
  --blue-glow: rgba(123, 140, 255, 0.45);
}
body:not([data-mode="light"])[data-theme="night"] .fx-gradient {
  background:
    radial-gradient(ellipse 40% 30% at 70% 12%, rgba(123, 140, 255, 0.18), transparent 50%),
    linear-gradient(170deg, #050510 0%, #07070f 100%);
}
