/*! Motion Kit · Constructor Web Moderno · v1.1
 *  Cargar ANTES de styles.css para que el sitio pueda sobrescribir tokens.
 *  Reglas de seguridad:
 *   - Sin JS (sin .mk-js) todo se ve en su estado final.
 *   - Estados ocultos solo bajo .mk-js:not(.mk-reduce):not(.mk-failed).
 *   - Layouts fijados (sticky/pin) solo bajo .mk-pin, que el JS activa en ≥768 px y sin reduced-motion.
 *   - Las transiciones de entrada se retiran al terminar (.mk-done) para no pisar hovers del sitio.
 */

:root {
  --mk-ease: cubic-bezier(.22, 1, .36, 1);
  --mk-ease-io: cubic-bezier(.77, 0, .175, 1);
  --mk-dur: 700ms;            /* aparecer / titulo */
  --mk-dur-photo: 1000ms;     /* cortina fotográfica */
  --mk-dur-ui: 300ms;         /* acordeón y UI */
  --mk-shift: 28px;
  --mk-stagger: 70ms;
  --mk-accent: var(--color-accent, currentColor);
  --mk-radius: 0px;
  --mk-progress-h: 3px;
  --mk-stack-top: 12vh;
  --mk-stack-gap: 22px;
  --mk-stack-space: 10vh;
  --mk-expand-len: 220vh;
  --mk-hgap: clamp(16px, 2vw, 28px);
  --mk-hpad: clamp(20px, 5vw, 64px);
}

html.mk-lock { overflow: hidden; }
html.mk-smooth, html.mk-smooth body { height: auto; }
html.mk-smooth { scroll-behavior: auto !important; }

/* ============================================================ ENTRADA ======== */

/* intro — secuencia de carga del hero (hijos directos, escalonados) */
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="intro"]:not(.mk-done) > * {
  transition: opacity 800ms var(--mk-ease), transform 950ms var(--mk-ease);
  transition-delay: calc(var(--mk-i, 0) * 110ms + 100ms);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="intro"]:not(.is-in) > * {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="intro"]:not(.mk-done) [data-intro-media] {
  transition: transform 1800ms var(--mk-ease);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="intro"]:not(.is-in) [data-intro-media] {
  opacity: 1;
  transform: scale(1.08);
}

/* aparecer — fade + desplazamiento corto */
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="aparecer"]:not(.mk-done) {
  transition: opacity var(--mk-dur) var(--mk-ease), transform var(--mk-dur) var(--mk-ease);
  transition-delay: var(--mk-delay, 0ms);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="aparecer"]:not(.is-in) {
  opacity: 0;
  transform: translate3d(0, var(--mk-shift), 0);
}

/* titulo — palabras que suben desde una máscara */
.mk-word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
.mk-word__in { display: inline-block; }
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="titulo"]:not(.mk-split) { opacity: 0; }
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="titulo"]:not(.mk-done) .mk-word__in {
  transition: transform 900ms var(--mk-ease);
  transition-delay: calc(var(--mk-i, 0) * 45ms);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="titulo"]:not(.is-in) .mk-word__in {
  transform: translate3d(0, 105%, 0);
}

/* cortina — clip-path que descubre la foto + zoom-out de la imagen */
[data-motion~="cortina"] { overflow: hidden; }
[data-motion~="cortina"][data-from="left"] { --mk-clip-from: 0 100% 0 0; }
[data-motion~="cortina"][data-from="right"] { --mk-clip-from: 0 0 0 100%; }
[data-motion~="cortina"][data-from="top"] { --mk-clip-from: 0 0 100% 0; }
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cortina"]:not(.mk-done) {
  transition: clip-path var(--mk-dur-photo) var(--mk-ease);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cortina"]:not(.mk-done) :is(img, video) {
  transition: transform calc(var(--mk-dur-photo) * 1.5) var(--mk-ease);
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cortina"]:not(.is-in) {
  clip-path: inset(var(--mk-clip-from, 100% 0 0 0) round var(--mk-radius));
}
/* clip-path no interpola hacia `none`: mantener inset(0) explícito hasta terminar */
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cortina"].is-in:not(.mk-done) {
  clip-path: inset(0 0 0 0 round var(--mk-radius));
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cortina"]:not(.is-in) :is(img, video) {
  transform: scale(1.22);
}

