/* ============================================================
   movimiento-scroll · estados iniciales y mecánica
   IMPORTANTE: todo lo que oculta contenido cuelga de html.ms-activo.
   Esa clase solo sobrevive si GSAP cargó. Sin GSAP → web normal.
   ============================================================ */

/* ---------- estados iniciales (solo con el motor activo) ---------- */

html.ms-activo [data-ms="reveal"],
html.ms-activo [data-ms="cascada"] > *,
html.ms-activo [data-ms="lineas"],
html.ms-activo [data-ms-encima] {
  opacity: 0;
}

html.ms-activo [data-ms="mosaico"] > *,
html.ms-activo [data-ms="mosaico"] [data-ms-pieza] {
  clip-path: inset(0% 0% 100% 0%);
}

/* ---------- titular línea a línea ---------- */

.ms-linea {
  display: block;
  overflow: hidden;
  /* aire extra para que la itálica no pierda los rabitos de las letras */
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}

.ms-linea > span {
  display: block;
  will-change: transform;
}

/* ---------- mosaico ---------- */

[data-ms="mosaico"] {
  display: grid;
  gap: var(--ms-hueco, 1px);
  /* el hueco de 1px + este fondo dibuja las líneas finas de rejilla */
  background: var(--ms-rejilla, rgba(0, 0, 0, 0.10));
}

[data-ms="mosaico"] > *,
[data-ms="mosaico"] [data-ms-pieza] {
  position: relative;
  overflow: hidden;
  background: var(--ms-fondo, #fff);
}

[data-ms="mosaico"] img,
[data-ms="mosaico"] video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: transform;
}

/* ---------- lupa: ampliar una foto al hacer clic ---------- */

[data-ms-ampliar] img { cursor: zoom-in; }

.ms-lupa {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(12, 10, 9, .93);
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s ease, visibility .4s;
}

.ms-lupa.is-abierta { opacity: 1; visibility: visible; }

.ms-lupa img {
  max-width: 94vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}

.ms-lupa__x {
  position: absolute;
  top: 16px;
  right: 22px;
  background: none;
  border: 0;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  opacity: .75;
  cursor: pointer;
}

.ms-lupa__x:hover { opacity: 1; }

/* ---------- parallax ---------- */
/* La caja recorta; la foto es más alta que la caja y se mueve dentro. */

.ms-caja {
  position: relative;
  overflow: hidden;
}

[data-ms="parallax"] {
  will-change: transform;
}

.ms-caja > [data-ms="parallax"] {
  position: absolute;
  inset: -9% 0;
  width: 100%;
  height: 118%;
  object-fit: cover;
}

/* ---------- sección fijada ---------- */

[data-ms="pin"] {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
}

[data-ms-zoom] {
  will-change: transform;
}

/* ---------- galería horizontal ---------- */

[data-ms="horizontal"] {
  overflow: hidden;
}

[data-ms="horizontal"] [data-ms-pista] {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--ms-hueco-h, 2vw);
  will-change: transform;
}

[data-ms="horizontal"] [data-ms-pista] > * {
  flex: 0 0 auto;
}

/* En móvil no se fija: se arrastra con el dedo. */
[data-ms-scroll-manual] {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

[data-ms-scroll-manual]::-webkit-scrollbar {
  display: none;
}

/* ---------- carrete: fila de fichas que se pasan a mano ---------- */

[data-ms="carrete"] { position: relative; }

[data-ms="carrete"] [data-ms-pista] {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--ms-hueco-h, 18px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

[data-ms="carrete"] [data-ms-pista]::-webkit-scrollbar { display: none; }

[data-ms="carrete"] [data-ms-pista] > * {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.ms-carrete--agarrado [data-ms-pista] {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
  user-select: none;
}

.ms-carrete__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(20, 17, 15, .16);
  background: rgba(255, 255, 255, .92);
  color: #14110F;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity .3s ease, background .3s ease;
}

.ms-carrete__btn:hover { background: #fff; }
.ms-carrete__btn--ant { left: -14px; }
.ms-carrete__btn--sig { right: -14px; }
.ms-carrete__btn[disabled] { opacity: .2; cursor: default; }
.ms-carrete--quieto .ms-carrete__btn { display: none; }

@media (max-width: 820px) {
  .ms-carrete__btn { display: none; }   /* en móvil se pasa con el dedo */
}

/* ---------- barra de progreso ---------- */

[data-ms="progreso"] {
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

/* ---------- marquee ---------- */

[data-ms="marquee"] {
  overflow: hidden;
  white-space: nowrap;
}

[data-ms="marquee"] [data-ms-pista] {
  display: inline-flex;
  align-items: center;
  gap: var(--ms-hueco-h, 3vw);
  will-change: transform;
}

/* ---------- accesibilidad ---------- */
/* Si el sistema pide menos movimiento, nada se oculta ni se mueve. */

@media (prefers-reduced-motion: reduce) {

  html.ms-activo [data-ms],
  html.ms-activo [data-ms-encima],
  html.ms-activo [data-ms-pieza] {
    opacity: 1 !important;
    clip-path: none !important;
    transform: none !important;
  }

  [data-ms="marquee"] [data-ms-pista] {
    animation: none !important;
  }
}
