/* ===== CERNS.IO — Main Stylesheet ===== */

/* --- CSS Variables / Theme (warm earthy palette, matches city/station pages) --- */
:root {
  --bg-primary:    #0f0f0e;
  --bg-surface:    #1a1a18;
  --bg-elevated:   #222220;
  --text-primary:  #eeebe6;
  --text-secondary:#9e9892;
  --text-muted:    #5e5a55;
  --border:        #2a2926;
  --border-strong: #3a3835;
  --border-lt:     #1f1f1d;

  /* AQI scale */
  --aqi-good:       #059669;
  --aqi-moderate:   #d97706;
  --aqi-usg:        #ea580c;
  --aqi-unhealthy:  #dc2626;
  --aqi-very:       #7c3aed;
  --aqi-hazardous:  #991b1b;

  /* Data colors */
  --color-temp:    #EF9F27;
  --color-rain:    #378ADD;
  --color-wind:    #7F77DD;
  --color-humid:   #1D9E75;
  --color-uv:      #EF9F27;
  --color-pressure:#888780;

  --max-width: 720px;
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'DM Mono', monospace;
  --ease: .2s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
  --bg-primary:    #f3f0ec;
  --bg-surface:    #ffffff;
  --bg-elevated:   #faf9f7;
  --text-primary:  #1a1a1a;
  --text-secondary:#6b6560;
  --text-muted:    #9e9892;
  --border:        #e8e4df;
  --border-strong: #d5d0ca;
  --border-lt:     #f0ede8;
}
@media(prefers-color-scheme:light){
  html:not([data-theme="dark"]){
    --bg-primary:    #f3f0ec;
    --bg-surface:    #ffffff;
    --bg-elevated:   #faf9f7;
    --text-primary:  #1a1a1a;
    --text-secondary:#6b6560;
    --text-muted:    #9e9892;
    --border:        #e8e4df;
    --border-strong: #d5d0ca;
    --border-lt:     #f0ede8;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Navbar (frosted glass, matching city/station pages) --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border-lt);
}
.nav-inner {
  padding: 0 clamp(14px, 3vw, 32px);
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.nav-logo b { color: var(--aqi-good); }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  transition: var(--ease);
}
.nav-btn svg { flex-shrink: 0; }
.nav-btn:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
}
@media (max-width: 479px) {
  .nav-links { gap: 0; }
  .nav-btn { padding: 4px 7px; font-size: 12px; }
}
.nav-search { position: relative; max-width: 380px; flex: 1; }
.nav-search input {
  width: 100%;
  padding: 7px 14px 7px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: var(--ease);
}
.nav-search input:focus {
  border-color: var(--aqi-good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--aqi-good) 14%, transparent);
}
.nav-search input::placeholder { color: var(--text-muted); }
.nav-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.nav-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--ease);
}
.theme-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* Theme toggle icons */
.icon-sun { display: block; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
@media(prefers-color-scheme:light){
  html:not([data-theme="dark"]) .icon-sun { display: none; }
  html:not([data-theme="dark"]) .icon-moon { display: block; }
}

.nav-tz-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font: 700 10px/34px var(--mono);
  height: 34px; padding: 0 6px;
  cursor: pointer; outline: none;
}
.nav-tz-select:focus { border-color: var(--text-muted); }
@media (max-width: 479px) { .nav-tz-select { font-size: 9px; padding: 0 4px; } }
.lang-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: var(--ease);
}
.lang-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* --- Page Container --- */
.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* --- City Header --- */
.city-header { margin-bottom: 20px; }
.city-name { font-size: 28px; font-weight: 600; line-height: 1.2; }
.city-country { color: var(--text-secondary); font-size: 14px; }

