/* registro.css — Página pública del registro de familias (PM-266).
   Solo estilos propios con prefijo reg-; colores, radios y sombras salen de theme.css.
   Breakpoints canónicos: 640px (teléfono), 1024px (tablet) y (hover: none) and (pointer: coarse). */

.reg-body {
  padding: 0;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-main);
  color: var(--text-dark);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

:root:has(.reg-body) { scroll-padding-bottom: 6.5rem; }   /* el campo enfocado no queda bajo la barra fija */

.reg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.reg-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.reg-skip {
  position: absolute; left: 16px; top: -100px; z-index: 50;
  background: var(--white); color: var(--primary-dark-blue); font-weight: 700;
  padding: .6rem 1rem; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.reg-skip:focus { top: 8px; }

/* ── Foco visible en todo control ─────────────────────────────────────── */
.reg-body :focus-visible {
  outline: 3px solid var(--secondary-light-blue);
  outline-offset: 2px;
}
.reg-body h2:focus,
.reg-wrap:focus { outline: none; }
.reg-body h2:focus-visible { outline: 3px solid var(--secondary-light-blue); outline-offset: 4px; border-radius: 4px; }

/* ── Encabezado ───────────────────────────────────────────────────────── */
.reg-header {
  width: calc(100% - 32px);
  max-width: 688px;                 /* = ancho de la tarjeta (720px − 2 × 16px) */
  margin: 1rem auto 0;
  padding: 1rem 1.25rem;
}
.reg-brand { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.reg-logo {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: var(--radius-md);
  background: var(--white); display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.reg-logo img { width: 52px; height: 52px; object-fit: contain; display: block; }
.reg-brand-text { min-width: 0; }
.reg-brand-text h1 { font-size: 1.45rem; line-height: 1.2; overflow-wrap: anywhere; }
.reg-brand-text p { overflow-wrap: anywhere; }

/* ── Contenedor y tarjeta ─────────────────────────────────────────────── */
.reg-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 16px calc(6.5rem + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 1rem;
}
.reg-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  min-width: 0;
}
.reg-card h2 { font-size: 1.25rem; font-weight: 800; color: var(--primary-dark-blue); line-height: 1.3; }
.reg-card h3 { font-size: 1.05rem; font-weight: 800; color: var(--text-dark); }
.reg-card p { line-height: 1.55; }
.reg-muted { color: var(--text-medium); font-size: .95rem; }
.reg-small { font-size: .88rem; color: var(--text-light); }
.reg-center { text-align: center; align-items: center; }
.reg-foot { text-align: center; font-size: .8rem; color: var(--text-light); }

/* ── Progreso ─────────────────────────────────────────────────────────── */
.reg-progress { display: flex; flex-direction: column; gap: .4rem; }
.reg-progress-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .88rem; }
.reg-progress-label { font-weight: 700; color: var(--primary-dark-blue); }
.reg-progress-name { color: var(--text-medium); }
.reg-progress-track { height: 8px; background: #dbe4ee; border-radius: var(--radius-full); overflow: hidden; }
.reg-progress-bar {
  height: 100%; width: 0; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary-dark-blue), var(--secondary-light-blue));
  transition: width .3s ease;
}

