:root {
  --bg-day: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  --bg-night: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  --bg-sunrise: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #4286f4 100%);
  --bg-sunset: linear-gradient(135deg, #2c3e50 0%, #fd746c 50%, #ff9068 100%);
  --card-bg: rgba(0, 0, 0, 0.28);
  --card-border: rgba(255, 255, 255, 0.08);
  --stat-bg: rgba(255, 255, 255, 0.07);
  --text: #f5f5f5;
  --text-dim: rgba(245, 245, 245, 0.7);
  --text-faint: rgba(245, 245, 245, 0.5);
  --accent: #ffb347;
  --error: #ff6b6b;
  /* Weather-condition palette — applied to icons by adding wx-* classes
     based on the OWM icon code. Keeps the orange "sunny" reading reserved
     for actual clear/sunny conditions. */
  --wx-sunny:  #ffb347;
  --wx-partly: #f0d49a;
  --wx-cloudy: #cfd6dc;
  --wx-rainy:  #5fb1ff;
  --wx-storm:  #c0a8ff;
  --wx-snow:   #e8f4ff;
  --wx-mist:   #aab0b8;
}

body {
  background: var(--bg-night);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  min-height: 100vh;
  transition: background 1s ease;
}
body.daytime { background: var(--bg-day); }
body.night   { background: var(--bg-night); }
body.sunrise { background: var(--bg-sunrise); }
body.sunset  { background: var(--bg-sunset); }

.weather-page {
  min-height: calc(100vh - 80px);
  padding: 0.4rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.weather-shell {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Header (utility row, kept compact and unobtrusive) ── */
.weather-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.location-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-dim);
}
.location-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 1px;
}

.search-block {
  position: relative;
  width: 220px;
  max-width: 100%;
}
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-faint);
  font-size: 0.78rem;
  pointer-events: none;
}
#locationSearch {
  width: 100%;
  padding: 0.4rem 2rem 0.4rem 1.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#locationSearch:focus {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}
#locationSearch::placeholder { color: var(--text-faint); }
.search-clear {
  position: absolute;
  right: 8px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.3rem;
  display: none;
}
.search-clear.visible { display: block; }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(20, 20, 30, 0.96);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.search-result {
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.active { background: rgba(255, 255, 255, 0.08); }
.search-result-meta { color: var(--text-faint); font-size: 0.78rem; margin-top: 2px; }
.search-empty { padding: 0.75rem 0.9rem; color: var(--text-dim); font-size: 0.88rem; }

/* ── Now hero (focal point) ── */
.now-hero {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 0.7rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Center alignment so each item's visual middle lines up. Each "block" is
   a single line of content (date is inline with time; feels is inline with
   conditions), so heights are uniform and there's no offset from one item
   having a hidden caption beneath it. */
.hero-readout {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* Time + small date inline next to each other, both baseline-aligned within
   the block — keeps the block height = time height so it center-aligns
   cleanly with the temp. */
.hero-time-block {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  flex: 0 0 auto;
}
.hero-time {
  font-size: 3.4rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.hero-date {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Prominent vertical divider between time and temp. */
.hero-divider {
  flex: 0 0 auto;
  width: 3px;
  height: 2.6rem;
  border-radius: 2px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 179, 71, 0.55) 25%,
    rgba(255, 179, 71, 0.55) 75%,
    rgba(255, 255, 255, 0) 100%
  );
}

.hero-temp {
  font-size: 3.4rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.hero-icon {
  font-size: 2.6rem;
  line-height: 1;
  flex: 0 0 auto;
  color: var(--wx-cloudy);
}

/* Conditions + feels inline (separated by middle-dot) so the whole text
   block is a single line. Center-aligned with the rest of the row, sits in
   the visual middle of the row instead of floating at the baseline. */
.hero-text {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1;
}
.hero-conditions {
  font-size: 1.05rem;
  font-weight: 400;
  text-transform: capitalize;
  color: var(--text);
}
.hero-feels {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.hero-feels::before {
  content: '· ';
}

/* Weather-condition icon palette — applied to .fas icons by JS based on
   the OWM icon code (01* clear, 02* partly, 03/04 cloudy, 09/10 rain,
   11 thunder, 13 snow, 50 mist). */
.wx-sunny  { color: var(--wx-sunny); }
.wx-partly { color: var(--wx-partly); }
.wx-cloudy { color: var(--wx-cloudy); }
.wx-rainy  { color: var(--wx-rainy); }
.wx-storm  { color: var(--wx-storm); }
.wx-snow   { color: var(--wx-snow); }
.wx-mist   { color: var(--wx-mist); }

/* ── Today (combined current + hourly) ── */
.today-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 0.5rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.current-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}
.stat {
  background: var(--stat-bg);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}
.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.wind-arrow {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  transform-origin: center;
  transition: transform 0.5s ease;
  filter: drop-shadow(0 0 2px rgba(255, 179, 71, 0.5));
}
.wind-dir,
.dew-tag {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 400;
}

/* ── Forecast ── */
.forecast-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 0.5rem 1.25rem;
}
.section-title {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.section-note {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-weight: 300;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}
.section-head .section-title { margin-bottom: 0; }
.sun-arc-status {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 300;
}

.hourly-scroll {
  overflow: hidden;
  padding: 0;
}

.day-canvas {
  position: relative;
  width: 100%;
  padding-top: 0.25rem;
  z-index: 0;
  --hour-card-width: 88px;
}

/* Inset coordinate space shared by every time-positioned element (sun arc,
   sun events, axis ticks, hour cards, now-line, gridlines). Inset by half
   a card on each side so a card at the 0h or 24h position fits fully on
   screen, and so left:N% maps to the same wall-clock time everywhere. */
.day-grid {
  position: relative;
  margin: 0 calc(var(--hour-card-width) / 2);
}

/* Hour slots — each slot is one hour wide, centered on its integer hour,
   spanning the full vertical extent of the timeline (sun arc → axis → cards).
   Alternating tint shows the hour structure as columns rather than lines. */
.day-slots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.hour-slot {
  position: absolute;
  top: 0;
  bottom: 0;
}
/* Slot tints intentionally invisible — kept in DOM as a structural placeholder
   in case we want to bring them back. */
.hour-slot.hour-slot-alt,
.hour-slot.hour-slot-major { background: transparent; }

/* Sun arc — top section of the day canvas. SVG viewBox stays 0..1000 × 0..140
   (path math is unchanged) and stretches to fill this wrap; the JS positions
   sun-marker via percentage so it scales with the wrap height. */
.sun-arc-wrap {
  position: relative;
  width: 100%;
  height: 130px;
}
.sun-arc-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.horizon-line {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1;
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
}
.sun-arc-path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 1.5;
  stroke-dasharray: 3 6;
  vector-effect: non-scaling-stroke;
}
.sun-event {
  position: absolute;
  top: 76%;
  transform: translateX(-50%);
  font-size: 0.66rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.sun-marker {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  transition: left 0.7s ease, top 0.7s ease;
}
.sun-glow {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 233, 168, 0.95) 0%,
    rgba(255, 179, 71, 0.4) 55%,
    rgba(255, 179, 71, 0) 100%);
  left: -25px;
  top: -25px;
  transition: opacity 0.7s ease;
}
.sun-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffd166;
  left: -9px;
  top: -9px;
  transition: background 0.7s ease;
  box-shadow: 0 0 6px rgba(255, 209, 102, 0.6);
}
.sun-marker.is-night .sun-dot {
  background: #6b7a99;
  box-shadow: none;
}
.sun-marker.is-night .sun-glow { opacity: 0; }

/* Axis row hidden — hour labels live on the forecast cards themselves now. */
.day-axis { display: none; }
.hour-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: rgba(245, 245, 245, 0.35);
  text-align: center;
  white-space: nowrap;
}
.hour-marker.hour-marker-mid {
  color: rgba(245, 245, 245, 0.6);
  font-size: 0.6rem;
}
.hour-marker.hour-marker-major {
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 500;
}

