/* ═══════════════════════════════════════════════════════
   ¿Cómo están los embalses? — hoja de estilo

   Dirección visual: cartel del DIVEDCO. Los afiches de servicio
   público que se imprimieron desde los años 40 para llevar mensajes
   de salud y agua al campo puertorriqueño. Color plano, tipografía
   gruesa, titular directo. Mismo trabajo que hace esta página.

   Texturas: losa hidráulica (el piso estampado de las casas viejas)
   y adoquín (el azul-gris de las piedras del Viejo San Juan).

   Móvil primero. Claro por defecto porque se lee mejor bajo el sol.
   ═══════════════════════════════════════════════════════ */

:root {
  /* Superficies: cal y losa */
  --cal:        #EDF1F0;   /* pared encalada con tinte de mar */
  --losa:       #FBFCFB;   /* la losa clara */
  --losa-honda: #E2E9E9;
  --linea:      #C6D3D5;
  --linea-suave: rgba(198, 211, 213, .55);

  /* Tinta: adoquín del Viejo San Juan */
  --adoquin:  #26343B;
  --tenue:    #5A7078;
  --tenue-2:  #85999F;

  /* Acentos de la isla */
  --anil:      #1B5E82;   /* el azul de puertas y persianas */
  --flamboyan: #D6342C;   /* el árbol que florece justo en esta temporada */
  --guayaba:   #E8A33D;

  /* Fases de alerta de la AAA. Son datos, no decoración: se mantienen
     reconocibles contra el boletín, solo templadas hacia esta paleta. */
  --desborde:    #6B4E96;
  --seguridad:   #4E8B3A;
  --observacion: #1B7A93;
  --ajustes:     #D18A1E;
  --control:     #D2601A;
  --fuera:       #C21F31;

  --display: "Archivo", system-ui, sans-serif;
  --texto:   "IBM Plex Sans", system-ui, sans-serif;
  --dato:    "IBM Plex Mono", ui-monospace, monospace;

  --radio: 3px;
  --ancho: 900px;

}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--cal);
  color: var(--adoquin);
  font-family: var(--texto);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 3rem;
  overflow-x: hidden;
}
.envoltura { max-width: var(--ancho); margin: 0 auto; padding: 0 1rem; position: relative; z-index: 1; }

a { color: var(--anil); }
:focus-visible { outline: 2.5px solid var(--anil); outline-offset: 3px; border-radius: 2px; }

/* ── Encabezado con banda de losa ───────────────── */
.cabezal {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.4rem 0 1.1rem;
}
.logo {
  font-family: var(--display); font-weight: 800;
  /* El nombre es una pregunta larga en dos líneas: la tipografía cede en
     pantallas angostas para que nunca se desborde. */
  font-size: clamp(1.4rem, 6.5vw, 2rem);
  line-height: .95; letter-spacing: -.035em; color: var(--adoquin);
}
/* Los signos de interrogación en flamboyán: son el acento de la marca. */
.logo-signo, .logo b { color: var(--flamboyan); }
.logo-signo { margin-left: -.05em; }
.lema { font-size: .8rem; color: var(--tenue); margin-top: .3rem; }
.cabezal-der { display: flex; align-items: center; gap: .75rem; }
#sello { font-family: var(--dato); font-size: .68rem; color: var(--tenue-2); text-align: right; }

.boton {
  font-family: var(--dato); font-size: .68rem; letter-spacing: .07em;
  background: var(--losa); border: 1.5px solid var(--adoquin); color: var(--adoquin);
  padding: .42rem .8rem; border-radius: var(--radio); cursor: pointer;
  transition: background .15s, color .15s;
}
.boton:hover { background: var(--adoquin); color: var(--losa); }
.boton[disabled] { opacity: .4; cursor: wait; }

