:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --glass: rgba(7, 15, 34, 0.58);
  --text: #f8fbff;
  --muted: #bad0ea;
  --accent: #93d5ff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  color: var(--text);
  background: linear-gradient(160deg, #0f2147 0%, #183f78 46%, #f7a15d 100%);
  transition: background 700ms ease;
}

body[data-weather="clear"] { background: linear-gradient(155deg, #2f84df 0%, #72c6ff 58%, #ffd077 100%); }
body[data-weather="clouds"] { background: linear-gradient(155deg, #64748b 0%, #91a6c2 55%, #d7e3f3 100%); }
body[data-weather="rain"] { background: linear-gradient(155deg, #14243f 0%, #28496d 58%, #657b9b 100%); }
body[data-weather="storm"] { background: linear-gradient(155deg, #080b16 0%, #1f2540 55%, #3e4668 100%); }
body[data-weather="snow"] { background: linear-gradient(155deg, #9cc8df 0%, #d8eef7 58%, #ffffff 100%); }
body[data-weather="fog"] { background: linear-gradient(155deg, #64748b 0%, #b6c0ca 58%, #eef2f5 100%); }
body[data-weather="night"] { background: radial-gradient(circle at top, #233d69 0%, #081226 65%, #050814 100%); }

/* ── Animated sky background ─────────────────────────────── */

.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.sun, .moon {
  position: absolute;
  width: 15rem;
  height: 15rem;
  border-radius: 999px;
  top: 9vh;
  right: 12vw;
  transition: opacity 600ms ease, transform 600ms ease;
}

.sun {
  opacity: 0;
  background: radial-gradient(circle, #fff8ba 0 22%, #ffd166 50%, rgba(255, 209, 102, 0) 72%);
  box-shadow: 0 0 5rem 1rem rgba(255, 209, 102, 0.48);
  animation: pulse 5s ease-in-out infinite;
}

.moon {
  opacity: 0;
  background: radial-gradient(circle at 35% 35%, #f8fbff 0 42%, #b9c4d6 76%);
  box-shadow: 0 0 3.5rem rgba(208, 226, 255, 0.35);
}

.stars {
  opacity: 0;
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.9) 0 1px, transparent 1.7px),
    radial-gradient(circle, rgba(255,255,255,.7) 0 1px, transparent 1.5px);
  background-size: 120px 120px, 180px 180px;
  animation: drift 40s linear infinite;
}

.cloud {
  position: absolute;
  width: 18rem;
  height: 6rem;
  border-radius: 999px;
  background: rgba(255,255,255,.62);
  filter: blur(.5px);
  opacity: .25;
  animation: float 24s linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.cloud::before { width: 8rem; height: 8rem; left: 3rem; top: -3.4rem; }
.cloud::after { width: 10rem; height: 10rem; right: 2.5rem; top: -4.8rem; }
.cloud-a { top: 16vh; left: -22rem; animation-duration: 30s; }
.cloud-b { top: 37vh; left: -28rem; animation-duration: 42s; animation-delay: -10s; transform: scale(1.35); }
.cloud-c { top: 69vh; left: -18rem; animation-duration: 36s; animation-delay: -19s; transform: scale(.8); }

.rain, .snow, .fog, .lightning {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 600ms ease;
}

.rain {
  background-image: linear-gradient(160deg, rgba(180,220,255,.65) 0 2px, transparent 2px 18px);
  background-size: 28px 28px;
  animation: rain 450ms linear infinite;
}

.snow {
  background-image:
    radial-gradient(circle, rgba(255,255,255,.95) 0 2px, transparent 2.5px),
    radial-gradient(circle, rgba(255,255,255,.75) 0 1.5px, transparent 2px);
  background-size: 70px 70px, 110px 110px;
  animation: snow 9s linear infinite;
}

.fog {
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.11) 0 26px, transparent 26px 70px);
  filter: blur(9px);
  animation: fog 12s ease-in-out infinite alternate;
}

.lightning { background: rgba(255,255,255,.0); animation: flash 4s steps(1,end) infinite; }

/* ── Card layout ─────────────────────────────────────────── */

.card {
  position: relative;
  z-index: 2;
  width: min(940px, calc(100vw - 2rem));
  padding: clamp(1.2rem, 3vw, 2.4rem);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 2rem;
  background: var(--glass);
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  backdrop-filter: blur(24px) saturate(125%);
}

.eyebrow { text-transform: uppercase; letter-spacing: .25em; color: var(--accent); font-size: .78rem; }
h1 { margin: .2rem 0; font-size: clamp(2.2rem, 8vw, 5.5rem); line-height: .9; }
.summary { color: var(--muted); font-size: clamp(1rem, 2vw, 1.25rem); }

.current {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr;
  gap: 1.2rem;
  align-items: center;
  margin: 2rem 0;
}
.temp { font-size: clamp(5rem, 18vw, 10rem); font-weight: 800; letter-spacing: -.08em; }
.unit { font-size: 2rem; color: var(--accent); }
.details { color: var(--muted); font-size: 1.1rem; }
.details p { margin: .35rem 0; }
.details strong { color: var(--text); font-size: 1.8rem; }

.forecast h2, .search label { font-size: .95rem; text-transform: uppercase; letter-spacing: .16em; color: var(--accent); }
.forecast-grid { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: .8rem; }
.day {
  padding: 1rem;
  min-height: 118px;
  border-radius: 1.2rem;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.15);
}
.day .name { color: var(--muted); }
.day .hi { font-size: 1.7rem; font-weight: 800; }
.day .lo { color: var(--muted); }

/* ── Hourly forecast ─────────────────────────────────────── */

.hourly-section {
  margin-top: 1.6rem;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(255,255,255,.12);
}
.hourly-section h2 { margin-bottom: 1rem; }
.hourly-container { overflow: visible; }

.hourly-day-group { margin-bottom: 1.2rem; }
.hourly-day-label {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--accent);
  margin-bottom: .5rem;
  padding-left: .3rem;
}

.hourly-scroll {
  display: flex;
  gap: .6rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: .6rem 0 .6rem .3rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.hourly-scroll::-webkit-scrollbar { height: 6px; }
.hourly-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,.05); border-radius: 3px; }
.hourly-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 3px; }

.hour {
  flex: 0 0 auto;
  width: 72px;
  padding: .7rem .4rem;
  text-align: center;
  border-radius: .9rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  transition: background 200ms ease, transform 200ms ease;
  cursor: default;
  font-size: .82rem;
}
.hour:hover { background: rgba(255,255,255,.18); transform: translateY(-2px); }
.hour-time { color: var(--muted); font-size: .75rem; margin-bottom: .3rem; }
.hour-temp { font-size: 1.3rem; font-weight: 800; margin-bottom: .25rem; }
.hour-icon { font-size: 1.6rem; margin-bottom: .2rem; }
.hour-rh { color: var(--muted); font-size: .7rem; }
.hour-wind { color: var(--muted); font-size: .7rem; }

/* ── Search ──────────────────────────────────────────────── */

.search { margin-top: 2rem; }
.search div { display: flex; gap: .7rem; margin-top: .6rem; }
input, button {
  border: 0;
  border-radius: 999px;
  padding: .9rem 1rem;
  font: inherit;
}
input { flex: 1; color: #081226; }
button { cursor: pointer; color: #081226; background: #93d5ff; font-weight: 800; }
#status { min-height: 1.2rem; color: var(--muted); }

/* ── Weather theme toggles ───────────────────────────────── */

body[data-weather="clear"] .sun { opacity: 1; }
body[data-weather="night"] .moon, body[data-weather="night"] .stars { opacity: 1; }
body[data-weather="clouds"] .cloud, body[data-weather="rain"] .cloud, body[data-weather="storm"] .cloud, body[data-weather="snow"] .cloud, body[data-weather="fog"] .cloud { opacity: .78; }
body[data-weather="rain"] .rain, body[data-weather="storm"] .rain { opacity: .85; }
body[data-weather="storm"] .lightning { opacity: 1; }
body[data-weather="snow"] .snow { opacity: .9; }
body[data-weather="fog"] .fog { opacity: .9; }

/* ── Animations ──────────────────────────────────────────── */

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes float { from { translate: -20vw 0; } to { translate: 140vw 0; } }
@keyframes rain { from { background-position: 0 0; } to { background-position: -28px 28px; } }
@keyframes snow { from { background-position: 0 -100px, 30px -40px; } to { background-position: 70px 100vh, 110px 100vh; } }
@keyframes fog { from { transform: translateX(-5vw); } to { transform: translateX(5vw); } }
@keyframes drift { to { background-position: 260px 180px, 180px 260px; } }
@keyframes flash { 0%, 89%, 100% { background: rgba(255,255,255,0); } 90%, 92% { background: rgba(255,255,255,.55); } 94% { background: rgba(255,255,255,.22); } }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 720px) {
  body { place-items: start center; padding: 1rem 0; }
  .current { grid-template-columns: 1fr; }
  .forecast-grid { grid-template-columns: repeat(2, 1fr); }
  .search div { flex-direction: column; }
}
@media (max-width: 480px) {
  .hour { width: 62px; padding: .6rem .3rem; font-size: .78rem; }
  .hour-temp { font-size: 1.1rem; }
  .hour-icon { font-size: 1.3rem; }
  .hourly-scroll { gap: .4rem; }
  .hourly-day-label { font-size: .78rem; }
}
