/* FIBRA: formularios públicos (postulación y ficha de ingreso). Frente SISTEMA.
   La sala oscura de EXPERIENCIA §1: negro cálido, rojo fibra, luz lateral. Usa tokens.css.
   Movimiento: solo transform, opacity y clip-path. Modo calmo (.fb-calmo): sin desplazamientos,
   solo fundidos. Todo lo que el JS pinta está definido acá (incluida .fb-oculto). */

/* ------------------------------------------------------------------ base */
.fb-form, .fb-dialogo {
  --fb-campo: var(--noche-2);
  --fb-borde: #6B625C; /* 3,2:1 contra el campo: el límite del campo se ve (WCAG 1.4.11) */
  --fb-destacada: #141110;
  color: var(--hueso);
  font-family: var(--f-texto);
  font-size: var(--t-texto);
  line-height: var(--interlinea);
  -webkit-font-smoothing: antialiased;
}
.fb-form *, .fb-form *::before, .fb-form *::after { box-sizing: border-box; }
.fb-form [hidden], .fb-dialogo [hidden] { display: none !important; }

.fb-oculto {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ diálogo a pantalla completa */
.fb-dialogo {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: var(--pantalla, 100vh);
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--noche);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.fb-dialogo::backdrop { background: var(--noche); }
/* Abierto con show() (no modal, postulacion.js): no está en la capa superior, así que va por encima
   de la cabecera fija y del menú; los avisos (z-index 120) siguen arriba. */
.fb-dialogo:not(:modal) { z-index: 110; }
.fb-dialogo[open] { animation: fb-entra 320ms var(--ease-salida) both; }
.fb-dialogo.fb-cerrando { animation: fb-sale 200ms var(--ease-suave) both; }
.fb-calmo.fb-dialogo[open] { animation: fb-funde 240ms linear both; }
.fb-calmo.fb-dialogo.fb-cerrando { animation: fb-funde-sale 160ms linear both; }
@keyframes fb-entra { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fb-sale { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(10px); } }
@keyframes fb-funde { from { opacity: 0; } to { opacity: 1; } }
@keyframes fb-funde-sale { from { opacity: 1; } to { opacity: 0; } }
/* Sin bloqueo del scroll de <html>: cambiaba el scroller raíz y forzaba el relayout de toda la
   portada al abrir la postulación. El diálogo modal a pantalla completa ya tapa la página. */

.fb-dialogo__barra {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--e-4);
  padding: var(--e-3) var(--margen);
  background: var(--noche);
  border-bottom: 1px solid var(--linea-noche);
}
.fb-dialogo__logo { display: block; height: 26px; width: auto; }
.fb-cerrar {
  display: inline-flex; align-items: center; gap: var(--e-2);
  min-height: 44px; padding: 0 var(--e-3); margin-right: calc(var(--e-3) * -1);
  background: none; border: 0; border-radius: var(--r-m);
  color: var(--hueso-2); font: 500 var(--t-chico)/1 var(--f-texto); cursor: pointer;
  transition: color var(--d-hover) var(--ease-suave);
}
.fb-cerrar svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .fb-cerrar:hover { color: var(--hueso); } }

/* ------------------------------------------------------------------ contenedor */
.fb-form {
  box-sizing: border-box;
  width: 100%;
  max-width: 38rem;
  margin: 0 auto;
  padding: var(--e-6) var(--margen) var(--e-9);
}
.fb-cabeza { display: grid; gap: var(--e-4); margin-bottom: var(--e-7); }
.fb-cabeza__logo { width: 150px; height: auto; display: block; margin-bottom: var(--e-3); }
.fb-titular {
  margin: 0;
  font-family: var(--f-titular);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(2.35rem, 1.6rem + 3.4vw, 3.6rem);
  line-height: var(--interlinea-titular);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--hueso);
  text-wrap: balance;
}
.fb-titular em { font-style: italic; color: var(--hueso-2); }
.fb-bajada { margin: 0; color: var(--hueso-2); max-width: 36rem; text-wrap: pretty; }
.fb-datos { margin: 0; color: var(--hueso-3); font-size: var(--t-nota); }
.fb-califica { margin: 0; color: var(--hueso); font-weight: 600; max-width: 36rem; text-wrap: pretty; }
/* Contador de cupos: apagado salvo que el panel prenda un tope y lo muestre (no reserva renglón). */
.fb-cupos {
  display: flex; align-items: center; gap: var(--e-3); flex-wrap: wrap;
  margin: 0; min-height: 1.6rem; color: var(--hueso-2); font-size: var(--t-chico);
}
.fb-cupos__marcas { display: inline-flex; gap: 4px; }
.fb-cupos__marca { width: 3px; height: 16px; background: var(--linea-noche); transform: skewX(var(--angulo)); }
.fb-cupos__marca--llena { background: var(--sangre); }
.fb-enlace {
  color: var(--hueso);
  text-decoration: underline;
  text-decoration-color: var(--fibra-brillo);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--d-hover) var(--ease-suave);
}
@media (hover: hover) and (pointer: fine) { .fb-enlace:hover { text-decoration-color: var(--sangre-2); } }
.fb-nota-borrador {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--e-2) var(--e-4);
  margin: 0 0 var(--e-5); padding: var(--e-3) var(--e-4);
  border-left: 2px solid var(--fibra-brillo);
  background: var(--noche-2);
  color: var(--hueso-2); font-size: var(--t-chico);
}
.fb-nota-borrador button { min-height: 44px; }

