/* =========================================================================
   Martilleros Río Grande. Movimiento.
   1) Piezas compartidas del panel y de Mi credencial (casillas del código,
      aviso de modo demo).
   2) El sistema de movimiento que maneja assets/js/efectos.js: revelado al
      bajar, escalonado, foco de luz, inclinación, imán, parallax, barra de
      lectura, transiciones entre páginas. API en docs/estilo.md,
      "Movimiento".
   Reglas: sólo se animan transform, opacity y filter (y clip-path en la
   cortina, stroke-dashoffset en los trazos). El estado oculto inicial se
   aplica sólo con <html class="js"> y sin prefers-reduced-motion: sin
   JavaScript, o con "reducir movimiento", todo se ve y nada se mueve.
   Cargar después de style.css.
   ========================================================================= */

/* ---------- 1. Casillas del código (panel y credencial) ---------- */
/* Las seis en un renglón: en compu miden 3rem y en un celular angosto se achican parejas
   (min-width: 0, porque un input no baja solo de su ancho propio). */
.codigo-casillas { display: flex; gap: .55rem; justify-content: flex-start; }
.codigo-casillas input {
  width: 3rem; min-width: 0; height: 3.6rem; text-align: center;
  font-family: var(--font-ui); font-size: 1.5rem; font-weight: 700;
  color: var(--texto); background: var(--blanco);
  border: 1.5px solid var(--linea-2); border-radius: var(--r-md);
  transition: border-color var(--trans), background var(--trans);
}
.codigo-casillas input:focus { outline: none; border-color: var(--azul-600); box-shadow: 0 0 0 3px var(--azul-100); }
.codigo-casillas input.lleno { border-color: var(--azul-300); background: var(--azul-050); }
.codigo-casillas.error input { border-color: var(--no-habilitado); }
.codigo-casillas.error { animation: sacudir 380ms ease; }
@keyframes sacudir {
  20%, 80% { transform: translateX(-2px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-4px); }
}

/* Cartel de modo demo (el código llega acá en vez de al correo) */
.demo-aviso {
  border: 1.5px dashed var(--cobre); background: var(--cobre-050);
  border-radius: var(--r-md); padding: .9rem 1.1rem; font-size: .9rem;
}
.demo-codigo {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 1.5rem; font-weight: 700; letter-spacing: .3em;
  color: var(--cobre-700); display: inline-block; margin-left: .3rem;
}

/* ---------- 2. Transiciones entre páginas (View Transitions entre documentos) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-sale 260ms cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: vt-entra 520ms cubic-bezier(.16, 1, .3, 1) both; }
::view-transition-group(encabezado), ::view-transition-group(menu) { animation-duration: 0s; }
@keyframes vt-sale  { to   { opacity: 0; transform: translate3d(0, -10px, 0); filter: blur(4px); } }
@keyframes vt-entra { from { opacity: 0; transform: translate3d(0, 22px, 0); } }

/* ---------- 3. Barra de lectura ---------- */
.progreso-lectura {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 120; pointer-events: none;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--cobre), var(--oro) 55%, var(--glaciar));
  box-shadow: 0 0 12px rgba(233, 183, 122, .55);
}
@supports (animation-timeline: scroll()) {
  .progreso-lectura { animation: progreso linear both; animation-timeline: scroll(root block); }
}
@keyframes progreso { to { transform: scaleX(1); } }

/* ---------- 4. Foco de luz que sigue al cursor (data-foco) ---------- */
[data-foco] { position: relative; isolation: isolate; }
[data-foco]::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), var(--foco-color, rgba(181, 101, 43, .13)), transparent 62%);
  opacity: 0; transition: opacity 320ms ease;
}
[data-foco]:hover::before { opacity: 1; }

