/* =========================================
   TYPED PROPERTIES (lets the background colors animate between themes)
   ========================================= */
@property --bg1 { syntax: '<color>'; inherits: true; initial-value: #020617; }
@property --bg2 { syntax: '<color>'; inherits: true; initial-value: #0f172a; }
@property --bg3 { syntax: '<color>'; inherits: true; initial-value: #1e1b4b; }
@property --bg4 { syntax: '<color>'; inherits: true; initial-value: #000000; }

/* =========================================
   BASE & VARIABLES
   ========================================= */
:root {
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --danger: #f87171;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --gutter: 40px;
  --side-col: 420px;
  --gap: 30px;
  --hpad: 20px;
  color-scheme: dark;

  /* Default theme: clear night */
  --bg1: #020617; --bg2: #0f172a; --bg3: #1e1b4b; --bg4: #000000;
  --blob1: #3b82f6; --blob2: #6366f1; --blob3: #8b5cf6;
}

/* Weather-reactive themes */
body[data-theme="clear-day"]   { --bg1:#0b1d3a; --bg2:#12386b; --bg3:#1d4f91; --bg4:#0a1a33; --blob1:#3b82f6; --blob2:#0ea5e9; --blob3:#f59e0b; }
body[data-theme="clear-night"] { --bg1:#020617; --bg2:#0f172a; --bg3:#1e1b4b; --bg4:#000000; --blob1:#3b82f6; --blob2:#6366f1; --blob3:#8b5cf6; }
body[data-theme="cloudy-day"]  { --bg1:#111827; --bg2:#1f2937; --bg3:#334155; --bg4:#0f172a; --blob1:#64748b; --blob2:#475569; --blob3:#3b82f6; }
body[data-theme="cloudy-night"]{ --bg1:#030712; --bg2:#0f172a; --bg3:#1e293b; --bg4:#000000; --blob1:#334155; --blob2:#475569; --blob3:#4f46e5; }
body[data-theme="rain"]        { --bg1:#0b1220; --bg2:#13233a; --bg3:#1e3a5f; --bg4:#060b14; --blob1:#2563eb; --blob2:#0e7490; --blob3:#475569; }
body[data-theme="snow"]        { --bg1:#1b2a41; --bg2:#2a3f5f; --bg3:#3d5a80; --bg4:#16233a; --blob1:#93c5fd; --blob2:#bfdbfe; --blob3:#60a5fa; }
body[data-theme="storm"]       { --bg1:#0a0a14; --bg2:#1a1a2e; --bg3:#2d1b4e; --bg4:#000000; --blob1:#4c1d95; --blob2:#1d4ed8; --blob3:#6d28d9; }
body[data-theme="fog"]         { --bg1:#1e2430; --bg2:#2c3441; --bg3:#3c4656; --bg4:#161b24; --blob1:#94a3b8; --blob2:#64748b; --blob3:#78716c; }

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
button,
input {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text-main);
  overflow-x: hidden;
  background-color: #020617;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =========================================
   LIVE LIQUID BACKGROUND
   ========================================= */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(-45deg, var(--bg1), var(--bg2), var(--bg3), var(--bg4));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  transition: --bg1 1.6s var(--ease), --bg2 1.6s var(--ease), --bg3 1.6s var(--ease), --bg4 1.6s var(--ease);
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -1;
  opacity: 0.5;
  animation: float 12s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
  will-change: transform;
  transition: background-color 1.6s var(--ease);
}
.blob-1 { top: 5%; left: 5%; width: 400px; height: 400px; background-color: var(--blob1); }
.blob-2 { bottom: 5%; right: 10%; width: 500px; height: 500px; background-color: var(--blob2); animation-delay: -4s; }
.blob-3 { top: 40%; left: 40%; width: 300px; height: 300px; background-color: var(--blob3); animation-delay: -8s; }

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 50px) scale(1.1); }
}

/* =========================================
   GLASS (with thin inner highlight)
   ========================================= */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: none;
  border-radius: 28px;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* =========================================
   NAVBAR
   ========================================= */
.navbar {
  position: absolute;
  top: 30px;
  left: calc(50% - min(600px, 50%) + var(--gutter));
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  height: 48px;
}

.brand {
  font-size: 1.5rem;
  line-height: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(to right, #ffffff, #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 0.8rem;
  line-height: 16px;
  color: var(--text-muted);
}

/* =========================================
   SEARCH BAR
   Resting edge lines up with the dashboard's right edge at any width.
   ========================================= */
.search-wrapper {
  position: absolute;
  top: 30px;
  left: calc(50% + min(600px, 50%) - var(--gutter) - 320px);
  width: 320px;
  height: 48px;
  z-index: 100;
  transition:
    top 0.6s var(--ease),
    left 0.6s var(--ease),
    width 0.6s var(--ease),
    height 0.6s var(--ease);
}

.search-wrapper.active {
  top: 30vh;
  left: calc(50% - 300px);
  width: 600px;
  height: 64px;
}

.search-box {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 32px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.search-wrapper.active .search-box {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.2), 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.search-box svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.3s var(--ease), width 0.3s var(--ease), height 0.3s var(--ease);
}
.search-wrapper.active .search-box svg { color: #fff; width: 24px; height: 24px; }

.search-box input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  margin-left: 12px;
  transition: font-size 0.3s var(--ease);
}
.search-wrapper.active .search-box input { font-size: 1.25rem; }
.search-box input::placeholder { color: var(--text-muted); }

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  width: 100%;
  max-height: 360px;
  overflow-y: auto;
  border-radius: 20px;
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease), visibility 0.4s;
}

.search-wrapper.active .dropdown.has-data {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0.1s;
}

.dropdown-item {
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.dropdown-item:hover,
.dropdown-item.is-active { background: rgba(255, 255, 255, 0.1); }

.dropdown-city,
.dropdown-country {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dropdown-city { font-weight: 500; font-size: 1.05rem; }
.dropdown-country { font-size: 0.85rem; color: var(--text-muted); text-align: right; }

.dropdown-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.dropdown-empty svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); }

/* Focus overlay */
.focus-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.focus-overlay.active { opacity: 1; pointer-events: auto; }

/* =========================================
   DASHBOARD GRID
   ========================================= */
.dashboard {
  width: 100%;
  flex: 1 0 auto;
  padding: 108px var(--gutter) var(--gap);
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-col);
  grid-template-areas:
    "toolbar    toolbar"
    "now        forecast"
    "conditions forecast"
    "hourly     hourly";
  gap: var(--gap);
  align-items: stretch;
  align-content: start;
}

.toolbar      { grid-area: toolbar; }
.block-now    { grid-area: now; }
.block-conditions { grid-area: conditions; }
.block-forecast   { grid-area: forecast; }
.block-hourly { grid-area: hourly; }
/* Error state hides everything except toolbar + the state card */
.dashboard.has-error {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "toolbar"
    "state";
}
.dashboard.has-error > .block { display: none; }
.dashboard.has-error > .state-card { grid-area: state; }

/* Each section: label on top, glass card fills the rest */
.block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  scroll-margin-top: 24px;
}
.block > .glass,
.block > .metrics-grid { flex: 1; }

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 32px;
  padding: 0 4px;
}
.section-head h2 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: -0.14em; /* cancel trailing letter-spacing */
}
.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s var(--ease);
}
.mini-btn[hidden] { display: none; }
.mini-btn:hover { background: rgba(255, 255, 255, 0.16); }
.mini-btn svg { width: 13px; height: 13px; color: var(--accent); }

.swap { animation: rise 0.35s var(--ease) backwards; }

.section-head .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
}

/* =========================================
   TOOLBAR
   ========================================= */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  min-height: 40px;
}