/* ── Formularios ──────────────────────────────────────────────────────── */
.reg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1rem; }
.reg-grid > .reg-field--full { grid-column: 1 / -1; }
.reg-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.reg-label { font-weight: 700; font-size: .92rem; color: var(--text-dark); }
.reg-input {
  width: 100%;
  min-height: var(--tap-min);
  padding: .6rem .8rem;
  font: inherit;
  font-size: 16px;
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid #b6c2d1;
  border-radius: .55rem;
  box-sizing: border-box;
}
.reg-input:focus { border-color: var(--secondary-light-blue); }
.reg-input[readonly] { background: #f1f5f9; color: var(--text-medium); }
.reg-input[aria-invalid="true"] { border-color: var(--danger); background: #fffafa; }
select.reg-input { appearance: auto; }
.reg-hint { font-size: .85rem; color: var(--text-medium); line-height: 1.45; }
.reg-err { font-size: .88rem; color: var(--danger); font-weight: 600; line-height: 1.4; }
.reg-err:empty { display: none; }

.reg-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: .4rem; }
.reg-fieldset legend { padding: 0; margin-bottom: .35rem; }
.reg-radios { display: flex; gap: .6rem; flex-wrap: wrap; }
.reg-radio {
  display: inline-flex; align-items: center; gap: .55rem;
  min-height: var(--tap-min); padding: .45rem 1rem;
  border: 1px solid #b6c2d1; border-radius: .55rem; background: var(--white);
  cursor: pointer; font-size: .95rem;
}
.reg-radio input { width: 1.15rem; height: 1.15rem; accent-color: var(--primary-dark-blue); margin: 0; }
.reg-radio:has(input:checked) { border-color: var(--primary-dark-blue); background: #eff6ff; font-weight: 700; }
.reg-fieldset[aria-invalid="true"] .reg-radio { border-color: var(--danger); }

.reg-check {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .8rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: #f8fafc; cursor: pointer; line-height: 1.5; font-size: .95rem;
}
.reg-check input { width: 1.3rem; height: 1.3rem; margin: .1rem 0 0; flex-shrink: 0; accent-color: var(--primary-dark-blue); }
.reg-check:has(input:checked) { border-color: var(--primary-dark-green); background: #f0fdf4; }
.reg-check a { color: var(--primary-dark-blue); font-weight: 700; }

/* ── Bloques de persona (acudientes) ──────────────────────────────────── */
.reg-person {
  border: 1px solid #c7d6e6; border-radius: var(--radius-md); padding: 1.1rem;
  display: flex; flex-direction: column; gap: 1rem; background: #fbfdff; min-width: 0;
}
.reg-person-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.reg-person-head h3 { display: inline-flex; align-items: center; gap: .5rem; color: var(--primary-dark-blue); }
.reg-people { display: flex; flex-direction: column; gap: 1rem; }
.reg-add { align-self: flex-start; }
.reg-opt { font-weight: 500; color: var(--text-light); font-size: .9em; }

/* ── Avisos ───────────────────────────────────────────────────────────── */
.reg-banner {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .85rem 1rem; border-radius: var(--radius-md);
  font-size: .93rem; line-height: 1.5;
}
.reg-banner .icon { margin-top: .1rem; }
.reg-banner > span { min-width: 0; overflow-wrap: anywhere; }
.reg-banner--info { background: #eff6ff; border-left: 4px solid var(--primary-dark-blue); color: var(--text-dark); }
.reg-banner--warning { background: #fff7ed; border-left: 4px solid var(--terciary-orange); color: #7c2d12; }
.reg-banner--error { background: #fef2f2; border-left: 4px solid var(--danger); color: #7f1d1d; }
.reg-banner--success { background: #f0fdf4; border-left: 4px solid var(--primary-dark-green); color: #14532d; }
.reg-banner:empty { display: none; }

/* ── Confirmación de correos ──────────────────────────────────────────── */
.reg-mails { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.reg-mail {
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
  padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: #f8fafc;
}
.reg-mail.is-current { border-color: var(--secondary-light-blue); background: #eff6ff; }
.reg-mail-who { font-weight: 700; }
.reg-mail-addr { color: var(--text-medium); overflow-wrap: anywhere; min-width: 0; flex: 1 1 10rem; }
.reg-chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem;
  border-radius: var(--radius-full); font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.reg-chip--ok { background: #dcfce7; color: #166534; }
.reg-chip--wait { background: #fff7ed; color: #9a3412; }

.reg-otp-box { display: flex; flex-direction: column; gap: .5rem; align-items: center; text-align: center; }
.reg-otp {
  width: 100%; max-width: 15rem; text-align: center;
  font-size: 1.6rem !important; letter-spacing: .4em; font-weight: 800;
  padding-left: calc(.8rem + .4em);
}
.reg-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: center; }
.reg-linkbtn {
  background: none; border: 0; padding: .5rem .25rem; font: inherit; font-size: .93rem;
  color: var(--primary-dark-blue); text-decoration: underline; cursor: pointer;
  min-height: var(--tap-min);
}
.reg-linkbtn:disabled { color: var(--text-light); text-decoration: none; cursor: default; }

/* ── Revisión ─────────────────────────────────────────────────────────── */
.reg-review { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.reg-review-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: #f1f5f9; border-bottom: 1px solid var(--border);
}
.reg-review-head h3 { display: inline-flex; align-items: center; gap: .5rem; color: var(--primary-dark-blue); }
.reg-dl { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: .45rem 1rem; padding: .9rem 1rem; margin: 0; }
.reg-dl dt { color: var(--text-light); font-size: .88rem; }
.reg-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ── Pantalla final ───────────────────────────────────────────────────── */
.reg-circle {
  width: 76px; height: 76px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e0ecf7; color: var(--primary-dark-blue);
}
.reg-circle--ok { background: #dcfce7; color: var(--primary-dark-green); }
.reg-circle--bad { background: #fef2f2; color: var(--danger); }
.reg-ref { font-size: .9rem; color: var(--text-medium); }
.reg-ref strong { letter-spacing: .05em; color: var(--text-dark); }

/* ── Botones (tamaño cómodo para padres desde el celular) ─────────────── */
.reg-body .activity-btn {
  min-height: var(--tap-min);
  font-size: .95rem;
  padding: .55rem 1.1rem;
  justify-content: center;
}
.reg-body .activity-btn-ghost { border-color: #cbd5e1; }
.reg-body .activity-btn[aria-busy="true"] { opacity: .85; }
.reg-spin {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: reg-spin .8s linear infinite; flex-shrink: 0;
}
@keyframes reg-spin { to { transform: rotate(360deg); } }

/* ── Barra de acciones fija abajo ─────────────────────────────────────── */
.reg-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--white); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 16px rgba(15, 23, 42, .08);
  padding: .7rem 16px calc(.7rem + env(safe-area-inset-bottom, 0px));
}
.reg-bar-inner { max-width: 720px; margin: 0 auto; display: flex; gap: .75rem; align-items: center; }
.reg-bar-next { margin-left: auto; min-width: 11rem; }
.reg-bar-back.is-hidden { visibility: hidden; }

/* ── Modal propio (sin alert/confirm) ─────────────────────────────────── */
.reg-modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.reg-modal-box {
  background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem;
  width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); box-sizing: border-box;
  max-height: 90vh; max-height: 90dvh; overflow: auto;
}
.reg-modal-box h3 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text-dark); }
.reg-modal-msg { color: var(--text-medium); line-height: 1.55; margin-bottom: 1.25rem; }
.reg-modal-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

/* ── Tablet ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .reg-card { padding: 1.25rem; }
}

/* ── Teléfono: una columna ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .reg-header { width: 100%; margin: 0; border-radius: 0; padding: .9rem 16px; }
  .reg-logo { width: 52px; height: 52px; }
  .reg-logo img { width: 42px; height: 42px; }
  .reg-brand-text h1 { font-size: 1.2rem; }
  .reg-card { padding: 1.1rem 1rem; }
  .reg-grid { grid-template-columns: minmax(0, 1fr); }
  .reg-person { padding: .9rem; }
  .reg-dl { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .reg-mail-addr { order: 3; flex-basis: 100%; }
  .reg-chip { margin-left: auto; }
  .reg-dl dd { margin-bottom: .5rem; }
  .reg-bar-next { min-width: 0; flex: 1 1 auto; }
  .reg-bar-back { flex: 0 0 auto; }
  .reg-add, .reg-person-head .activity-btn { width: 100%; }
  .reg-modal-actions .activity-btn { flex: 1 1 8rem; }
}

/* ── Táctil: sin hover pegado y campos de 16px ────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .reg-input { font-size: 16px; }
  .reg-check { min-height: var(--tap-min); }
}

@media (prefers-reduced-motion: reduce) {
  .reg-spin { animation-duration: 2s; }
  .reg-progress-bar { transition: none; }
}
