/* firma.selia.es: DNI por delante, por detrás y firma.
   Paleta: azul sobre azul marino (colores de superficies reales de Selia:
   marino #0A1E3C y azul #1F6BFF de segurosvida.selia.es; éxito y error de la web selia.es). */

/* Inter (OFL, assets/Inter-OFL.txt): pensada para pantalla, letras abiertas y altura de x generosa.
   Variable de 100 a 900 en un solo fichero; subconjunto latino (incluye á, é, ñ, ü, ¿, ¡). */
@font-face {
  font-family: "Inter";
  src: url("assets/inter-latin-wght.woff2") format("woff2-variations"), url("assets/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --marino: #0A1E3C;
  --marino-alto: #14305A;      /* tramos y elementos sobre la banda */
  --cielo: #A9C4F2;            /* texto secundario sobre marino (8:1) */
  --azul: #1F6BFF;             /* acción principal (blanco encima 4.6:1) */
  --azul-hondo: #1250D4;       /* pulsado y enlaces sobre blanco (6.7:1) */
  --azul-vivo: #5B93FF;        /* paso actual sobre marino */
  --azul-velo: #E8F0FF;        /* fondos suaves de acento */

  --fondo: #EEF2F8;
  --panel: #FFFFFF;
  --tinta: #0A1E3C;
  --tinta-suave: #4B5B73;      /* 6.9:1 sobre blanco */
  --linea: #DCE3EE;
  --dni-tarjeta: #F4F7FC;
  --dni-trazo: #C6D2E4;
  --dni-relleno: #DCE4F0;
  --dni-silueta: #B9C7DC;

  --ok: #048164;               /* web selia.es --action-strong */
  --ok-velo: #DBF5EF;          /* web selia.es --action-soft */
  --error: #D52C20;            /* web selia.es --destructive */
  --error-velo: #FDECEA;

  --tinta-firma: #0B2A66;

  --radio: 16px;
  --radio-in: 10px;
  --sombra: 0 1px 2px rgba(10, 30, 60, .06), 0 10px 30px -8px rgba(10, 30, 60, .14);

  --curva: cubic-bezier(0.16, 1, 0.3, 1);
  --t-rapido: 120ms;
  --t-estado: 200ms;
  --t-vista: 280ms;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --titular: var(--sans);

  --ancho: 34rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--fondo);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-optical-sizing: auto;
  font-feature-settings: "cv05", "cv08";  /* l con cola e I con remates: no se confunden l, I y 1 */
  -webkit-font-smoothing: antialiased;
  color: var(--tinta);
  background: var(--fondo);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
img, svg { display: block; }
p { margin: 0; }
h1, h2 { margin: 0; text-wrap: balance; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.oculto {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  padding: 10px 14px; border-radius: var(--radio-in);
  background: var(--panel); color: var(--tinta); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.banda :focus-visible { outline-color: #fff; }

[hidden] { display: none !important; }

/* ---------- Banda superior (marino) ---------- */
.banda {
  background: var(--marino);
  color: #fff;
  padding: env(safe-area-inset-top) 0 0;
}
.banda__in {
  max-width: var(--ancho);
  margin: 0 auto;
  padding: 8px 20px 64px;
}

.barra {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 56px;
}
.logo { height: 30px; width: auto; grid-column: 2; }
.barra__hueco { grid-column: 3; }

.atras {
  grid-column: 1; justify-self: start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px 0 6px; margin-left: -6px;
  border: 0; border-radius: var(--radio-in);
  background: transparent; color: var(--cielo);
  font-size: 16px; font-weight: 600; cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--t-estado) var(--curva), color var(--t-estado) var(--curva);
}
.atras:active { background: var(--marino-alto); color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .atras:hover { background: var(--marino-alto); color: #fff; }
}

/* Progreso de 3 pasos */
.progreso {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.progreso li { display: grid; gap: 8px; }
.progreso__tramo {
  height: 4px; border-radius: 2px; background: var(--marino-alto);
  transition: background-color var(--t-estado) var(--curva);
}
.progreso__txt {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--cielo);
}
.progreso li.es-hecho .progreso__tramo { background: var(--azul-vivo); }
.progreso li[aria-current="step"] .progreso__tramo { background: #fff; }
.progreso li[aria-current="step"] .progreso__txt { color: #fff; font-weight: 600; }

.antetitulo {
  margin-top: 24px;
  font-size: 15px; color: var(--cielo);
}
.titulo {
  margin-top: 6px;
  font-family: var(--titular); font-weight: 700;
  font-size: 28px; line-height: 1.15; letter-spacing: -0.015em;
  outline: none;
}
/* El foco llega aquí por programa al cambiar de paso (lectores de pantalla); no es un control, sin anillo */
.titulo:focus, .titulo:focus-visible { outline: none; }
.antetitulo[hidden] + .titulo { margin-top: 24px; }
.entradilla {
  margin-top: 10px;
  color: var(--cielo); font-size: 17px; max-width: 30em;
}

/* ---------- Cuerpo ---------- */
.cuerpo {
  flex: 1;
  width: 100%;
  max-width: var(--ancho);
  margin: -44px auto 0;
  padding: 0 12px 24px;
}

.vista { display: grid; gap: 12px; }
.vista.entra { animation: entrar var(--t-vista) var(--curva) both; }
.vista.entra.atras-dir { animation-name: entrar-atras; }
@keyframes entrar { from { opacity: 0; transform: translateX(14px); } }
@keyframes entrar-atras { from { opacity: 0; transform: translateX(-14px); } }

.panel {
  background: var(--panel);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
  display: grid;
  gap: 16px;
}
.panel__titulo {
  font-size: 17px; font-weight: 700; line-height: 1.3;
}
.suave { color: var(--tinta-suave); }

/* Inicio */
.pasos { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.pasos li { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: center; }
.pasos li > span:last-child { display: grid; line-height: 1.35; }
.pasos li .suave { font-size: 15px; }
.pasos__n {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--azul-velo); color: var(--azul-hondo);
  font-family: var(--titular); font-weight: 700; font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.nota {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radio-in);
  background: var(--fondo); color: var(--tinta-suave); font-size: 15px; line-height: 1.45;
}
.nota .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--tinta); }
.pie-panel { font-size: 15px; color: var(--tinta-suave); text-align: center; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 20px;
  border-radius: 12px; border: 0;
  font-size: 17px; font-weight: 600; line-height: 1.2; text-align: center;
  cursor: pointer; touch-action: manipulation; user-select: none;
  transition: background-color var(--t-estado) var(--curva), box-shadow var(--t-estado) var(--curva), transform var(--t-rapido) var(--curva);
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { cursor: default; transform: none; }
.btn--primario { background: var(--azul); color: #fff; box-shadow: 0 1px 2px rgba(10, 30, 60, .12); }
.btn--primario:active { background: var(--azul-hondo); }
.btn--primario[disabled] { background: #8FA9D9; }
.btn--secundario { background: var(--azul-velo); color: var(--azul-hondo); }
.btn--secundario:active { background: #D6E4FF; }
@media (hover: hover) and (pointer: fine) {
  .btn--primario:hover:not([disabled]) { background: var(--azul-hondo); }
  .btn--secundario:hover { background: #D6E4FF; }
}

.acciones { display: grid; gap: 10px; }
.acciones--fila { grid-template-columns: 1fr 1.4fr; }

.enlace {
  min-height: 44px; min-width: 44px; padding: 0 6px;
  border: 0; background: none; cursor: pointer;
  color: var(--azul-hondo); font-weight: 600; font-size: 16px;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  touch-action: manipulation;
}

/* Escritorio: sin cámara, el archivo pasa a ser la acción principal */
.txt-escritorio, .pista-escritorio { display: none; }
.es-escritorio .solo-tactil { display: none; }
.es-escritorio .txt-tactil { display: none; }
.es-escritorio .txt-escritorio { display: inline; }
.es-escritorio .pista-escritorio { display: block; font-size: 15px; color: var(--tinta-suave); text-align: center; }
.es-escritorio .acciones--guia [data-accion="archivo"] { background: var(--azul); color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .es-escritorio .acciones--guia [data-accion="archivo"]:hover { background: var(--azul-hondo); }
}

/* ---------- Captura del DNI ---------- */
.marco { margin: 0; padding: 4px 6px 0; }
.dni { width: 100%; height: auto; max-width: 360px; margin: 0 auto; }
.dni__tarjeta { fill: var(--dni-tarjeta); stroke: var(--dni-trazo); stroke-width: 1.5; }
.dni__barra { fill: var(--dni-relleno); }
.dni__barra--clara { fill: #E7EDF6; }
.dni__foto { fill: var(--dni-relleno); }
.dni__silueta { fill: var(--dni-silueta); }
.dni__firma { fill: none; stroke: var(--dni-silueta); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.dni__mrz { fill: none; stroke: var(--dni-relleno); stroke-width: 9; stroke-dasharray: 7 3; }
.esquina { fill: none; stroke: var(--azul); stroke-width: 4; stroke-linecap: round; }

.consejos {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.consejos li {
  display: grid; justify-items: center; gap: 6px;
  padding: 10px 4px; border-radius: var(--radio-in);
  background: var(--fondo);
  font-size: 14px; line-height: 1.25; text-align: center; color: var(--tinta);
}
.consejos .ico { color: var(--azul-hondo); }

.previa {
  aspect-ratio: 1.585;
  border-radius: 12px;
  background: var(--marino);
  overflow: hidden;
  display: grid; place-items: center;
}
.previa { position: relative; }
.previa img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.previa--pdf { background: var(--fondo); }
.pdf {
  display: grid; justify-items: center; gap: 8px; padding: 16px; text-align: center;
  color: var(--tinta-suave); font-size: 15px;
}
.pdf .ico { width: 36px; height: 36px; color: var(--azul-hondo); stroke-width: 1.5; }
.pdf strong { color: var(--tinta); font-weight: 600; word-break: break-all; }
.captura__pregunta { font-weight: 600; text-align: center; text-wrap: balance; }

.ocupado {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; color: var(--tinta-suave);
}
.giro {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--linea); border-top-color: var(--azul);
  animation: girar 0.9s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* Avisos */
.aviso {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radio-in);
  font-size: 15px; line-height: 1.45;
}
.aviso::before {
  content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px;
  background: currentColor;
  -webkit-mask: var(--icono) center / contain no-repeat; mask: var(--icono) center / contain no-repeat;
}
.aviso--error {
  background: var(--error-velo); color: #9F1D14;
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}
.aviso--info {
  background: var(--fondo); color: var(--tinta-suave);
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
}
.aviso--leve {
  background: #FFF6E0; color: #7A4B00;
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

/* ---------- Firma ---------- */
.lienzo {
  position: relative;
  height: clamp(220px, 36dvh, 300px);
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--linea);
  overflow: hidden;
  touch-action: none;
}
.lienzo canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair;
  -webkit-user-select: none; user-select: none;
  z-index: 1;
}
.lienzo__linea {
  position: absolute; left: 20px; right: 20px; top: 70%;
  border-bottom: 1.5px dashed var(--dni-trazo);
  pointer-events: none;
}
.lienzo__linea span {
  position: absolute; left: 0; bottom: 4px;
  font-size: 22px; line-height: 1; color: var(--dni-silueta);
}
.lienzo__hueco {
  position: absolute; left: 0; right: 0; top: 70%;
  transform: translateY(-160%);
  text-align: center; color: #8A99B0; font-size: 17px;
  pointer-events: none;
  transition: opacity var(--t-estado) var(--curva);
}
.lienzo.con-trazo .lienzo__hueco { opacity: 0; }
.lienzo:focus-within { box-shadow: inset 0 0 0 2px var(--azul); }

.girar {
  display: none;
  align-items: center; gap: 10px;
  font-size: 15px; color: var(--tinta-suave);
}
.girar .ico { color: var(--azul-hondo); }
@media (orientation: portrait) and (max-width: 599px) {
  .girar { display: flex; }
}

/* ---------- Revisión ---------- */
.resumen { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.resumen li {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 14px; align-items: center;
  padding: 8px 0;
}
.resumen li + li { border-top: 1px solid var(--linea); padding-top: 12px; }
.resumen__mini {
  width: 76px; aspect-ratio: 1.585; border-radius: 8px;
  background: var(--marino); overflow: hidden;
  display: grid; place-items: center;
}
.resumen__mini { position: relative; }
.resumen__mini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.resumen__mini--firma { background: #fff; box-shadow: inset 0 0 0 1px var(--linea); }
.resumen__mini--firma img { object-fit: contain; padding: 4px; }
.resumen__mini--pdf { background: var(--fondo); color: var(--azul-hondo); }
.resumen__mini--pdf .ico { width: 24px; height: 24px; stroke-width: 1.75; }
.resumen__txt { display: grid; min-width: 0; line-height: 1.35; }
.resumen__meta { font-size: 15px; overflow-wrap: anywhere; }

.casilla {
  position: relative;
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  cursor: pointer; padding: 4px 0;
  font-size: 16px; line-height: 1.45;
}
.casilla input { position: absolute; opacity: 0; width: 28px; height: 28px; margin: 0; }
.casilla__caja {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: #fff; box-shadow: inset 0 0 0 2px #9AA9C0;
  color: transparent;
  transition: background-color var(--t-rapido) var(--curva), box-shadow var(--t-rapido) var(--curva);
}
.casilla__caja .ico { width: 18px; height: 18px; stroke-width: 3; }
.casilla input:checked + .casilla__caja { background: var(--azul); box-shadow: none; color: #fff; }
.casilla input:focus-visible + .casilla__caja { outline: 3px solid var(--azul); outline-offset: 2px; }
.casilla.con-error .casilla__caja { box-shadow: inset 0 0 0 2px var(--error); }
.privacidad { font-size: 15px; }
.privacidad a { color: var(--azul-hondo); text-underline-offset: 3px; }

.barra-envio {
  height: 4px; border-radius: 2px; background: var(--linea); overflow: hidden;
}
.barra-envio span {
  display: block; height: 100%; width: 100%; background: var(--azul);
  transform-origin: left; transform: scaleX(0);
  transition: transform var(--t-estado) linear;
}

/* ---------- Hecho ---------- */
.panel--hecho { justify-items: center; text-align: center; padding: 28px 20px; gap: 12px; }
.hecho__icono {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok-velo); color: var(--ok);
}
.hecho__icono .ico { width: 32px; height: 32px; stroke-width: 2.5; }
.hecho__txt { font-size: 18px; font-weight: 600; }
.panel--hecho .suave { font-size: 15px; max-width: 26em; }

/* ---------- Pie ---------- */
.pie {
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  text-align: center; font-size: 14px; color: var(--tinta-suave);
}

/* ---------- Tamaños ---------- */
@media (min-width: 600px) {
  .banda__in { padding: 12px 24px 72px; }
  .titulo { font-size: 34px; }
  .cuerpo { padding: 0 24px 32px; margin-top: -48px; }
  .panel { padding: 28px; gap: 20px; }
  .lienzo { height: 280px; }
  .vista { gap: 16px; }
}

/* Móvil en horizontal: la banda se compacta y el lienzo gana alto */
@media (orientation: landscape) and (max-height: 500px) {
  .banda__in { padding-bottom: 52px; }
  .barra { min-height: 48px; }
  .progreso { margin-top: 8px; }
  .antetitulo, .entradilla { display: none; }
  .titulo, .antetitulo[hidden] + .titulo { margin-top: 10px; font-size: 22px; }
  .pie { display: none; }
  /* Firma en horizontal: botones a la derecha, el lienzo ocupa todo el alto posible */
  body:has([data-vista="firma"]:not([hidden])) :is(.cuerpo, .banda__in) { max-width: 100%; }
  .panel--firma {
    grid-template-columns: 1fr 150px;
    grid-template-rows: auto auto;
    align-items: start;
    padding: 14px;
    gap: 12px;
  }
  .panel--firma .lienzo { grid-column: 1; grid-row: 1 / span 2; height: calc(100dvh - 204px); min-height: 140px; }
  .panel--firma .acciones--fila { grid-column: 2; grid-row: 1; grid-template-columns: 1fr; }
  .panel--firma .aviso { grid-column: 2; grid-row: 2; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .vista.entra, .vista.entra.atras-dir { animation: aparecer 150ms linear both; }
  @keyframes aparecer { from { opacity: 0; } }
  .btn:active { transform: none; }
  .giro { animation-duration: 2.4s; }
  .barra-envio span { transition: none; }
}