/* --- AQI Hero Banner --- */
.aqi-hero {
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-bottom: 16px;
  text-align: center;
}
.aqi-hero-inner { max-width: 480px; margin: 0 auto; }
.aqi-hero-number {
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.aqi-hero-label {
  font-size: 22px;
  font-weight: 600;
  margin-top: 4px;
  opacity: 0.95;
}
.aqi-hero-advice {
  font-size: 14px;
  margin-top: 12px;
  opacity: 0.85;
  line-height: 1.5;
}

/* --- AQI Legend --- */
.aqi-legend {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  border-radius: 6px;
  overflow: hidden;
}
.aqi-legend-band {
  flex: 1;
  height: 6px;
}

/* --- Weather Strip --- */
.weather-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.wx-card {
  flex: 0 0 auto;
  min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.wx-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.wx-value { font-size: 20px; font-weight: 600; }
.wx-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.wx-sub { font-size: 12px; color: var(--text-muted); }

/* --- Pollutant Color-Scale Bars --- */
.pollutant-bars { margin-bottom: 28px; }
.pollutant-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.pollutant-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.pollutant-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pollutant-danger {
  font-size: 13px;
  font-weight: 500;
}
.pollutant-ug {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* Color scale bar */
.color-scale {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: visible;
  position: relative;
}
.color-scale-seg {
  flex: 1;
}
.color-scale-seg:first-child { border-radius: 5px 0 0 5px; }
.color-scale-seg:last-child { border-radius: 0 5px 5px 0; }
.color-scale-marker {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 16px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 2px;
  transform: translateX(-2px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* --- Section Titles --- */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* --- Chart Sections --- */
.chart-section { margin-bottom: 28px; }
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
}
.hourly-chart-container { overflow-x: auto; }

/* --- Ad Slots --- */
.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 12px;
}
.ad-placeholder-label { opacity: 0.4; }
.ad-desktop-only { display: none; }

/* --- Model Confidence --- */
.model-confidence { margin-bottom: 28px; }
.confidence-pills { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.confidence-pill {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.confidence-high { background: rgba(0,228,0,0.15); color: var(--aqi-good); }
.confidence-medium { background: rgba(255,126,0,0.15); color: var(--aqi-usg); }
.confidence-low { background: rgba(255,0,0,0.15); color: var(--aqi-unhealthy); }
.confidence-unknown { background: var(--bg-elevated); color: var(--text-muted); }
.confidence-detail { font-size: 13px; color: var(--text-secondary); }

/* --- Nearby Stations --- */
.stations-section { margin-bottom: 28px; }
.stations-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.station-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.station-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.station-aqi-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.station-aqi-num {
  font-size: 18px;
  font-weight: 600;
}
.station-aqi-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.station-name {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}
.station-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Nearby Cities --- */
.nearby-section { margin-bottom: 28px; }
.nearby-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.nearby-card {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color var(--ease);
}
.nearby-card:hover { border-color: var(--border-strong); }
.nearby-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.nearby-country { font-size: 12px; color: var(--text-secondary); }

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px;
  text-align: center;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
.footer-tagline { font-style: italic; }

/* --- Locate Page --- */
.locate-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 20px;
}
.locate-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--aqi-good);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.locate-status {
  color: var(--text-secondary);
  font-size: 15px;
}

/* --- jQuery UI Autocomplete Overrides --- */
.ui-autocomplete {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200 !important;
  padding: 4px 0 !important;
}
.ui-autocomplete .ui-menu-item {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
}
.ui-autocomplete .ui-menu-item-wrapper {
  padding: 0 !important;
  border: none !important;
}
.ui-autocomplete .ui-state-active,
.ui-autocomplete .ui-state-focus {
  background: var(--bg-elevated) !important;
  border: none !important;
  margin: 0 !important;
}
.ac-item {
  padding: 0 !important;
}
.ac-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.ac-icon {
  font-size: 10px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.ac-icon-city { color: var(--aqi-good); }
.ac-icon-station { color: var(--color-wind); }
.ac-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.ac-secondary {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.ac-aqi-dot {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  min-width: 32px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  flex-shrink: 0;
}

/* --- Responsive --- */
@media (min-width: 480px) {
  .weather-strip { flex-wrap: wrap; }
  .wx-card { flex: 1 1 calc(33% - 10px); min-width: 0; }
}

@media (min-width: 640px) {
  .stations-grid { grid-template-columns: 1fr 1fr; }
  .weather-strip { flex-wrap: wrap; }
  .wx-card { flex: 1 1 calc(20% - 10px); min-width: 0; }
}

@media (min-width: 1024px) {
  .ad-desktop-only { display: block; }
}

/* --- Screen-reader only --- */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
