/* ─────────────────────────────────────────────────────────────
   Movimiento · Andrés Díaz-Granados
   Sobrio y lento: como se habla con la puerta cerrada.
   Solo se animan transform, opacity, clip-path y colores.
   Lo que aparece, aparece una vez y se queda.
   ───────────────────────────────────────────────────────────── */

:root{
  /* Duraciones */
  --dur-instant: 100ms;   /* presionar un botón */
  --dur-fast:    180ms;   /* hover de color, subrayados, foco de campo */
  --dur-base:    300ms;   /* estados de UI: header, acordeón, menú */
  --dur-slow:    700ms;   /* tarjetas, el guion al dibujarse */
  --dur-reveal:  1200ms;  /* todo lo que aparece */
  --dur-photo:   2400ms;  /* el retrato del hero al asentarse */
  --stagger:     120ms;   /* desfase entre piezas de un mismo grupo */

  /* Curvas (sin rebotes ni resortes) */
  --ease-out:    cubic-bezier(.22, 1, .36, 1);   /* interacciones */
  --ease-reveal: cubic-bezier(.16, 1, .3, 1);    /* solo apariciones: frena largo */
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);   /* algo que va y vuelve; desclasificar */
  --ease-in:     cubic-bezier(.4, 0, 1, 1);      /* salidas */

  /* Distancias */
  --rise: 12px;           /* bloques que aparecen */
  --lift: 4px;            /* tarjetas en hover */
  --nudge: 3px;           /* el guion del botón en hover */
}

/* ── 1 · Hero al cargar ───────────────────────────────────────
   Orden de lectura: retrato → guion → antetítulo → título por líneas
   → entradilla → formulario → cifras. El título se lee a ~1 s;
   la secuencia termina a los 2,4 s. Header y fondo ya están. */
@keyframes adg-settle { from{opacity:.001; transform:scale(1.05)} 35%{opacity:1} to{opacity:1; transform:none} }
@keyframes adg-draw   { from{transform:scaleX(0)} to{transform:none} }
@keyframes adg-rise   { from{opacity:0; transform:translateY(var(--rise))} to{opacity:1; transform:none} }
@keyframes adg-line   { from{transform:translateY(105%)} to{transform:none} }
@keyframes adg-fade   { from{opacity:0} to{opacity:1} }

.hero__foto            { animation: adg-settle var(--dur-photo) var(--ease-reveal) both; transform-origin: 70% 40%; }
.hero__txt .eb .g      { transform-origin: left center; animation: adg-draw var(--dur-slow) var(--ease-reveal) 200ms both; }
.hero__txt .eb         { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 300ms both; }
.hero__txt h1 > *      { display:block; overflow:hidden; padding-bottom:.1em; margin-bottom:-.1em; }   /* máscara de cada línea, sin cortar descendentes */
.hero__txt h1 > * > i  { display:block; font-style:normal; animation: adg-line var(--dur-reveal) var(--ease-reveal) both; }
.hero__txt h1 > :nth-child(1) > i { animation-delay: 450ms; }
.hero__txt h1 > :nth-child(2) > i { animation-delay: 570ms; }
.hero__txt h1 > :nth-child(3) > i { animation-delay: 690ms; }
.hero__txt .lead       { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 900ms both; }
.hero__txt .suscribe,
.hero__txt .ctas       { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 1050ms both; }
.hero__in > .cifras    { animation: adg-fade var(--dur-reveal) var(--ease-reveal) 1200ms both; }

/* ── 2 · Aparición al hacer scroll (data-reveal) ──────────────
   Se dispara al 20 % visible, una sola vez (ver motion.js).
   Lo que ya está en pantalla al cargar no se anima, salvo el hero. */
.js [data-reveal]:not(.is-in) { opacity:0; }
[data-reveal]                 { --d: 0ms; }

/* heading: guion → antetítulo → líneas del título → bajada → acción */
[data-reveal="heading"].is-in .eb .g { transform-origin:left center; animation: adg-draw var(--dur-slow) var(--ease-reveal) both; }
[data-reveal="heading"].is-in .eb    { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 100ms both; }
[data-reveal="heading"].is-in :is(h2,h1) { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 220ms both; }
[data-reveal="heading"].is-in :is(p,.lead) { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 360ms both; }
[data-reveal="heading"].is-in :is(.btn,.ctas) { animation: adg-rise var(--dur-reveal) var(--ease-reveal) 480ms both; }

/* rise: el bloque completo sube 12 px (formularios, citas, footer) */
[data-reveal="rise"].is-in { animation: adg-rise var(--dur-reveal) var(--ease-reveal) var(--d) both; }

