/* Capa de motion — Saberes Internacionales (6-11-2026)
   Transiciones entre páginas, entrada al hacer scroll, hero con constelación,
   vidrio y profundidad. Todo se anula con prefers-reduced-motion. */

/* ---- Transiciones entre páginas (View Transitions, mismo origen) ---- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-sale .22s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: vt-entra .38s cubic-bezier(.2, .7, .3, 1) both; }
.cabecera { view-transition-name: cabecera; }
::view-transition-group(cabecera) { animation-duration: 0s; }
@keyframes vt-sale { to { opacity: 0; transform: translateY(-8px); } }
@keyframes vt-entra { from { opacity: 0; transform: translateY(14px); } }

/* ---- Hero: constelación, halo y texto escalonado ---- */
.hero { position: relative; isolation: isolate; overflow: clip; }
.hero::before {
  content: ""; position: absolute; inset: -20% -10% auto; height: 120%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 18% 30%, rgba(201, 162, 39, .18), transparent 70%),
    radial-gradient(45% 55% at 85% 20%, rgba(70, 120, 190, .22), transparent 70%);
  animation: halo 18s ease-in-out infinite alternate;
}
@keyframes halo { to { transform: translate3d(3%, 4%, 0) scale(1.08); } }
.hero-carrusel .diapositiva-texto { position: relative; z-index: 2; }
.diapositiva[data-activa] .diapositiva-texto > * { animation: sube .7s cubic-bezier(.2, .7, .3, 1) both; }
.diapositiva[data-activa] .diapositiva-texto > *:nth-child(2) { animation-delay: .08s; }
.diapositiva[data-activa] .diapositiva-texto > *:nth-child(3) { animation-delay: .16s; }
.diapositiva[data-activa] .diapositiva-texto > *:nth-child(4) { animation-delay: .24s; }
@keyframes sube { from { opacity: 0; transform: translateY(18px); } }
.diapositiva-texto h1, .diapositiva-texto .titulo-diapositiva {
  background: linear-gradient(100deg, #fff 30%, #f1d98a 50%, #fff 70%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sube .7s cubic-bezier(.2, .7, .3, 1) both, destello 6s 1s ease-in-out infinite;
}
@keyframes destello { 0%, 60% { background-position: 100% 0; } 100% { background-position: -50% 0; } }

/* Destacado del hero: vidrio con borde luminoso */
.hero-destacado {
  position: relative;
  background: linear-gradient(160deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .62));
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .6);
  box-shadow: 0 1px 2px rgba(14, 42, 71, .08), 0 24px 60px -20px rgba(14, 42, 71, .45);
  animation: sube .8s .2s cubic-bezier(.2, .7, .3, 1) both;
}
.hero-destacado::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(201, 162, 39, .9), transparent 35%, transparent 65%, rgba(201, 162, 39, .6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.hero-portada img { transition: transform .3s cubic-bezier(.2, .7, .3, 1), box-shadow .3s cubic-bezier(.2, .7, .3, 1); }
.hero-portada:hover img { transform: translateY(-6px) rotate(-1deg) scale(1.02); box-shadow: 0 30px 50px -18px rgba(14, 42, 71, .55); }

/* ---- Entrada al hacer scroll ---- */
.js-motion .revela { opacity: 0; transform: translateY(28px); transition: opacity .6s cubic-bezier(.2, .7, .3, 1), transform .6s cubic-bezier(.2, .7, .3, 1); transition-delay: var(--retraso, 0s); }
.js-motion .revela.visible { opacity: 1; transform: none; }

/* Profundidad suave de las imágenes con scroll-driven animations */
@supports (animation-timeline: view()) {
  .seccion img:not(.hero img) { animation: aparece-img linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  @keyframes aparece-img { from { opacity: .4; transform: scale(.96); } }
}

/* ---- Microinteracciones ---- */
.boton { position: relative; overflow: hidden; transition: transform .2s cubic-bezier(.2, .7, .3, 1), box-shadow .2s cubic-bezier(.2, .7, .3, 1); }
.boton::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .5s cubic-bezier(.2, .7, .3, 1);
}
.boton:hover::after { transform: translateX(120%); }
.boton:active { transform: scale(.97); }
.enlace-flecha svg { transition: transform .2s cubic-bezier(.2, .7, .3, 1); }
.enlace-flecha:hover svg { transform: translateX(4px); }

/* Cabecera de vidrio al desplazarse */
.desplazado .cabecera {
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 1px 0 rgba(14, 42, 71, .06), 0 10px 30px -18px rgba(14, 42, 71, .4);
}

/* ---- Movimiento reducido: todo quieto ---- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .hero::before, .hero-destacado, .diapositiva[data-activa] .diapositiva-texto > *,
  .diapositiva-texto h1, .diapositiva-texto .titulo-diapositiva, .seccion img { animation: none !important; }
  .js-motion .revela { opacity: 1; transform: none; transition: none; }
  .boton::after { display: none; }
  .boton, .hero-portada img, .enlace-flecha svg { transition: none; }
}

/* ---- Segunda tanda ---- */
/* Portada del libro en 3D con lomo */
.libro-3d { perspective: 1200px; }
.libro-3d img {
  transform: rotateY(var(--ry, -8deg)) rotateX(var(--rx, 0deg));
  transform-style: preserve-3d; transform-origin: 50% 50%;
  transition: transform .35s cubic-bezier(.2, .7, .3, 1);
  box-shadow: -10px 0 0 -2px #0b2039, -12px 2px 0 -2px rgba(201, 162, 39, .55), 0 30px 50px -20px rgba(14, 42, 71, .55);
  border-radius: 2px 6px 6px 2px;
}
.libro-3d:hover img { transition-duration: .12s; }

/* Catálogo: las fichas nuevas al filtrar entran con movimiento */
.tarjeta-libro { transition: opacity .35s cubic-bezier(.2, .7, .3, 1), transform .35s cubic-bezier(.2, .7, .3, 1); }
@starting-style { .tarjeta-libro { opacity: 0; transform: translateY(16px) scale(.97); } }

/* Lectores por país: entran escalonados y la barra crece */
.mapa-pais { animation: sube .5s cubic-bezier(.2, .7, .3, 1) both; }
.mapa-pais:nth-child(2) { animation-delay: .05s; } .mapa-pais:nth-child(3) { animation-delay: .1s; }
.mapa-pais:nth-child(4) { animation-delay: .15s; } .mapa-pais:nth-child(5) { animation-delay: .2s; }
.mapa-pais:nth-child(n+6) { animation-delay: .25s; }
.mapa-barra i { transform-origin: left; animation: barra 1.1s .3s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes barra { from { transform: scaleX(0); } }
.mapa-pais.top::before {
  content: ""; position: absolute; top: .6rem; right: .6rem; width: 8px; height: 8px; border-radius: 50%;
  background: #c9a227; box-shadow: 0 0 0 0 rgba(201, 162, 39, .6); animation: latido 2s ease-out infinite;
}
.mapa-pais.top { position: relative; }
@keyframes latido { to { box-shadow: 0 0 0 12px rgba(201, 162, 39, 0); } }

@media (prefers-reduced-motion: reduce) {
  .libro-3d img, .tarjeta-libro { transition: none; }
  .mapa-pais, .mapa-barra i, .mapa-pais.top::before { animation: none; }
}