/* cascada — hijos directos escalonados por lote visible */
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cascada"] > :not(.mk-done) {
  transition: opacity 650ms var(--mk-ease), transform 750ms var(--mk-ease);
  transition-delay: calc(var(--mk-i, 0) * var(--mk-stagger));
}
.mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="cascada"] > :not(.is-in) {
  opacity: 0;
  transform: translate3d(0, var(--mk-shift), 0);
}

/* contador — números estables mientras cuentan */
[data-motion~="contador"] { font-variant-numeric: tabular-nums; }

/* ========================================================== SCROLL ========== */

/* progreso — barra de lectura (CSS nativo con respaldo JS) */
.mk-progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--mk-progress-h); pointer-events: none;
}
.mk-progress > span {
  display: block; height: 100%;
  background: var(--mk-accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
@supports (animation-timeline: scroll()) {
  .mk-progress > span { animation: mk-progress linear both; animation-timeline: scroll(root); }
}
@keyframes mk-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* parallax — capas con data-depth dentro de un marco con margen de recorte */
[data-motion~="parallax"] { position: relative; overflow: hidden; }
.mk-parallax-media {
  position: absolute; left: 0; width: 100%;
  top: -14%; height: 128%;
  object-fit: cover; max-width: none;
}
.mk-motion [data-motion~="parallax"] [data-depth] { will-change: transform; }

/* texto — las palabras las ilumina el JS; aquí solo la transición fina */
.mk-w { transition: opacity 120ms linear; }

/* expandir — tarjeta que crece a pantalla completa (pin con sticky nativo) */
[data-motion~="expandir"] { position: relative; }
.mk-expand__sticky { position: relative; }
.mk-expand__media { position: relative; overflow: hidden; aspect-ratio: 16 / 9; margin: 0; }
.mk-expand__media :is(img, video) { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Velo inferior para que el texto sobre la foto sea legible en todos los modos */
.mk-expand__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 42%, var(--mk-expand-scrim, rgba(0, 0, 0, .55)));
}
.mk-expand__caption {
  position: absolute; z-index: 1;
  left: var(--mk-hpad); right: var(--mk-hpad); bottom: clamp(20px, 6%, 64px);
  color: #fff;
}
@media (max-width: 767.98px) {
  .mk-expand__media { aspect-ratio: 4 / 5; }
}
.mk-pin [data-motion~="expandir"] { height: var(--mk-expand-len); }
.mk-pin [data-motion~="expandir"] .mk-expand__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
.mk-pin [data-motion~="expandir"] .mk-expand__media {
  position: absolute; inset: 0; aspect-ratio: auto;
  clip-path: inset(22% 28% round 24px);
  will-change: clip-path;
}
.mk-pin [data-motion~="expandir"] .mk-expand__media :is(img, video) { transform: scale(1.3); will-change: transform; }
.mk-pin [data-motion~="expandir"] .mk-expand__caption { bottom: 10%; opacity: 0; }
/* Móvil: sin pin; la foto entra como cortina */
@media (max-width: 767.98px) {
  .mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="expandir"]:not(.mk-done) .mk-expand__media {
    transition: clip-path var(--mk-dur-photo) var(--mk-ease);
  }
  .mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="expandir"]:not(.is-in) .mk-expand__media {
    clip-path: inset(100% 0 0 0);
  }
  .mk-js:not(.mk-reduce):not(.mk-failed) [data-motion~="expandir"].is-in:not(.mk-done) .mk-expand__media {
    clip-path: inset(0 0 0 0);
  }
}