/* NOW row — legacy slot above the sun arc, now empty (NOW card lives inline
   with the hourly track at its current-hour position). */
.now-row { display: none; }

/* Hourly cards — sparse (every 3h from OWM), positioned at their actual hour */
.hourly-track {
  position: relative;
  height: 105px;
  margin-top: 0.2rem;
}
.hour-card {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: var(--hour-card-width);
  background: rgba(0, 0, 0, 0.32);
  border-radius: 10px;
  padding: 0.4rem 0.3rem;
  text-align: center;
  transition: opacity 0.3s, background 0.2s;
  z-index: 2;
  line-height: 1.1;
}
.hour-card.is-past { opacity: 0.35; }
.hour-time { font-size: 0.78rem; color: var(--text-dim); font-weight: 500; }
.hour-icon { font-size: 1.2rem; margin: 0.15rem 0; }
.hour-temp { font-size: 1rem; font-weight: 500; }
.hour-precip {
  font-size: 0.72rem;
  color: var(--wx-rainy);
  margin-top: 2px;
  min-height: 0.9em;
}
.hour-wind {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
}
.hour-wind-arrow {
  display: inline-block;
  color: var(--accent);
  transform-origin: center;
  line-height: 0;
}

/* NOW indicator — spans the sun arc + axis only, stops above the hourly
   track so it never visually crosses an hour card. Current conditions live
   in the .now-hero focal section above; this is just the timeline anchor. */
.now-line {
  position: absolute;
  top: 0;
  bottom: 105px;
  width: 2px;
  background: rgba(255, 179, 71, 0.7);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
}
.now-line::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(255, 179, 71, 0.7);
}

.hourly-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1rem 0;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
}
.day-card {
  background: var(--stat-bg);
  border-radius: 8px;
  padding: 0.5rem 0.5rem;
  text-align: center;
}
.day-name { font-weight: 500; font-size: 0.85rem; }
.day-date { font-size: 0.68rem; color: var(--text-faint); margin-bottom: 0.2rem; }
.day-icon { font-size: 1.4rem; margin: 0.2rem 0; }
.day-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: capitalize;
  margin-bottom: 0.2rem;
  min-height: 1em;
}
.day-temps { display: flex; justify-content: center; gap: 0.4rem; align-items: baseline; }
.day-high { font-weight: 600; font-size: 0.95rem; }
.day-low { color: var(--text-dim); font-size: 0.82rem; }

/* ── Loading & error ── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-left-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-banner {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffd0d0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.weather-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-faint);
  padding-top: 0.2rem;
}

@media (max-width: 800px) {
  .weather-header {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .search-block { width: 100%; }
  .hero-readout { gap: 0.8rem; }
  .hero-time, .hero-temp { font-size: 2.6rem; }
  .hero-icon { font-size: 2.1rem; }
  .hero-conditions { font-size: 0.95rem; }
  .current-stats { grid-template-columns: repeat(2, 1fr); }
}
