/* skyblu² — midnight data-viz. Mobile first: everything must read at 390 px. */

:root {
  --bg: #050816;
  --panel: #0a1024;
  --panel-2: #0d1630;
  --panel-3: #111c3c;
  --line: #263557;
  --line-soft: #18233f;
  --text: #dce9ff;
  --text-dim: #8fa3c8;
  --text-mute: #5b6d92;
  --cyan: #00e5ff;
  --mint: #62f6bf;
  --warn: #c98500;
  --bad: #d95926;

  /* categorical source palette (CVD-validated on #0a1024) */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;

  /* punchcard cells: yellow = direct sun, blues = cloud. The hue switch at the
     sun/no-sun boundary is the point of the encoding. */
  --pc-sun: #ffd84d;
  --pc-bright: #c9a838;
  --pc-filtered: #64779f;
  --pc-overcast: #223154;
  --pc-night: #07091a;
  --pc-twilight: #191f3e;
  --pc-upcoming: #0a0f22;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: var(--cyan); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* --- masthead --- */
.masthead {
  padding: 14px 14px 0;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #070b1e 0%, var(--bg) 100%);
}
.brand h1 {
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--text);
}
.brand h1 .sup { color: var(--cyan); font-size: 16px; vertical-align: super; }
.tagline { font-family: var(--mono); font-size: 10.5px; color: var(--text-mute); margin-top: 2px; }

.site-tabs { display: flex; gap: 6px; margin-top: 12px; }
.site-tabs button {
  flex: 1;
  padding: 8px 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.site-tabs button.on { color: #08132b; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }

.view-tabs { display: flex; margin-top: 10px; }
.view-tabs button {
  flex: 1;
  padding: 9px 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-mute);
  border-bottom: 2px solid transparent;
}
.view-tabs button.on { color: var(--text); border-bottom-color: var(--cyan); }

/* --- layout --- */
main { flex: 1; padding: 14px; max-width: 760px; width: 100%; margin: 0 auto; }
.loading { font-family: var(--mono); color: var(--text-mute); padding: 40px 0; text-align: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.card h2 {
  display: flow-root; /* contain the floated .tag so it can't squeeze siblings */
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 10px;
}
.card h2 .tag { float: right; letter-spacing: 0; text-transform: none; color: var(--text-mute); font-weight: 400; }
.sub { font-size: 12.5px; color: var(--text-dim); }
.mut { color: var(--text-mute); }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- hero --- */
.hero .headline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero .state { font-size: 26px; font-weight: 700; letter-spacing: .3px; }
.hero .state.sun, .hero .state.bright { color: var(--pc-sun); }
.hero .state.filtered { color: #a9b8d9; }
.hero .state.broken, .hero .state.overcast { color: var(--text-dim); }
.hero .state.nightState { color: #9db1dd; }
.hero .score { font-family: var(--mono); font-size: 13px; color: var(--text-mute); }
.hero .stats { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.stat {
  flex: 1 1 100px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 96px;
}
.stat .v { font-family: var(--mono); font-size: 17px; color: var(--text); }
.stat .v.hot { color: var(--pc-sun); }
.stat .k { font-size: 10.5px; color: var(--text-mute); letter-spacing: .5px; text-transform: uppercase; margin-top: 1px; }

/* --- punchcard --- */
.pc-wrap { overflow-x: auto; }
.pc-table { border-collapse: separate; border-spacing: 3px; margin: 0 auto; }
.pc-table th {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-mute);
  padding: 0 4px;
  text-align: center;
}
.pc-table th.hour { text-align: right; padding-right: 7px; }
.pc-cell {
  width: 40px;
  height: 26px;
  border-radius: 5px;
  position: relative;
  padding: 0;
  border: 1px solid transparent;
  display: block;
}
@media (max-width: 420px) { .pc-cell { width: 34px; height: 24px; } }
.pc-cell.sun { background: var(--pc-sun); }
.pc-cell.bright { background: var(--pc-bright); }
.pc-cell.filtered { background: var(--pc-filtered); }
.pc-cell.overcast { background: var(--pc-overcast); }
.pc-cell.broken { background: var(--pc-overcast); }
.pc-cell.broken::after {
  content: '';
  position: absolute;
  right: 3px; top: 3px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--pc-sun);
}
.pc-cell.night { background: var(--pc-night); border-color: #10162c; }
.pc-cell.twilight { background: var(--pc-twilight); }
.pc-cell.nodata { background: transparent; border: 1px dashed var(--line); }
.pc-cell.upcoming { background: var(--pc-upcoming); border: 1px solid var(--line-soft); opacity: .55; }
.pc-cell.now-slot { outline: 2px solid var(--cyan); outline-offset: 1px; }
.pc-cell:not(.upcoming):not(.nodata) { cursor: pointer; }

.pc-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 12px; }
.pc-legend .li { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.pc-legend .sw {
  width: 14px; height: 14px; border-radius: 4px; position: relative; flex: none;
  border: 1px solid transparent;
}
.pc-legend .sw.nodata { border: 1px dashed var(--line); }
.pc-legend .sw.broken::after {
  content: ''; position: absolute; right: 1px; top: 1px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--pc-sun);
}

/* --- three-site strip: contiguous flexible barcode, always fits the width --- */
.strip2-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.strip2-lbl {
  width: 64px; flex: none; text-align: right;
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}
.strip2-cells {
  display: flex; flex: 1; height: 22px;
  border-radius: 4px; overflow: hidden;
  border: 1px solid var(--line-soft);
}
.strip2-cells i { flex: 1; display: block; }
.strip2-cells i.sun { background: var(--pc-sun); }
.strip2-cells i.bright { background: var(--pc-bright); }
.strip2-cells i.filtered { background: var(--pc-filtered); }
.strip2-cells i.overcast, .strip2-cells i.broken { background: var(--pc-overcast); }
.strip2-cells i.night { background: var(--pc-night); }
.strip2-cells i.twilight { background: var(--pc-twilight); }
.strip2-cells i.nodata { background: #0c1226; }
.strip2-cells i.upcoming { background: var(--pc-upcoming); opacity: .4; }
.strip2-axis { position: relative; height: 15px; margin-left: 72px; }
.strip2-axis span {
  position: absolute; top: 1px;
  font-family: var(--mono); font-size: 10px; color: var(--text-mute);
  white-space: nowrap;
}

/* --- sensors --- */
.sensor-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .sensor-cards { grid-template-columns: 1fr; } }
.sensor {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 10px;
}
.sensor.primary { border-color: var(--line); background: var(--panel-3); }
.sensor .head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; }
.sensor .head .icao { color: var(--text); font-weight: 700; }
.sensor .big { font-family: var(--mono); font-size: 19px; margin-top: 3px; }
.sensor .det { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.pill {
  font-family: var(--mono); font-size: 10.5px;
  border-radius: 4px; padding: 1px 5px;
}
.pill.warn { background: rgba(201,133,0,.18); color: #e8b45c; }
.pill.bad { background: rgba(217,89,38,.18); color: #ef8a63; }

.oktas-strip { margin-top: 12px; }
.oktas-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.oktas-row .lbl { font-family: var(--mono); font-size: 11px; color: var(--text-dim); width: 44px; flex: none; }
.oktas-cells { display: flex; gap: 2px; flex: 1; min-width: 0; }
.okt {
  flex: 1; height: 18px; border-radius: 2px; min-width: 4px;
  background: var(--panel-3);
}
.oktas-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: var(--text-mute); margin-top: 4px; padding-left: 50px; }

/* --- satellite tile --- */
figure.sat { margin: 0; }
.tile-wrap { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-soft); }
.tile-wrap img { width: 100%; display: block; }
.marker {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--cyan); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(0,0,0,.45);
}
.marker.dim { border-color: rgba(220,233,255,.55); }
.marker span {
  position: absolute; left: 12px; top: -4px;
  font-family: var(--mono); font-size: 10px; color: var(--text);
  text-shadow: 0 1px 3px rgba(0,0,0,.9); white-space: nowrap;
}
figure > figcaption { font-size: 11.5px; color: var(--text-mute); margin-top: 8px; line-height: 1.5; }

/* --- frame modal --- */
.frame-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3,5,14,.82);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
/* display:flex above would override the hidden attribute's display:none. */
.frame-modal[hidden] { display: none; }
.frame-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(560px, 100%);
  overflow: hidden;
}
.frame-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  font-family: var(--mono); font-size: 13px;
}
.frame-head button { font-size: 22px; color: var(--text-mute); line-height: 1; padding: 0 4px; }
.frame-img-wrap { position: relative; }
.frame-img-wrap img { width: 100%; display: block; min-height: 200px; background: var(--panel-2); }
.frame-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
}
.frame-nav > button {
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  border: 1px solid var(--line-soft); border-radius: 6px; padding: 6px 10px;
  white-space: nowrap;
}
.frame-nav > button:disabled { opacity: .35; }
.frame-readings { display: flex; gap: 10px; font-family: var(--mono); font-size: 11px; }
.frame-readings .fr { text-align: center; }
.frame-readings .fr b { display: block; font-size: 13px; }

