/* ==========================================================================
   MeteoVlox — Design tokens
   Concept: estación meteorológica hiperlocal · instrumento + app moderna
   Paleta: cielo despejado al amanecer + acentos de instrumentos analógicos
   Tipografía: Space Grotesk (títulos), JetBrains Mono (lecturas numéricas),
               Inter (texto de apoyo/etiquetas)
   ========================================================================== */

:root{
  /* atmósfera */
  --sky-top:    #85dee6;
  --sky-mid:    #2e2266;
  --sky-low:    #5a7a88;

  /* tinta */
  --ink:        #0a131b;
  --ink-soft:   #4c6478;
  --ink-faint:  #3a444c;

  /* vidrio / superficies */
  --glass:        rgba(255,255,255,0.58);
  --glass-strong: rgba(255,255,255,0.78);
  --glass-border: rgba(255,255,255,0.9);
  --hairline:     rgba(22,40,58,0.08);

  /* acentos de instrumento */
  --accent-temp:  #dd6a2c;   /* ámbar termómetro */
  --accent-wind:  #2f7fab;   /* azul barométrico */
  --accent-rain:  #2f9c93;   /* verde-agua lluvia */
  --accent-good:  #4f9a55;
  --accent-bad:   #c5502f;

  --shadow-sm: 0 2px 10px rgba(22,40,58,0.06);
  --shadow-md: 0 10px 34px rgba(22,40,58,0.10);
  --shadow-lg: 0 18px 48px rgba(22,40,58,0.14);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
  --font-body:    'Inter', sans-serif;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky-top);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.brand-logo {
  height: 80px;
  width: auto;
  display: block;
}

button{ font-family: inherit; }