/* ------------------------------------------------------------------ la fibra de avance */
.fb-avance { display: grid; gap: var(--e-3); margin-bottom: var(--e-6); }
.fb-fibra { position: relative; display: grid; gap: 3px; padding: 2px 0; }
.fb-fibra__hebra {
  position: relative; display: block; height: 2px; overflow: hidden;
  background: var(--linea-noche);
}
.fb-fibra__hebra:nth-child(2) { height: 3px; }
.fb-fibra__hebra::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--fibra-brillo);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  transition: transform 700ms var(--ease-salida);
}
.fb-fibra__hebra:nth-child(2)::after { background: var(--sangre); transition-delay: 40ms; }
.fb-fibra__hebra:nth-child(3)::after { transition-delay: 80ms; }
.fb-calmo .fb-fibra__hebra::after { transition: none; }
.fb-avance__texto { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--e-1) var(--e-4); }
.fb-avance__bloque {
  margin: 0;
  font-family: var(--f-titular); font-style: italic; font-weight: 700;
  font-size: var(--t-h3); line-height: 1; letter-spacing: -0.005em; text-transform: uppercase;
  color: var(--hueso);
}
.fb-avance__bloque:focus { outline: none; }
.fb-avance__sigue { color: var(--hueso-3); font-size: var(--t-nota); }