/* horizontal — fila que avanza con el scroll vertical; sin pin = carrusel nativo con snap */
[data-motion~="horizontal"] { position: relative; }
.mk-hscroll__track {
  display: flex; gap: var(--mk-hgap);
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 8px var(--mk-hpad) 16px;
  scroll-padding-inline: var(--mk-hpad);
}
.mk-hscroll__track > * { flex: none; scroll-snap-align: start; }
.mk-hscroll__track:focus-visible { outline: 2px solid var(--mk-accent); outline-offset: -2px; }
.mk-pin [data-motion~="horizontal"].mk-pinned .mk-hscroll__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}
.mk-pin [data-motion~="horizontal"].mk-pinned .mk-hscroll__track {
  overflow: visible; scroll-snap-type: none;
  width: max-content; max-width: none;
  will-change: transform;
}

/* apiladas — tarjetas sticky que se encogen al ser tapadas */
.mk-motion [data-motion~="apiladas"]:not(.mk-flat) {
  display: grid;
  gap: var(--mk-stack-space);
}
.mk-motion [data-motion~="apiladas"]:not(.mk-flat) > * {
  position: sticky;
  top: calc(var(--mk-stack-top) + var(--mk-i, 0) * var(--mk-stack-gap));
  transform-origin: 50% 0;
  will-change: transform;
}

/* linea — trazo SVG (pathLength=1) o línea CSS con .mk-line */
.mk-line:not(path):not(line):not(polyline):not(circle):not(rect):not(ellipse) { transform-origin: 0 0; }

/* ======================================================= INTERACCIÓN ======== */

/* magnetico — usa la propiedad `translate`, compatible con el transform propio del botón */
@media (hover: hover) and (pointer: fine) {
  .mk-motion [data-motion~="magnetico"] { will-change: translate; }
}

/* inclinacion — brillo opcional con data-glare */
[data-motion~="inclinacion"][data-glare] { position: relative; isolation: isolate; }
.mk-glare {
  position: absolute; inset: 0; z-index: 2;
  border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--mk-gx, 50%) var(--mk-gy, 50%), rgba(255, 255, 255, .28), transparent 55%);
  opacity: 0; transition: opacity 250ms ease;
}
.mk-tilt-on .mk-glare { opacity: 1; }

/* acordeon — paneles abiertos sin JS; con JS colapsan con grid-template-rows */
.mk-acc__icon { display: none; }
.mk-ready .mk-acc__icon {
  display: inline-block; flex: none; position: relative;
  width: 16px; height: 16px;
  transition: transform var(--mk-dur-ui) var(--mk-ease);
}
.mk-acc__icon::before, .mk-acc__icon::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; margin-top: -1px; border-radius: 2px; background: currentColor;
}
.mk-acc__icon::after { transform: rotate(90deg); }
.mk-acc__item.is-open .mk-acc__icon { transform: rotate(45deg); }
.mk-ready [data-motion~="acordeon"] .mk-acc__panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--mk-dur-ui) var(--mk-ease);
}
.mk-ready [data-motion~="acordeon"] .mk-acc__item.is-open > .mk-acc__panel { grid-template-rows: 1fr; }
.mk-ready [data-motion~="acordeon"] .mk-acc__panel > * { overflow: hidden; min-height: 0; }