.app{
  height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 620px at 82% -10%, rgba(255,255,255,0.9), transparent 60%),
    radial-gradient(900px 520px at 8% 106%, rgba(196,222,236,0.65), transparent 55%),
    linear-gradient(165deg, var(--sky-top) 0%, var(--sky-mid) 52%, var(--sky-low) 100%);
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.topbar{
  flex: 0 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  gap: 20px;
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.brand-mark{
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: conic-gradient(from 210deg, var(--accent-wind), var(--accent-rain), var(--accent-temp), var(--accent-wind));
  box-shadow: 0 0 0 3px rgba(255,255,255,0.7), 0 2px 6px rgba(22,40,58,0.18);
}

.brand-name{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.nav{
  display: flex;
  gap: 4px;
  background: rgba(22,40,58,0.05);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
}

.nav-item{
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav-item:hover{ color: var(--ink); }

.nav-item.active{
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.nav-item:focus-visible,
.seg-btn:focus-visible,
.chip:focus-visible{
  outline: 2px solid var(--accent-wind);
  outline-offset: 2px;
}

.status{
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
}

.station-name{
  font-weight: 600;
  color: var(--ink);
}

.status-pill{
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(79,154,85,0.12);
  color: var(--accent-good);
  font-weight: 600;
}

.dot{ width: 7px; height: 7px; border-radius: 50%; }
.dot-online{ background: var(--accent-good); box-shadow: 0 0 0 3px rgba(79,154,85,0.22); }

.updated b{ color: var(--ink); font-weight: 600; }

/* ==========================================================================
   STAGE / SCREENS
   ========================================================================== */

.stage{
  flex: 1 1 auto;
  position: relative;
  padding: 20px 26px 22px;
  min-height: 0;
}

.screen{
  display: none;
  height: 100%;
  min-height: 0;
}

.screen.active{ display: block; }

/* Panel base ------------------------------------------------------------- */

.panel{
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 22px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.panel-title{
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.panel-tag{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}

/* ==========================================================================
   SCREEN 1 — ACTUAL
   ========================================================================== */

.grid-actual{
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: 1fr auto auto;
  gap: 16px;
  grid-template-areas:
    "condiciones viento"
    "precip      precip"
    "sensores    sensores";
}

.panel-condiciones{ grid-area: condiciones; }
.panel-viento{ grid-area: viento; }
.panel-precipitacion{ grid-area: precip; }

.temp-hero{
  display: flex;
  align-items: flex-start;
  gap: 4px;
  line-height: 0.9;
  margin-top: 6px;
}

.temp-value{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(56px, 8vw, 96px);
  color: var(--accent-temp);
  letter-spacing: -0.02em;
}

.temp-unit{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  color: var(--accent-temp);
  margin-top: 10px;
}

.temp-caption{
  margin: 2px 0 14px;
  font-size: 13px;
  color: var(--ink-faint);
}

.temp-sub{
  display: flex;
  gap: 28px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

.sub-item{ display: flex; flex-direction: column; gap: 3px; }
.sub-label{ font-size: 11.5px; color: var(--ink-faint); }
.sub-value{ font-family: var(--font-mono); font-weight: 600; font-size: 15.5px; }

.metric-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  flex: 1;
  align-content: end;
}

.metric{ display: flex; flex-direction: column; gap: 6px; }

.metric-label{
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.3;
}

.metric-value{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
}

.metric-value small{
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 3px;
}

.metric-value.trend-down{ color: var(--accent-wind); font-size: 16px; }

/* Viento / brújula --------------------------------------------------------- */

.panel-viento{ align-items: center; }

.compass-wrap{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
}

.compass{ width: min(100%, 200px); height: auto; }

.compass-ring-outer{
  fill: rgba(255,255,255,0.5);
  stroke: var(--ink);
  stroke-opacity: 0.14;
  stroke-width: 1.5;
}

.compass-ring-inner{
  fill: none;
  stroke: var(--ink);
  stroke-opacity: 0.1;
  stroke-width: 1;
}

.tick-major{ stroke: var(--ink-soft); stroke-width: 1.6; }
.tick-minor{ stroke: var(--ink); stroke-opacity: 0.22; stroke-width: 1; }

.compass-label{
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink-soft);
  text-anchor: middle;
  dominant-baseline: middle;
}
.compass-label.primary{ fill: var(--ink); font-size: 12.5px; }

.compass-needle{ transition: transform 1.1s cubic-bezier(0.22,1,0.36,1); }
.needle-north{ fill: var(--accent-temp); }
.needle-south{ fill: var(--ink); fill-opacity: 0.28; }
.compass-hub{ fill: var(--ink); }

.wind-readouts{
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

.wind-item{ display: flex; flex-direction: column; gap: 4px; align-items: center; flex: 1; }
.wind-label{ font-size: 10.5px; color: var(--ink-faint); }
.wind-value{ font-family: var(--font-mono); font-weight: 700; font-size: 15.5px; color: var(--accent-wind); }
.wind-value small{ font-family: var(--font-body); font-weight: 500; font-size: 10.5px; color: var(--ink-faint); }

/* Precipitación ------------------------------------------------------------ */

.precip-body{
  display: flex;
  align-items: center;
  gap: 26px;
  flex: 1;
}

.precip-stat{ display: flex; flex-direction: column; gap: 4px; }

.precip-value{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 30px;
  color: var(--accent-rain);
}

.precip-value small{
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: 4px;
}

.precip-caption{ font-size: 11.5px; color: var(--ink-faint); }

.precip-divider{ width: 1px; align-self: stretch; background: var(--hairline); }

.precip-visual{ flex: 1; height: 46px; }
.drop-gauge{ width: 100%; height: 100%; }
.drop-bar{ fill: var(--accent-rain); opacity: 0.85; }
.drop-bar.dim{ opacity: 0.22; }

/* Sensores ------------------------------------------------------------------ */

.sensor-bar{
  grid-area: sensores;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 10px 22px;
  box-shadow: var(--shadow-sm);
}

.sensor{
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.sensor em{
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent-good);
  margin-left: 2px;
}

.sensor-dot{
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-good);
  box-shadow: 0 0 0 3px rgba(79,154,85,0.18);
}

/* ==========================================================================
   SCREEN 2 — PREDICCIÓN
   ========================================================================== */

.grid-prediccion{
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.timeline{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.time-step{
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.time-step.now{
  background: var(--ink);
  border-color: var(--ink);
}

.time-step.now .time-tag,
.time-step.now .time-cond{ color: rgba(255,255,255,0.62); }
.time-step.now .time-temp{ color: #fff; }

.time-tag{
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.time-icon{
  width: 30px; height: 30px;
  margin: 4px 0 2px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.time-icon[data-icon="clear"]{ background-image: radial-gradient(circle, #f2b148 0 40%, transparent 41%), conic-gradient(from 0deg, transparent 0 350deg, transparent 350deg); filter: drop-shadow(0 0 0 transparent); }
.time-icon[data-icon="clear"]::before{ content:''; }

.time-temp{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
}

.time-cond{ font-size: 12px; color: var(--ink-faint); }

.row-main{
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  min-height: 0;
}

.prob-body{
  display: flex;
  align-items: center;
  gap: 30px;
  flex: 1;
}

.prob-ring-wrap{ position: relative; width: 140px; height: 140px; flex: 0 0 auto; }
.prob-ring{ width: 100%; height: 100%; transform: rotate(-90deg); }
.prob-ring-track{ fill: none; stroke: var(--hairline); stroke-width: 11; }
.prob-ring-value{
  fill: none;
  stroke: var(--accent-wind);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-dasharray: 364.4;
  stroke-dashoffset: 364.4;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.22,1,0.36,1);
}

.prob-ring-label{
  position: absolute; inset: 0;
  display: flex; align-items: baseline; justify-content: center; gap: 2px;
  font-family: var(--font-mono);
}
.prob-ring-label span{ font-size: 34px; font-weight: 700; color: var(--ink); }
.prob-ring-label small{ font-size: 15px; color: var(--ink-faint); }

.prob-meta{ display: flex; flex-direction: column; gap: 16px; }
.meta-row{ display: flex; flex-direction: column; gap: 4px; }
.meta-label{ font-size: 11.5px; color: var(--ink-faint); }
.meta-value{ font-family: var(--font-mono); font-weight: 600; font-size: 17px; }

.trend-list{
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  flex: 1;
}

.trend-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.trend-item:last-child{ border-bottom: none; }

.trend-name{ font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.trend-arrow{ font-family: var(--font-mono); font-weight: 700; font-size: 17px; }
.trend-arrow.up{ color: var(--accent-bad); }
.trend-arrow.down{ color: var(--accent-wind); }

.interpret-panel{
  background: linear-gradient(120deg, rgba(47,127,171,0.14), rgba(47,156,147,0.12));
  border: 1px solid rgba(47,127,171,0.22);
  flex-direction: row;
  align-items: center;
  gap: 22px;
  padding: 18px 26px;
}

.interpret-tag{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-wind);
  background: rgba(255,255,255,0.6);
  padding: 7px 14px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.interpret-text{
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}

.interpret-source{
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  flex: 0 0 auto;
}

/* ==========================================================================
   SCREEN 3 — HISTÓRICOS
   ========================================================================== */

.grid-historicos{
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.controls-bar{
  display: flex;
  align-items: center;
  gap: 34px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
}

.control-group{ display: flex; align-items: center; gap: 12px; }
.control-group:last-child{ flex: 1; }

.control-label{
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  flex: 0 0 auto;
}

.segmented{
  display: flex;
  background: rgba(22,40,58,0.05);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.seg-btn{
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  padding: 6px 14px; border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg-btn.active{ background: var(--ink); color: #fff; }

.chip-row{ display: flex; gap: 8px; flex-wrap: nowrap; }

.chip{
  appearance: none; cursor: pointer;
  background: rgba(22,40,58,0.05);
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.chip.active{
  background: rgba(47,127,171,0.14);
  border-color: rgba(47,127,171,0.4);
  color: var(--accent-wind);
}

.chart-panel{ min-height: 0; }

.chart-svg{ width: 100%; flex: 1; min-height: 0; }

.chart-grid-line{ stroke: var(--ink); stroke-opacity: 0.06; stroke-width: 1; }
.chart-axis-label{ font-family: var(--font-mono); font-size: 11px; fill: var(--ink-faint); }
.chart-area{ opacity: 0.16; }
.chart-line{ fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot{ fill: var(--sky-top); stroke-width: 2.4; }

.stats-row{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-block{
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label{ font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value{ font-family: var(--font-mono); font-weight: 700; font-size: 24px; }
.stat-value small{ font-family: var(--font-body); font-weight: 500; font-size: 13px; color: var(--ink-faint); margin-left: 4px; }

/* ==========================================================================
   ACCESIBILIDAD / MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}

/* Fallback en pantallas angostas: se permite scroll para no romper el contenido */
@media (max-width: 900px){
  html, body{ overflow: auto; }
  .app{ height: auto; min-height: 100vh; }
  .stage{ padding: 16px; }
  .grid-actual{ grid-template-columns: 1fr; grid-template-areas: "condiciones" "viento" "precip" "sensores"; height: auto; }
  .row-main{ grid-template-columns: 1fr; }
  .timeline{ grid-template-columns: repeat(2, 1fr); }
  .sensor-bar{ flex-wrap: wrap; gap: 10px; }
  .controls-bar{ flex-direction: column; align-items: flex-start; gap: 12px; }
}