/* ------------------------------------------------------------------ pasos */
.fb-paso { border: 0; margin: 0; padding: 0; min-width: 0; }
.fb-paso[hidden] { display: none; }
.fb-paso--entra { animation: fb-paso 380ms var(--ease-salida) both; }
.fb-calmo .fb-paso--entra { animation: fb-funde 220ms linear both; }
@keyframes fb-paso { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.fb-intro { margin: 0 0 var(--e-5); color: var(--hueso-3); font-size: var(--t-chico); text-wrap: pretty; }
.fb-campos { display: grid; grid-template-columns: 1fr 1fr; gap: var(--e-5) var(--e-4); }
.fb-campo { grid-column: 1 / -1; display: grid; gap: var(--e-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.fb-campo--medio { grid-column: span 1; }
@media (max-width: 22rem) { .fb-campo--medio { grid-column: 1 / -1; } }

.fb-etiqueta { display: block; padding: 0; font-weight: 500; font-size: 1rem; line-height: 1.35; color: var(--hueso); text-wrap: pretty; }
.fb-etiqueta__nota { margin-left: var(--e-2); font-weight: 400; font-size: var(--t-nota); color: var(--hueso-3); }
.fb-ayuda { margin: calc(var(--e-1) * -1) 0 0; font-size: var(--t-nota); line-height: 1.5; color: var(--hueso-3); text-wrap: pretty; }

.fb-campo--destacada {
  padding: var(--e-5) var(--e-4);
  background: var(--fb-destacada);
  border: 1px solid var(--fibra-honda);
  border-radius: var(--r-l);
}
.fb-campo--destacada .fb-etiqueta { font-weight: 600; font-size: 1.0625rem; }

.fb-entrada { position: relative; }
.fb-input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  background: var(--fb-campo);
  border: 1px solid var(--fb-borde);
  border-radius: var(--r-m);
  color: var(--hueso);
  font: 400 1rem/1.5 var(--f-texto);
  font-variant-numeric: tabular-nums;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--d-hover) var(--ease-suave), background-color var(--d-hover) var(--ease-suave);
}
.fb-input::placeholder { color: var(--hueso-3); opacity: 1; }
textarea.fb-input { resize: vertical; min-height: 7.5rem; }
.fb-campo--destacada .fb-input { background: #0F0D0C; border-color: var(--fibra-honda); }
.fb-entrada--unidad .fb-input { padding-right: 3.2rem; }
.fb-unidad {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: var(--hueso-3); font-size: var(--t-nota); pointer-events: none;
}
@media (hover: hover) and (pointer: fine) { .fb-input:hover { border-color: #7D746E; } }
.fb-input:focus { outline: none; border-color: var(--hueso-3); }
.fb-input:focus-visible, .fb-form :focus-visible, .fb-dialogo :focus-visible {
  outline: 2px solid var(--sangre);
  outline-offset: 2px;
}
.fb-form [tabindex="-1"]:focus-visible, .fb-dialogo [tabindex="-1"]:focus-visible { outline: none; }
.fb-input[aria-invalid="true"] { border-color: var(--error); }
.fb-contador { justify-self: end; margin-top: calc(var(--e-1) * -1); font-size: var(--t-nota); color: var(--hueso-3); font-variant-numeric: tabular-nums; }
.fb-contador[hidden] { display: none; }
.fb-error {
  display: flex; gap: var(--e-2); align-items: flex-start;
  margin: 0; color: #F07275; font-size: var(--t-nota); line-height: 1.45;
}
.fb-error[hidden] { display: none; }
.fb-error::before {
  content: ""; flex: none; width: 3px; height: 1em; margin-top: 0.2em;
  background: var(--error); transform: skewX(var(--angulo));
}

/* Opciones (radio y casillas) */
.fb-opciones { display: grid; gap: var(--e-2); }
.fb-opciones--grilla { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
.fb-opcion {
  position: relative;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--e-3);
  min-height: 52px; padding: 12px 14px;
  background: var(--fb-campo);
  border: 1px solid var(--fb-borde);
  border-radius: var(--r-m);
  cursor: pointer;
  transition: border-color var(--d-hover) var(--ease-suave), background-color var(--d-hover) var(--ease-suave), transform 100ms var(--ease-suave);
}
.fb-opcion:active { transform: scale(0.99); }
@media (hover: hover) and (pointer: fine) { .fb-opcion:hover { border-color: #7D746E; } }
.fb-opcion input {
  width: 20px; height: 20px; margin: 0;
  accent-color: var(--sangre);
  cursor: pointer;
}
.fb-opcion__texto { display: grid; gap: 2px; color: #E3DED8; font-size: var(--t-chico); line-height: 1.35; }
.fb-opcion__detalle { color: var(--hueso-3); font-size: var(--t-nota); }
.fb-opcion:has(input:checked) { border-color: var(--fibra-brillo); background: var(--noche-3); }
.fb-opcion:has(input:focus-visible) { outline: 2px solid var(--sangre); outline-offset: 2px; }
.fb-opcion input:focus-visible { outline: none; }
.fb-grupo[aria-invalid="true"] .fb-opcion { border-color: rgb(229 72 77 / 0.55); }

/* Escala del 1 al 5 */
.fb-escala { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--e-2); }
.fb-escala .fb-opcion {
  grid-template-columns: 1fr; justify-items: center; min-height: 56px; padding: 8px 0;
}
.fb-escala input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; }
.fb-escala__numero {
  font-family: var(--f-titular); font-style: italic; font-weight: 700; font-size: 1.6rem; line-height: 1;
  color: #E3DED8;
}
.fb-escala .fb-opcion:has(input:checked) { background: var(--sangre); border-color: var(--sangre); }
.fb-escala .fb-opcion:has(input:checked) .fb-escala__numero { color: var(--sobre-sangre); }
.fb-escala__extremos { display: flex; justify-content: space-between; color: var(--hueso-3); font-size: var(--t-nota); }

/* Casilla de compromiso */
.fb-casilla {
  display: grid; grid-template-columns: auto 1fr; gap: var(--e-3); align-items: start;
  padding: var(--e-4); cursor: pointer;
  background: var(--fb-destacada);
  border: 1px solid var(--fibra-honda);
  border-radius: var(--r-l);
  color: #E3DED8; font-size: var(--t-chico); line-height: 1.55;
}
.fb-casilla input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--sangre); cursor: pointer; }
.fb-casilla:has(input:focus-visible) { outline: 2px solid var(--sangre); outline-offset: 2px; }
.fb-casilla input:focus-visible { outline: none; }
.fb-casilla[aria-invalid="true"] { border-color: var(--error); }

/* ------------------------------------------------------------------ acciones */
.fb-acciones {
  display: flex; flex-wrap: wrap-reverse; align-items: center; justify-content: space-between;
  gap: var(--e-4); margin-top: var(--e-7); padding-top: var(--e-5);
  border-top: 1px solid var(--linea-noche);
}
.fb-acciones__pie { flex-basis: 100%; margin: 0; color: var(--hueso-3); font-size: var(--t-nota); text-align: center; text-wrap: pretty; }
.fb-estado { flex-basis: 100%; margin: 0; font-size: var(--t-chico); color: #F07275; }
.fb-estado:empty { display: none; }
.fb-estado--ok { color: var(--hueso-2); }
.fb-alternativa { flex-basis: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--e-2); }
.fb-alternativa[hidden] { display: none; }
/* Plan B (revisión del 28-sep): el aviso no va en rojo (no es un error de la persona) y el WhatsApp es
   la acción principal; su texto, si parte en dos renglones, respira. */
.fb-estado--plan-b { color: var(--hueso); line-height: 1.5; text-wrap: pretty; }
.fb-boton--wa { line-height: 1.25; text-align: center; padding-block: var(--e-2); }
.fb-alternativa__nota { margin: 0; max-width: 34rem; color: var(--hueso-3); font-size: var(--t-nota); line-height: 1.5; text-align: center; text-wrap: pretty; }
/* "Copiar mis respuestas" (revisión del 28-sep): por si WhatsApp no abre; si el navegador no deja copiar,
   el texto aparece en un recuadro para copiarlo a mano. */
.fb-copiar { width: 100%; max-width: 34rem; display: flex; flex-direction: column; align-items: center; gap: var(--e-2); }
.fb-copiar__texto { width: 100%; min-height: 9rem; font-size: var(--t-nota); }

.fb-boton {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  min-height: 52px; padding: 0 var(--e-6);
  overflow: hidden;
  border: 0; border-radius: var(--r-m);
  background: var(--sangre); color: var(--sobre-sangre);
  font: 600 1.0625rem/1 var(--f-texto);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--d-hover) var(--ease-suave), transform 100ms var(--ease-suave);
}
.fb-boton::after {
  /* la hebra de luz que cruza en diagonal al pasar el puntero */
  content: "";
  position: absolute; top: -20%; bottom: -20%; left: 0; width: 18%;
  background: rgb(255 255 255 / 0.22);
  /* el mismo gesto que .boton--principal de la web: la pendiente de la marca (-8°) y 220 ms */
  transform: translateX(-180%) skewX(var(--angulo));
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  /* el fondo no aclara a --sangre-2: con el texto claro, --sangre da 4,87:1 (AA) */
  .fb-boton:hover::after { transform: translateX(640%) skewX(var(--angulo)); transition: transform 220ms var(--ease-suave); }
}
.fb-boton:active { transform: scale(0.97); }
.fb-boton svg { width: 20px; height: 20px; flex: none; }
.fb-boton[aria-busy="true"] { cursor: progress; opacity: 0.8; }
.fb-boton--ancho { flex: 1 1 14rem; }
.fb-boton--sec {
  background: transparent; color: var(--hueso);
  border: 1px solid var(--linea-noche);
}
.fb-boton--sec::after { display: none; }
@media (hover: hover) and (pointer: fine) { .fb-boton--sec:hover { background: var(--noche-3); border-color: #3A3431; } }
.fb-volver {
  min-height: 44px; padding: 0 var(--e-2); margin-left: calc(var(--e-2) * -1);
  background: none; border: 0; color: var(--hueso-2);
  font: 500 var(--t-chico)/1 var(--f-texto); cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px;
  transition: color var(--d-hover) var(--ease-suave), text-decoration-color var(--d-hover) var(--ease-suave);
}
.fb-volver[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) { .fb-volver:hover { color: var(--hueso); text-decoration-color: var(--fibra-brillo); } }

/* ------------------------------------------------------------------ pantalla final y estados */
.fb-final { display: grid; gap: var(--e-5); padding-top: var(--e-4); }
.fb-final--entra { animation: fb-paso 480ms var(--ease-salida) both; }
.fb-calmo .fb-final--entra { animation: fb-funde 240ms linear both; }
.fb-final__trazo { display: block; width: 72px; height: 3px; background: var(--sangre); transform: skewX(var(--angulo)); }
.fb-final__texto { margin: 0; color: var(--hueso-2); max-width: 34rem; text-wrap: pretty; }
.fb-final__acciones { display: flex; flex-wrap: wrap; gap: var(--e-3); margin-top: var(--e-2); }
.fb-cita { margin: 0; font-family: var(--f-cita); font-style: italic; font-size: 1.35rem; line-height: 1.3; color: var(--hueso); }

.fb-esqueleto { display: grid; gap: var(--e-4); padding-top: var(--e-4); }
.fb-esqueleto span {
  display: block; height: 14px; border-radius: var(--r-s);
  background: var(--noche-2);
  animation: fb-respira 1600ms ease-in-out infinite alternate;
}
.fb-esqueleto span:nth-child(1) { height: 44px; width: 70%; }
.fb-esqueleto span:nth-child(2) { width: 92%; }
.fb-esqueleto span:nth-child(3) { width: 84%; }
.fb-calmo .fb-esqueleto span { animation: none; }
@keyframes fb-respira { from { opacity: 0.55; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .fb-boton::after { display: none; }
}

@media (min-width: 48rem) {
  .fb-form { padding-top: var(--e-8); }
  .fb-dialogo .fb-form { padding-top: var(--e-7); }
}

/* Campos que dependen de otra respuesta (FB.esquemas: soloSi). */
.fb-form [data-solo-si][hidden] { display: none; }
