/* =========================================================
   Aura — Wetter & Luftqualität
   Design-System: dunkel, atmosphärisch, luftqualitäts-reaktiv.
   Der Akzent (--aqi) wird per JS gesetzt und färbt Gauge,
   Himmel und Details – die ganze Seite "atmet" die Luftqualität.
   ========================================================= */

:root {
  color-scheme: dark;

  /* Grundfläche */
  --bg-0: #070a12;
  --bg-1: #0b0f1c;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --ink: #eef2fb;
  --ink-soft: #aab3c8;
  --ink-faint: #6b7488;

  /* Reaktiver Luftqualitäts-Akzent (Default = "gut") */
  --aqi: #34d399;
  --aqi-soft: rgba(52, 211, 153, 0.16);

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.75);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.011em;
}

a { color: inherit; }

/* ---------- Dynamischer Himmel ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(140% 100% at 50% -20%, color-mix(in oklab, var(--aqi) 26%, transparent) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 60%);
  transition: background 1.2s var(--ease);
}
.sky-orb {
  position: absolute;
  top: -18vmax;
  left: 50%;
  width: 60vmax;
  height: 60vmax;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in oklab, var(--aqi) 55%, transparent) 0%, transparent 62%);
  filter: blur(30px);
  opacity: 0.5;
  transition: background 1.2s var(--ease);
  animation: breathe 11s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.42; }
  50%      { transform: translateX(-50%) scale(1.08); opacity: 0.58; }
}
.sky-grain {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.particles { position: absolute; inset: 0; overflow: hidden; }
.particles span {
  position: absolute;
  bottom: -8px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--aqi) 70%, white);
  opacity: 0;
  animation: rise linear infinite;
}
@keyframes rise {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  10%  { opacity: 0.55; }
  100% { transform: translateY(-104vh) scale(0.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sky-orb, .particles span { animation: none; }
}

/* ---------- Topbar & Suche ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(16px, 4vw, 40px);
  backdrop-filter: blur(14px) saturate(140%);
  background: linear-gradient(180deg, rgba(7,10,18,0.75), rgba(7,10,18,0.25));
  border-bottom: 1px solid var(--stroke);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand-mark { font-size: 1.35rem; filter: drop-shadow(0 0 12px var(--aqi-soft)); }
.brand-name { background: linear-gradient(90deg, var(--ink), var(--ink-soft)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.search { position: relative; flex: 1; max-width: 560px; margin-left: auto; }
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  height: 48px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
.search-field:focus-within {
  border-color: color-mix(in oklab, var(--aqi) 60%, var(--stroke-strong));
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--aqi-soft);
}
.search-icon { color: var(--ink-faint); flex-shrink: 0; }
#search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.98rem;
  font-family: inherit;
  outline: none;
}
#search-input::placeholder { color: var(--ink-faint); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.geo-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.geo-btn:hover { background: var(--aqi-soft); color: var(--aqi); transform: scale(1.05); }
.geo-btn.locating { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  background: rgba(14, 18, 30, 0.94);
  backdrop-filter: blur(18px);
  border: 1px solid var(--stroke-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 50;
}
.suggestions li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: var(--surface-2); }
.suggestions .sug-name { font-weight: 600; }
.suggestions .sug-meta { color: var(--ink-faint); font-size: 0.83rem; }
.suggestions .sug-empty { color: var(--ink-faint); cursor: default; }

/* ---------- Layout ---------- */
.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 52px) clamp(16px, 4vw, 40px) 80px;
}
.state { text-align: center; }

/* Intro */
.state-intro { min-height: 62vh; display: grid; place-items: center; }
.intro-inner { max-width: 640px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 18px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--aqi);
  background: var(--aqi-soft);
  border: 1px solid color-mix(in oklab, var(--aqi) 30%, transparent);
}
.intro-title {
  margin: 0 0 18px;
  font-size: clamp(2.3rem, 6.5vw, 3.9rem);
  line-height: 1.03;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.intro-sub { margin: 0 auto 30px; max-width: 520px; color: var(--ink-soft); font-size: 1.06rem; line-height: 1.6; }
.intro-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--stroke-strong); background: var(--surface-2); transform: translateY(-2px); }

