/* ==========================================================================
   ONG USAR Ñuble — Sistema de diseño
   --------------------------------------------------------------------------
   Base común para el sitio público, los accesos y los portales.
   Identidad: azul noche (operación), naranja del triángulo de protección
   civil del escudo y celeste de los uniformes institucionales.

   1. Tokens   2. Base   3. Tipografía   4. Marca   5. Botones
   6. Formularios   7. Mensajes e insignias   8. Utilidades
   ========================================================================== */

/* 0. Fuentes (alojadas en el sitio: no dependen de Google) --------------------- */

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fuentes/barlow-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fuentes/barlow-latin-500-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fuentes/barlow-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fuentes/barlow-latin-700-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fuentes/barlow-condensed-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fuentes/barlow-condensed-latin-700-normal.woff2") format("woff2");
}

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  /* Azul noche */
  --noche: #0a1828;
  --noche-2: #10233a;
  --noche-3: #19324f;
  --noche-4: #24456a;
  /* Naranja protección civil */
  --naranja: #f07a2a;
  --naranja-2: #f5934f;
  --naranja-osc: #b4500e;     /* texto naranja sobre fondo claro (AA) */
  --naranja-suave: #fdeee3;
  /* Celeste uniforme */
  --celeste: #5bb8e6;
  --celeste-osc: #1d6f9c;     /* enlaces sobre fondo claro (AA) */
  --celeste-suave: #e6f4fb;
  /* Neutros */
  --blanco: #ffffff;
  --papel: #f3f5f8;
  --papel-2: #e9edf2;
  --tinta: #0f1d2c;
  --tinta-2: #44546a;
  --tinta-3: #6c7a8c;
  --linea: #dce2e9;
  --linea-2: #c7d0db;
  --linea-oscura: rgba(255, 255, 255, 0.12);
  --sobre-noche: #e8eef5;
  --sobre-noche-2: #a9b8c9;
  /* Estados */
  --ok: #17803d;
  --ok-suave: #e3f4e9;
  --alerta: #a35b00;
  --alerta-suave: #fff3df;
  --peligro: #c0182f;
  --peligro-suave: #fde8eb;

  /* Tipografía */
  --f-titulo: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-texto: "Barlow", "Segoe UI", system-ui, sans-serif;

  /* Escala */
  --t-xs: 0.78rem;
  --t-s: 0.9rem;
  --t-m: 1.0625rem;
  --t-l: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem);
  --t-xl: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --t-2xl: clamp(2rem, 1.5rem + 2.2vw, 3.1rem);
  --t-3xl: clamp(2.6rem, 1.6rem + 4.4vw, 5.2rem);

  /* Espacio y forma */
  --gutter: clamp(16px, 4vw, 48px);
  --ancho: 1240px;
  --r: 6px;
  --r-l: 12px;
  --sombra: 0 1px 2px rgba(15, 29, 44, 0.06), 0 12px 32px -16px rgba(15, 29, 44, 0.22);
  --sombra-l: 0 30px 70px -30px rgba(10, 24, 40, 0.45);
  --salida: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

/* 2. Base ------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--blanco);
  color: var(--tinta);
  font: 400 var(--t-m) / 1.6 var(--f-texto);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: var(--celeste-osc);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--naranja);
  outline-offset: 2px;
}

::selection {
  background: var(--naranja);
  color: var(--noche);
}

[hidden] {
  display: none !important;
}

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

/* 3. Tipografía ------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--f-titulo);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

h3 {
  font-weight: 600;
  line-height: 1.15;
}

p {
  margin: 0;
  text-wrap: pretty;
}

.rotulo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 600 var(--t-xs) / 1 var(--f-texto);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--naranja-osc);
}

/* Triángulo de protección civil como marcador */
.rotulo::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 10px solid var(--naranja);
}

.oscuro .rotulo,
.rotulo.claro {
  color: var(--naranja-2);
}

.entradilla {
  font-size: var(--t-l);
  line-height: 1.55;
  color: var(--tinta-2);
  max-width: 60ch;
}

.oscuro {
  background: var(--noche);
  color: var(--sobre-noche);
}

