/* ============================================================================
 * styles.css — Sistema visual de los formularios institucionales
 * Diseño sobrio, editorial y de aire "documento". El color de etapa entra como
 * acento mediante variables (--stage*) que app.js inyecta desde config.js.
 * ========================================================================== */

/* ---- Tokens base -------------------------------------------------------- */
:root {
  --ink: #1b1f24;
  --slate: #3d4753;
  --muted: #697585;
  --faint: #8b96a3;
  --line: #e3e7ec;
  --line-strong: #cfd6de;
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eef1f5;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --ok: #1e7d5a;

  /* Fallbacks de etapa (app.js los sobrescribe según la etapa activa). */
  --stage: #1b3a6b;
  --stage-strong: #16305a;
  --stage-tint: #e9eef6;
  --stage-tint-2: #f1f5fa;
  --stage-ink: #1b1f24;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20,28,40,.06), 0 1px 3px rgba(20,28,40,.05);
  --shadow-md: 0 6px 24px rgba(20,28,40,.08), 0 2px 6px rgba(20,28,40,.05);
  --maxw: 780px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--stage-strong); }

/* ---- Barra institucional superior --------------------------------------- */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar__logos { display: flex; align-items: center; gap: 14px; }
/* Logos alineados por su centro óptico y a una misma altura para verse parejos. */
.topbar__logos img { height: 50px; width: auto; display: block; object-fit: contain; }
.topbar__name {
  display: flex; flex-direction: column; line-height: 1.15;
}
.topbar__name b { font-size: .98rem; letter-spacing: .2px; }
.topbar__name span { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.topbar__spacer { flex: 1; }
.topbar__back {
  font-size: .84rem; color: var(--muted); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-radius: 999px; transition: background .18s var(--ease), color .18s var(--ease);
}
.topbar__back:hover { background: var(--surface); color: var(--ink); }

/* Portada: barra superior más baja para dejar todo el recorrido visible sin scroll. */
body.home .topbar__inner { padding: 7px 20px; }
body.home .topbar__logos img { height: 36px; }

/* ---- Contenedor principal ----------------------------------------------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 96px; }
/* Portada: sin el margen inferior pensado para formularios largos. */
.page--home { padding: 6px 20px 6px; }

/* ---- Encabezado de etapa (web) ------------------------------------------ */
.stage-head {
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: 4px solid var(--stage);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.stage-head__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.stage-head__kicker {
  font-size: .72rem; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); font-weight: 600; margin: 0 0 4px;
}
.stage-head__title {
  margin: 0; font-size: clamp(1.5rem, 4.5vw, 2.15rem); line-height: 1.1;
  letter-spacing: -.4px; font-weight: 700;
}
.stage-head__title .stage-name { color: var(--stage-strong); }
.stage-head__sub { margin: 8px 0 0; color: var(--slate); font-size: .95rem; max-width: 46ch; }
.stage-head__meta {
  font-size: .72rem; color: var(--muted); text-align: right; line-height: 1.5;
  border-left: 1px solid var(--line); padding-left: 14px; white-space: nowrap;
}
.stage-head__meta b { color: var(--slate); font-weight: 600; }

/* ---- Stepper "usted está aquí" ------------------------------------------ */
.stepper { margin: 20px 0 0; }
.stepper__track {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.step {
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 10px 10px 12px;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.step__dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--bg);
  display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--faint);
}
.step__label { min-width: 0; }
.step__num { font-size: .64rem; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); display: block; }
.step__name { font-size: .82rem; font-weight: 600; color: var(--muted); overflow-wrap: break-word; } /* nombres completos, sin cortes */
.step__here {
  display: none; font-size: .64rem; font-weight: 700; letter-spacing: .4px;
  color: var(--stage-strong); text-transform: uppercase;
}
.step--active {
  border-color: var(--stage);
  background: var(--stage-tint-2);
  box-shadow: inset 0 0 0 1px var(--stage);
}
.step--active .step__dot { border-color: var(--stage-strong); background: var(--stage-strong); color: #fff; }
.step--active .step__name { color: var(--ink); }
.step--active .step__num { color: var(--stage-strong); }
.step--active .step__here { display: block; }

/* ---- Frase motivacional ------------------------------------------------- */
.motiv {
  margin: 16px 0 0;
  border-left: 3px solid var(--stage);
  background: var(--stage-tint-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  color: var(--slate);
  font-size: .96rem;
}
.motiv p { margin: 0; }

/* ---- Formulario --------------------------------------------------------- */
form { margin-top: 22px; }
.form-intro { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }

fieldset.section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0;
  margin: 0 0 20px;
  box-shadow: var(--shadow-sm);
  overflow: clip;
}
.section > legend { padding: 0; }
.section__head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 20px;
  background: var(--stage-tint);
  border-bottom: 1px solid var(--line);
}
.section__num {
  font-size: .78rem; font-weight: 800; color: var(--stage-strong);
  background: var(--bg); border: 1px solid var(--stage);
  border-radius: 6px; padding: 1px 8px; line-height: 1.5;
}
.section__title { font-size: 1.02rem; font-weight: 700; color: var(--ink); letter-spacing: -.2px; }
.section__body { padding: 18px 20px 6px; }
.section__note {
  margin: -4px 20px 0; padding: 10px 14px;
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm); color: var(--muted); font-size: .84rem;
}
.section__body > .section__note:first-child { margin: 0 0 14px; }

