/* Movimiento al hacer scroll: la página "se construye" mientras bajas.
   Idea: BLANC es el espacio en blanco que se ocupa. Las líneas se dibujan, lo vacío se rellena, el concreto se abre.
   Va después del <style> de cada página. Sin soporte de animaciones por scroll, todo queda quieto y legible. */

.progress { display: none; }

/* Aparición escalonada de elementos en grupo (motion.js pone --d y la clase .st) */
.js .rv { transition-delay: calc(var(--d, 0) * 90ms); }
.js .st { opacity: 0; translate: 0 18px; transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1), translate 800ms cubic-bezier(0.16, 1, 0.3, 1); transition-delay: calc(var(--d, 0) * 70ms); }
.js .st.in { opacity: 1; translate: 0 0; }

/* Total del cotizador: pequeño golpe cuando cambia */
.bump { animation: sdBump 420ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes sdBump { from { translate: 0 8px; opacity: 0.35; } to { translate: 0 0; opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {

    /* Barra de avance de lectura: se ve sobre claro y sobre oscuro */
    .progress { display: block; position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 40; pointer-events: none; background: #fff; mix-blend-mode: difference; transform-origin: 0 50%; animation: sdGrow linear both; animation-timeline: scroll(root); }

    /* Filete de cada sección: se dibuja de izquierda a derecha al entrar */
    .sec-head { position: relative; border-top-color: transparent !important; }
    .sec-head::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: var(--ink); transform-origin: 0 50%; animation: sdGrow linear both; animation-timeline: view(); animation-range: entry 20% cover 35%; }

    /* Proceso: una sola línea que corre por encima de los pasos */
    .process { position: relative; }
    .process > div { border-top-color: transparent !important; }
    .process::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--ink); transform-origin: 0 50%; animation: sdGrow linear both; animation-timeline: view(); animation-range: entry 60% cover 55%; }

    /* PORTADA: el hero se queda atrás al bajar */
    .hero-bg { animation: sdSink linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
    .hero-logo { animation: sdLift linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
    .hero-words { animation: sdAway linear both; animation-timeline: scroll(root); animation-range: 0 55vh; }

    /* Frase "Lo básico no es parte de lo que hacemos": el primer renglón se corre y lo vacío se rellena */
    .statement .line:nth-of-type(1) .big { animation: sdDriftR linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
    .statement .big.outline, header.hero .big.outline { background: linear-gradient(var(--ink), var(--ink)) 0 0 / 0% 100% no-repeat; -webkit-background-clip: text; background-clip: text; }
    .statement .big.outline { animation: sdFill linear both; animation-timeline: view(); animation-range: cover 25% cover 60%; }

    /* LANDINGS: el titular se rellena y se corre en cuanto empiezas a bajar */
    header.hero .line:nth-of-type(1) .big { animation: sdPush linear both; animation-timeline: scroll(root); animation-range: 0 70vh; }
    header.hero .big.outline { animation: sdFill linear both; animation-timeline: scroll(root); animation-range: 0 45vh; }

    /* Franja: se desliza mientras cruza la pantalla */
    .band-track { animation: sdBand linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }

    /* Concreto de Nosotros: se abre desde el centro */
    .about img { animation: sdOpen linear both; animation-timeline: view(); animation-range: entry 0% cover 45%; }

    /* BUILD / REBUILD: suben a destiempo, la segunda llega después */
    .paths .card { animation: sdRise linear both; animation-timeline: view(); animation-range: entry 0% cover 40%; }
    .paths .card + .card { animation-name: sdRiseLate; }

    /* Tarjeta grande de build.html / rebuild.html: se hunde un poco al bajar */
    .top .card { animation: sdRecede linear both; animation-timeline: scroll(root); animation-range: 0 90vh; }

    /* Paquetes de landings: suben como tarjetas */
    .packs .pack { animation: sdRise linear both; animation-timeline: view(); animation-range: entry 0% cover 30%; }
    .packs .pack + .pack { animation-name: sdRiseLate; }

    /* Logo del pie: sale desde abajo cuando llegas al final */
    footer .wm { animation: sdWm linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  }
}

/* Franja de palabras de la portada: miniatura en letras de puntos (Doto), se desliza con el scroll */
.band { overflow: hidden; margin-top: clamp(64px, 8vw, 112px); border-block: 1px solid var(--line); padding-block: 14px 12px; font-family: 'Doto', var(--mono); font-weight: 800; text-transform: uppercase; font-size: clamp(18px, 1.8vw, 26px); letter-spacing: 0.06em; line-height: 1; color: var(--ink); }
.band-track { display: flex; width: max-content; gap: 1.4em; white-space: nowrap; }
.band-track span { display: inline-flex; align-items: center; gap: 1.4em; }
.band-track span::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.band-track .o { color: var(--muted); }

/* Hero de la portada: capas que siguen al puntero (motion.js pone --mx / --my entre -1 y 1) */
.hero { --mx: 0; --my: 0; }
.js .hero .hero-bg img { translate: calc(var(--mx) * -1.4%) calc(var(--my) * -1.4%); transition: translate 1400ms cubic-bezier(0.16, 1, 0.3, 1), transform 2600ms cubic-bezier(0.16, 1, 0.3, 1); }
.hero-logo img { translate: calc(var(--mx) * 10px) calc(var(--my) * 6px); transition: translate 1100ms cubic-bezier(0.16, 1, 0.3, 1); }
.hero-words { translate: calc(var(--mx) * 18px) calc(var(--my) * 10px); transition: translate 900ms cubic-bezier(0.16, 1, 0.3, 1); }
@media (prefers-reduced-motion: reduce) { .hero-bg img, .hero-logo img, .hero-words { translate: none; } }

@keyframes sdGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sdSink { to { translate: 0 28%; } }
@keyframes sdLift { to { translate: 0 -22%; } }
@keyframes sdAway { to { opacity: 0; scale: 0.92; } }
@keyframes sdDriftR { from { translate: -5vw 0; } to { translate: 9vw 0; } }
@keyframes sdPush { to { translate: 14vw 0; } }
@keyframes sdFill { to { background-size: 100% 100%; } }
@keyframes sdOpen { from { clip-path: inset(16% 20% 16% 20% round 28px); scale: 1.08; } to { clip-path: inset(0 0 0 0 round 0); scale: 1; } }
@keyframes sdRise { from { translate: 0 12vh; scale: 0.94; } to { translate: 0 0; scale: 1; } }
@keyframes sdRiseLate { from { translate: 0 26vh; scale: 0.9; } to { translate: 0 0; scale: 1; } }
@keyframes sdRecede { to { scale: 0.94; translate: 0 6vh; } }
@keyframes sdWm { from { clip-path: inset(100% 0 0 0); translate: 0 35%; } to { clip-path: inset(0 0 0 0); translate: 0 0; } }
@keyframes sdBand { from { translate: 4% 0; } to { translate: -38% 0; } }