.oscuro .entradilla {
  color: var(--sobre-noche-2);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* 4. Marca -------------------------------------------------------------------- */

.marca {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.marca img {
  width: 46px;
  height: 46px;
  flex: none;
}

.marca-texto {
  display: grid;
  gap: 3px;
  line-height: 1;
}

.marca-texto strong {
  font: 700 1.28rem / 1 var(--f-titulo);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.marca-texto small {
  font: 500 0.68rem / 1 var(--f-texto);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

/* 5. Botones ------------------------------------------------------------------ */

.boton {
  --b-fondo: var(--noche);
  --b-texto: var(--blanco);
  --b-borde: transparent;
  --b-hover: var(--noche-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1.5px solid var(--b-borde);
  border-radius: var(--r);
  background: var(--b-fondo);
  color: var(--b-texto);
  font: 600 0.98rem / 1 var(--f-texto);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s var(--salida);
}

.boton:hover {
  background: var(--b-hover);
}

.boton:active {
  transform: translateY(1px);
}

.boton:disabled {
  opacity: 0.6;
  cursor: progress;
}

.boton svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.boton--naranja {
  --b-fondo: var(--naranja);
  --b-texto: var(--noche);
  --b-hover: var(--naranja-2);
}

.boton--contorno {
  --b-fondo: transparent;
  --b-texto: var(--tinta);
  --b-borde: var(--linea-2);
  --b-hover: var(--papel);
}

.oscuro .boton--contorno,
.boton--contorno.claro {
  --b-texto: var(--blanco);
  --b-borde: rgba(255, 255, 255, 0.35);
  --b-hover: rgba(255, 255, 255, 0.08);
}

.boton--bloque {
  width: 100%;
}

.boton--chico {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.88rem;
}

.enlace-flecha {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  text-decoration: none;
  color: var(--celeste-osc);
}

.enlace-flecha::after {
  content: "→";
  transition: transform 0.2s var(--salida);
}

.enlace-flecha:hover::after {
  transform: translateX(4px);
}

/* 6. Formularios ---------------------------------------------------------------- */

.campo,
.fg {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.campo label,
.fg label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--tinta);
}

.campo label .req,
.fg label span {
  color: var(--peligro);
  font-weight: 700;
}

.campo input,
.campo select,
.campo textarea,
.fg input,
.fg select,
.fg textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--linea-2);
  border-radius: var(--r);
  background: var(--blanco);
  color: var(--tinta);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.campo textarea,
.fg textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus,
.fg input:focus,
.fg select:focus,
.fg textarea:focus {
  outline: none;
  border-color: var(--celeste-osc);
  box-shadow: 0 0 0 4px rgba(29, 111, 156, 0.15);
}

.campo [aria-invalid="true"],
.fg [aria-invalid="true"] {
  border-color: var(--peligro);
}

.campo .ayuda {
  font-size: 0.82rem;
  color: var(--tinta-3);
}

.campo .error-campo {
  font-size: 0.82rem;
  color: var(--peligro);
  font-weight: 600;
}

.casilla {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  font-size: 0.94rem;
  color: var(--tinta-2);
  cursor: pointer;
}

.casilla input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--naranja-osc);
}

/* 7. Mensajes e insignias ---------------------------------------------------------- */

/* Mensajes que muestran auth.js y registro.js (clases existentes) */
.auth-msg {
  display: none;
  padding: 13px 16px;
  border-radius: var(--r);
  border-left: 4px solid var(--peligro);
  background: var(--peligro-suave);
  color: #7d0f1f;
  font-size: 0.94rem;
  line-height: 1.45;
}

.auth-msg.exito {
  border-left-color: var(--ok);
  background: var(--ok-suave);
  color: #0d5a2a;
}

.insignia {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font: 600 0.74rem / 1 var(--f-texto);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--papel-2);
  color: var(--tinta-2);
  white-space: nowrap;
}

/* 8. Utilidades ------------------------------------------------------------------- */

.contenedor {
  width: 100%;
  max-width: var(--ancho);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.solo-lectores {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.saltar {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--naranja);
  color: var(--noche);
  font-weight: 700;
  text-decoration: none;
}

.saltar:focus {
  top: 16px;
}

.icono {
  width: 22px;
  height: 22px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Aviso de conexión (config.js) ---------- */
.aviso-conexion {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 9999;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--peligro);
  color: var(--blanco);
  font: 600 var(--t-s) / 1.4 var(--f-texto);
  text-align: center;
  box-shadow: 0 10px 30px rgba(10, 24, 40, 0.3);
}
.aviso-conexion.ok { background: var(--ok); }

/* ---------- Campo trampa de formularios (no visible para personas) ---------- */
.campo-trampa {
  position: absolute !important;
  left: -10000px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

[aria-busy="true"] { cursor: progress; }