/* ---- Campos ------------------------------------------------------------- */
.field { margin: 0 0 18px; }
.field__label {
  display: block; font-weight: 600; font-size: .92rem; color: var(--ink);
  margin: 0 0 6px;
}
.field__req { color: var(--danger); margin-left: 3px; font-weight: 700; }
.field__opt { color: var(--faint); font-weight: 500; font-size: .8rem; margin-left: 6px; }
.field__help { color: var(--muted); font-size: .82rem; margin: -2px 0 8px; }

.control {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.control::placeholder { color: var(--faint); }
.control:hover { border-color: var(--muted); }
.control:focus {
  outline: none; border-color: var(--stage);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--stage) 22%, transparent);
}
textarea.control { min-height: 108px; resize: vertical; line-height: 1.5; }
input[type="date"].control { max-width: 220px; }

/* Grupo de opciones (checkbox / radio) */
.optgroup { display: grid; gap: 8px; }
.optgroup.optgroup--cols { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; background: var(--bg);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.opt:hover { border-color: var(--muted); background: var(--surface); }
.opt input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--stage-strong); flex: none; }
.opt__text { font-size: .92rem; color: var(--slate); }
.opt:has(input:checked) { border-color: var(--stage); background: var(--stage-tint-2); }
.opt:has(input:checked) .opt__text { color: var(--ink); font-weight: 600; }

/* Campo "otro, especifique" condicional */
.otherspec { margin-top: 8px; overflow: hidden; }
.otherspec[hidden] { display: none; }

/* ---- Tablas dinámicas / estructuradas ----------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 4px 0 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.grid { width: 100%; border-collapse: collapse; min-width: 520px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; }
table.grid th:last-child, table.grid td:last-child { border-right: none; }
table.grid thead th {
  background: var(--stage-tint); color: var(--ink); font-size: .8rem; font-weight: 700;
  position: sticky; top: 0;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.rowhead { background: var(--surface); font-weight: 600; color: var(--slate); font-size: .88rem; }
table.grid td.rownum { background: var(--surface); text-align: center; font-weight: 700; color: var(--muted); width: 42px; }
table.grid .control { border: 1px solid transparent; background: transparent; padding: 7px 8px; border-radius: 6px; }
table.grid .control:focus { border-color: var(--stage); background: var(--bg); }
table.grid textarea.control { min-height: 58px; }
.rowdel {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.rowdel:hover { color: var(--danger); background: var(--danger-bg); }
.table-actions { display: flex; justify-content: flex-start; margin: 8px 0 2px; }

/* Card responsive para tablas de filas fijas (móvil) */
@media (max-width: 620px) {
  table.grid.stack, table.grid.stack thead, table.grid.stack tbody,
  table.grid.stack th, table.grid.stack td, table.grid.stack tr { display: block; }
  table.grid.stack { min-width: 0; }
  table.grid.stack thead { display: none; }
  table.grid.stack tr { border-bottom: 1px solid var(--line-strong); padding: 6px 4px; }
  table.grid.stack tr:last-child { border-bottom: none; }
  table.grid.stack td { border: none; padding: 6px 4px; }
  table.grid.stack td::before {
    content: attr(data-col); display: block; font-size: .72rem; font-weight: 700;
    color: var(--stage-strong); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px;
  }
  table.grid.stack td.rownum { background: transparent; text-align: left; color: var(--stage-strong); }
  table.grid.stack td.rownum::before { content: ""; }
}

