/* Animaciones explicativas.
   Regla de oro: sin JavaScript o con "reducir movimiento", todo se ve en su estado final.
   Los estados iniciales solo se aplican cuando <html> tiene la clase .js (se añade en el <head>). */

/* ---------- Aparición al hacer scroll ---------- */
.js [data-reveal] { opacity: 0; transition: opacity .7s ease var(--d, 0s), transform .7s ease var(--d, 0s); }
.js [data-reveal="left"] { transform: translateX(-56px); }
.js [data-reveal="right"] { transform: translateX(56px); }
.js [data-reveal="up"] { transform: translateY(28px); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
/* Las tarjetas que entran de costado nunca deben crear desplazamiento horizontal */
.sec { overflow-x: clip; }
@media (max-width: 699px) {
  .js [data-reveal="left"] { transform: translateX(-24px); }
  .js [data-reveal="right"] { transform: translateX(24px); }
}

/* ---------- Ruta que se llena con el scroll ---------- */
.route { --p: 1; }
.route::after { content: ""; position: absolute; left: 17px; top: 8px; width: 2px; height: calc((100% - 16px) * var(--p)); background: linear-gradient(var(--blue), var(--purple-2)); border-radius: 2px; }
.js .route li { transition: opacity .5s ease; }
.js .route li:not(.is-on) { opacity: .38; }
.route li::before { transition: background .35s ease, color .35s ease, transform .35s ease, box-shadow .35s ease; }
.js .route li.is-on::before { background: var(--yellow); color: var(--ink); transform: scale(1.12); box-shadow: 0 0 0 6px rgba(255, 194, 14, .22); }

/* ---------- Sello del acuerdo ---------- */
.seal { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 28px auto 0; max-width: 560px; padding: 14px 20px; border-radius: 999px; background: #e9f8ef; border: 1px solid #b7e4c7; color: #0f5d34; font-weight: 700; text-align: center; }
.seal__check { width: 30px; height: 30px; flex: none; fill: none; stroke: #137a43; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.seal__check circle { stroke-dasharray: 63; stroke-dashoffset: 0; }
.seal__check path { stroke-dasharray: 20; stroke-dashoffset: 0; }
.js .seal__check circle { stroke-dashoffset: 63; transition: stroke-dashoffset .8s ease calc(var(--d, 0s) + .2s); }
.js .seal__check path { stroke-dashoffset: 20; transition: stroke-dashoffset .5s ease calc(var(--d, 0s) + .8s); }
.js .seal.is-in .seal__check circle, .js .seal.is-in .seal__check path { stroke-dashoffset: 0; }

/* ---------- De tu Excel al sistema ---------- */
.flow { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 640px) { .flow { grid-template-columns: 1fr 104px 1fr; } }
.flow__panel { border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .85rem; }
.flow__head { padding: 9px 14px; font-weight: 700; font-size: .8rem; color: #fff; background: #5a6b5d; }
.flow__panel--sys .flow__head { background: var(--purple); }
.flow__rows { margin: 0; padding: 8px 10px 12px; list-style: none; display: grid; gap: 6px; }
.flow__rows li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; background: #f6f6f2; border: 1px dashed #d5d5c8; color: #4a4a40; transition: opacity .5s ease calc(var(--i, 0) * .22s), transform .5s ease calc(var(--i, 0) * .22s); }
.flow__rows li em { font-style: normal; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #ffe3e3; color: #b42318; white-space: nowrap; }
.flow__panel--sys .flow__rows li { background: #fff; border: 1px solid var(--line); color: var(--text); transition-delay: calc(1.3s + var(--i, 0) * .38s); }
.flow__panel--sys .flow__rows li b { color: #137a43; }
/* Estado inicial (y reinicio del bucle): las filas se ocultan al instante, sin transición,
   para que TODAS reaparezcan en cada vuelta y no solo las primeras. */
.js .flow:not(.is-in) .flow__rows li { opacity: 0; transform: translateY(8px); transition: none; }

/* Checks de Credinnova: se apagan al reiniciar y se reactivan en verde cuando el engranaje termina de girar
   (el engranaje gira 4 vueltas de 1,1 s a partir de 0,5 s: termina a los 4,9 s). */
.js .flow:not(.is-in) .flow__panel--sys .flow__rows li b { color: #b9b4c8; }
.js .flow.is-in .flow__panel--sys .flow__rows li b { display: inline-block; animation: checkOn .55s ease calc(4.9s + var(--i, 0) * .14s) both; }
@keyframes checkOn { 0% { color: #b9b4c8; transform: scale(.7); } 55% { color: #137a43; transform: scale(1.55); } 100% { color: #137a43; transform: scale(1); } }
.js .flow.is-in .flow__panel--sys { animation: panelOk .9s ease 5.1s both; }
@keyframes panelOk { 0%, 100% { box-shadow: var(--shadow); } 40% { box-shadow: 0 0 0 4px rgba(19, 122, 67, .28), var(--shadow); } }
.flow__panel--sys .flow__rows li span { font-weight: 600; }

/* Cabeceras con ícono */
.flow__head { display: flex; align-items: center; gap: 8px; }
.flow__head--xls { background: #1d6f42; }
.xls-ico { width: 28px; height: 28px; flex: none; }
.flow__head img { display: block; flex: none; }

/* Zona central: línea punteada, engranaje que gira, etiqueta y flecha */
.flow__belt { position: relative; display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 120px; }
.flow__belt::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed #b9a9e6; transform: translateY(-1px); }
.flow__belt i { position: absolute; top: 50%; left: 0; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--yellow); opacity: 0; }
.flow__gear { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--purple); box-shadow: 0 0 0 6px var(--tint), 0 6px 16px rgba(57, 25, 110, .35); }
.flow__gear svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.flow__gear .teeth { stroke-width: 2.6; }
.flow__label { position: relative; z-index: 1; font-size: .72rem; font-weight: 700; color: var(--purple); padding: 1px 6px; background: var(--tint); border-radius: 6px; }
.flow__arrow { position: relative; z-index: 1; width: 26px; height: 26px; padding: 3px; border-radius: 50%; background: var(--yellow); fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.js .flow.is-in .flow__gear svg { animation: gira 1.1s linear 4 .5s; }
.js .flow.is-in .flow__belt i { animation: viaja 1.3s ease-in-out 3 calc(.6s + var(--k, 0) * .24s) both; }
@keyframes gira { to { transform: rotate(360deg); } }
@keyframes viaja { 0% { left: 0; opacity: 0; } 15%, 85% { opacity: 1; } 100% { left: calc(100% - 10px); opacity: 0; } }

@media (max-width: 639px) {
  .flow__belt { min-height: 130px; }
  .flow__belt::before { left: 50%; right: auto; top: 0; bottom: 0; border-top: 0; border-left: 2px dashed #b9a9e6; transform: translateX(-1px); }
  .flow__belt i { left: 50%; top: 0; margin: 0 0 0 -5px; }
  .flow__arrow { transform: rotate(90deg); }
  @keyframes viaja { 0% { top: 0; opacity: 0; } 15%, 85% { opacity: 1; } 100% { top: calc(100% - 10px); opacity: 0; } }
}
.flow .mock__tag { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; text-align: center; color: var(--muted); }

/* ---------- Reducir movimiento: todo en su estado final ---------- */
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal], .js [data-reveal].is-in { opacity: 1 !important; transform: none !important; transition: none !important; }
  .js .route li:not(.is-on) { opacity: 1; }
  .js .route li::before, .route li::before { transition: none; }
  .js .flow:not(.is-in) .flow__rows li { opacity: 1; transform: none; }
  .js .flow:not(.is-in) .flow__panel--sys .flow__rows li b { color: #137a43; }
  .js .flow.is-in .flow__panel--sys .flow__rows li b, .js .flow.is-in .flow__panel--sys { animation: none; }
  .flow__rows li, .flow__panel--sys .flow__rows li { transition: none; }
  .js .flow.is-in .flow__belt i, .js .flow.is-in .flow__gear svg { animation: none; }
  .js .seal__check circle, .js .seal__check path { stroke-dashoffset: 0 !important; transition: none !important; }
}