/* group: hijos con stagger, máximo cuatro en cadena */
[data-reveal="group"].is-in > *            { animation: adg-rise var(--dur-reveal) var(--ease-reveal) both; }
[data-reveal="group"].is-in > :nth-child(2){ animation-delay: calc(var(--stagger) * 1); }
[data-reveal="group"].is-in > :nth-child(3){ animation-delay: calc(var(--stagger) * 2); }
[data-reveal="group"].is-in > :nth-child(n+4){ animation-delay: calc(var(--stagger) * 3); }

/* rows: cada línea fina se dibuja de izquierda a derecha y su texto sube con ella */
[data-reveal="rows"] > *            { position:relative; }
[data-reveal="rows"].is-in > *::before{ content:""; position:absolute; inset:0 0 auto 0; height:1px; background:currentColor; opacity:.14; transform-origin:left; animation: adg-draw var(--dur-reveal) var(--ease-reveal) both; }
[data-reveal="rows"].is-in > *      { animation: adg-rise var(--dur-reveal) var(--ease-reveal) both; }
[data-reveal="rows"].is-in > :nth-child(2), [data-reveal="rows"].is-in > :nth-child(2)::before { animation-delay: calc(var(--stagger) * 1); }
[data-reveal="rows"].is-in > :nth-child(3), [data-reveal="rows"].is-in > :nth-child(3)::before { animation-delay: calc(var(--stagger) * 2); }
[data-reveal="rows"].is-in > :nth-child(n+4), [data-reveal="rows"].is-in > :nth-child(n+4)::before { animation-delay: calc(var(--stagger) * 3); }

/* figure: cifras. La línea se dibuja y la cifra sube. Nunca contador. */
[data-reveal="figure"].is-in       { animation: adg-rise var(--dur-reveal) var(--ease-reveal) var(--d) both; }

/* photo: fundido y 1,05 → 1 dentro de su marco */
[data-reveal="photo"]              { overflow:hidden; }
[data-reveal="photo"].is-in img    { animation: adg-settle 1800ms var(--ease-reveal) both; }

/* ── 3 · Subrayar (la frase que pesa) ──────────────────────
   El guion de la marca se dibuja debajo de la parte que pesa, de izquierda
   a derecha, una vez, y se queda. Nunca tapa el texto. La clase sigue
   llamándose .desclasificar para no cambiar el marcado. */
@keyframes adg-subraya { from{transform:scaleX(0)} to{transform:scaleX(1)} }
/* Tema de Ghost: el subrayado va como fondo de un elemento en línea (no inline-block con ::after), para que la frase
   pueda partirse en varias líneas en móvil sin salirse de la pantalla. Medidas del manual v24: 2 px, .1em bajo la
   línea base, termina .04em antes del final; mismo tiempo, curva y dirección. */
.desclasificar{ --sub-c:var(--acero);
  background:linear-gradient(var(--sub-c),var(--sub-c)) 0 calc(100% - .08em) / 0% 2px no-repeat;
  -webkit-box-decoration-break:clone; box-decoration-break:clone; }
@keyframes adg-subraya-linea { from{background-size:0% 2px} to{background-size:calc(100% - .04em) 2px} }
.is-in .desclasificar, .desclasificar.is-in { animation: adg-subraya-linea 900ms var(--ease-out) 500ms both; }
.halo-c .desclasificar, .dark .desclasificar, .on-dark .desclasificar { --sub-c:var(--acero-claro); }

/* ── 4 · Interacciones ────────────────────────────────────── */
.btn{ transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.btn .g{ transition: transform var(--dur-base) var(--ease-out); }
.btn:hover .g{ transform: translateX(var(--nudge)); }
.btn:active{ transform: scale(.98); }
a:not(.btn){ transition: text-decoration-thickness var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.card{ transition: transform var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out); }
.card:hover{ transform: translateY(calc(var(--lift) * -1)); }
.campo, input, textarea{ transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.acordeon__panel{ display:grid; grid-template-rows:0fr; transition: grid-template-rows var(--dur-base) var(--ease-in-out); }
.acordeon[open] .acordeon__panel, .acordeon.is-open .acordeon__panel{ grid-template-rows:1fr; }

/* ── 5 · Entre páginas ────────────────────────────────────────
   Fundido cruzado de 300 ms (View Transitions). Sin deslizar páginas. */
@view-transition { navigation: auto; }
::view-transition-old(root){ animation: adg-fade var(--dur-base) var(--ease-in) reverse both; }
::view-transition-new(root){ animation: adg-fade var(--dur-base) var(--ease-out) both; }

/* ── 6 · Movimiento reducido ──────────────────────────────────
   Solo fundido de 150 ms, sin cadena; líneas y barras aparecen completas.
   El subrayado aparece completo, sin dibujarse. */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: 150ms !important; animation-delay: 0ms !important; transition-duration: 0ms !important; }
  .hero__foto, .hero__txt *, [data-reveal].is-in, [data-reveal].is-in *{ animation-name: adg-fade !important; }
  .desclasificar{ animation:none !important; background-size:calc(100% - .04em) 2px; }
  @view-transition { navigation: none; }
}