/* transicion — lightbox con elemento compartido + transición entre páginas */
.mk-lightbox {
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: clamp(16px, 4vw, 48px);
  border: 0; background: transparent; color: #fff;
  overflow: hidden;
}
.mk-lightbox[open] { display: grid; place-items: center; }
.mk-lightbox::backdrop { background: rgba(8, 9, 14, .88); }
.mk-lightbox__figure { margin: 0; display: grid; gap: 12px; justify-items: center; max-width: 100%; max-height: 100%; }
.mk-lightbox__img { max-width: min(100%, 1400px); max-height: calc(100dvh - 140px); width: auto; height: auto; object-fit: contain; border-radius: 6px; }
.mk-lightbox__caption { font-size: .95rem; opacity: .85; text-align: center; max-width: 60ch; }
.mk-lightbox__btn {
  position: absolute; font: inherit; font-size: .9rem; font-weight: 600;
  color: #fff; background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28); border-radius: 999px;
  padding: 10px 16px; cursor: pointer;
}
.mk-lightbox__btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.mk-lightbox__close { top: 16px; right: 16px; }
.mk-lightbox__prev { left: 16px; top: 50%; transform: translateY(-50%); }
.mk-lightbox__next { right: 16px; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) {
  .mk-lightbox__prev, .mk-lightbox__next { top: auto; bottom: 16px; transform: none; }
}
::view-transition-group(mk-media) {
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(.77, 0, .175, 1);
}
[data-vt="header"] { view-transition-name: mk-header; }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: 260ms cubic-bezier(.4, 0, 1, 1) both mk-vt-out; }
  ::view-transition-new(root) { animation: 420ms cubic-bezier(.22, 1, .36, 1) both mk-vt-in; }
}
@keyframes mk-vt-out { to { opacity: 0; } }
@keyframes mk-vt-in { from { opacity: 0; transform: translate3d(0, 14px, 0); } }

/* ====================================================== BOTONES (FX) ======== */
/* Capas decorativas inyectadas por el JS (.mk-fx): sin JS el botón queda intacto. */
:root {
  --mk-shine: rgba(255, 255, 255, .55);
  --mk-sparkle: var(--mk-accent);
  --mk-pulse: var(--mk-accent);
  --mk-border-a: var(--mk-accent);
  --mk-border-b: #fff;
}
.mk-fx { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1; }
/* brillo — barrido de luz al pasar el mouse; data-auto: barrido periódico */
.mk-fx--brillo { overflow: hidden; }
.mk-fx--brillo::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%;
  background: linear-gradient(105deg, transparent 0%, var(--mk-shine) 50%, transparent 100%);
  transform: translateX(0) skewX(-18deg); opacity: 0;
}
.mk-motion [data-motion~="brillo"]:is(:hover, :focus-visible) > .mk-fx--brillo::before { animation: mk-shine 900ms var(--mk-ease) both; }
.mk-motion [data-motion~="brillo"][data-auto] > .mk-fx--brillo::before { animation: mk-shine-auto 4.2s var(--mk-ease) 1.2s infinite; }
@keyframes mk-shine { 0% { transform: translateX(0) skewX(-18deg); opacity: 1; } 100% { transform: translateX(420%) skewX(-18deg); opacity: 1; } }
@keyframes mk-shine-auto {
  0% { transform: translateX(0) skewX(-18deg); opacity: 1; }
  24% { transform: translateX(420%) skewX(-18deg); opacity: 1; }
  25%, 100% { transform: translateX(420%) skewX(-18deg); opacity: 0; }
}
/* reflejo — luz que sigue al puntero sobre la superficie */
.mk-fx--reflejo {
  background: radial-gradient(circle at var(--mk-rx, 50%) var(--mk-ry, 50%), rgba(255, 255, 255, .38), transparent 60%);
  opacity: 0; transition: opacity 250ms ease;
}
.mk-motion [data-motion~="reflejo"]:hover > .mk-fx--reflejo { opacity: 1; }
/* destello — chispas que salen del borde (hover, clic o foco por teclado) */
.mk-spark {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  pointer-events: none; z-index: 2; color: var(--mk-sparkle);
  background: currentColor;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: mk-spark 750ms var(--mk-ease) both;
}
@keyframes mk-spark {
  0% { transform: translate(0, 0) scale(0) rotate(0deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(var(--mk-dx), var(--mk-dy)) scale(var(--mk-s, 1)) rotate(90deg); opacity: 0; }
}
/* pulso — halo que respira alrededor del CTA principal (uno por página) */
.mk-motion [data-motion~="pulso"] > .mk-fx--pulso { animation: mk-pulse 2.6s ease-out infinite; }
@keyframes mk-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mk-pulse) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--mk-pulse) 0%, transparent); }
}
/* borde — trazo de gradiente que gira alrededor del botón al pasar el mouse */
@property --mk-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.mk-fx--borde {
  inset: -2px; padding: 2px;
  background: conic-gradient(from var(--mk-angle), var(--mk-border-a), var(--mk-border-b), var(--mk-border-a));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .9;
}
.mk-motion [data-motion~="borde"]:is(:hover, :focus-visible) > .mk-fx--borde { animation: mk-spin-border 1.6s linear infinite; }
@keyframes mk-spin-border { to { --mk-angle: 360deg; } }
/* lottie — animación de LottieFiles dentro del botón o icono */
.mk-lottie { display: inline-block; width: var(--mk-lottie-size, 1.4em); height: var(--mk-lottie-size, 1.4em); vertical-align: middle; }
.mk-lottie-ready > .mk-lottie-fallback { display: none; }