.status { font-size: 0.9rem; color: var(--text-muted); }
.status.is-error { color: var(--danger); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.pill-btn:hover { background: rgba(255, 255, 255, 0.18); transform: translateY(-1px); }
.pill-btn:active { transform: scale(0.97); }
.pill-btn svg { width: 16px; height: 16px; color: var(--accent); transition: transform 0.4s var(--ease); }
.pill-btn.icon-only { width: 40px; padding: 0; justify-content: center; }
.pill-btn.icon-only:hover svg { transform: rotate(90deg); }
.pill-btn.primary { background: var(--accent); color: #020617; font-weight: 600; }
.pill-btn.primary:hover { background: #93c5fd; }
.pill-btn.primary svg { color: #020617; }
.pill-btn.spinning svg { animation: spin 1s linear infinite; }

.unit-toggle {
  display: flex;
  height: 40px;
  padding: 4px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}
.unit-btn {
  padding: 0 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.unit-btn:hover { color: #fff; }
.unit-btn.active { background: #fff; color: #020617; }

/* =========================================
   CURRENT WEATHER CARD
   ========================================= */
.current-card {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: 300px;
  position: relative;
  overflow: hidden;
}

.current-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.weather-icon-wrap { display: flex; }
.weather-icon-large {
  width: 72px;
  height: 72px;
  stroke-width: 1.5;
  color: #fff;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.4));
}

.city-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
  max-width: 65%;
}

.card-city {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
}
.card-city span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-city svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

.local-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.local-time svg { width: 14px; height: 14px; }
.local-time span { display: inline-block; }

.current-body { display: flex; flex-direction: column; align-items: flex-start; }

.temp-main {
  font-size: 6rem;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -4px;
}

.condition-text {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.chip b { color: var(--text-main); font-weight: 600; }

.summary {
  margin-top: 16px;
  max-width: 44ch;
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 3em; /* always 2 lines so the card never changes height */
  text-wrap: pretty;
  color: #cbd5e1;
}

/* =========================================
   METRICS (6 cards, each with a gauge)
   ========================================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 16px;
}

.metric-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}
.metric-card:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.07); }

.metric-top { display: flex; align-items: center; gap: 8px; }
.metric-icon { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.25;
  white-space: nowrap;
}

.gauge {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.gauge span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.55), var(--accent));
  transition: width 0.9s var(--ease);
}

.metric-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  font-size: 0.8rem;
  line-height: 18px;
  color: var(--text-muted);
}
.wind-arrow {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--accent);
  transition: transform 0.6s var(--ease);
}
.wind-arrow svg { width: 100%; height: 100%; }

/* =========================================
   7-DAY FORECAST
   ========================================= */
.forecast-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.forecast-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forecast-item {
  flex: 1;
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-radius: 20px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: background 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.forecast-item:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.forecast-item:active { background: rgba(255, 255, 255, 0.09); }
.forecast-item.is-selected,
.forecast-item.is-selected:hover {
  background: rgba(96, 165, 250, 0.14);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.28);
}

.f-day { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.f-name { font-weight: 600; font-size: 0.95rem; }
.f-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f-mid { display: flex; align-items: center; gap: 8px; }
.f-icon { width: 20px; height: 20px; flex-shrink: 0; color: #fff; }
.f-pop { width: 34px; font-size: 0.72rem; font-weight: 600; color: var(--accent); }
.f-temps {
  justify-self: end;
  white-space: nowrap;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.f-temps b { color: var(--text-main); font-weight: 600; }

/* =========================================
   HOURLY STRIP
   ========================================= */
.hourly-card { padding: 0; overflow: hidden; }

.hourly-scroll {
  padding: 20px 0;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--hpad);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  cursor: grab;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--hpad), #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--hpad), #000 calc(100% - 40px), transparent);
}
.hourly-scroll::-webkit-scrollbar { display: none; }
.hourly-scroll.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }

.hourly-list {
  display: flex;
  gap: 10px;
  width: max-content;
  padding: 0 40px 0 var(--hpad);
}

.hour-item {
  flex: 0 0 auto;
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  scroll-snap-align: start;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.hour-item:hover { background: rgba(255, 255, 255, 0.09); transform: translateY(-3px); }
.hour-item.is-now { background: rgba(96, 165, 250, 0.16); }

.h-time { font-size: 0.78rem; line-height: 16px; color: var(--text-muted); font-weight: 500; }
.hour-item.is-now .h-time { color: var(--accent); font-weight: 600; }
.h-icon { width: 24px; height: 24px; color: #fff; }
.h-temp { font-size: 1.05rem; line-height: 22px; font-weight: 700; }
.h-pop { min-height: 14px; line-height: 14px; font-size: 0.72rem; font-weight: 600; color: var(--accent); }

.scroll-btns { display: flex; gap: 6px; }
.scroll-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s var(--ease);
}
.scroll-btn:hover { background: rgba(255, 255, 255, 0.18); }
.scroll-btn svg { width: 16px; height: 16px; }
@media (hover: none) { .scroll-btns { display: none; } }

/* =========================================
   STAGGERED ENTRANCE
   ========================================= */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim {
  animation: rise 0.5s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* =========================================
   SKELETON LOADING
   ========================================= */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel,
.is-loading [data-skel] {
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 10px;
}
.skel { display: block; }

.is-loading [data-skel] {
  color: transparent !important;
  user-select: none;
}
.is-loading [data-skel] * { visibility: hidden; }

/* Give skeleton blocks a believable size */
.is-loading .temp-main[data-skel]      { min-width: 8.5rem; border-radius: 18px; }
.is-loading .condition-text[data-skel] { min-width: 9rem; }
.is-loading .summary[data-skel]        { width: min(44ch, 100%); min-height: 3em; }
.is-loading .metric-value[data-skel]   { min-width: 5.5rem; }
.is-loading .metric-sub[data-skel]     { min-width: 6rem; }
.is-loading .local-time [data-skel]    { min-width: 9rem; }
.is-loading .weather-icon-large        { opacity: 0.25; }
.is-loading .gauge span                { width: 0 !important; }
.is-loading .metric-value[data-skel],
.is-loading .metric-sub[data-skel]     { align-self: flex-start; }
.is-loading .hour-item,
.is-loading .forecast-item             { pointer-events: none; }

/* =========================================
   ERROR / EMPTY STATE
   ========================================= */
.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
}
.state-card[hidden] { display: none; }
.state-icon { width: 56px; height: 56px; color: var(--accent); stroke-width: 1.5; opacity: 0.9; margin-bottom: 4px; }
.state-card h3 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.5px; text-wrap: balance; }
.state-card p { max-width: 40ch; font-size: 0.95rem; line-height: 1.5; color: var(--text-muted); margin-bottom: 8px; }

/* =========================================
   FOOTER
   ========================================= */
.footer {
  width: 100%;
  flex-shrink: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter) 32px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer a { color: #cbd5e1; text-decoration: underline; text-underline-offset: 3px; }
.footer a:hover { color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   TABLET & BELOW (<=1024px)
   Desktop layout above is untouched.
   ========================================= */
@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "toolbar"
      "now"
      "hourly"
      "conditions"
      "forecast";
  }
  .forecast-item { min-height: 60px; }
}

/* =========================================
   NARROW DESKTOP (1025-1180px)
   Keeps the 3 metric columns from crowding.
   ========================================= */
@media (min-width: 1025px) and (max-width: 1180px) {
  :root { --side-col: 360px; }
  .metric-card { padding: 18px; }
  .metric-value { font-size: 1.3rem; }
}

/* =========================================
   MOBILE (<=768px)
   ========================================= */
@media (max-width: 768px) {
  :root {
    --gutter: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --gap: 20px;
    --hpad: 16px;
  }

  .navbar { top: calc(20px + env(safe-area-inset-top, 0px)); left: var(--gutter); }
  .brand { font-size: 1.35rem; }

  .search-wrapper {
    top: calc(84px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2 * var(--gutter));
    height: 52px;
  }
  .search-wrapper.active {
    top: calc(12vh + env(safe-area-inset-top, 0px));
    left: 50%;
    width: calc(100% - 24px);
    height: 60px;
  }

  .dropdown { max-height: min(360px, 50vh); }
  .dropdown-item { padding: 14px 18px; }

  .dashboard { padding-top: calc(156px + env(safe-area-inset-top, 0px)); }

  .toolbar { gap: 12px; }
  .toolbar-actions { width: 100%; margin-left: 0; gap: 8px; }
  .pill-btn { height: 44px; padding: 0 14px; border-radius: 22px; }
  .pill-btn.icon-only { width: 44px; padding: 0; }
  #locateBtn { flex: 1; justify-content: center; min-width: 0; }
  .unit-toggle { height: 44px; border-radius: 22px; }
  .unit-btn { min-width: 44px; border-radius: 18px; }

  .current-card { padding: 24px; min-height: 0; gap: 22px; }
  .weather-icon-large { width: 60px; height: 60px; }
  .temp-main { font-size: 4.75rem; letter-spacing: -3px; }
  .condition-text { font-size: 1.1rem; }
  .city-block { max-width: 60%; }

  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .metric-card { padding: 16px; gap: 8px; }
  .metric-value { font-size: 1.25rem; }

  .forecast-card { padding: 10px; }
  .forecast-item { gap: 8px; padding: 0 18px; border-radius: 20px; }
  .mini-btn { height: 32px; }

  .hourly-scroll { padding: 16px 0; }
  .hour-item { width: 68px; padding: 14px 6px; }

  .state-card { padding: 40px 20px; }

  .footer { flex-direction: column; align-items: center; text-align: center; padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }

  .blob { filter: blur(60px); }
  .blob-2 { width: 300px; height: 300px; }
  .blob-3 { width: 220px; height: 220px; }
}

/* Larger phones / small tablets: 3 metric columns fit */
@media (min-width: 560px) and (max-width: 768px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Touch devices: no sticky hover states after a tap */
@media (hover: none) {
  .pill-btn:hover { background: rgba(255, 255, 255, 0.1); transform: none; }
  .pill-btn.primary:hover { background: var(--accent); }
  .pill-btn.icon-only:hover svg { transform: none; }
  .scroll-btn:hover { background: rgba(255, 255, 255, 0.08); }
  .metric-card:hover { transform: none; background: var(--glass-bg); }
  .hour-item:not(.is-now):hover { background: rgba(255, 255, 255, 0.04); transform: none; }
  .forecast-item:not(.is-selected):hover { background: transparent; box-shadow: none; }
}

/* Very small phones */
@media (max-width: 380px) {
  .brand { font-size: 1.2rem; }
  .temp-main { font-size: 4rem; }
  .current-card { padding: 20px; }
  .metric-value { font-size: 1.1rem; }
  .forecast-item { gap: 6px; padding: 0 14px; }
  .f-mid { gap: 6px; }
  .f-pop { width: 32px; }
  .pill-btn { padding: 0 12px; gap: 6px; }
  .unit-btn { min-width: 40px; padding: 0 10px; }
  .f-name { font-size: 0.88rem; }
  .f-temps { font-size: 0.88rem; }
}

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