/* ---- Hipótesis (bloque de 3 frases) ------------------------------------- */
.hypo { display: grid; gap: 10px; }
.hypo__lead { font-weight: 600; color: var(--slate); font-size: .9rem; }

/* ---- Sí/No con detalle -------------------------------------------------- */
.yesno { display: flex; gap: 10px; }
.yesno .opt { flex: 1; }

/* ---- Mensajes de error -------------------------------------------------- */
.error-msg {
  display: none; align-items: center; gap: 6px;
  color: var(--danger); font-size: .82rem; margin-top: 6px; font-weight: 600;
}
.error-msg::before { content: "⚠"; font-size: .9rem; }
.field--invalid .error-msg { display: flex; }
.field--invalid .control { border-color: var(--danger); background: var(--danger-bg); }
.field--invalid .optgroup, .field--invalid .table-wrap, .field--invalid .yesno { outline: 2px solid var(--danger); outline-offset: 3px; border-radius: var(--radius-sm); }

/* ---- Banner de errores (resumen) ---------------------------------------- */
.form-alert {
  display: none; border: 1px solid var(--danger); background: var(--danger-bg);
  color: #7a1a15; border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 18px;
  font-size: .9rem;
}
.form-alert.is-visible { display: block; }
.form-alert b { color: var(--danger); }

/* ---- Botones ------------------------------------------------------------ */
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; padding: 13px 22px; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 9px; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--stage-strong); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { box-shadow: var(--shadow-md); }
.btn--primary:disabled { opacity: .65; cursor: progress; }
.btn--ghost { background: var(--bg); color: var(--slate); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--muted); color: var(--ink); }
.btn--lg { padding: 15px 28px; font-size: 1.02rem; }
.btn .spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff;
  animation: spin .7s linear infinite; display: none;
}
.btn.is-loading .spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn:focus-visible, a:focus-visible, .opt:focus-within {
  outline: 3px solid color-mix(in srgb, var(--stage) 55%, transparent); outline-offset: 2px;
}

/* ---- Pantalla final ----------------------------------------------------- */
.final { display: none; }
.final.is-visible { display: block; }
.final-card {
  background: var(--bg); border: 1px solid var(--line); border-top: 4px solid var(--stage);
  border-radius: var(--radius); padding: 32px 28px; text-align: center; box-shadow: var(--shadow-md);
}
.final-check {
  width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--stage-tint); display: grid; place-items: center;
  color: var(--stage-strong); font-size: 2rem;
}
.final-card h2 { margin: 0 0 8px; font-size: 1.5rem; letter-spacing: -.3px; }
.final-card p { margin: 0 auto 8px; color: var(--slate); max-width: 52ch; }
.final-actions { margin: 22px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.final-note {
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 16px; color: var(--muted); font-size: .88rem; margin: 18px 0 0; text-align: left;
}
.contact-block { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 20px; text-align: left; }
.contact-block h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 12px; }
.contact-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.contact-chip {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 14px;
  color: var(--slate); font-size: .9rem; background: var(--bg);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.contact-chip:hover { border-color: var(--stage); background: var(--stage-tint-2); color: var(--ink); }
.contact-chip .ic { color: var(--stage-strong); font-weight: 700; }

/* ---- Selector (index) --------------------------------------------------- */
.hero { text-align: center; padding: 0; }
.hero h1 { font-size: clamp(1.1rem, 2.6vw, 1.45rem); margin: 0 0 2px; letter-spacing: -.3px; }
.hero p { color: var(--slate); max-width: 66ch; margin: 0 auto; font-size: .78rem; line-height: 1.35; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 28px; }
.card {
  --stage: #1b3a6b;
  position: relative; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: inherit; overflow: hidden;
  box-shadow: var(--shadow-sm);
  isolation: isolate;   /* contexto de apilamiento: la marca de agua queda detrás del texto */
  transition: transform .16s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--stage); z-index: 1; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--stage); }
