/* ============================================================
   Per-view layouts, the scrubber, overlays and boot sequence
   ============================================================ */

/* ------------------------------------------------------------ boot */

#boot {
  position: fixed; inset: 0; z-index: 50;
  background: var(--void);
  display: grid; place-items: center;
  transition: opacity .6s var(--ease), visibility 0s .6s;
}
#boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { width: min(560px, 86vw); }
#bootLog {
  font-family: var(--mono); font-size: .72rem; line-height: 1.75;
  color: var(--cy); text-shadow: 0 0 8px rgba(0,234,255,.5);
  white-space: pre-wrap; min-height: 210px;
}
#bootLog .ok  { color: var(--lm); }
#bootLog .err { color: var(--rd); }
#bootLog .mut { color: var(--faint); }
#bootLog::after {
  content: '▊'; animation: blink 1s steps(2) infinite; color: var(--mg);
}

/* ------------------------------------------------------- scrubber */

#scrub {
  position: relative; z-index: 4;
  height: var(--scrub);
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 14px 4px;
  background: linear-gradient(0deg, rgba(4,9,19,.94), rgba(4,9,19,.62));
  border-top: 1px solid rgba(0,234,255,.18);
  backdrop-filter: blur(10px);
}
#scrub::before {
  content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,45,143,.5) 25%, rgba(0,234,255,.5) 75%, transparent);
}

.tl-controls { display: flex; align-items: center; gap: 5px; }
.tl-btn {
  font-family: var(--ui); font-size: .68rem; font-weight: 600; letter-spacing: .1em;
  background: rgba(0,234,255,.06); color: var(--dim);
  border: 1px solid rgba(0,234,255,.18);
  padding: 6px 10px; cursor: pointer; min-width: 34px;
  clip-path: polygon(4px 0,100% 0,100% calc(100% - 4px),calc(100% - 4px) 100%,0 100%,0 4px);
  transition: all .16s;
}
.tl-btn:hover { color: var(--ink); border-color: var(--cy); background: rgba(0,234,255,.13); }
.tl-btn.on { background: var(--cy); color: var(--void); border-color: var(--cy); box-shadow: 0 0 14px rgba(0,234,255,.45); }
.tl-btn.sm { min-width: 26px; padding: 4px 6px; font-size: .6rem; }
.tl-play { font-size: .75rem; }
.tl-rate { display: flex; align-items: center; gap: 3px; margin-left: 6px; }
.tl-rate .lbl { font-size: .52rem; letter-spacing: .16em; color: var(--faint); text-transform: uppercase; margin-right: 2px; }

.tl-readout { display: flex; flex-direction: column; gap: 1px; min-width: 132px; }
.tl-when b {
  display: block; font-family: var(--mono); font-size: 1.15rem; font-weight: 700;
  color: var(--ink); line-height: 1.05; font-variant-numeric: tabular-nums;
}
.tl-when span { font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.tl-delta {
  font-family: var(--mono); font-size: .66rem; font-weight: 700; letter-spacing: .08em;
  margin-top: 2px; align-self: flex-start;
  padding: 1px 6px;
  clip-path: polygon(3px 0,100% 0,100% calc(100% - 3px),calc(100% - 3px) 100%,0 100%,0 3px);
}
.tl-delta.now  { background: rgba(109,255,74,.16); color: var(--lm); }
.tl-delta.fwd  { background: rgba(255,45,143,.16); color: var(--mg); }
.tl-delta.back { background: rgba(167,92,255,.16); color: var(--vi); }

.tl-canvas { width: 100%; height: 100%; display: block; min-height: 74px; }

/* ============================================================ DECK */

.deck {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 3.4fr) minmax(0, 5.2fr) minmax(230px, 3fr);
  grid-template-rows: minmax(0, 1.45fr) minmax(0, .92fr) minmax(0, 1.15fr);
  gap: var(--gap);
  grid-template-areas:
    "hero  meteo  side"
    "gauge gauge  side"
    "act   tenday tenday";
}
.deck > .hero   { grid-area: hero; }
.deck > .meteo  { grid-area: meteo; }
.deck > .side   { grid-area: side; }
.deck > .gauge  { grid-area: gauge; }
.deck > .act    { grid-area: act; }
.deck > .tenday { grid-area: tenday; }

