/* ============================================================
   Weatherly — style.css
   Design tokens live at the top as CSS custom properties so the
   whole theme (including dark mode + weather-based accents) can
   shift by swapping a handful of variables.
   ============================================================ */

:root {
  /* --- Palette: "instrument panel meets sky" --- */
  --navy-950: #0b1d3a;
  --navy-800: #142a4d;
  --sky-500: #4a7fc1;
  --sky-100: #eaf1fb;
  --amber-400: #ffb454;
  --cyan-300: #7dd3e8;
  --ink-900: #10192b;
  --ink-500: #55617a;
  --paper-0: #f4f7fb;
  --paper-50: #ffffff;
  --line: #dde5f0;
  --danger: #e2554a;

  --accent-warm: var(--amber-400);
  --accent-cool: var(--cyan-300);

  /* --- Semantic tokens (light theme default) --- */
  --bg: var(--paper-0);
  --surface: var(--paper-50);
  --surface-2: #f0f4fa;
  --text-primary: var(--ink-900);
  --text-muted: var(--ink-500);
  --border: var(--line);
  --shadow: 0 12px 32px -16px rgba(11, 29, 58, 0.18);
  --shadow-sm: 0 4px 14px -8px rgba(11, 29, 58, 0.16);

  /* --- Type --- */
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #081327;
  --surface: #0f1e38;
  --surface-2: #122442;
  --text-primary: #eef2f9;
  --text-muted: #93a2bf;
  --border: #1c2f52;
  --shadow: 0 16px 36px -18px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 6px 16px -10px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   Reset
   ============================================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  transition: background 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
.mono-text { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted-text { color: var(--text-muted); }
.small-text { font-size: 0.85rem; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   Signature element: animated sky strip
   A thin atmospheric band that changes gradient + drifting
   particles based on the current weather condition. It sits
   behind the header, like a live readout of the sky outside.
   ============================================================ */
.sky-strip {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 220px;
  z-index: 0;
  background: linear-gradient(180deg, #6fa8dc 0%, #a9cdf0 60%, transparent 100%);
  overflow: hidden;
  transition: background 0.6s ease;
}
[data-theme="dark"] .sky-strip {
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-800) 60%, transparent 100%);
}

body[data-condition="clear"] .sky-strip { background: linear-gradient(180deg, #4f9cd6 0%, #bfe0f7 60%, transparent 100%); }
body[data-condition="clouds"] .sky-strip { background: linear-gradient(180deg, #7c93a8 0%, #c3cfd9 60%, transparent 100%); }
body[data-condition="rain"] .sky-strip { background: linear-gradient(180deg, #435870 0%, #7c93a8 60%, transparent 100%); }
body[data-condition="snow"] .sky-strip { background: linear-gradient(180deg, #93a9c2 0%, #e4ecf5 60%, transparent 100%); }
body[data-condition="thunderstorm"] .sky-strip { background: linear-gradient(180deg, #23293a 0%, #4a5268 60%, transparent 100%); }
body[data-condition="mist"] .sky-strip { background: linear-gradient(180deg, #9aa7b0 0%, #cfd8dd 60%, transparent 100%); }

[data-theme="dark"] body[data-condition] .sky-strip { filter: brightness(0.45) saturate(0.85); }

.sky-particles { position: absolute; inset: 0; }
.sky-particles span {
  position: absolute;
  top: -10px;
  border-radius: 50%;
  opacity: 0.55;
}
body[data-condition="rain"] .sky-particles span {
  width: 2px; height: 14px; border-radius: 2px;
  background: rgba(255,255,255,0.55);
  animation: fall 1.1s linear infinite;
}
body[data-condition="snow"] .sky-particles span {
  width: 5px; height: 5px;
  background: rgba(255,255,255,0.85);
  animation: fall-slow 4.5s linear infinite;
}
body[data-condition="thunderstorm"] .sky-particles span {
  width: 2px; height: 16px; border-radius: 2px;
  background: rgba(220,230,255,0.6);
  animation: fall 0.8s linear infinite;
}
@keyframes fall {
  from { transform: translateY(-10px); opacity: 0.6; }
  to { transform: translateY(220px); opacity: 0; }
}
@keyframes fall-slow {
  from { transform: translateY(-10px) translateX(0); opacity: 0.9; }
  to { transform: translateY(220px) translateX(12px); opacity: 0.1; }
}

/* ============================================================
   App shell
   ============================================================ */
.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0,0,0,0.15);
}
[data-theme="dark"] .brand-name,
body[data-condition] .brand-name { color: #fff; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--navy-950);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }
[data-theme="dark"] .btn-primary { background: var(--accent-warm); color: var(--navy-950); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 9px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}
.btn-ghost:hover { background: rgba(255,255,255,0.3); }
.btn-ghost.small { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost.small:hover { background: var(--border); }

/* ============================================================
   Search panel
   ============================================================ */
.search-panel { margin-bottom: 22px; }
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.98rem;
  color: var(--text-primary);
  padding: 12px 4px;
  min-width: 0;
}
.search-input::placeholder { color: var(--text-muted); }
.search-btn { flex-shrink: 0; }

.error-banner {
  margin-top: 12px;
  background: #fdeceb;
  color: #9c2b22;
  border: 1px solid #f4c2bd;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
[data-theme="dark"] .error-banner { background: #3a1a17; color: #f4a49c; border-color: #5c2a24; }

/* ============================================================
   Loading state
   ============================================================ */
.loading-state {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 70px 20px;
  color: var(--text-muted);
}
.loading-state[hidden] {
  display: none;
}
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent-warm);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 90px 20px;
  color: var(--text-muted);
}
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--sky-500);
  margin-bottom: 18px;
}
.empty-state h2 { font-size: 1.2rem; margin-bottom: 6px; color: var(--text-primary); }

/* ============================================================
   Current weather card (hero)
   ============================================================ */
.current-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 28px;
}
.current-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.current-location h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.current-location p { margin-top: 4px; font-size: 0.85rem; color: var(--text-muted); }

.current-icon-wrap { text-align: center; flex-shrink: 0; }
.weather-icon { width: 72px; height: 72px; display: block; margin: 0 auto; }
.condition-label { font-size: 0.85rem; color: var(--text-muted); margin-top: -6px; text-transform: capitalize; }

.current-temp-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 18px 0 24px;
}
.current-temp {
  font-family: var(--font-display);
  font-size: 4.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.feels-like { color: var(--text-muted); font-size: 0.95rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-chip {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-value { font-size: 1.02rem; font-weight: 600; }

.current-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============================================================
   Forecast sections
   ============================================================ */
.forecast-section { margin-bottom: 28px; }
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.hourly-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.hour-card {
  flex: 0 0 auto;
  min-width: 92px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.hour-card:hover { transform: translateY(-3px); }
.hour-time { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.hour-card img { width: 42px; height: 42px; margin: 4px auto; display: block; }
.hour-temp { font-weight: 700; font-size: 1rem; }
.hour-desc { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; margin-top: 2px; }

.daily-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.day-card:hover { transform: translateY(-3px); }
.day-name { font-weight: 700; font-size: 0.88rem; }
.day-card img { width: 46px; height: 46px; margin: 6px auto; display: block; }
.day-desc { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; min-height: 26px; }
.day-temps { font-family: var(--font-mono); font-size: 0.85rem; margin-top: 6px; }
.day-max { font-weight: 600; }
.day-min { color: var(--text-muted); }

/* ============================================================
   Recent searches
   ============================================================ */
.recent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.recent-chip:hover { background: var(--surface-2); border-color: var(--sky-500); }

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  text-align: center;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .daily-grid { grid-template-columns: repeat(3, 1fr); }
  .current-temp { font-size: 3.4rem; }
}

@media (max-width: 560px) {
  .app { padding: 14px 14px 48px; }
  .app-header { padding-top: 4px; }
  .brand-name { font-size: 1.1rem; }
  .header-actions { width: 100%; justify-content: space-between; }
  .btn-ghost span, .btn-primary span { display: inline; }
  .search-form { padding-left: 14px; }
  .search-input { padding: 11px 2px; font-size: 0.92rem; }
  .search-btn { padding: 10px 14px; }
  .current-card { padding: 20px; }
  .current-top { flex-wrap: wrap; }
  .current-temp { font-size: 3rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .daily-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .day-card { padding: 12px 6px; }
  .day-desc { display: none; }
  .current-footer { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
  .daily-grid { grid-template-columns: repeat(2, 1fr); }
}