/* Ícono temático de fondo: sutil, translúcido, detrás del contenido. */
.card__icon {
  position: absolute; right: -14px; bottom: -20px; width: 122px; height: 122px;
  color: var(--stage); opacity: .07; z-index: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.card__icon svg { width: 100%; height: 100%; display: block; }
.card:hover .card__icon { opacity: .13; transform: scale(1.06) rotate(-4deg); }
.card__step, .card__name, .card__desc, .card__cta { position: relative; z-index: 1; }
.card__step { font-size: .72rem; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.card__name { font-size: 1.35rem; font-weight: 800; margin: 4px 0 8px; color: var(--stage); letter-spacing: -.3px; }
.card__desc { font-size: .9rem; color: var(--slate); margin: 0 0 16px; flex: 1; }
.card__cta { font-size: .88rem; font-weight: 700; color: var(--stage); display: inline-flex; align-items: center; gap: 6px; }
.card__cta .arw { transition: transform .16s var(--ease); }
.card:hover .card__cta .arw { transform: translateX(3px); }
.flow-hint { text-align: center; color: var(--muted); font-size: .74rem; margin-top: 8px; }

/* ---- Recorrido secuencial (index) — 4 etapas conectadas ------------------ */
/* Envoltura de ancho completo: esta sección rompe el maxw del documento para
   ocupar casi todo el ancho de la ventana, como en la referencia visual. */
.flow-wrap {
  width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  padding: 0 clamp(16px, 4vw, 48px);
}
.flow { position: relative; max-width: 1180px; margin: 8px auto 0; }
/* Trazo curvo que conecta un círculo con el siguiente (dibujado por JS en
   index.html, según la posición real de cada círculo). Va detrás de las filas. */
.flow__path { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.flow__path path { fill: none; stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 7 9; }
.flow__row {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: clamp(14px, 3.5vw, 40px);
  text-decoration: none; color: inherit;
  padding: 3px 0;
}
/* El círculo alterna de lado: en --l se invierte el orden visual para que
   quede al borde derecho; en --r se queda al borde izquierdo (orden natural). */
.flow__row--l { flex-direction: row-reverse; }
.flow__text { flex: 1; min-width: 0; }
.flow__row--r .flow__text { text-align: left; }
.flow__row--l .flow__text { text-align: right; }

.flow__circle {
  flex: none;
  width: 88px; height: 88px; border-radius: 50%; box-sizing: border-box;
  background: var(--bg); border: 4px solid var(--stage);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 6px; text-align: center;
  box-shadow: var(--shadow-md); position: relative;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.flow__row:hover .flow__circle { transform: scale(1.045); box-shadow: 0 10px 30px rgba(20,28,40,.14); }
.flow__step { font-size: .4rem; font-weight: 800; letter-spacing: .6px; color: var(--faint); text-transform: uppercase; }
.flow__icon { width: 14px; height: 14px; color: var(--stage); }
.flow__icon svg { width: 100%; height: 100%; display: block; }
.flow__name {
  font-size: .56rem; font-weight: 800; letter-spacing: 0; color: var(--ink);
  line-height: 1.05; max-width: 62px; overflow-wrap: anywhere;
}

.flow__quote { margin: 0 0 3px; font-style: italic; font-weight: 700; color: var(--stage-strong); font-size: .92rem; letter-spacing: -.2px; }
.flow__desc { margin: 0; color: var(--slate); font-size: .78rem; line-height: 1.35; }
.flow__cta {
  margin-top: 4px; font-size: .76rem; font-weight: 700; color: var(--stage);
  display: inline-flex; align-items: center; gap: 6px;
}
.flow__row--l .flow__cta { flex-direction: row-reverse; }
.flow__cta .arw { transition: transform .16s var(--ease); }
.flow__row:hover .flow__cta .arw { transform: translateX(3px); }
.flow__row--l:hover .flow__cta .arw { transform: translateX(-3px); }

@media (max-width: 720px) {
  .flow-wrap { padding: 0 14px; }
  .flow__row, .flow__row--l { flex-direction: row; gap: 14px; padding: 12px 0; }
  .flow__row--l .flow__text, .flow__row--r .flow__text { text-align: left; }
  .flow__circle { width: 108px; height: 108px; border-width: 5px; padding: 8px; gap: 2px; }
  .flow__step { font-size: .5rem; }
  .flow__icon { width: 20px; height: 20px; }
  .flow__name { font-size: .7rem; max-width: 84px; }
  .flow__row--l .flow__cta { flex-direction: row; }
  .flow__row--l:hover .flow__cta .arw { transform: translateX(3px); }
}

/* ---- Pie global --------------------------------------------------------- */
.site-foot { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 40px; color: var(--faint); font-size: .78rem; text-align: center; }
body.home .site-foot { padding: 8px 20px 14px; font-size: .68rem; }

/* ---- Animaciones de entrada --------------------------------------------- */
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.anim-rise { animation: riseIn .5s var(--ease) both; }
.anim-rise.d1 { animation-delay: .06s; }
.anim-rise.d2 { animation-delay: .12s; }
.anim-rise.d3 { animation-delay: .18s; }
.reveal { animation: riseIn .28s var(--ease) both; }

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

/* ---- Ajustes responsive ------------------------------------------------- */
@media (max-width: 640px) {
  .page { padding: 18px 14px 84px; }
  .topbar__logos { gap: 10px; }
  .topbar__logos img { height: 42px; }
  .stage-head { padding: 18px 16px; }
  .stage-head__meta { text-align: left; border-left: none; border-top: 1px solid var(--line); padding: 8px 0 0; white-space: normal; }
  .section__body { padding: 16px 14px 4px; }
  .section__head { padding: 12px 14px; }

  /* Stepper compacto (vertical) en móvil */
  .stepper__track { grid-template-columns: 1fr; gap: 6px; }
  .step { padding: 9px 12px; }
  .btn--lg, .actions .btn { width: 100%; justify-content: center; }
}

/* ============================================================================
 * MOTION ENRIQUECIDO (capa web) — no afecta al PDF.
 * Los estados que "empiezan ocultos y aparecen" viven bajo .can-animate, que
 * app.js añade solo cuando NO hay prefers-reduced-motion; así, sin animación,
 * todo se ve completo por defecto.
 * ========================================================================== */

/* ---- Barra de progreso institucional (bajo la barra superior) ---------- */
.topbar { position: sticky; top: 0; z-index: 40; }
.topbar__progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.topbar__progress-fill {
  height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, var(--stage), var(--stage-strong));
  transition: transform .55s var(--ease);
}
.progress-chip {
  margin-left: auto; font-size: .72rem; font-weight: 700; letter-spacing: .3px;
  color: var(--stage-strong); background: var(--stage-tint-2);
  border: 1px solid var(--stage); border-radius: 999px; padding: 2px 10px;
  white-space: nowrap; transition: background .3s var(--ease);
}
.stepper > .step__num { display: flex; align-items: center; }

/* ---- Revelado de secciones al hacer scroll -----------------------------
 * IMPORTANTE: el contenido SIEMPRE es visible en reposo. El "revelado" es solo
 * una animación de entrada que se dispara al entrar en pantalla; una sección
 * solo está a opacity 0 mientras su animación se reproduce (lo cual únicamente
 * ocurre en una pestaña visible). Así jamás queda contenido oculto de forma
 * permanente, aunque el navegador pause animaciones o el JS falle.            */
.can-animate .section.in-view { animation: sectionIn .55s var(--ease); }
.can-animate .phase-banner.in-view { animation: sectionIn .5s var(--ease); }
@keyframes sectionIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---- Insignia "sección completada" ------------------------------------- */
.section__done {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; color: var(--stage-strong);
  opacity: 0; transform: scale(.7); transition: opacity .32s var(--ease), transform .32s var(--ease);
}
.section__done .tick {
  width: 17px; height: 17px; border-radius: 50%; background: var(--stage-strong);
  color: #fff; display: grid; place-items: center; font-size: .74rem; line-height: 1;
}
.section--done .section__done { opacity: 1; transform: none; }
.section--done .section__head { box-shadow: inset 3px 0 0 var(--stage-strong); }

/* ---- Microinteracciones de campo --------------------------------------- */
.field:focus-within > .field__label { color: var(--stage-strong); }
.control { transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease), transform .16s var(--ease); }
.field:focus-within > .control:not(textarea) { transform: translateY(-1px); }
.can-animate .opt:has(input:checked) { animation: optPop .3s var(--ease); }
@keyframes optPop { 0% { transform: scale(1); } 45% { transform: scale(1.04); } 100% { transform: scale(1); } }
.can-animate table.grid tbody tr.row-new { animation: rowIn .3s var(--ease) both; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Aparición condicional (otro / detalle) con leve deslizamiento */
.otherspec:not([hidden]) { animation: none; }
.can-animate .otherspec.reveal { animation: slideDown .3s var(--ease); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- Overlay "generando documento" ------------------------------------- */
.gen-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
}
.can-animate .gen-overlay { animation: fadeIn .28s var(--ease); }
.gen-card { text-align: center; padding: 20px; }
.gen-ring {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%;
  border: 5px solid var(--stage-tint); border-top-color: var(--stage-strong);
  animation: spin .8s linear infinite;
}
.gen-ring--seal {
  display: grid; place-items: center; border-top-color: var(--stage-tint); animation: none;
  color: var(--stage-strong); font-size: 1.7rem; font-weight: 800;
}
.gen-text { font-weight: 700; color: var(--slate); letter-spacing: .3px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Pantalla final cinematográfica ------------------------------------ */
.final-check svg { width: 40px; height: 40px; display: block; }
.final-check .chk-circle { stroke-dasharray: 166; stroke-dashoffset: 0; }
.final-check .chk-mark { stroke-dasharray: 48; stroke-dashoffset: 0; }
.can-animate .final-check .chk-circle { stroke-dashoffset: 166; }
.can-animate .final-check .chk-mark { stroke-dashoffset: 48; }
.can-animate .final.is-visible .final-check .chk-circle { animation: draw .5s var(--ease) forwards; }
.can-animate .final.is-visible .final-check .chk-mark { animation: draw .4s var(--ease) .35s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.final-seal {
  display: inline-block; margin: 14px auto 0; transform: rotate(-7deg);
  border: 2.5px solid var(--stage-strong); color: var(--stage-strong);
  border-radius: 8px; padding: 5px 14px; font-weight: 800; font-size: .74rem;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.can-animate .final.is-visible .final-seal { animation: sealStamp .45s var(--ease) .75s both; }
@keyframes sealStamp {
  0% { opacity: 0; transform: rotate(-7deg) scale(1.6); }
  55% { opacity: 1; }
  70% { transform: rotate(-7deg) scale(.94); }
  100% { opacity: 1; transform: rotate(-7deg) scale(1); }
}
.can-animate .final.is-visible .final-card > *:not(.final-check):not(.final-seal) { animation: riseIn .5s var(--ease) both; }
.can-animate .final.is-visible .final-card > h2 { animation-delay: .1s; }
.can-animate .final.is-visible .final-card > p { animation-delay: .16s; }
.can-animate .final.is-visible .final-card > .final-actions { animation-delay: .24s; }
.can-animate .final.is-visible .final-card > .final-note { animation-delay: .3s; }
.can-animate .final.is-visible .final-card > .contact-block { animation-delay: .36s; }