/* --- hero --- */
.hero { --ac: var(--cy); justify-content: space-between; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hero-temp {
  font-family: var(--ui); font-weight: 700;
  font-size: clamp(4.6rem, 9.5vw, 9rem);
  line-height: .84; letter-spacing: -.035em;
  color: #fff;
}
.hero-temp sup { font-size: .3em; vertical-align: super; opacity: .55; font-weight: 600; }
.hero-cond {
  font-size: clamp(.95rem, 1.5vw, 1.35rem); font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--cy); margin-top: 2px;
}
.hero-feels { font-family: var(--mono); font-size: .78rem; color: var(--dim); margin-top: 5px; }
.hero-feels b { color: var(--ink); }
.hero-obs {
  font-family: var(--mono); font-size: .66rem; color: var(--faint);
  margin-top: 4px; letter-spacing: .02em;
}
.hero-obs b { color: var(--lm); font-weight: 700; }
.hero-obs span { color: var(--faint); }
.hero-obs em { font-style: normal; color: var(--am); }
.hero-glyph { font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1; opacity: .9; filter: drop-shadow(0 0 14px rgba(0,234,255,.45)); }
.hero-range { display: flex; gap: 16px; margin-top: 8px; }
.hero-range .stat .v { font-size: 1.25rem; }
.hero-spark { height: 42px; margin-top: auto; }
.hero-sun {
  display: flex; gap: 14px; margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.07); padding-top: 8px;
}

/* --- gauge band --- */
.gauge .body { flex-direction: row; gap: 4px; align-items: stretch; }
.gauge-cell {
  flex: 1 1 0; min-width: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gauge-cell + .gauge-cell::before {
  content: ''; position: absolute; left: 0; top: 12%; bottom: 12%; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(0,234,255,.16), transparent);
}
.gauge-cell canvas { width: 100%; flex: 1 1 auto; min-height: 0; }
.gauge-note {
  flex: 0 0 auto; text-align: center; padding: 0 4px 1px;
  font-size: .52rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--faint); pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- side column --- */
.side { display: flex; flex-direction: column; gap: var(--gap); }
.side > .panel { flex: 0 0 auto; }
.side > .panel.grow { flex: 1 1 auto; }

.alert-item {
  --ac: var(--rd);
  padding: 7px 9px; margin-bottom: 6px;
  background: color-mix(in srgb, var(--ac) 12%, transparent);
  border-left: 2px solid var(--ac);
  cursor: pointer;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item b {
  display: block; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ac); margin-bottom: 2px;
}
.alert-item span { font-size: .6rem; color: var(--dim); font-family: var(--mono); }

.nowcast { display: flex; flex-direction: column; gap: 6px; }
.nowcast-line { font-size: .84rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.nowcast-line.wet { color: var(--cy); }
.nowcast-bars { height: 30px; }
.nowcast-scale { display: flex; justify-content: space-between; font-size: .52rem; color: var(--faint); letter-spacing: .1em; }

/* --- activity --- */
.act .body { gap: 5px; overflow-y: auto; }
.act-row {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center;
  gap: 9px; padding: 4px 0;
}
.act-row + .act-row { border-top: 1px solid rgba(255,255,255,.045); }
.act-icon { font-size: .95rem; text-align: center; filter: drop-shadow(0 0 6px currentColor); }
.act-name { font-size: .64rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink); }
.act-when { font-size: .58rem; color: var(--dim); font-family: var(--mono); margin-top: 1px; }
.act-when em { font-style: normal; color: var(--faint); }
.act-score {
  font-family: var(--mono); font-weight: 700; font-size: .95rem;
  min-width: 30px; text-align: right; font-variant-numeric: tabular-nums;
}
.act-bar { grid-column: 2 / -1; height: 3px; margin-top: 3px; }

/* --- ten day --- */
.tenday .body { overflow: hidden; }
.tenday-grid {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: 100%; gap: 1px;
}
.tenday-col {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 2px; min-width: 0; position: relative; cursor: pointer;
  transition: background .2s;
}
.tenday-col:hover { background: rgba(0,234,255,.07); }
.tenday-col.today { background: rgba(0,234,255,.06); }
.tenday-col.today::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: var(--cy); box-shadow: 0 0 8px var(--cy);
}
.td-day { font-size: .56rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.td-date { font-size: .5rem; color: var(--faint); font-family: var(--mono); }
.td-glyph { font-size: 1.05rem; line-height: 1.1; }
.td-bar { flex: 1 1 auto; width: 5px; position: relative; min-height: 16px; background: rgba(255,255,255,.05); }
.td-bar i { position: absolute; left: 0; right: 0; display: block; }
.td-hi { font-family: var(--mono); font-size: .74rem; font-weight: 700; color: var(--ink); }
.td-lo { font-family: var(--mono); font-size: .62rem; color: var(--faint); }
.td-pop { font-size: .52rem; font-family: var(--mono); color: var(--ice); min-height: 12px; }

/* ------------------------------------------------------------ modal */

.modal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: start center;
  padding: 8vh 16px 16px;
  background: rgba(2,4,9,.72);
  backdrop-filter: blur(6px);
  animation: fade .18s var(--ease);
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  --ac: var(--cy);
  width: min(620px, 100%); max-height: 76vh;
  padding: 16px 18px;
  animation: rise .22s var(--ease);
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

.search-input {
  width: 100%; font-family: var(--mono); font-size: 1rem;
  background: rgba(0,0,0,.45); border: 1px solid rgba(0,234,255,.3);
  color: var(--ink); padding: 10px 12px; outline: none;
  clip-path: polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);
}
.search-input:focus { border-color: var(--cy); box-shadow: 0 0 18px rgba(0,234,255,.22); }
.search-input::placeholder { color: var(--faint); }

