/* Meteo Campo Quito
   Concreto y pizarra: una herramienta de obra que se lee al sol.
   Lo único que se permite gritar es la respuesta y la franja de la jornada. */

/* Oscuro por defecto, como una app de alertas; "Modo sol" (data-theme="light") vuelve al concreto claro
   para leer en exteriores. Estados siempre con palabra, no solo color. */
:root {
  color-scheme: dark;
  --page: #0b1424;
  --surface: #13223b;   /* controles */
  --card: #111f36;      /* tarjetas */
  --ink: #eef3fa;
  --ink-2: #b3c0d4;
  --muted: #8494ad;
  --rule: #24395b;
  --focus: #ffd23f;
  --accent: #ffd23f;    /* titulares de tarjeta y botón de reproducir */
  --now: #ff4d61;       /* "Ahora" y la tormenta */
  --you: #3b82f6;       /* tu zona */

  --good: #3db15c; --good-tint: #133324;
  --warn: #f0b43a; --warn-tint: #3a2e12;
  --bad: #ef5a5a;  --bad-tint: #3d1c22;
  --off: #8494ad;  --off-tint: #1a2a44;

  --s-rain: #3d8bff; --s-gust: #f0743c; --s-wind: #22b07d;
  --s-cl-low: #d3dde7; --s-cl-mid: #8ea4bb; --s-cl-high: #57708a;
  --shade: rgba(238, 243, 250, .05);

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --text: "Barlow", system-ui, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #e6e9ec; --surface: #f7f8f9; --card: #ffffff; --ink: #1b2a3a; --ink-2: #4a5868; --muted: #6b7785; --rule: #cdd3d9;
  --focus: #2a78d6; --accent: #8a5a00; --now: #d62839; --you: #2563eb;
  --good: #1e8e3e; --good-tint: #d9eedf;
  --warn: #e8a317; --warn-tint: #faedcd;
  --bad: #c62828;  --bad-tint: #f6dada;
  --off: #8a949e;  --off-tint: #dde2e6;
  --s-rain: #2a78d6; --s-gust: #eb6834; --s-wind: #1baf7a;
  --s-cl-low: #34475c; --s-cl-mid: #6f87a1; --s-cl-high: #a9bacb;
  --shade: rgba(27, 42, 58, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 16px/1.5 var(--text); }
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
p { margin: 0; }

/* Cabecera */
.top { max-width: 1120px; margin: 0 auto; padding: 18px 16px 0; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font: 800 clamp(32px, 8vw, 40px)/1 var(--text); letter-spacing: -.02em; }
.for { margin-top: 6px; font-size: 17px; color: var(--ink-2); }
.for b { color: var(--ink); }
.top .stamp { margin-top: 4px; }
.theme { min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: 14px; background: var(--surface); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stamp { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

main { max-width: 1120px; margin: 0 auto; padding: 12px 16px 32px; }
.msg:empty { display: none; }
.msg { margin-bottom: 12px; padding: 10px 14px; background: var(--bad-tint); border-left: 4px solid var(--bad); }
.msg[data-kind="warn"] { background: var(--warn-tint); border-left-color: var(--warn); }
.stamp[data-level="aging"] { color: var(--ink); }
.stamp[data-level="aging"]::before { content: "● "; color: var(--warn); }
.stamp[data-level="stale"] { color: var(--ink); font-weight: 600; }
.stamp[data-level="stale"]::before { content: "● "; color: var(--bad); }
.v-src:empty { display: none; }
.v-src { margin-top: 10px; font-size: 14px; font-weight: 600; }

/* La respuesta */
.verdict { --c: var(--off); --t: var(--off-tint); margin-top: 20px; background: var(--card); border: 1px solid var(--rule); border-left: 8px solid var(--c); padding: 18px 20px 22px; border-radius: 20px; }
.v-kicker { margin-bottom: 10px; font: 700 18px/1.2 var(--text); color: var(--accent); }
.verdict.good { --c: var(--good); --t: var(--good-tint); }
.verdict.warn { --c: var(--warn); --t: var(--warn-tint); }
.verdict.bad  { --c: var(--bad);  --t: var(--bad-tint); }
.flag { display: inline-block; background: var(--c); color: #fff; font: 700 18px/1 var(--display); letter-spacing: .02em; padding: 7px 12px 6px; border-radius: 3px; }
.verdict.warn .flag { color: #1b2a3a; }
.answer { margin: 12px 0 0; font: 700 clamp(40px, 10vw, 72px)/.95 var(--display); letter-spacing: -.01em; max-width: 14ch; text-wrap: balance; }
.why { margin-top: 12px; font-size: 18px; color: var(--ink-2); max-width: 60ch; }

/* Bloques */
.block { margin-top: 20px; padding: 18px 18px 20px; background: var(--card); border: 1px solid var(--rule); border-radius: 20px; }
.block h2 { margin: 0; font: 600 26px/1.1 var(--display); }
.block-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.block > h2 { margin-bottom: 14px; }
.help { margin-top: 10px; font-size: 14px; color: var(--ink-2); max-width: 70ch; }
label { color: var(--ink-2); font-size: 14px; }
select, button { font: 500 15px/1 var(--text); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 8px 10px; min-height: 40px; }
button { cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--ink-2); }
.jornada, .actions { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }

/* Franja de la jornada: cronograma de obra */
.timeline { display: grid; gap: 18px; }
.tl-day { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 10px; align-items: start; }
.tl-label { font: 600 18px/44px var(--display); }
.tl-track { position: relative; }
.tl-row { display: flex; gap: 2px; height: 44px; }
.tl-cell { flex: 1 1 0; min-width: 0; display: grid; place-items: center; border: 0; padding: 0; min-height: 0; border-radius: 0; font: 700 16px/1 var(--text); color: #fff; cursor: pointer; }
.tl-cell:first-child { border-radius: 4px 0 0 4px; }
.tl-cell:last-child { border-radius: 0 4px 4px 0; }
.tl-cell.good { background: var(--good); }
.tl-cell.warn { background: var(--warn); color: #1b2a3a; }
.tl-cell.bad { background: var(--bad); }
.tl-cell.past { opacity: .35; }
.tl-cell[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: -3px; }
.tl-ticks { display: flex; gap: 2px; margin-top: 4px; }
.tl-ticks span { flex: 1 1 0; min-width: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-now { position: absolute; top: -6px; height: 56px; width: 0; border-left: 2px solid var(--ink); pointer-events: none; }
.tl-now::before { content: ""; position: absolute; top: -2px; left: -6px; border: 5px solid transparent; border-top: 7px solid var(--ink); }
.tl-detail { margin-top: 14px; min-height: 1.5em; font-weight: 500; }
.key { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.key li { display: inline-flex; gap: 6px; align-items: center; }
.sw { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 3px; color: #fff; font-weight: 700; font-size: 12px; }
.sw.good { background: var(--good); } .sw.warn { background: var(--warn); color: #1b2a3a; } .sw.bad { background: var(--bad); }
.rules { margin-top: 14px; font-size: 14px; color: var(--ink-2); max-width: 70ch; }
.rules summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.rules ul { padding-left: 18px; margin: 8px 0; }

/* Perfil y avisos */
.profile { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: -4px 0 16px; }
.profile .help { flex-basis: 100%; margin-top: 0; }
.push { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.push .help { margin-top: 0; flex: 1 1 260px; }
.push button[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* Reporte de campo */
.report { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.report-q { margin: 0; font-weight: 600; }
.report .help { flex-basis: 100%; margin-top: 0; }
.report-near { flex-basis: 100%; margin: 0; font-weight: 600; }
.report-near:empty { display: none; }
.report button[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* Ahora */
.now { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--ink); }
.now > div { padding: 10px 12px 0 0; }
.now dt { font-size: 14px; color: var(--ink-2); }
.now dd { margin: 2px 0 0; font: 600 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.now dd.note { font: 400 14px/1.3 var(--text); color: var(--muted); }

/* Satélite */
.sat { display: block; background: #05080b; border-radius: 14px; overflow: hidden; aspect-ratio: 5 / 3; }
.sat img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sat.fail { display: none; }
.own { margin: 0 0 8px; }
.own-sat { aspect-ratio: auto; }
.own-sat img { height: auto; }
.ir-key { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
/* Vista 3D a pantalla completa. */
.v3d { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #0b1118; color: #fff; }
.v3d[hidden] { display: none; }
.v3d-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 6px; }
.v3d-title { margin: 0; font: 700 20px/1.1 var(--display); }
.v3d-sub { margin: 0; flex: 1; font-size: 13px; color: #b8c4d0; }
.v3d-head button { background: transparent; color: #fff; border-color: #44515f; }
.v3d-stage { position: relative; flex: 1; overflow: hidden; }
.v3d-stage canvas { display: block; width: 100%; height: 100%; }
.v3d-note { margin: 0; padding: 8px 16px 14px; font-size: 12px; color: #b8c4d0; }
.v3d-label { position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: 3px; font: 700 14px/1.2 var(--display); white-space: nowrap; pointer-events: none; background: rgba(10, 14, 20, 0.8); }
.v3d-label.quito { border: 1px solid #dc1e1e; }
.v3d-label.cold { font-size: 22px; color: #ff9be8; }

/* Lluvia según 3 modelos. */
.mmap { margin: 10px 0 8px; }
.mmap-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 6px; }
.mmap-when { font: 600 15px/1.2 var(--display); }
.mmap input[type=range] { width: 100%; margin: 0 0 6px; }
.mmap canvas { display: block; width: 100%; height: auto; border-radius: 4px; background: #05080b; }
.models { margin: 0 0 16px; }
.models-sum { margin: 0 0 6px; font: 600 16px/1.3 var(--display); }
.models-list { margin: 0 0 6px; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
/* Estado sobre Quito según el satélite, arriba de la imagen. */
.sat-storm { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); }
.sat-metar[data-tormenta="1"] { font-weight: 600; color: var(--ink, inherit); }
.sat-tools { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.own-sat { position: relative; }
/* Etiqueta de la cima más fría: un punto sobre la nube y el texto encima. */
.sat-cold { position: absolute; transform: translate(-50%, calc(-100% - 6px)); padding: 3px 7px; border-radius: 3px; background: rgba(10, 14, 20, 0.85); color: #fff; font: 600 12px/1.2 var(--text); white-space: nowrap; pointer-events: none; }
.sat-cold::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 8px; height: 8px; margin-left: -5px; border: 1px solid #fff; border-radius: 50%; background: #ff3dd2; }
.sat-frame { font: 600 15px/1 var(--display); }
.sat-quito { margin: 0 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface); font: 600 16px/1.3 var(--display); }
.sat-quito[data-estado="tormenta"] { background: var(--warn-tint); }
.sat-quito[data-estado="lluvia"] { background: color-mix(in srgb, var(--s-rain) 22%, var(--card)); }
.ir-key span.bolt { background: #ffe100; border-radius: 50%; box-shadow: 0 0 0 2px #141414; }
.ir-key span { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
.sat-sub { margin: 18px 0 8px; font: 600 18px/1.2 var(--display); }

/* Gráficos */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.charts figure { margin: 0; min-width: 0; }
.charts .wide { grid-column: 1 / -1; }
figcaption { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.cv { position: relative; height: 210px; }
.cv.short { height: 160px; }

/* Registro */
.table-wrap { margin-top: 14px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th { font-weight: 600; color: var(--ink-2); border-bottom: 2px solid var(--ink); }
th, td { padding: 8px 10px 8px 0; text-align: right; white-space: nowrap; }
td { border-bottom: 1px solid var(--rule); }
th:first-child, td:first-child { text-align: left; }

footer { max-width: 1120px; margin: 0 auto; padding: 16px 16px 32px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--rule); }

@media (max-width: 720px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .block { padding: 16px 14px 18px; }
  .charts { grid-template-columns: 1fr; }
  .now { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; }
  .tl-day { grid-template-columns: 1fr; }
  .tl-label { line-height: 1.2; margin-bottom: 6px; }
  .why { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- Tarjeta principal: infrarrojo, línea de tiempo y lluvia acumulada ---------- */
.alerta { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .alerta { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: 24px; align-items: start; }
}
.alerta-side { display: grid; gap: 14px; align-content: start; }
.ir-lab.storm.near b { position: absolute; top: 24px; left: -4px; }
.ir-lab.storm.near.flip b { left: auto; right: -4px; }
.ir { margin: 0; }
.ir-stage { position: relative; border-radius: 22px; overflow: hidden; background: #0c1220; box-shadow: 0 0 0 1px var(--rule); }
.ir-stage canvas { display: block; width: 100%; height: 100%; }
.ir-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ir-svg path { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ln-prov { stroke: rgba(225, 235, 250, .42); stroke-width: 1; }
.ln-border { stroke: rgba(255, 210, 63, .85); stroke-width: 1.6; }
.ln-coast { stroke: rgba(225, 235, 250, .75); stroke-width: 1.3; }
.ln-storm { stroke: var(--now); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.bolts circle { fill: #ffe100; stroke: #141414; stroke-width: 1; vector-effect: non-scaling-stroke; }
.ir-lab { position: absolute; transform: translate(-50%, -50%); color: #fff; font: 600 13px/1.1 var(--text); white-space: nowrap; pointer-events: none; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, .7); }
.ir-lab.city { font-size: 12px; opacity: .9; }
.ir-lab.you, .ir-lab.storm { display: flex; align-items: center; gap: 8px; transform: translate(-9px, -50%); text-shadow: none; z-index: 1; }
.ir-lab.flip { flex-direction: row-reverse; transform: translate(calc(-100% + 9px), -50%); }
.ir-lab b { padding: 5px 11px; border-radius: 999px; background: rgba(8, 14, 26, .86); font: 700 14px/1.1 var(--text); }
.ir-lab .pt { flex: none; width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.ir-lab .ring { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #ff4d61; background: rgba(255, 77, 97, .25); }
.ir-lab.storm b { border: 1.5px solid #ff4d61; }
.ir-pill { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; padding: 5px 16px 5px 5px; min-height: 0; border: 0; border-radius: 999px; background: rgba(8, 14, 26, .86); color: #fff; font: 600 15px/1 var(--text); font-variant-numeric: tabular-nums; }
.ir-btn { width: 38px; height: 38px; border-radius: 50%; background: #ffd23f; display: grid; place-items: center; color: #111; font-size: 15px; font-weight: 800; }
.ir-pill[data-state="playing"] .ir-btn::before { content: "❚❚"; letter-spacing: -1px; }
.ir-pill[data-state="paused"] .ir-btn::before { content: "▶"; margin-left: 3px; }
.ir-pill[data-state="single"] { padding-left: 14px; cursor: default; }
.ir-pill[data-state="single"] .ir-btn { display: none; }
.ir-age { position: absolute; right: 12px; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(8, 14, 26, .78); color: #dfe7f3; font-size: 12px; }
.ir-age:empty { display: none; }
.ir figcaption { margin-top: 10px; }
.ir-desc { font: 600 16px/1.35 var(--text); }
.ir-scale { margin-top: 10px; }
.ir-bar { display: block; height: 8px; border-radius: 4px; }
.ir-ticks { display: flex; justify-content: space-between; margin-top: 3px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ir-ticks i { font-style: normal; }
.ir-note { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.dot-you, .dot-bolt { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; }
.dot-you { background: #3b82f6; box-shadow: 0 0 0 2px #fff inset; }
.dot-bolt { background: #ffe100; box-shadow: 0 0 0 1.5px #141414; }
.ir-fallback { padding: 18px; border-radius: 18px; background: var(--card); border: 1px dashed var(--rule); color: var(--ink-2); }

.ev { --n: 4; list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.ev li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 0 2px; }
.ev li::before { content: ""; position: absolute; top: 14px; left: 0; right: 0; height: 3px; background: var(--rule); }
.ev li:first-child::before { left: 50%; }
.ev li:last-child::before { right: 50%; }
.ev li:only-child::before { display: none; }
.ev-dot { position: relative; width: 30px; height: 30px; margin-bottom: 8px; border-radius: 50%; border: 3px solid var(--ink-2); background: var(--page); }
.ev-obs .ev-dot { background: var(--you); border-color: var(--you); }
.ev-now .ev-dot { background: var(--now); border-color: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--now) 35%, transparent); }
.ev-l { font: 700 16px/1.15 var(--text); }
.ev-now .ev-l { color: var(--now); }
.ev-t { font: 600 15px/1.2 var(--text); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ev-s { font-size: 12px; color: var(--muted); }
.ev-fc .ev-s { font-style: italic; }
.ev-note { font-size: 14px; color: var(--ink-2); }
.ev-note:empty { display: none; }

.acc { padding: 16px 16px 14px; border-radius: 20px; background: var(--card); border: 1px solid var(--rule); }
.acc-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.acc-head h3 { margin: 0; font: 700 18px/1.2 var(--text); }
.acc-total { color: var(--ink-2); font-size: 14px; }
.acc-total b { color: var(--ink); font: 700 22px/1 var(--text); margin-left: 4px; }
.acc-total small { display: block; text-align: right; font-size: 12px; color: var(--muted); }
.acc-cv { height: 190px; margin-top: 6px; }
.acc-note { margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* Barra de secciones abajo, solo en el celular. */
.tabs { display: none; }
@media (max-width: 720px) {
  .tabs { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--page) 94%, transparent);
    border-top: 1px solid var(--rule); backdrop-filter: blur(8px); }
  .tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--muted); font: 600 12px/1 var(--text); text-decoration: none; }
  .tabs a span { font-size: 20px; line-height: 1; }
  .tabs a:first-child { color: var(--accent); }
  .ir-stage { border-radius: 18px; }
  .ev-l { font-size: 14px; }
  .ev-t { font-size: 13px; }
}
html { scroll-behavior: smooth; scroll-padding-top: 12px; }
.v-sat { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bad-tint); border: 1px solid var(--now); font-weight: 600; }