/* ====================================================== CURSOR =============== */
.mk-cursor { position: fixed; inset: 0; pointer-events: none; z-index: 2147483000; opacity: 0; transition: opacity 200ms ease; }
.mk-cursor.is-on { opacity: 1; }
.mk-cursor.is-hidden, .mk-cursor.is-text { opacity: 0; }
.mk-cursor__ring, .mk-cursor__dot { position: absolute; top: 0; left: 0; will-change: transform; }
.mk-cursor__ring::before {
  content: ""; position: absolute; left: 0; top: 0;
  width: var(--mk-cursor-size, 34px); height: var(--mk-cursor-size, 34px);
  margin: calc(var(--mk-cursor-size, 34px) / -2) 0 0 calc(var(--mk-cursor-size, 34px) / -2);
  border: 1.5px solid var(--mk-cursor-color, var(--mk-accent)); border-radius: 999px;
  transition: transform 260ms var(--mk-ease), background-color 260ms ease, border-color 260ms ease;
}
.mk-cursor__dot::before {
  content: ""; position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: var(--mk-cursor-color, var(--mk-accent));
}
.mk-cursor--halo .mk-cursor__dot { display: none; }
.mk-cursor.is-link .mk-cursor__ring::before { transform: scale(1.7); background: color-mix(in srgb, var(--mk-cursor-color, var(--mk-accent)) 14%, transparent); }
.mk-cursor.is-press .mk-cursor__ring::before { transform: scale(.75); }
.mk-cursor.is-label .mk-cursor__ring::before { transform: scale(2.7); background: var(--mk-cursor-color, var(--mk-accent)); border-color: transparent; }
.mk-cursor__label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  font: 600 12px/1 system-ui, sans-serif; letter-spacing: .02em; white-space: nowrap;
  color: var(--mk-cursor-label, #fff); opacity: 0; transition: opacity 200ms ease;
}
.mk-cursor.is-label .mk-cursor__label { opacity: 1; }
.mk-cursor--blend { mix-blend-mode: difference; --mk-cursor-color: #fff; }
html.mk-cursor-none, html.mk-cursor-none * { cursor: none !important; }
html.mk-cursor-none :is(input, textarea, select, [contenteditable="true"], iframe),
html.mk-cursor-none.mk-lock, html.mk-cursor-none.mk-lock * { cursor: auto !important; }

/* ======================================================= SEGURIDAD ========== */

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .mk-acc__panel, .mk-acc__icon, .mk-w, .mk-glare, .mk-fx { transition: none !important; }
  .mk-fx, .mk-fx::before, .mk-spark { animation: none !important; }
  .mk-spark, .mk-cursor { display: none !important; }
}
@media print {
  [data-motion], [data-motion] * {
    opacity: 1 !important; transform: none !important; translate: none !important;
    clip-path: none !important;
  }
  .mk-progress, .mk-lightbox, .mk-cursor, .mk-fx, .mk-spark { display: none !important; }
}