.res-list { margin-top: 10px; overflow-y: auto; max-height: 48vh; }
.res-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .14s, border-color .14s;
}
.res-item:hover, .res-item.sel { background: rgba(0,234,255,.09); border-left-color: var(--cy); }
.res-item b { font-size: .84rem; font-weight: 600; color: var(--ink); }
.res-item span { font-size: .62rem; color: var(--dim); letter-spacing: .08em; }
.res-item .coord { margin-left: auto; font-family: var(--mono); font-size: .58rem; color: var(--faint); }
.res-item .rm {
  margin-left: 8px; color: var(--faint); background: none; border: 0; cursor: pointer; font-size: .8rem;
}
.res-item .rm:hover { color: var(--rd); }

.modal h3 {
  font-size: .62rem; font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
  color: var(--faint); margin: 14px 0 4px;
}
.modal h3:first-child { margin-top: 0; }

.keyhelp { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 18px; }
.keyhelp div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: .7rem; color: var(--dim); border-bottom: 1px solid rgba(255,255,255,.04); }
.keyhelp kbd {
  font-family: var(--mono); font-size: .62rem; color: var(--cy);
  border: 1px solid rgba(0,234,255,.3); padding: 0 5px; background: rgba(0,234,255,.07);
}

.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.setrow label { font-size: .72rem; color: var(--ink); }
.setrow .hint { font-size: .58rem; color: var(--faint); display: block; margin-top: 1px; }
.seg { display: flex; gap: 2px; }
.seg button {
  font-family: var(--ui); font-size: .6rem; font-weight: 600; letter-spacing: .1em;
  padding: 4px 9px; cursor: pointer; text-transform: uppercase;
  background: rgba(0,234,255,.06); border: 1px solid rgba(0,234,255,.18); color: var(--dim);
}
.seg button.on { background: var(--cy); color: var(--void); border-color: var(--cy); }

/* Full-bleed canvas inside a panel. A replaced element ignores inset:0
   for sizing, so width/height must be stated explicitly. */
