/* ------------------------------------------------------------------ */
/* Skycast — dark glass UI, no external assets                        */
/* ------------------------------------------------------------------ */
:root {
  --fg: #f4f8fc;
  /* was #9db0c3 — measured 4.19:1 in the worst zone (below WCAG AA 4.5:1 on
     small text). #c9d7e6 measures 6.37:1 worst-case over the photo+scrim+glass
     composite. */
  --muted: #c9d7e6;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(10, 16, 26, 0.72);
  --border: rgba(255, 255, 255, 0.22);
  --accent: #9fd2ff;
  --accent2: #ffd166;
  --radius: 20px;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: #0b1220;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Dynamic weather-photo background (set from JS).
   Two stacked layers crossfade so the scene changes smoothly when the
   location's forecast changes (sun → rain → snow …). Each layer is a
   background-image <div> JS fills with url(img/<scene>.webp). */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(160deg, #3f86c0 0%, #6aa8d8 55%, #a8cbe8 100%);
  transition: background 1.2s ease;
}
.bg-layer {
  position: absolute;
  inset: 0;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 1.1s ease;
}
.bg-layer.on { opacity: 1; }
/* Photo credit note: photos are Unsplash (free license), fetched at build time
   into img/ — sunny photo-1502082553048, night photo-1419242902214,
   partly photo-1536514498073, clouds photo-1499346030926, rain photo-1515694346937,
   snow photo-1491002052546, thunder photo-1605727216801. */
/* Scrim carries text contrast over bright photos. Strength is set per
   day/night from JS (--scrim-a base tint, --scrim-b bottom shade): daytime
   stays noticeably brighter than before (was 0.45–0.62 flat dark), nights
   go darker for readability. */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      var(--scrim-a, rgba(10, 16, 26, 0.34)) 0%,
      var(--scrim-m, rgba(10, 16, 26, 0.22)) 45%,
      var(--scrim-b, rgba(10, 16, 26, 0.44)) 100%),
    radial-gradient(900px 500px at -10% 110%, rgba(0, 0, 0, 0.22), transparent 55%);
}

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 22px 18px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------------------------- header -------------------------------- */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 6px;
}
.brand-icon { display: inline-flex; }
.brand-icon svg { filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }

.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
}
.search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--fg);
  font-size: 14px;
  outline: none;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); background: var(--glass-strong); }

/* ---- saved-locations dropdown ---- */
.locations {
  position: relative;
  display: flex;
  align-items: center;
}
.loc-pin {
  position: absolute;
  left: 12px;
  display: inline-flex;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}
.locations select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 168px;
  padding: 10px 30px 10px 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 55% / 5px 5px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 55% / 5px 5px no-repeat,
    var(--glass);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}
.locations select:focus { border-color: var(--accent); background-color: var(--glass-strong); }
.locations select option { background: #0b1220; color: var(--fg); }

.results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: rgba(12, 19, 30, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
}
.results li {
  display: flex;
  flex-direction: column;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.results li:hover { background: rgba(124, 192, 255, 0.14); }
.results li strong { font-size: 14px; }
.results li span { font-size: 12px; color: var(--muted); }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: wait; }

/* Touch targets: 44px minimum (Apple HIG) on coarse pointers */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .unit { min-height: 44px; min-width: 46px; }
  #search { min-height: 44px; }
  .results li { padding: 12px 10px; }
}

.units {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--glass);
}
.unit {
  padding: 9px 13px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.unit.active {
  background: var(--accent);
  color: #0b1622;
}

/* ---------------------------- glass --------------------------------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.30);
}
/* Panels are OUTLINE-ONLY: fully transparent fill, the sky photo shows
   straight through. Readability comes from the frost blur + the page scrim
   behind everything (user ask: completely transparent, just the outline). */
.glass {
  background: transparent;
  background-image: none;
  box-shadow: none;
}
.card { position: relative; padding: 18px 20px 20px; }
.card h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

/* ---------------------------- hero ---------------------------------- */
.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px;
  flex-wrap: wrap;
}
.hero-main { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.loc h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: 0.2px; }
.sub { color: var(--muted); font-size: 13px; }
.hero-temp { display: flex; align-items: center; gap: 14px; margin: 6px 0 2px; }
.icon-big { display: inline-flex; }
.icon-big svg { filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35)); }
#tempBig { font-size: 64px; font-weight: 200; line-height: 1; letter-spacing: -2px; }
.cond-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.cond { font-size: 17px; font-weight: 600; }

.hero-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  align-content: center;
  flex: 1;
  min-width: 280px;
}
.hero-stats li {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 700;
}
.stat-val { font-size: 16px; font-weight: 700; }

