:root {
  /* Sky gradient stops — driven by JS (time of day + condition) */
  --sky-1: #0a0e27;
  --sky-2: #16213e;
  --sky-3: #1a1a3a;

  /* Orb (sun / moon) */
  --sun-warm: rgba(255, 214, 150, 0.92);
  --orb-glow: rgba(255, 255, 255, 0.25);
  --orb-x: 78%;
  --orb-y: 22%;
  --orb-size: 130px;

  /* Clouds */
  --cloud-tint: rgba(255, 255, 255, 0.55);

  /* Foreground ink */
  --ink: rgba(255, 255, 255, 0.96);
  --ink-soft: rgba(255, 255, 255, 0.66);
  --ink-faint: rgba(255, 255, 255, 0.40);
  --ink-line: rgba(255, 255, 255, 0.14);

  /* Veil overlay (haze / overcast) */
  --veil-color: transparent;

  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
html, body { min-height: 100%; }

body {
  font-family: var(--font-mono);
  color: var(--ink);
  background: #0a0e27;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Atmospheric layers ---------- */

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 120%, transparent 40%, rgba(0,0,0,0.28) 100%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 52%, var(--sky-3) 100%);
  transition: background 2400ms var(--ease);
  z-index: 0;
}

.orb {
  position: fixed;
  left: var(--orb-x);
  top: var(--orb-y);
  width: var(--orb-size);
  height: var(--orb-size);
  transform: translate(-50%, -50%);
  transition: left 2400ms var(--ease), top 2400ms var(--ease),
    width 2400ms var(--ease), height 2400ms var(--ease),
    opacity 2400ms var(--ease);
  z-index: 1;
  opacity: 0.95;
  pointer-events: none;
}

/* Wide atmospheric bloom — a gradient layer, not box-shadow, so there is no
   hard silhouette edge */
.orb-glow {
  position: absolute;
  inset: -140%;
  background: radial-gradient(circle, var(--orb-glow) 0%, rgba(0, 0, 0, 0) 62%);
  transition: background 2400ms var(--ease);
}

.sun-layer, .moon-layer {
  position: absolute;
  inset: 0;
  transition: opacity 2400ms var(--ease);
}

.sun-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    #fffdf6 0%, #fff6dd 28%, var(--sun-warm) 50%,
    rgba(255, 190, 110, 0.18) 68%, rgba(255, 190, 110, 0) 78%);
  animation: sun-breathe 9s ease-in-out infinite;
}

.sun-rays {
  position: absolute;
  inset: -80%;
  border-radius: 50%;
  background: repeating-conic-gradient(
    rgba(255, 226, 164, 0.15) 0deg 7deg,
    rgba(255, 226, 164, 0) 7deg 26deg);
  -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,0) 15%, #000 31%, rgba(0,0,0,0) 67%);
  mask-image: radial-gradient(circle, rgba(0,0,0,0) 15%, #000 31%, rgba(0,0,0,0) 67%);
  animation: rays-spin 120s linear infinite;
}

@keyframes sun-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes rays-spin { to { transform: rotate(360deg); } }

.moon-layer svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 16px rgba(200, 215, 255, 0.35));
}

/* Drifting clouds */
.clouds {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2400ms var(--ease);
}
.cloud {
  position: absolute;
  background: radial-gradient(ellipse 50% 50% at 50% 55%, var(--cloud-tint) 0%, rgba(255, 255, 255, 0) 70%);
  filter: blur(14px);
  animation: cloud-drift linear infinite;
}
.cloud.c1 { top: 2%;  width: 58vw; height: 24vh; animation-duration: 240s; animation-delay: -20s; }
.cloud.c2 { top: 15%; width: 44vw; height: 18vh; animation-duration: 180s; animation-delay: -95s; }
.cloud.c3 { top: 29%; width: 64vw; height: 26vh; animation-duration: 300s; animation-delay: -160s; }
.cloud.c4 { top: 7%;  width: 36vw; height: 15vh; animation-duration: 150s; animation-delay: -55s; }
.cloud.c5 { top: 43%; width: 52vw; height: 20vh; animation-duration: 260s; animation-delay: -215s; }
.cloud.c6 { top: 57%; width: 70vw; height: 24vh; animation-duration: 330s; animation-delay: -120s; opacity: 0.7; }

@keyframes cloud-drift {
  from { transform: translateX(-85vw); }
  to   { transform: translateX(115vw); }
}

