/* ===== Tokens ===== */

:root {
  --font-display: 'Fraunces', serif;
  --font-ui: 'Space Grotesk', sans-serif;
  --font-data: 'JetBrains Mono', monospace;
  --radius: 14px;
}

body[data-theme="synoptic"] {
  --bg: #eef1ea;
  --bg-alt: #e2e7dd;
  --panel: #f7f9f4;
  --ink: #1c2b3a;
  --ink-soft: #4c5c66;
  --line: #b9c4bd;
  --accent: #b5762a;
  --accent-2: #3a6b63;
  --warn: #a1442a;
  --shadow: rgba(28, 43, 58, 0.08);
}

body[data-theme="nocturne"] {
  --bg: #0b1026;
  --bg-alt: #131a3a;
  --panel: #121936;
  --ink: #e6e9f5;
  --ink-soft: #9aa3c7;
  --line: #2b3566;
  --accent: #6ee7c8;
  --accent-2: #a78bfa;
  --warn: #f97066;
  --shadow: rgba(0, 0, 0, 0.4);
}

body[data-theme="analog"] {
  --bg: #1f1b16;
  --bg-alt: #17130f;
  --panel: #262019;
  --ink: #f2ead9;
  --ink-soft: #b8a98e;
  --line: #4a3f30;
  --accent: #f2a93b;
  --accent-2: #c9502f;
  --warn: #e0563a;
  --shadow: rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  transition: background .35s ease, color .35s ease;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

a { color: var(--accent); }

/* ===== Topbar ===== */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0 22px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.brand-mark { color: var(--accent); flex-shrink: 0; }
.brand-name {
  font-family: var(--font-data);
  letter-spacing: .22em;
  font-size: 13px;
  font-weight: 700;
}

.search {
  position: relative;
  flex: 1;
  min-width: 180px;
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
}
.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
}
.search input::placeholder { color: var(--ink-soft); }
.search button {
  border: none;
  background: var(--accent);
  color: var(--bg);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 20;
  box-shadow: 0 12px 28px var(--shadow);
}
.search-results li {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.search-results li:hover,
.search-results li:focus {
  background: var(--bg-alt);
}

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

.unit-toggle {
  font-family: var(--font-data);
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.unit-toggle:hover { border-color: var(--accent); color: var(--accent); }

.theme-picker { display: flex; gap: 8px; }
.theme-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.theme-dot[data-theme="synoptic"] { background: #b5762a; }
.theme-dot[data-theme="nocturne"] { background: #6ee7c8; }
.theme-dot[data-theme="analog"] { background: #f2a93b; }
.theme-dot.active { border-color: var(--ink); transform: scale(1.15); }

/* ===== Hero ===== */

.hero {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  min-height: 260px;
  padding: 32px;
  margin-bottom: 34px;
  overflow: hidden;
}

.hero-loading {
  font-family: var(--font-data);
  color: var(--ink-soft);
  font-size: 14px;
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-left { flex: 1; min-width: 240px; }

.place {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.temp-row { display: flex; align-items: flex-start; gap: 4px; line-height: 1; }
.temp {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 92px;
  letter-spacing: -0.02em;
}
.temp-unit {
  font-family: var(--font-data);
  font-size: 24px;
  color: var(--accent);
  margin-top: 10px;
}

.condition {
  font-family: var(--font-ui);
  font-size: 18px;
  margin: 6px 0 2px;
}
.feels {
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

.meta-row { display: flex; gap: 22px; flex-wrap: wrap; }
.meta { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
}
.meta-value { font-family: var(--font-data); font-size: 14px; }

.hero-right {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}

.scene {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-alt);
}

.gauge { position: relative; z-index: 2; overflow: visible; }
.gauge-track { stroke: var(--line); opacity: .6; }
.gauge-hub { fill: var(--ink); }
#gaugeArc { stroke: var(--accent); }
#gaugeNeedle { stroke: var(--accent); }
.gauge-tick { stroke: var(--line); }
.gauge-scale {
  font-family: var(--font-data);
  font-size: 11px;
  fill: var(--ink-soft);
}

/* --- Scene animations --- */
.sun {
  position: absolute; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 30px var(--accent);
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.08); opacity: 1; } }

.cloud {
  position: absolute;
  background: var(--ink-soft);
  opacity: .55;
  border-radius: 40%;
  animation: drift 14s linear infinite;
}
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(240px); } }

.rain {
  position: absolute; width: 2px; height: 14px;
  background: var(--accent-2);
  opacity: .7;
  animation: fall 0.9s linear infinite;
}
@keyframes fall { from { transform: translateY(-20px); opacity: .8; } to { transform: translateY(200px); opacity: 0; } }

.snow {
  position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: var(--ink);
  opacity: .8;
  animation: snowfall 5s linear infinite;
}
@keyframes snowfall { from { transform: translate(0,-20px); } to { transform: translate(10px, 210px); } }

.star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: var(--ink);
  animation: twinkle 2.6s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: .2; } 50% { opacity: 1; } }

.bolt {
  position: absolute;
  color: var(--warn);
  animation: flash 2.4s ease-in-out infinite;
}
@keyframes flash { 0%, 92%, 100% { opacity: 0; } 94%, 97% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sun, .cloud, .rain, .snow, .star, .bolt { animation: none !important; }
}

/* ===== Hourly ===== */

.section-title {
  font-family: var(--font-ui);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.hourly-section { margin-bottom: 34px; }

.hourly-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.hour-card {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  min-width: 72px;
  text-align: center;
}
.hour-time {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.hour-icon { margin: 4px 0; }
.hour-temp {
  font-family: var(--font-data);
  font-weight: 700;
  font-size: 15px;
  margin-top: 4px;
}
.hour-precip {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--accent-2);
  margin-top: 2px;
}

/* ===== Daily ===== */

.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.day-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 14px;
  text-align: center;
}
.day-name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  text-transform: capitalize;
  margin-bottom: 8px;
}
.day-icon { margin: 6px 0; }
.day-range {
  font-family: var(--font-data);
  font-size: 13px;
  margin-top: 8px;
}
.day-range .lo { color: var(--ink-soft); }
.day-precip {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--accent-2);
  margin-top: 4px;
}

/* ===== Footer ===== */

.foot {
  text-align: center;
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--ink-soft);
  padding-top: 10px;
}

/* ===== Responsive ===== */

@media (max-width: 640px) {
  .temp { font-size: 68px; }
  .hero-content { flex-direction: column; align-items: flex-start; }
  .hero-right { align-self: center; }
  .topbar { gap: 10px; }
}