/* Loading */
.state-loading { min-height: 50vh; display: grid; place-content: center; gap: 20px; color: var(--ink-soft); }
.loader { display: flex; gap: 9px; justify-content: center; }
.loader span {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--aqi);
  animation: bounce 1.1s ease-in-out infinite;
}
.loader span:nth-child(2) { animation-delay: 0.15s; }
.loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* Error */
.state-error { min-height: 50vh; display: grid; place-items: center; }
.error-card {
  max-width: 420px;
  padding: 40px 32px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
}
.error-emoji { font-size: 2.6rem; }
.error-card h2 { margin: 14px 0 8px; font-size: 1.3rem; }
.error-card p { color: var(--ink-soft); margin: 0 0 22px; }

.btn {
  padding: 12px 22px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--aqi) 40%, transparent);
  background: var(--aqi-soft);
  color: var(--aqi);
  font-weight: 600;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: color-mix(in oklab, var(--aqi) 22%, transparent); }

/* ---------- Dashboard ---------- */
.dashboard { display: grid; gap: 20px; animation: fade-up 0.6s var(--ease); }
@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.place-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.place-name { margin: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; }
.place-meta { margin: 4px 0 0; color: var(--ink-soft); font-size: 0.95rem; }
.place-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.updated { color: var(--ink-faint); font-size: 0.82rem; font-family: var(--mono); }
.share-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--ink-soft);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.share-btn:hover { color: var(--aqi); border-color: color-mix(in oklab, var(--aqi) 40%, var(--stroke)); background: var(--aqi-soft); }

.card {
  position: relative;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.hint { color: var(--ink-faint); font-size: 0.78rem; font-family: var(--mono); }

/* Hero */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } }

/* AQI-Gauge */
.aqi-card { display: flex; flex-direction: column; }
.scale-toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--stroke); }
.scale-toggle button {
  border: none; background: none; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  font: inherit; font-size: 0.78rem; font-weight: 600;
  color: var(--ink-faint); transition: all 0.2s;
}
.scale-toggle button.active { background: var(--aqi-soft); color: var(--aqi); }

.gauge-wrap { position: relative; width: 220px; max-width: 100%; margin: 4px auto 6px; aspect-ratio: 1; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.gauge-fill {
  fill: none;
  stroke: var(--aqi);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 515;
  stroke-dashoffset: 515;
  filter: drop-shadow(0 0 10px var(--aqi-soft));
  transition: stroke-dashoffset 1.1s var(--ease), stroke 0.8s var(--ease);
}
.gauge-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge-value { font-size: 3.2rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.gauge-label { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }

.aqi-verdict { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 4px; font-weight: 700; font-size: 1.05rem; }
.verdict-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--aqi); box-shadow: 0 0 12px var(--aqi); }
.aqi-advice { margin: 12px 0 0; text-align: center; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }

/* AQI-Kurzausblick */
.aqi-outlook { display: flex; gap: 8px; margin-top: 16px; }
.outlook-chip {
  --c: var(--aqi);
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
}
.outlook-day { font-size: 0.72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.outlook-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.outlook-label { font-size: 0.78rem; font-weight: 700; color: var(--c); }

/* Weather */
.weather-card { display: flex; flex-direction: column; }
.wx-code { color: var(--ink-soft); font-size: 0.9rem; }
.wx-main { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.wx-icon { font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.4)); }
.temp-now { display: block; font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.temp-feels { color: var(--ink-faint); font-size: 0.9rem; }
.wx-stats { list-style: none; margin: auto 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wx-stats li { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--stroke); }
.s-label { color: var(--ink-faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.s-val { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.wind-arrow {
  position: absolute;
  top: 10px; right: 12px;
  width: 15px; height: 15px;
  color: var(--aqi);
  transform-origin: 50% 55%;
  transition: transform 0.6s var(--ease);
}

/* Schadstoffe */
.pollutant-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.pollutant {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--stroke);
}
.pollutant-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.pollutant-name { font-weight: 700; font-size: 0.9rem; }
.pollutant-full { color: var(--ink-faint); font-size: 0.72rem; }
.pollutant-val { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pollutant-unit { color: var(--ink-faint); font-size: 0.72rem; font-weight: 500; margin-left: 3px; }
.pollutant-bar { position: relative; height: 6px; margin-top: 10px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.pollutant-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; transition: width 0.9s var(--ease); }

/* Vorhersagen (Spark-Charts) */
.forecast-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .forecast-row { grid-template-columns: 1fr; } }
.spark { position: relative; width: 100%; }
.spark svg { width: 100%; height: 130px; overflow: visible; display: block; }
.spark-axis { fill: var(--ink-faint); font-size: 10px; font-family: var(--mono); }
.spark-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot { r: 3; }
.spark-lbl { fill: var(--ink); font-size: 10px; font-weight: 700; font-family: var(--mono); text-anchor: middle; }

/* Pollen */
.pollen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.pollen-item { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--stroke); text-align: center; }
.pollen-emoji { font-size: 1.5rem; }
.pollen-name { font-size: 0.8rem; color: var(--ink-soft); margin: 6px 0 4px; }
.pollen-level { font-weight: 700; font-size: 0.9rem; }

/* Dominanter Schadstoff-Badge */
.dominant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--aqi);
  background: var(--aqi-soft);
  border: 1px solid color-mix(in oklab, var(--aqi) 30%, transparent);
}
.dominant::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--aqi); }

/* Kompakte Sonnen-Zelle */
.s-sun { font-size: 0.92rem; letter-spacing: -0.01em; }

/* 7-Tage-Vorhersage */
.days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.day {
  display: grid;
  grid-template-columns: 2.8rem 1.7rem 3.2rem 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-radius: 12px;
  transition: background 0.15s;
}
.day + .day { border-top: 1px solid var(--stroke); }
.day:hover { background: var(--surface-2); }
.day-name { font-weight: 600; font-size: 0.92rem; }
.day-name.today { color: var(--aqi); }
.day-icon { font-size: 1.3rem; text-align: center; }
.day-rain { color: #60a5fa; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.day-bar { position: relative; width: 100%; min-width: 48px; height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.day-bar span { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, var(--aqi)); }
.day-temps { display: inline-flex; align-items: center; gap: 10px; justify-self: end; font-variant-numeric: tabular-nums; }
.day-max { font-weight: 700; }
.day-min { color: var(--ink-faint); }
@media (max-width: 520px) {
  .day { grid-template-columns: 2.6rem 1.6rem 2.8rem 1fr; }
  .day-bar { display: none; }
}

/* Zuletzt gesucht */
.intro-recent { margin-top: 26px; }
.recent-label { display: block; margin-bottom: 10px; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); }
.recent-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.recent-chips .chip { font-size: 0.86rem; padding: 8px 14px; }
.recent-chips .chip::before { content: "↻"; margin-right: 6px; color: var(--aqi); }

/* Aktivitätsempfehlungen */
.activity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.activity {
  padding: 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--stroke);
}
.activity-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.activity-icon { font-size: 1.4rem; }
.activity-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.activity-title { margin: 0 0 6px; font-size: 0.88rem; font-weight: 700; }
.activity-text { margin: 0; color: var(--ink-soft); font-size: 0.82rem; line-height: 1.5; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(16, 20, 32, 0.95);
  border: 1px solid var(--stroke-strong);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  z-index: 60;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dash-footer { text-align: center; color: var(--ink-faint); font-size: 0.82rem; line-height: 1.6; margin-top: 8px; }
.dash-footer a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }

/* Utility */
[hidden] { display: none !important; }