.fill { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ============================================================ RADAR */

.radar-wrap {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  gap: var(--gap);
}
.radar-main { position: relative; overflow: hidden; }
.radar-main canvas#r-map { position: absolute; inset: 0; width: 100%; height: 100%; }

.radar-hud {
  position: absolute; top: 10px; left: 12px; z-index: 3;
  pointer-events: none; display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start;
}
.radar-stamp {
  background: rgba(4,9,19,.78); backdrop-filter: blur(6px);
  border-left: 2px solid var(--cy);
  padding: 5px 10px;
}
.radar-stamp b {
  display: block; font-family: var(--mono); font-size: 1.05rem; font-weight: 700;
  color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums;
}
.radar-stamp span { font-size: .54rem; letter-spacing: .16em; text-transform: uppercase; color: var(--lm); }

.radar-legend {
  display: flex; align-items: center; gap: 9px;
  background: rgba(4,9,19,.80); backdrop-filter: blur(6px);
  padding: 6px 10px; flex-wrap: nowrap;
}
.radar-legend b { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.radar-legend i { width: 13px; height: 6px; display: block; flex: 0 0 auto; }
.radar-legend b, .radar-legend .lg-title {
  font-size: .48rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim);
  white-space: nowrap;
}
.radar-legend .lg-title { color: var(--faint); border-right: 1px solid rgba(255,255,255,.12); padding-right: 9px; }

.radar-tools {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  display: flex; flex-direction: column; gap: 4px;
}
.radar-tools .tl-btn { min-width: 30px; padding: 6px 0; text-align: center; }

.radar-frames {
  position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  background: rgba(4,9,19,.78); backdrop-filter: blur(6px);
  padding: 6px 8px;
}
.radar-frames canvas { flex: 1; height: 22px; display: block; cursor: pointer; }

.radar-side { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.radar-side > .panel { flex: 0 0 auto; }
.radar-side > .panel.grow { flex: 1 1 auto; min-height: 0; }

/* ============================================================== SKY */

.skyview {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(220px, 1fr) minmax(220px, 1fr);
  grid-template-rows: minmax(0, .82fr) minmax(0, 1.18fr);
  gap: var(--gap);
  grid-template-areas:
    "dome moon sun"
    "dome kp   see";
}
.skyview > .dome-panel { grid-area: dome; position: relative; }
.skyview > .moon-panel { grid-area: moon; }
.skyview > .sun-panel  { grid-area: sun; }
.skyview > .panel:nth-of-type(4) { grid-area: kp; }
.skyview > .panel:nth-of-type(5) { grid-area: see; overflow-y: auto; }

.dome-cap {
  position: absolute; left: 12px; right: 12px; bottom: 9px;
  display: flex; justify-content: space-between; pointer-events: none;
}
.sunmoon-body { flex-direction: row !important; gap: 12px; align-items: flex-start; }
.sunmoon-body canvas { width: 74px; height: 74px; flex: 0 0 74px; }
.moon-body { flex-direction: row !important; gap: 12px; align-items: flex-start; }
.moon-body canvas { width: 88px; height: 88px; flex: 0 0 88px; }

/* ============================================================== AIR */

.airview {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, .8fr);
  gap: var(--gap);
  grid-template-areas:
    "aqi  pol  pln"
    "uv   cmf  pln"
    "fc   fc   fc";
}
.airview > .aqi-panel            { grid-area: aqi; }
.airview > .panel:nth-of-type(2) { grid-area: pol; overflow-y: auto; }
.airview > .panel:nth-of-type(3) { grid-area: pln; overflow-y: auto; }
.airview > .panel:nth-of-type(4) { grid-area: uv; }
.airview > .panel:nth-of-type(5) { grid-area: cmf; overflow-y: auto; }
.airview > .panel:nth-of-type(6) { grid-area: fc; }

.aqi-body { flex-direction: row !important; gap: 10px; align-items: stretch; }
.aqi-body canvas { flex: 0 0 44%; min-width: 110px; height: 100%; align-self: stretch; }
.aqi-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.aqi-cat { font-size: .92rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.aqi-note { font-size: .6rem; color: var(--dim); line-height: 1.45; margin-top: 3px; }

.burngrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px 8px; }
.burngrid div { display: flex; justify-content: space-between; gap: 5px; align-items: baseline; }
.burngrid b { font-family: var(--mono); font-size: .68rem; }

.dewstrip { display: flex; gap: 2px; height: 8px; margin-top: 3px; }
.dewstrip i { flex: 1; background: rgba(255,255,255,.07); display: block; transition: all .3s var(--ease); }
.dewstrip i.on { background: var(--c); box-shadow: 0 0 10px var(--c); transform: scaleY(1.7); }

.pollen-fc { display: flex; gap: 5px; align-items: flex-end; flex: 1 1 auto; min-height: 62px; }
.pollen-fc > div {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; gap: 2px; height: 100%;
}
.pollen-fc .bar { width: 60%; display: block; min-height: 3px; }
.pollen-fc b { font-family: var(--mono); font-size: .58rem; color: var(--ink); }
.pollen-fc span { font-size: .48rem; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }

/* ============================================================= DATA */

.dataview {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(225px, .78fr);
  grid-template-rows: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap);
  grid-template-areas:
    "clim   clim   stats"
    "spread trend  stats"
    "meteo  meteo  deriv";
}
.dataview > .data-climate { grid-area: clim; }
.dataview > .data-spread  { grid-area: spread; }
.dataview > .data-stats   { grid-area: stats; overflow-y: auto; }
.dataview > .data-trend   { grid-area: trend; }
.dataview > .data-derived { grid-area: deriv; overflow-y: auto; }
.dataview > .data-meteo   { grid-area: meteo; }

/* ------------------------------------------------ narrower windows */

@media (max-width: 1250px) {
  .deck {
    grid-template-columns: minmax(240px, 1fr) minmax(0, 1.6fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "hero  meteo"
      "side  meteo"
      "gauge gauge"
      "act   tenday";
    overflow-y: auto;
  }
  .airview, .dataview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(190px, auto);
    grid-template-areas: none;
    overflow-y: auto;
  }
  .airview > .panel, .dataview > .panel { grid-area: auto !important; }
  .airview > .panel:nth-of-type(6), .dataview > .data-meteo { grid-column: 1 / -1; }
  .skyview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(210px, auto);
    grid-template-areas: none;
    overflow-y: auto;
  }
  .skyview > .panel { grid-area: auto !important; }
  .skyview > .dome-panel { grid-column: 1 / -1; min-height: 320px; }
  .radar-wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(340px, 1.6fr) auto; }
  .radar-side { flex-direction: row; }
  .radar-side > .panel { flex: 1 1 0; }
}
