/* =========================================================================
   TusRifas: base.css
   Tokens de diseño, reset, tipografía y piezas atómicas (botones,
   formularios, chips, badges). Cargar SIEMPRE primero.
   ========================================================================= */

:root {
  /* Paleta: celeste y sol de la bandera + tinta de talonario impreso */
  --tinta: #0F2B46;
  --tinta-80: #2A4561;
  --tinta-60: #51677E;
  --celeste: #2F7FC8;
  --celeste-texto: #1D65A6;
  --celeste-50: #E8F2FB;
  --celeste-100: #CFE3F6;
  --sol: #F4B41A;
  --sol-hover: #E3A20A;
  --sol-50: #FFF5D9;
  --azul: #1565C0;
  --azul-hover: #0D4FA0;
  --azul-50: #EAF2FB;
  --azul-100: #D3E4F6;
  --indigo: #3F51B5;
  --papel: #EEF3F7;
  --blanco: #FFFFFF;
  --linea: #D2DCE6;
  --linea-fuerte: #A9BBCD;

  /* Estados */
  --ok: #17744A;       --ok-50: #E2F3EA;
  --alerta: #875800;   --alerta-50: #FFF1CC;
  --error: #B42318;    --error-50: #FDECEA;
  --neutro: #5B6B7C;   --neutro-50: #ECEFF3;

  /* Forma */
  --radio-s: 6px;
  --radio-m: 10px;
  --radio-l: 16px;
  --sombra: 0 1px 2px rgba(15, 43, 70, .08), 0 10px 28px -14px rgba(15, 43, 70, .28);
  --sombra-alta: 0 24px 60px -20px rgba(15, 43, 70, .45);

  /* Tipografía: una sola familia (Archivo) jugando con su eje de ancho */
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --ancho-expandido: 100%;
  --ancho-condensado: 92%;

  --t-xs: .8125rem;   /* 13 */
  --t-s: .875rem;     /* 14 */
  --t-m: 1rem;        /* 16 */
  --t-l: 1.1875rem;   /* 19 */
  --t-xl: 1.5rem;     /* 24 */
  --t-2xl: 2rem;      /* 32 */
  --t-3xl: clamp(2.125rem, 1.4rem + 3vw, 3.5rem);

  --ancho-max: 1200px;
  --header-h: 68px;
  --foco: 0 0 0 3px var(--blanco), 0 0 0 6px var(--celeste);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  font-family: var(--font);
  font-size: var(--t-m);
  line-height: 1.55;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--celeste-texto); text-underline-offset: .18em; }
a:hover { color: var(--tinta); }
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: var(--radio-s); }
[hidden] { display: none !important; }
::selection { background: var(--sol); color: var(--tinta); }

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

/* ---------- Tipografía ---------- */
h1, h2, h3, h4 { line-height: 1.15; font-weight: 700; letter-spacing: -.015em; font-stretch: var(--ancho-expandido); }
h1 { letter-spacing: -.025em; line-height: 1.08; }
h1 { font-size: var(--t-3xl); }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-l); }
p { max-width: 68ch; }
.lead { font-size: var(--t-l); color: var(--tinta-80); }
.texto-suave { color: var(--tinta-60); }
.texto-chico { font-size: var(--t-s); }
.num { font-stretch: var(--ancho-condensado); font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .01em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Contenedores ---------- */
.contenedor { width: min(100% - 2rem, var(--ancho-max)); margin-inline: auto; }
.seccion { padding-block: clamp(2.5rem, 5vw, 4.5rem); }
.seccion__titulo { margin-bottom: 1.5rem; }
.seccion__titulo p { margin-top: .5rem; }
.pila > * + * { margin-top: 1rem; }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--blanco); --btn-fg: var(--tinta); --btn-borde: var(--linea-fuerte);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .625rem 1.125rem;
  border: 1.5px solid var(--btn-borde); border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; font-size: var(--t-m); line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { --btn-borde: var(--tinta); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primario { --btn-bg: var(--sol); --btn-fg: var(--tinta); --btn-borde: var(--sol); }
.btn--primario:hover { --btn-bg: var(--sol-hover); --btn-borde: var(--sol-hover); }
.btn--tinta { --btn-bg: var(--tinta); --btn-fg: var(--blanco); --btn-borde: var(--tinta); }
.btn--tinta:hover { --btn-bg: var(--tinta-80); --btn-borde: var(--tinta-80); }
.btn--fantasma { --btn-bg: transparent; --btn-borde: transparent; padding-inline: .5rem; }
.btn--fantasma:hover { --btn-borde: transparent; text-decoration: underline; }
.btn--grande { min-height: 54px; font-size: var(--t-l); padding-inline: 1.5rem; }
.btn--bloque { width: 100%; }
.btn--chico { min-height: 36px; padding: .375rem .75rem; font-size: var(--t-s); }

/* ---------- Formularios ---------- */
.campo { display: grid; gap: .375rem; }
.campo + .campo { margin-top: 1rem; }
.campo label, .etiqueta { font-weight: 600; font-size: var(--t-s); }
.campo__ayuda { font-size: var(--t-xs); color: var(--tinta-60); }
.campo__error { font-size: var(--t-xs); color: var(--error); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: .625rem .875rem;
  border: 1.5px solid var(--linea); border-radius: 8px; background: var(--blanco);
  transition: border-color .15s;
}
.textarea { min-height: 120px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--linea-fuerte); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--celeste); box-shadow: 0 0 0 3px var(--celeste-100); }
.input[aria-invalid="true"] { border-color: var(--error); }
.input--con-icono { position: relative; }
.input--con-icono > i { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--tinta-60); pointer-events: none; }
.input--con-icono > .input { padding-left: 2.5rem; }
.campos-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.campos-fila > .campo + .campo { margin-top: 0; }