/* --- forecast view --- */
.chart-wrap { overflow-x: auto; }
svg.chart { display: block; width: 100%; height: auto; aspect-ratio: 680 / 250; }

.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.tbl th, .tbl td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.tbl th { font-family: var(--mono); font-size: 10.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .8px; font-weight: 500; }
.tbl td:first-child { white-space: nowrap; }
.tbl .num { text-align: right; }
.heat {
  font-family: var(--mono); font-size: 12px; text-align: center;
  border-radius: 4px; padding: 4px 0; min-width: 38px;
}
.band-chip { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

.deck-grid { border-collapse: separate; border-spacing: 2px; width: 100%; }
.deck-grid th { font-family: var(--mono); font-size: 10.5px; font-weight: 400; color: var(--text-mute); padding: 2px 6px; }
.deck-grid th:first-child { text-align: right; white-space: nowrap; }
.deck-grid td { border-radius: 4px; height: 26px; text-align: center; font-family: var(--mono); font-size: 11px; }

/* --- sources view --- */
.src { border-left: 3px solid var(--line); padding: 8px 12px; margin-bottom: 10px; background: var(--panel-2); border-radius: 0 8px 8px 0; }
.src .name { font-family: var(--mono); font-size: 13.5px; }
.src .name .kind { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-mute); margin-left: 8px; }
.src .meta { font-size: 11.5px; color: var(--text-mute); margin-top: 3px; line-height: 1.5; }
.src.err { border-left-color: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 12.5px; }
.kv dt { color: var(--text-mute); font-family: var(--mono); font-size: 11px; padding-top: 1px; }
.kv dd { color: var(--text-dim); }

.note { font-size: 12px; color: var(--text-mute); line-height: 1.6; }
.note code { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.foot { padding: 14px; text-align: center; }
.foot p { font-size: 10.5px; color: var(--text-mute); font-family: var(--mono); line-height: 1.6; }

.err-banner {
  background: rgba(217,89,38,.12);
  border: 1px solid rgba(217,89,38,.4);
  color: #ef8a63;
  border-radius: 8px; padding: 8px 12px; margin-bottom: 14px;
  font-family: var(--mono); font-size: 12px;
}
