/* ============================================================
   DevEps — «Convierte una factura a Excel» (/factura-a-excel/ y /ca/factura-a-excel/)
   Se apoya en styles.css y analiza.css (cabecera, paneles, pasos, llamada a la acción).
   ============================================================ */

.fx-hero { padding-bottom: 72px; }
/* Con la cabecera oculta, los paneles quedan debajo de la barra de navegación fija */
#fxEspera, #fxFallo, #fxResultado { padding-top: 120px; }

/* ── Dibujo: una factura que se lee y pasa a una tabla ── */
.fx-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 28px auto 0;
  height: 96px;
}
.fx-doc {
  position: relative;
  width: 72px;
  height: 92px;
  padding: 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.fx-doc span { display: block; height: 5px; border-radius: 3px; background: #c9cbd6; }
.fx-doc .fx-doc-cab { width: 60%; height: 7px; background: #ff6b00; }
.fx-doc .fx-corta { width: 55%; }
.fx-doc .fx-doc-total { width: 45%; margin-left: auto; margin-top: auto; background: #1a1a2e; }
.fx-escaner {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ff6b00, transparent);
  box-shadow: 0 0 12px 2px rgba(255, 107, 0, 0.6);
  opacity: 0;
}
.fx-flecha { width: 44px; height: 22px; fill: none; stroke: var(--orange); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fx-tabla {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}
.fx-tabla span { height: 14px; border-radius: 3px; background: rgba(34, 197, 94, 0.55); }
.fx-tabla span:nth-child(-n+3) { background: rgba(34, 197, 94, 0.9); }

@media (prefers-reduced-motion: no-preference) {
  .fx-escaner { animation: fx-escanear 4.8s ease-in-out infinite; }
  .fx-flecha path { stroke-dasharray: 60; animation: fx-flecha 4.8s ease-in-out infinite; }
  .fx-tabla span { animation: fx-celda 4.8s ease-out infinite backwards; }
  .fx-tabla span:nth-child(3n+2) { animation-delay: 0.08s; }
  .fx-tabla span:nth-child(3n) { animation-delay: 0.16s; }
  .fx-tabla span:nth-child(n+4) { animation-name: fx-celda-2; }
  .fx-tabla span:nth-child(n+7) { animation-name: fx-celda-3; }
  .fx-tabla span:nth-child(n+10) { animation-name: fx-celda-4; }
  .fx-hero h1, .fx-hero .analiza-sub, .fx-visual, .fx-tarjeta {
    animation: fx-entrar 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  }
  .fx-hero .analiza-sub { animation-delay: 0.08s; }
  .fx-visual { animation-delay: 0.16s; }
  .fx-tarjeta { animation-delay: 0.24s; }
}
@keyframes fx-entrar { from { opacity: 0; transform: translateY(18px); } }
@keyframes fx-escanear {
  0% { top: 0; opacity: 0; }
  8% { opacity: 1; }
  40% { top: calc(100% - 3px); opacity: 1; }
  48%, 100% { top: calc(100% - 3px); opacity: 0; }
}
@keyframes fx-flecha {
  0%, 35% { stroke-dashoffset: 60; }
  50%, 90% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -60; }
}
/* Cada fila de la tabla se rellena un poco después de la anterior y todas se vacían al final */
@keyframes fx-celda   { 0%, 45% { opacity: 0.12; transform: scaleX(0.4); } 52%, 92% { opacity: 1; transform: none; } 100% { opacity: 0.12; } }
@keyframes fx-celda-2 { 0%, 52% { opacity: 0.12; transform: scaleX(0.4); } 59%, 92% { opacity: 1; transform: none; } 100% { opacity: 0.12; } }
@keyframes fx-celda-3 { 0%, 59% { opacity: 0.12; transform: scaleX(0.4); } 66%, 92% { opacity: 1; transform: none; } 100% { opacity: 0.12; } }
@keyframes fx-celda-4 { 0%, 66% { opacity: 0.12; transform: scaleX(0.4); } 73%, 92% { opacity: 1; transform: none; } 100% { opacity: 0.12; } }

/* ── Formulario ── */
.fx-tarjeta {
  max-width: 600px;
  margin: 28px auto 0;
  padding: 22px;
  text-align: left;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}
.fx-zona {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 18px;
  text-align: center;
  cursor: pointer;
  color: var(--text-light);
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}
.fx-zona:hover, .fx-zona.activa, .fx-zona:focus-within { border-color: var(--orange); background: var(--glass-bg-hover); }
.fx-zona.activa { transform: scale(1.01); }
.fx-zona svg { width: 34px; height: 34px; fill: none; stroke: var(--orange); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fx-zona-titulo { font-weight: 600; }
.fx-zona-nota { font-size: 0.85rem; color: var(--text-secondary); }
.fx-zona input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fx-elegido {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 0.93rem;
  overflow-wrap: anywhere;
}
.fx-elegido[hidden] { display: none; }
.fx-elegido button {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.fx-elegido button:hover { color: var(--text-light); border-color: var(--orange); }
.fx-aviso {
  margin: 16px 0 0;
  padding: 10px 14px 10px 40px;
  position: relative;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--text-light);
  font-size: 0.93rem;
}
.fx-aviso::before {
  content: "!";
  position: absolute;
  left: 12px; top: 50%;
  translate: 0 -50%;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #f59e0b;
  color: #0a0a1a;
  font-size: 0.75rem;
  font-weight: 700;
}
.fx-check { margin: 14px 0 0; }
.fx-captcha { margin-top: 16px; min-height: 0; }
.fx-captcha:empty { display: none; }
.fx-error { min-height: 1.4em; margin: 10px 0; color: #ffb27a; font-size: 0.9rem; }
.fx-error:empty { min-height: 0; margin: 6px 0; }
.page-analiza button.fx-boton { width: 100%; justify-content: center; }

/* ── Resultado ── */
.fx-resultado {
  padding: 28px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}
.fx-resultado-cab { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.fx-nombre { font-family: var(--font-heading); font-size: clamp(1.3rem, 3vw, 1.8rem); color: var(--text-light); overflow-wrap: anywhere; }
.fx-nombre:focus { outline: none; }
.fx-veredicto {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.45);
  color: #b9f5d0;
}
.fx-veredicto.revisar { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.5); color: #fde3a7; }
.fx-datos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
  margin: 22px 0 0;
}
.fx-datos > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.95rem;
}
.fx-datos dt { color: var(--text-secondary); flex-shrink: 0; }
.fx-datos dd { margin: 0; color: var(--text-light); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fx-datos dd.vacio { color: #6e6e82; }
.fx-datos > .fx-total { grid-column: 1 / -1; border-bottom: 0; border-top: 1px solid rgba(255, 255, 255, 0.18); margin-top: -1px; }
.fx-datos .fx-total dt, .fx-datos .fx-total dd { color: var(--text-light); font-weight: 700; font-size: 1.05rem; }
.fx-avisos { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; }
.fx-avisos li {
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.93rem;
  color: var(--text-light);
}
.fx-avisos li.nota { background: var(--glass-bg); border-color: var(--glass-border); color: var(--text-secondary); }
.fx-descarga { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 24px; }
.fx-descarga-nota { flex: 1 1 260px; font-size: 0.88rem; color: var(--text-secondary); }
.fx-descarga-nota.hecho { color: #b9f5d0; }
.fx-cta { margin-top: 24px; }

@media (prefers-reduced-motion: no-preference) {
  #fxResultado:not([hidden]) .fx-datos > div { animation: fx-entrar 0.45s ease-out backwards; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(2) { animation-delay: 0.04s; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(3) { animation-delay: 0.08s; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(4) { animation-delay: 0.12s; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(5) { animation-delay: 0.16s; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(6) { animation-delay: 0.2s; }
  #fxResultado:not([hidden]) .fx-datos > div:nth-child(n+7) { animation-delay: 0.24s; }
  /* Las tarjetas de «Qué pasa con tu factura» aparecen al llegar con el scroll */
  @supports (animation-timeline: view()) {
    .fx-info .analiza-info-grid > div {
      animation: fx-entrar linear backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }
}

@media (max-width: 640px) {
  #fxEspera, #fxFallo, #fxResultado { padding-top: 96px; }
  .fx-tarjeta { padding: 16px; }
  .fx-resultado { padding: 20px 16px; }
  .fx-datos { grid-template-columns: 1fr; }
  .fx-visual { height: 80px; transform: scale(0.85); }
}