/* ── Buscador por pueblo ────────────────────────── */
.buscador { margin-bottom: 1rem; }
.buscador-rotulo {
  display: block; font-family: var(--dato); font-size: .68rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--tenue); margin-bottom: .4rem;
}
.buscador-campo {
  width: 100%; max-width: 30rem; font: inherit; font-size: .95rem;
  padding: .55rem .8rem; border: 1.5px solid var(--linea);
  border-radius: var(--radio); background: var(--losa); color: inherit;
}
.buscador-campo:focus { outline: none; border-color: var(--anil); }
.buscador-resultado { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .45rem; }
.buscador-ficha {
  font: inherit; font-size: .85rem; background: var(--losa);
  border: 1.5px solid var(--anil); color: inherit;
  border-radius: var(--radio); padding: .4rem .7rem; cursor: pointer;
}
.buscador-ficha:hover { background: var(--anil); color: var(--cal); }
.buscador-ficha:hover b { color: var(--cal); }
.buscador-ficha b { color: var(--anil); }
.buscador-vacio { font-size: .83rem; color: var(--tenue); max-width: 52ch; }
.buscador-frase { flex-basis: 100%; font-size: .88rem; color: var(--tenue); max-width: 60ch; }
.buscador-frase strong { color: var(--adoquin); }

