/* =========================================================
   BASE — variables de diseño, reset y componentes comunes
   ========================================================= */
:root {
  --verde: #58cc02;
  --verde-oscuro: #46a302;
  --verde-claro: #d7ffb8;
  --azul: #186ab4;          /* azul NAF */
  --azul-oscuro: #12528c;
  --rojo: #ff4b4b;
  --rojo-oscuro: #ea2b2b;
  --rojo-claro: #ffdfe0;
  --naranja: #ff9600;
  --dorado: #ffc800;
  --dorado-oscuro: #e5a400;

  --fondo: #ffffff;
  --superficie: #ffffff;
  --superficie-2: #f7f7f7;
  --borde: #e5e5e5;
  --texto: #3c3c3c;
  --texto-suave: #777777;
  --bloqueado: #e5e5e5;
  --bloqueado-oscuro: #c8c8c8;
  --exito-fondo: #d7ffb8;
  --exito-texto: #58a700;
  --error-fondo: #ffdfe0;
  --error-texto: #ea2b2b;
  --morado: #ce82ff;
  /* Estados de las opciones y del ítem activo de la navegación */
  --sel-fondo: #e3f0fb; --sel-borde: #8ec0ea; --sel-texto: #186ab4;
  --ok-fondo: #d7ffb8;  --ok-borde: #a5ed6e;  --ok-texto: #58a700;
  --mal-fondo: #ffdfe0; --mal-borde: #ffb2b2; --mal-texto: #ea2b2b;

  /* Marca: NAF (azul y rojo del símbolo) y CERTUS (azul marino) */
  --naf-azul: #186ab4;
  --naf-rojo: #ef1923;
  --certus: #00205b;
  --certus-texto: #ffffff;
  --certus-acento: #8fc3f2;  /* celeste legible sobre el azul marino (que no cambia con el tema) */
  --placa: #ffffff;          /* fondo blanco fijo detrás de los logos, en ambos temas */

  --radio: 16px;
  --sombra: 0 2px 0 var(--borde);
  --fuente: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Tema oscuro: sigue al sistema salvo que se elija «claro» a mano (data-theme), y también se puede forzar */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #131f24;
    --superficie: #131f24;
    --superficie-2: #1f2f36;
    --borde: #37464f;
    --texto: #f1f7fb;
    --texto-suave: #8fa3ad;
    --bloqueado: #37464f;
    --bloqueado-oscuro: #2a3840;
    --exito-fondo: #202f36;
    --exito-texto: #79d634;
    --error-fondo: #202f36;
    --error-texto: #ff6b6b;
    --sel-fondo: #13304a; --sel-borde: #2f6fa8; --sel-texto: #7cbcf2;
    --azul: #5aa9ef; --azul-oscuro: #2f6fa8;
    --ok-fondo: #1f3a12;  --ok-borde: #4c8a1c;  --ok-texto: #79d634;
    --mal-fondo: #3d1d1f; --mal-borde: #8a3034; --mal-texto: #ff6b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #131f24;
  --superficie: #131f24;
  --superficie-2: #1f2f36;
  --borde: #37464f;
  --texto: #f1f7fb;
  --texto-suave: #8fa3ad;
  --bloqueado: #37464f;
  --bloqueado-oscuro: #2a3840;
  --exito-fondo: #202f36;
  --exito-texto: #79d634;
  --error-fondo: #202f36;
  --error-texto: #ff6b6b;
  --sel-fondo: #13304a; --sel-borde: #2f6fa8; --sel-texto: #7cbcf2;
    --azul: #5aa9ef; --azul-oscuro: #2f6fa8;
  --ok-fondo: #1f3a12;  --ok-borde: #4c8a1c;  --ok-texto: #79d634;
  --mal-fondo: #3d1d1f; --mal-borde: #8a3034; --mal-texto: #ff6b6b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fuente);
  background: var(--fondo);
  color: var(--texto);
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.visualmente-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html, body { overscroll-behavior-y: none; } /* sin «rebote» ni pull-to-refresh: se siente como app */
button {
  font-family: inherit; cursor: pointer;
  touch-action: manipulation;              /* sin retraso ni zoom por doble toque */
  -webkit-user-select: none; user-select: none;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* ---------- Botones 3D estilo Duolingo ---------- */
.btn {
  --c: var(--verde);
  --c-osc: var(--verde-oscuro);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 24px;
  border: none; border-radius: var(--radio);
  background: var(--c); color: #fff;
  font-size: 15px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  box-shadow: 0 4px 0 var(--c-osc);
  transition: transform .05s, filter .15s;
}
@media (hover: hover) {
  .btn:hover:not(:disabled) { filter: brightness(1.06); }
  .btn-icono:hover { background: var(--superficie-2); }
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.btn:disabled { background: var(--bloqueado); color: var(--texto-suave); box-shadow: 0 4px 0 var(--bloqueado-oscuro); cursor: default; }
.btn-azul { --c: var(--azul); --c-osc: var(--azul-oscuro); }
.btn-rojo { --c: var(--rojo); --c-osc: var(--rojo-oscuro); }
.btn-blanco { --c: var(--superficie); --c-osc: var(--borde); color: var(--azul); border: 2px solid var(--borde); }
.btn-bloque { width: 100%; }

.btn-icono {
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: transparent; color: var(--texto-suave);
  font-size: 22px; font-weight: 900;
}

/* ---------- Tarjetas ---------- */
.tarjeta {
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  padding: 20px;
  background: var(--superficie);
}

.chip {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--superficie-2); color: var(--texto-suave);
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-fondo { position: absolute; inset: 0; background: rgba(0,0,0,.5); animation: aparecer .2s; }
.modal-caja {
  position: relative; width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--superficie); border-radius: 20px; padding: 28px 24px 24px;
  animation: subir .25s ease-out;
}
.modal-cerrar { position: absolute; top: 12px; right: 12px; }

/* En celular el modal es una «hoja» que sube desde abajo, como en las apps nativas */
@media (max-width: 640px) {
  .modal { place-items: end stretch; padding: 0; }
  .modal-caja {
    width: 100%; max-height: 88dvh;
    border-radius: 24px 24px 0 0;
    padding: 30px 20px calc(24px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    animation: hoja .28s ease-out;
  }
  .modal-caja::before { /* «agarradera» de la hoja */
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 5px; border-radius: 3px; background: var(--borde);
  }
}
@keyframes hoja { from { transform: translateY(100%); } to { transform: none; } }

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes latido { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes rebote { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes sacudir { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

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