/* ---------- 5. Todo lo que se mueve: sólo sin "reducir movimiento" ---------- */
@media (prefers-reduced-motion: no-preference) {

  /* 5.1 Revelado al bajar (data-revelar, data-escalonar). efectos.js pone data-visto (atributo: un className = "..." de otro script no lo borra). */
  .js [data-revelar] {
    opacity: 0;
    transition:
      opacity 700ms var(--ease-salida),
      transform 900ms var(--ease-salida),
      filter 900ms var(--ease-salida),
      clip-path 1000ms var(--ease-salida);
    transition-delay: var(--retraso, 0ms);
  }
  .js [data-revelar="arriba"]    { transform: translate3d(0, 34px, 0); }
  .js [data-revelar="abajo"]     { transform: translate3d(0, -34px, 0); }
  .js [data-revelar="izquierda"] { transform: translate3d(-44px, 0, 0); }
  .js [data-revelar="derecha"]   { transform: translate3d(44px, 0, 0); }
  .js [data-revelar="zoom"]      { transform: scale(.9); }
  .js [data-revelar="blur"]      { transform: translate3d(0, 14px, 0) scale(.98); filter: blur(14px); }
  .js [data-revelar="cortina"]   { opacity: 1; clip-path: inset(0 0 100% 0 round 16px); transform: translate3d(0, 24px, 0); }
  .js [data-revelar][data-visto] { opacity: 1; transform: none; filter: none; }
  /* La cortina termina más grande que la caja, así no recorta sombras ni halos. */
  .js [data-revelar="cortina"][data-visto] { clip-path: inset(-60px -60px -60px -60px round 0); }
  .js [data-revelar][data-visto="instante"] { transition: none; }
  /* La rayita del kicker se dibuja cuando aparece su sección. */
  .js [data-revelar] .kicker::before { transform: scaleX(0); transform-origin: 0 50%; transition: transform 800ms var(--ease-salida) calc(var(--retraso, 0ms) + 250ms); }
  .js [data-revelar][data-visto] .kicker::before { transform: none; }

  /* Mientras el puerto la inclina, que responda rápido; al soltar, vuelve suave. */
  [data-inclinar] { transition: transform 700ms var(--ease-salida); transform-style: preserve-3d; }
  .js [data-revelar][data-inclinar][data-visto] { transition: opacity 700ms var(--ease-salida), transform 700ms var(--ease-salida); }
  [data-inclinar].inclinando { transition: transform 140ms ease-out !important; }
  [data-magnetico] { transition: transform 450ms var(--ease-salida), background var(--trans), border-color var(--trans), color var(--trans), box-shadow var(--trans); }
  [data-magnetico].imantado { transition: transform 120ms ease-out, background var(--trans), border-color var(--trans), color var(--trans); }

  /* 5.2 Parallax con animation-timeline donde se puede (si no, efectos.js). */
  @supports (animation-timeline: view()) {
    [data-parallax] { animation: paralaje linear both; animation-timeline: view(); animation-range: cover; }
  }
  @keyframes paralaje {
    from { transform: translate3d(0, calc(var(--px, .2) * 120px), 0); }
    to   { transform: translate3d(0, calc(var(--px, .2) * -120px), 0); }
  }

  /* 5.3 Situación "Habilitado": el punto late. */
  .estado--habilitado::after {
    content: ""; position: absolute; left: .6rem; top: 50%; width: .6rem; height: .6rem; margin-top: -.3rem;
    border-radius: 50%; background: currentColor; pointer-events: none;
    animation: latido-punto 2.4s cubic-bezier(.2, .7, .3, 1) infinite;
  }
  .estado--grande.estado--habilitado::after { left: .8rem; }
  @keyframes latido-punto { 0% { transform: scale(1); opacity: .55; } 70%, 100% { transform: scale(2.8); opacity: 0; } }

  /* 5.4 Acordeón con animación de altura (navegadores que interpolan "auto"). */
  .acordeon::details-content {
    block-size: 0; overflow-y: clip;
    transition: block-size 420ms var(--ease-salida), content-visibility 420ms allow-discrete;
  }
  .acordeon[open]::details-content { block-size: auto; }

  /* 5.5 Encabezado de página interna: entra al cargar. */
  .js .page-head .contenedor > * { animation: entrar 900ms var(--ease-salida) both; }
  .js .page-head .contenedor > :nth-child(2) { animation-delay: 90ms; }
  .js .page-head .contenedor > :nth-child(3) { animation-delay: 180ms; }
  .js .page-head .contenedor > :nth-child(n+4) { animation-delay: 260ms; }
  .page-head::before { animation: malla 22s ease-in-out infinite alternate; }
  .page-head::after { animation: flotar-forma 14s ease-in-out infinite alternate; }

  /* 5.6 Botones: brillo que barre al pasar. */
  .btn:hover::after, .btn:focus-visible::after { transform: translateX(130%) skewX(-18deg); transition: transform 750ms var(--ease-salida); }

  /* 5.7 Lo que está fuera de pantalla no gasta (data-pausable + .fuera). */
  .fuera, .fuera *, .fuera *::before, .fuera *::after { animation-play-state: paused !important; }
}

@keyframes entrar { from { opacity: 0; transform: translate3d(0, 22px, 0); filter: blur(6px); } }
@keyframes malla {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(4%, -3%, 0) rotate(8deg) scale(1.08); }
  100% { transform: translate3d(-3%, 4%, 0) rotate(-6deg) scale(1.02); }
}
@keyframes flotar-forma {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to   { transform: translate3d(-30px, 24px, 0) rotate(25deg); }
}

/* ---------- 6. Reducir movimiento: nada se mueve, todo se ve ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .progreso-lectura { display: none; }
  [data-revelar] { opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; }
}

/* ---------- 7. Impresión: todo a la vista ---------- */
@media print {
  .progreso-lectura { display: none; }
  [data-revelar] { opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; }
}