.check { display: flex; gap: .625rem; align-items: flex-start; font-size: var(--t-s); cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: .1rem; accent-color: var(--tinta); flex-shrink: 0; }

/* ---------- Chips y badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .375rem;
  min-height: 36px; padding: .375rem .875rem; border-radius: 999px;
  border: 1.5px solid var(--linea); background: var(--blanco);
  font-size: var(--t-s); font-weight: 600;
}
.chip[aria-pressed="true"], .chip.is-activo { background: var(--tinta); color: var(--blanco); border-color: var(--tinta); }
.chip:hover:not([aria-pressed="true"]):not(.is-activo) { border-color: var(--tinta-60); }
.chip__cuenta { font-stretch: var(--ancho-condensado); font-variant-numeric: tabular-nums; opacity: .75; }

.badge {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .1875rem .625rem; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 700; line-height: 1.4; white-space: nowrap;
  background: var(--neutro-50); color: var(--neutro);
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-50); color: var(--ok); }
.badge--alerta { background: var(--alerta-50); color: var(--alerta); }
.badge--info { background: var(--celeste-50); color: var(--celeste-texto); }
.badge--error { background: var(--error-50); color: var(--error); }
.badge--sol { background: var(--sol); color: var(--tinta); }
.badge--sol::before { display: none; }

/* Número de rifa en formato "boleto" */
.numero-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .125rem .5rem; border-radius: 5px;
  background: var(--sol-50); border: 1px dashed #D9A21C;
  font-stretch: var(--ancho-condensado); font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--t-s);
}
.numero-chip button { border: 0; background: none; padding: 0 0 0 .125rem; color: var(--tinta-60); line-height: 1; }
.numero-chip button:hover { color: var(--error); }

/* ---------- Avisos ---------- */
.aviso { display: flex; gap: .75rem; padding: 1rem 1.125rem; border-radius: var(--radio-m); background: var(--celeste-50); font-size: var(--t-s); }
.aviso > i { color: var(--celeste-texto); margin-top: .2rem; }
.aviso--alerta { background: var(--alerta-50); }
.aviso--alerta > i { color: var(--alerta); }
.aviso--ok { background: var(--ok-50); }
.aviso--ok > i { color: var(--ok); }
.aviso strong { display: block; margin-bottom: .125rem; }

/* ---------- Barra de progreso ---------- */
.progreso { display: grid; gap: .5rem; }
.progreso__barra { height: 10px; border-radius: 999px; background: var(--linea); overflow: hidden; }
.progreso__relleno { height: 100%; background: var(--tinta); border-radius: inherit; width: 0; transition: width .6s ease-out; }
.progreso__texto { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--t-s); color: var(--tinta-60); }
.progreso__texto strong { color: var(--tinta); }

/* Enlace "saltar al contenido" (accesibilidad con teclado) */
.saltar { position: absolute; left: 1rem; top: -100px; z-index: 300; padding: .75rem 1rem; background: var(--tinta); color: var(--blanco); border-radius: 8px; font-weight: 700; }
.saltar:focus { top: 1rem; color: var(--blanco); }

/* En pantallas muy angostas los botones pueden partir su texto en dos líneas */
@media (max-width: 480px) { .btn { white-space: normal; text-align: center; } }

/* ---------- Cambio de página sin corte ----------
   Los navegadores que lo soportan (Chrome/Edge 126+, Safari 18.2+) mantienen la página
   anterior en pantalla hasta que la nueva está lista y hacen un fundido corto entre las dos.
   Los demás navegadores siguen navegando normalmente. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; animation-timing-function: ease-out; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
html { background: var(--papel); }