/* ---------------------------- chart --------------------------------- */
.hour-wrap { position: relative; }
.hour-scroll { overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
/* inner wrapper must size to the chips' full width so the chart above spans
   the ENTIRE 48-hour scroll frame 1:1 (block default would squeeze it to viewport) */
.hour-inner { width: max-content; min-width: 100%; }
.chart-wrap { position: relative; margin-bottom: 10px; width: 100%; }
#chart { display: block; width: 100%; height: auto; }
#chart text { font-family: inherit; }
.clab { fill: var(--fg); font-size: 15px; font-weight: 600; opacity: 1; }
.clab.ylab { fill: var(--muted); font-size: 12px; font-weight: 700; opacity: 1; }
.grid { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1; }
.popbar { fill: rgba(124, 192, 255, 0.28); }

.tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  background: rgba(10, 16, 26, 0.94);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 11px;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.tip .tt { color: var(--muted); font-size: 12px; }
.tip strong { font-size: 15px; }
.tip .tp { color: var(--accent); font-size: 11px; }

/* ---------------------------- chips --------------------------------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 4px 0 2px;
}
.chip {
  position: relative;
  flex: 0 0 64px;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 12px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: background 0.15s ease, transform 0.15s ease;
}
.chip:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-2px); }
.chip .ct { font-size: 13.5px; color: var(--fg); font-weight: 700; letter-spacing: 0.2px; }
.chip .cd {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #0b1622;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 1px 8px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.chip strong { font-size: 15px; font-weight: 700; }
.chip .cp { font-size: 10px; color: var(--accent); font-weight: 700; }

/* ---------------------------- daily --------------------------------- */
.daily { display: flex; flex-direction: column; gap: 4px; }
.drow {
  display: grid;
  grid-template-columns: 88px 46px 52px 1fr 52px 58px 108px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 13px;
  transition: background 0.15s ease;
}
.drow:hover { background: rgba(255, 255, 255, 0.07); }
.dname { font-weight: 700; font-size: 14px; display: flex; flex-direction: column; line-height: 1.2; }
.dname small { color: var(--muted); font-weight: 500; font-size: 11px; }
.dicon { display: flex; justify-content: center; }
.dtemps { font-size: 14px; font-weight: 700; }
.dtemps .lo { color: var(--muted); font-weight: 600; }
.rbar {
  position: relative;
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.rbar span {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, #5eb3f6, #ffd166);
}
.dpop { font-size: 12px; color: var(--accent); font-weight: 700; text-align: right; }
.dss { font-size: 11px; color: var(--muted); text-align: right; }

/* ---------------------------- install card --------------------------- */
.install-card { display: flex; flex-direction: column; gap: 10px; }
.install-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.install-icon { border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.4); flex: 0 0 auto; }
.install-text { display: flex; flex-direction: column; gap: 3px; flex: 1 1 200px; }
.install-text strong { font-size: 15px; }
.install-text span { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.install-btn { background: var(--accent); color: #0b1622; border: none; font-weight: 800; padding: 11px 22px; border-radius: 12px; }
.install-btn:hover { background: #b8e0ff; }
.install-x {
  background: none; border: none; color: var(--muted); font-size: 22px;
  cursor: pointer; padding: 4px 10px; border-radius: 8px; line-height: 1;
}
.install-x:hover { color: var(--fg); background: rgba(255,255,255,.08); }
.ios-steps {
  font-size: 13px; color: var(--fg); line-height: 1.6;
  background: rgba(10, 16, 28, 0.4);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 12px 14px;
}
.ios-share { font-family: -apple-system; }

/* ---------------------------- misc ---------------------------------- */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding-top: 4px;
}

.banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: rgba(120, 30, 30, 0.92);
  border: 1px solid rgba(255, 120, 120, 0.4);
  color: #ffe3e3;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 13px;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

body.loading .hero,
body.loading .card { opacity: 0.55; transition: opacity 0.25s ease; }

/* ---------------------------- responsive ---------------------------- */
@media (max-width: 760px) {
  .wrap { padding: 14px 12px 36px; gap: 14px; }
  .controls { margin-left: 0; width: 100%; justify-content: space-between; }
  .search { max-width: none; }
  .hero { padding: 20px; }
  #tempBig { font-size: 52px; }
  .hero-stats { min-width: 0; grid-template-columns: repeat(3, 1fr); }
  .drow { grid-template-columns: 74px 40px 46px 1fr 46px 48px; gap: 8px; }
  .dss { display: none; }
  .card { padding: 14px 14px 16px; }
}
/* Phone: the side-by-side hero layout starves the stats grid (hero-main keeps
   its 240px min-width, squeezing the UL to ~64px so tiles overflow the card
   and force page-wide horizontal scroll). Stack instead. */
@media (max-width: 540px) {
  .hero { flex-direction: column; align-items: stretch; }
  .hero-main { min-width: 0; }
  .hero-stats { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  /* iOS safe areas when installed via PWA / notched Safari */
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .wrap { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@media (max-width: 460px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .loc h1 { font-size: 24px; }
}