/* ── Selector de embalses ───────────────────────── */
.selector-envoltura { position: sticky; top: 0; z-index: 20; background: var(--cal); padding: .85rem 0 .8rem; }
.selector-rotulo {
  font-family: var(--display); font-weight: 700; font-size: .74rem;
  letter-spacing: .15em; text-transform: uppercase; color: var(--tenue);
  margin-bottom: .55rem;
}
.selector {
  display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem;
  scrollbar-width: thin; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.selector::-webkit-scrollbar { height: 3px; }
.selector::-webkit-scrollbar-thumb { background: var(--linea); border-radius: 2px; }

.ficha {
  display: flex; align-items: center; gap: .55rem;
  flex: 0 0 auto; scroll-snap-align: start;
  background: var(--losa); border: 1.5px solid var(--linea);
  border-radius: var(--radio); padding: .58rem .85rem;
  cursor: pointer; text-align: left; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.ficha:hover { border-color: var(--tono); }
.ficha:active { transform: scale(.98); }
.ficha.activa { border-color: var(--tono); box-shadow: inset 0 -3px 0 var(--tono); }
.ficha-punto { width: 10px; height: 10px; border-radius: 50%; background: var(--tono); flex-shrink: 0; }
.ficha-texto { display: flex; flex-direction: column; min-width: 0; }
.ficha-nombre { font-family: var(--display); font-weight: 700; font-size: 1rem; line-height: 1.15; white-space: nowrap; letter-spacing: -.015em; }
.ficha-fase { font-size: .66rem; color: var(--tenue-2); white-space: nowrap; }
.ficha.activa .ficha-fase { color: var(--tono); font-weight: 500; }

/* ── Estado: el titular del cartel ──────────────── */
.estado {
  background: var(--losa); border: 1.5px solid var(--adoquin);
  border-left: 6px solid var(--tono);
  border-radius: var(--radio); padding: 1.2rem 1.2rem 1.3rem; margin-bottom: 1rem;
}
.estado-cinta {
  display: inline-block; font-family: var(--display); font-weight: 700;
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  background: var(--tono); color: #fff;
  padding: .25rem .6rem; border-radius: 2px; margin-bottom: .65rem;
}
.estado-titular { font-family: var(--display); font-weight: 800; font-size: 1.85rem; line-height: 1.08; letter-spacing: -.03em; margin-bottom: .55rem; }
.estado-explica { font-size: .95rem; color: #3E5158; max-width: 62ch; }
.estado-accion { font-size: .9rem; color: var(--tenue); margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--linea-suave); }
.estado-accion strong { color: var(--flamboyan); font-weight: 600; }

/* ── Resumen: la respuesta en cinco segundos ────── */
.resumen {
  background: var(--losa); border: 1.5px solid var(--adoquin);
  border-left: 6px solid var(--tono);
  border-radius: var(--radio); padding: 1.2rem 1.2rem 1.3rem; margin-bottom: 1rem;
}
.respuestas {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  margin-top: .9rem;
}
/* En celular apiladas: tres columnas dejarían los números ilegibles. */
@media (max-width: 560px) { .respuestas { grid-template-columns: 1fr; gap: .35rem; } }

.respuesta {
  display: flex; flex-direction: column; gap: .12rem;
  background: var(--losa-honda); border-radius: var(--radio);
  padding: .65rem .75rem;
}
.respuesta-rotulo {
  font-family: var(--display); font-weight: 700; font-size: .64rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--tenue);
}
.respuesta-valor {
  font-family: var(--display); font-weight: 800; font-size: 1.5rem;
  line-height: 1.05; letter-spacing: -.03em; color: var(--adoquin);
}
.respuesta-valor small { font-size: .9rem; font-weight: 600; color: var(--tenue); }
.respuesta-nota { font-size: .76rem; color: var(--tenue); line-height: 1.3; }
.respuesta-nota.baja, .respuesta-nota.malo { color: var(--flamboyan); }
.respuesta-nota.sube, .respuesta-nota.bueno { color: var(--seguridad); }
.respuesta-nota.regular { color: var(--ajustes); }

/* ── Corte hacia el detalle ─────────────────────── */
.corte {
  font-family: var(--display); font-weight: 800; font-size: 1.1rem;
  letter-spacing: -.02em; color: var(--tenue);
  padding-top: 1.4rem; margin-bottom: .2rem;
  border-top: 1.5px solid var(--linea);
}
.corte-sub { font-size: .9rem; color: var(--tenue); max-width: 62ch; margin-bottom: 1rem; }

/* ── A quién suple ──────────────────────────────── */
.abastece {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  background: var(--losa-honda); border-radius: var(--radio);
  padding: .7rem .9rem; margin-bottom: 1rem;
}
.abastece-rotulo { font-family: var(--display); font-weight: 700; font-size: .7rem; color: var(--tenue); text-transform: uppercase; letter-spacing: .1em; }
.abastece-lista { display: flex; gap: .35rem; flex-wrap: wrap; }
.pueblo { font-size: .82rem; background: var(--losa); border: 1px solid var(--linea); padding: .12rem .5rem; border-radius: 2px; }
.abastece-nota { font-family: var(--dato); font-size: .7rem; color: var(--tenue-2); margin-left: auto; }

/* ── Panel principal ────────────────────────────── */
.panel { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (min-width: 660px) { .panel { grid-template-columns: 210px 1fr; gap: 1.25rem; } }

.panel-medidor { background: var(--losa); border: 1.5px solid var(--linea); border-radius: var(--radio); padding: 1rem; }
.medidor-svg { display: block; width: 100%; max-width: 200px; height: auto; margin: 0 auto; }
.medidor-banda { font-family: var(--display); font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.medidor-cota { font-family: var(--dato); font-size: 8.5px; fill: var(--tenue); }
.medidor-linea { stroke: #fff; stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .85; }
.medidor-proyeccion { stroke: var(--flamboyan); stroke-width: 1.5; stroke-dasharray: 3 4; }
.medidor-marco { fill: none; stroke: var(--adoquin); stroke-width: 1.5; }
.medidor-pie { font-size: .72rem; color: var(--tenue-2); text-align: center; margin-top: .75rem; line-height: 1.4; }

.panel-datos { display: flex; flex-direction: column; gap: .7rem; }
.dato-grande { background: var(--adoquin); color: var(--losa); border-radius: var(--radio); padding: 1.05rem 1.15rem; }
.dato-num { font-family: var(--dato); font-weight: 600; font-size: 3rem; line-height: .95; letter-spacing: -.04em; }
.dato-unidad { font-family: var(--dato); font-size: 1rem; opacity: .65; margin-left: .35rem; }
.dato-fuente { display: block; font-size: .71rem; opacity: .6; margin-top: .5rem; }

.tarjeta { background: var(--losa); border: 1.5px solid var(--linea); border-radius: var(--radio); padding: .8rem .95rem; }
.tarjeta.destacada { border-color: var(--adoquin); border-width: 2px; }
.tarjeta-rotulo { font-family: var(--display); font-weight: 700; font-size: .68rem; color: var(--tenue); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .25rem; }
.tarjeta-valor { font-family: var(--dato); font-weight: 600; font-size: 1.5rem; line-height: 1.1; }
.tarjeta-nota { font-size: .8rem; color: var(--tenue); margin-top: .3rem; }
.tarjeta-aviso { font-size: .74rem; color: var(--control); margin-top: .45rem; }
.sube { color: var(--seguridad); }
.baja { color: var(--control); }
.igual { color: var(--tenue); }

/* ── Veredicto ──────────────────────────────────── */
.veredicto {
  background: var(--losa); border: 1.5px solid var(--linea);
  border-left: 6px solid var(--tenue-2);
  border-radius: var(--radio); padding: 1.15rem 1.2rem; margin-bottom: 1.25rem;
}
.veredicto.bueno   { border-left-color: var(--seguridad); }
.veredicto.regular { border-left-color: var(--ajustes); }
.veredicto.malo    { border-left-color: var(--flamboyan); }
.veredicto-rotulo { font-family: var(--display); font-weight: 700; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--tenue); margin-bottom: .45rem; }
.veredicto h3 { font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1.12; letter-spacing: -.025em; margin-bottom: .45rem; }
.veredicto p { font-size: .9rem; color: #3E5158; max-width: 62ch; }
.veredicto-clave { font-size: .82rem !important; color: var(--tenue) !important; margin-top: .65rem; padding-top: .6rem; border-top: 1px solid var(--linea-suave); }

/* ── Bloques ────────────────────────────────────── */
.bloque { background: var(--losa); border: 1.5px solid var(--linea); border-radius: var(--radio); padding: 1.15rem; margin-bottom: 1.25rem; }
.bloque-titulo { font-family: var(--display); font-weight: 800; font-size: 1.4rem; letter-spacing: -.025em; }
.bloque-sub { font-size: .85rem; color: var(--tenue); margin-top: .2rem; margin-bottom: .9rem; max-width: 62ch; }
.vacio { font-size: .85rem; color: var(--tenue-2); padding: 1rem 0; }

/* ── Ríos ───────────────────────────────────────── */
.rios { display: flex; flex-direction: column; }
.rio { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--linea-suave); }
.rio:last-child { border-bottom: none; }
.rio-nombre { font-size: .84rem; color: var(--tenue); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chispa { width: 80px; height: 24px; flex-shrink: 0; color: var(--tenue-2); }
.chispa.sube { color: var(--seguridad); }
.rio-valor { font-family: var(--dato); font-size: .84rem; width: 92px; text-align: right; flex-shrink: 0; }
.rio-valor small { font-size: .66rem; color: var(--tenue-2); }
.rios-veredicto { font-size: .84rem; color: var(--tenue); margin-top: .75rem; padding-top: .7rem; border-top: 1.5px solid var(--linea); }
.rios-veredicto.sube { color: var(--seguridad); font-weight: 500; }

/* ── Histórico día a día ────────────────────────── */
.hist-svg { width: 100%; height: auto; display: block; margin-top: .4rem; }
.hist-linea {
  fill: none; stroke: var(--anil); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
.hist-punto { fill: var(--anil); }
.hist-valor { font-family: var(--dato); font-size: 11px; font-weight: 600; fill: var(--adoquin); }
.hist-cota { stroke-dasharray: 4 5; stroke-width: 1.2; opacity: .55; }
.hist-cota-rotulo {
  font-family: var(--dato); font-size: 9.5px; letter-spacing: .04em;
  /* Halo del color del fondo: el rótulo se lee aunque pise la línea punteada. */
  paint-order: stroke; stroke: var(--cal); stroke-width: 3px; stroke-linejoin: round;
}
.hist-eje { font-family: var(--dato); font-size: 10px; fill: var(--tenue-2); }
.hist-toque { fill: transparent; }

/* ── Lluvia ─────────────────────────────────────── */
.lluvia-total { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .9rem; }
.lluvia-num { font-family: var(--dato); font-weight: 600; font-size: 2.2rem; line-height: 1; letter-spacing: -.035em; color: var(--anil); }
.lluvia-unidad { font-size: .85rem; color: var(--tenue); }

.barras { display: flex; align-items: flex-end; gap: 3px; height: 96px; border-bottom: 1.5px solid var(--adoquin); }
.barra { flex: 1; background: var(--losa-honda); min-height: 3px; transition: height .45s cubic-bezier(.2,.7,.3,1); }
.barra.mojada { background: var(--anil); }
.barras-eje { display: flex; justify-content: space-between; font-family: var(--dato); font-size: .64rem; color: var(--tenue-2); margin-top: .35rem; }

.perilla { margin-top: 1.25rem; padding-top: 1.15rem; border-top: 1.5px solid var(--linea); }
.perilla-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .55rem; }
.perilla-fila label { font-size: .88rem; font-weight: 500; }
.perilla-fila output { font-family: var(--dato); font-weight: 600; font-size: 1.15rem; color: var(--anil); }
input[type=range] { width: 100%; accent-color: var(--anil); height: 26px; cursor: pointer; }
.perilla-nota { font-size: .8rem; color: var(--tenue); margin-top: .55rem; line-height: 1.5; max-width: 62ch; }

.resultado { margin-top: 1rem; padding: .95rem 1rem; background: var(--losa-honda); border-left: 4px solid var(--anil); border-radius: 0 var(--radio) var(--radio) 0; }
.resultado-frase { font-size: .95rem; }
.resultado-frase strong { color: var(--anil); }
.resultado-traduccion { font-size: .88rem; color: var(--tenue); margin-top: .4rem; }
.resultado-traduccion strong { color: var(--seguridad); }
.resultado-cuenta { font-family: var(--dato); font-size: .69rem; color: var(--tenue-2); margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--linea); }

/* ── Avisos y publicidad ────────────────────────── */
.aviso {
  padding: .78rem .95rem; border-radius: var(--radio); font-size: .82rem;
  background: #FBF0DA; border: 1.5px solid var(--guayaba);
  color: #7A5410; margin-bottom: 1rem;
}
.espacio-ad { min-height: 100px; display: flex; align-items: center; justify-content: center; margin: 1.25rem 0; }
.ad-etiqueta { position: absolute; top: .5rem; left: .85rem; font-family: var(--dato); font-size: .57rem; letter-spacing: .1em; text-transform: uppercase; color: var(--tenue-2); }
.ad-casa { position: relative; width: 100%; background: var(--losa); border: 1.5px dashed var(--linea); border-radius: var(--radio); padding: 1.65rem 1rem 1.05rem; }
.ad-casa strong { font-family: var(--display); font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; display: block; margin-bottom: .25rem; }
.ad-casa p { font-size: .84rem; color: var(--tenue); max-width: 58ch; }

/* ── Ayuda y pie ────────────────────────────────── */
.ayuda { background: var(--losa); border: 1.5px solid var(--linea); border-radius: var(--radio); margin-bottom: 1.25rem; }
.ayuda summary { padding: .9rem 1.15rem; cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; list-style: none; }
.ayuda summary::-webkit-details-marker { display: none; }
.ayuda summary::after { content: "＋"; float: right; color: var(--flamboyan); font-weight: 400; }
.ayuda[open] summary::after { content: "－"; }
.ayuda-cuerpo { padding: 0 1.15rem 1.15rem; }
.ayuda-cuerpo dt { font-family: var(--display); font-weight: 700; font-size: 1rem; margin-top: .95rem; letter-spacing: -.015em; }
.ayuda-cuerpo dd { font-size: .87rem; color: var(--tenue); margin-top: .15rem; max-width: 64ch; }

.pie { margin-top: 2.5rem; padding-top: 1.35rem; border-top: 3px solid var(--adoquin); font-size: .78rem; color: var(--tenue); line-height: 1.65; }
.pie p + p { margin-top: .6rem; }
.pie strong { color: var(--adoquin); }
.pie a { color: var(--anil); text-decoration: none; border-bottom: 1px solid var(--linea); }
.pie a:hover { border-bottom-color: var(--anil); }
.pie-legal { margin-top: 1.15rem; padding-top: .95rem; border-top: 1px solid var(--linea-suave); font-size: .74rem; color: var(--tenue-2); }

/* ── De noche: el Viejo San Juan con las farolas prendidas ── */
@media (prefers-color-scheme: dark) {
  :root {
    --cal:        #16232A;
    --losa:       #1D2F37;
    --losa-honda: #243A43;
    --linea:      #33505C;
    --linea-suave: rgba(51, 80, 92, .5);
    --adoquin:    #E8EFEE;
    --tenue:      #9DB3BA;
    --tenue-2:    #74909A;
    --anil:       #5AAFD0;
    --flamboyan:  #F2685E;
    --guayaba:    #E8A33D;
    --seguridad:   #6FB84F;
    --observacion: #3FA6C0;
    --ajustes:     #E8A93A;
    --control:     #EC7C34;
    --fuera:       #E14456;
    --desborde:    #9273C4;
  }
  .dato-grande { background: var(--losa-honda); color: var(--adoquin); }
  .estado-cinta { color: #16232A; }
  .medidor-linea { stroke: var(--cal); }
  .aviso { background: rgba(232,163,61,.12); color: #F0C87E; }
  .boton:hover { background: var(--adoquin); color: var(--cal); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