.particles {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.condition-veil {
  position: fixed;
  inset: 0;
  z-index: 3;
  background: var(--veil-color);
  transition: background 2400ms var(--ease);
  pointer-events: none;
}

/* Fine film grain for depth */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 7s steps(6) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -4%); }
  60%  { transform: translate(-2%, 3%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(130% 110% at 50% 42%, transparent 55%, rgba(0,0,0,0.42) 100%);
}

/* ---------- Foreground layout ---------- */

.screen {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  padding: clamp(1.6rem, 4vw, 3.4rem);
  gap: clamp(1rem, 2.4vh, 2rem);
}

/* Staggered entrance */
.topbar, .hero, .weather, .charts {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(8px);
  animation: rise 1100ms var(--ease) forwards;
}
.topbar  { animation-delay: 120ms; }
.hero    { animation-delay: 300ms; }
.weather { animation-delay: 560ms; }
.charts  { animation-delay: 760ms; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.location { display: flex; align-items: center; gap: 0.6em; font-weight: 400; }
.location .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-soft);
  box-shadow: 0 0 8px 1px var(--ink-faint);
}
.location.fallback .dot { background: #e8a74f; box-shadow: 0 0 8px 1px rgba(232,167,79,0.6); }

.precise-btn {
  margin-left: 0.4em;
  background: none;
  border: 1px solid var(--ink-line);
  border-radius: 2px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.35em 0.7em;
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.precise-btn:hover { color: var(--ink); border-color: var(--ink-soft); }

.world-clocks { display: flex; gap: 1.6rem; text-align: right; }
.wclock { display: flex; flex-direction: column; gap: 0.3em; align-items: flex-end; }
.wclock .wc-city { color: var(--ink-faint); font-size: 0.66rem; }
.wclock .wc-time { color: var(--ink); font-size: 0.92rem; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

/* Hero time */
.hero {
  align-self: center;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(5.5rem, 22vw, 17rem);
  line-height: 0.86;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-optical-sizing: auto;
  text-shadow: 0 0 60px var(--orb-glow), 0 2px 30px rgba(0, 0, 0, 0.35);
}

.date {
  margin-top: clamp(0.6rem, 1.6vh, 1.2rem);
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.1rem, 2.6vw, 1.9rem);
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

/* Weather */
.weather { display: flex; flex-direction: column; align-items: center; }

.weather-main {
  display: flex;
  align-items: center;
  gap: clamp(1.2rem, 3.6vw, 3rem);
  flex-wrap: wrap;
  justify-content: center;
}

.wx-icon { width: 56px; height: 56px; color: var(--ink); filter: drop-shadow(0 2px 12px rgba(0,0,0,0.3)); }
.wx-icon svg { width: 100%; height: 100%; }

.temp-block { display: flex; flex-direction: column; align-items: flex-start; }
.temp {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.temp-alt {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-top: 0.35em;
  display: flex;
  gap: 0.5em;
}
.temp-alt .sep { color: var(--ink-faint); }

.wx-meta { display: flex; flex-direction: column; gap: 0.55em; text-align: left; }
.condition {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 2.6vw, 1.55rem);
  color: var(--ink);
}
.hilo { display: flex; gap: 1.3em; font-size: 1.02rem; letter-spacing: 0.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
.hilo .hi, .hilo .lo { display: inline-flex; align-items: baseline; gap: 0.45em; }
.hilo .caret { font-size: 0.78em; }
.hilo .hi .caret { color: #f0a868; }
.hilo .lo .caret { color: #7fb2e8; }
.hilo .lbl { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em; color: var(--ink-faint); }

.uv {
  border-left: 1px solid var(--ink-line);
  padding-left: clamp(1.2rem, 3vw, 2.4rem);
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}
.uv-label { font-size: 0.64rem; letter-spacing: 0.22em; color: var(--ink-faint); }
.uv-value { display: flex; align-items: baseline; gap: 0.5em; }
.uv-value #uvValue { font-size: 1.8rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.uv-band {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.2em 0.6em;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  color: var(--ink);
}

.moon-stat-value { display: flex; align-items: center; gap: 0.6em; }
.moon-mini { width: 26px; height: 26px; flex: none; }
.moon-mini svg { width: 100%; height: 100%; }
.moon-name { font-size: 0.95rem; }
.moon-illum { background: rgba(190, 205, 240, 0.18); }

.wx-error {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

/* 24h timeline charts (UV + rain) */
.charts { display: flex; gap: clamp(1.5rem, 4vw, 3.2rem); }
.chart { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.64rem;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
}
.chart-legend { color: var(--ink-soft); }

.chart-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 3px;
  height: clamp(48px, 9vh, 84px);
  border-bottom: 1px solid var(--ink-line);
  padding-bottom: 1px;
}
.bar {
  position: relative;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transform-origin: bottom;
  transform: scaleY(0);
  animation: bar-grow 900ms var(--ease) forwards;
}
.bar.now { box-shadow: 0 0 12px rgba(255, 255, 255, 0.45); }
.bar.past { opacity: 0.38; }

/* Rain bars (blue) */
.rbar { background: linear-gradient(180deg, rgba(150, 200, 255, 0.95), rgba(120, 170, 235, 0.35)); }
.rbar.now { background: linear-gradient(180deg, #cfe6ff, rgba(170, 210, 255, 0.5)); box-shadow: 0 0 12px rgba(180, 215, 255, 0.5); }
.rbar.dry { background: rgba(255, 255, 255, 0.08); }
/* UV bars get their colour inline (band-based); muted when zero */
.uvbar.zero { background: rgba(255, 255, 255, 0.08) !important; }

@keyframes bar-grow { to { transform: scaleY(1); } }

.chart-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.chart-axis span { text-align: center; visibility: hidden; }
.chart-axis span.tick { visibility: visible; }
.chart-axis span.tick.now { color: var(--ink); font-weight: 500; }

@media (max-width: 760px) {
  /* Stack the charts; UV sits above rain */
  .charts { flex-direction: column; gap: 1.2rem; }
}

/* ---------- Scroll hint ---------- */

.scroll-hint {
  justify-self: center;
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  animation: hint-bob 2.6s ease-in-out infinite;
  transition: opacity 0.5s var(--ease);
}
.scroll-hint:hover { color: var(--ink-soft); }
.scroll-hint .chev { font-size: 1rem; line-height: 0.4; }
.scroll-hint.gone { opacity: 0; pointer-events: none; }

@keyframes hint-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ---------- 7-day forecast (glassmorphism) ---------- */

.forecast {
  position: relative;
  z-index: 10;
  padding: clamp(1.4rem, 4vh, 3rem) clamp(1.6rem, 4vw, 3.4rem) clamp(2.4rem, 6vh, 4rem);
}

.week-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.3rem, 3vw, 2rem);
  color: var(--ink);
  margin-bottom: clamp(0.9rem, 2vh, 1.4rem);
}

.week-panel {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.day-wrap { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.day-wrap:last-child { border-bottom: none; }

.day {
  display: grid;
  grid-template-columns: 1.1fr 46px 1.4fr 0.9fr 1.1fr 2.4fr 16px;
  align-items: center;
  gap: clamp(0.6rem, 1.6vw, 1.5rem);
  padding: clamp(0.7rem, 1.7vh, 1.1rem) clamp(1rem, 2.4vw, 1.9rem);
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.3s var(--ease);
}
.day:hover { background: rgba(255, 255, 255, 0.05); }
.day.today { background: rgba(255, 255, 255, 0.06); }

.d-chev {
  justify-self: end;
  color: var(--ink-faint);
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 0.4s var(--ease), color 0.4s var(--ease);
}
.day-wrap.open .d-chev { transform: rotate(90deg); color: var(--ink-soft); }

/* Expanding detail drawer */
.drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 500ms var(--ease);
}
.day-wrap.open .drawer { grid-template-rows: 1fr; }
.drawer-inner { overflow: hidden; min-height: 0; }

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.8em;
  padding: 0.9rem clamp(1rem, 2.4vw, 1.9rem) 0.1rem;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}
.drawer-meta b { color: var(--ink); font-weight: 500; letter-spacing: 0.08em; }

.drawer-charts {
  display: flex;
  gap: clamp(1.4rem, 3vw, 2.6rem);
  padding: 0.9rem clamp(1rem, 2.4vw, 1.9rem) 1.3rem;
}
.drawer-charts .chart-bars { height: 52px; }

.d-name { display: flex; flex-direction: column; gap: 0.15em; }
.d-day { font-size: 0.95rem; color: var(--ink); }
.day.today .d-day { font-family: var(--font-display); font-style: italic; }
.d-date { font-size: 0.62rem; letter-spacing: 0.12em; color: var(--ink-faint); }

.d-icon { width: 32px; height: 32px; color: var(--ink); opacity: 0.92; }
.d-icon svg { width: 100%; height: 100%; }

.d-cond { font-size: 0.82rem; color: var(--ink-soft); }

.d-rain { font-size: 0.82rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.d-rain .rdrop { color: #8fc0f0; margin-right: 0.35em; font-size: 0.7em; }
.d-rain .muted { color: var(--ink-faint); }

.d-uv { display: flex; align-items: center; gap: 0.55em; }
.uv-chip {
  min-width: 1.7em;
  text-align: center;
  padding: 0.18em 0.4em;
  border-radius: 3px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.d-uvlabel { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }

.d-range {
  display: grid;
  grid-template-columns: 2.6em 1fr 2.6em;
  align-items: center;
  gap: 0.7em;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.d-range .t-lo { text-align: right; color: var(--ink-soft); }
.d-range .t-hi { color: var(--ink); }
.range-track { position: relative; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.13); }
.range-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #7fb2e8, #e8c24a, #ef8a4b);
}

@media (max-width: 720px) {
  .day {
    grid-template-columns: 1.2fr 30px 0.9fr 0.8fr 1.9fr 12px;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
  }
  .d-cond { display: none; }
  .d-uvlabel { display: none; }
  .d-icon { width: 26px; height: 26px; }
  .drawer-charts { flex-direction: column; gap: 1.1rem; }
}

@media (max-width: 560px) {
  .uv { border-left: none; padding-left: 0; }
  .weather-main { gap: 1.4rem; }
  .world-clocks { gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .bar, .topbar, .hero, .weather, .charts, .scroll-hint,
  .sun-core, .sun-rays, .cloud { animation: none; }
  .topbar, .hero, .weather, .charts { opacity: 1; transform: none; filter: none; }
  .bar { transform: scaleY(1); }
}
