/* Carrusel de video-testimonios · «tira cinematográfica» (oleada 1c)
 * Regla del 2/3: en reposo se ven n tarjetas completas y 2/3 de la siguiente.
 *   ancho = (100% - n·gap) / (n + 0,6667), con margin-right = gap en cada tarjeta.
 *   n = 1 hasta 640 px, 2 de 641 a 1024, 3 desde 1025. Nunca más de 3: con 5 tarjetas,
 *   Embla solo hace bucle si las 4 restantes llenan la vista. carrusel.js lee --n para atenuar la que asoma.
 * Animación solo con transform, opacity y clip-path. Tokens de css/styles.css con respaldo.
 */

.carrusel,
.reproductor {
  --c-navy-900: var(--navy-900, #0B1F3A);
  --c-navy-800: var(--navy-800, #14304F);
  --c-navy-700: var(--navy-700, #1E3F66);
  --c-oro: var(--gold-500, #D7B561);
  --c-oro-hondo: var(--gold-600, #C7A14A);
  --c-texto-2: rgba(255, 255, 255, .78);
  --anillo-foco: 3px solid var(--c-oro);
  --ease-salida: cubic-bezier(0.22, 1, 0.36, 1);
  --f-display: var(--font-display, 'Poppins', system-ui, sans-serif);
  --f-cuerpo: var(--font-body, 'Inter', system-ui, sans-serif);
  color: #fff;
}

.carrusel { --n: 1; --gap: 16px; --asoma: .6667; --titulo: 22px; position: relative; }
@media (min-width: 641px) { .carrusel { --n: 2; --gap: 20px; --titulo: 24px; } }
@media (min-width: 1025px) { .carrusel { --n: 3; --gap: 24px; --titulo: 26px; } }

.carrusel *, .carrusel *::before, .carrusel *::after,
.reproductor *, .reproductor *::before, .reproductor *::after { box-sizing: border-box; }

/* ---------- viewport y pista ---------- */

/* El relleno vertical deja sitio a la sombra y al crecimiento de 1,02 sin cambiar la medida horizontal. */
.carrusel__viewport {
  overflow: hidden;
  padding-block: 14px 30px;
  margin-block: -14px -30px;
  touch-action: pan-y pinch-zoom; /* el arrastre horizontal es de Embla; con Lenis: ver informe */
}
/* Escritorio, en la página: la tarjeta que asoma (2/3) se funde hacia la derecha en vez de cortarse en seco
 * en el borde del contenedor. Se conserva el tamaño de tarjeta aprobado (2026-11-12); la sangría hasta el
 * borde de la ventana lo agrandaba (319 → 411 px a 1920). El fundido empieza en la tarjeta que asoma. */
@media (min-width: 1025px) {
  .testi-videos .carrusel__viewport {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 140px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 140px), transparent);
  }
}
.carrusel__viewport:focus { outline: none; }
.carrusel__viewport:focus-visible { outline: var(--anillo-foco); outline-offset: -3px; border-radius: 28px; }

.carrusel__pista { display: flex; touch-action: pan-y pinch-zoom; backface-visibility: hidden; }

.carrusel__tarjeta {
  flex: 0 0 calc((100% - var(--n) * var(--gap)) / (var(--n) + var(--asoma)));
  min-width: 0;
  margin-right: var(--gap);
}

/* ---------- tarjeta: póster y video a sangre ---------- */

.tarjeta-video__marco {
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0;
  padding: 0;
  overflow: hidden;
  isolation: isolate; /* Safari: que el radio recorte al video */
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 24px;
  background: var(--c-navy-800);
  box-shadow: 0 26px 44px -26px rgba(2, 8, 20, .85), 0 2px 10px rgba(2, 8, 20, .28);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 100%;
  transition: transform 420ms var(--ease-salida);
}
.tarjeta-video__marco:focus { outline: none; }
.tarjeta-video__marco:focus-visible { outline: var(--anillo-foco); outline-offset: -3px; }
.tarjeta-video__marco:active { transform: scale(.985); transition-duration: 120ms; }
.tarjeta-video__marco.is-encima { transform: scale(1.02); }

.tarjeta-video__marco video,
.tarjeta-video__poster,
.tarjeta-video__velo,
.tarjeta-video__sombra {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.tarjeta-video__marco video,
.tarjeta-video__poster { display: block; object-fit: cover; -webkit-user-drag: none; user-select: none; }
.tarjeta-video__poster { transition: opacity 320ms ease-out; }
.is-previa .tarjeta-video__poster { opacity: 0; }

/* Degradado navy-900 → transparente (≈45 % del alto) y un calor dorado tenue bajo el rótulo. */
.tarjeta-video__velo {
  background:
    radial-gradient(85% 34% at 0% 100%, rgba(215, 181, 97, .16), rgba(215, 181, 97, 0) 72%),
    linear-gradient(to top, rgba(11, 31, 58, .96) 0%, rgba(11, 31, 58, .84) 20%, rgba(11, 31, 58, .4) 34%, rgba(11, 31, 58, 0) 46%);
  transition: opacity 420ms var(--ease-salida);
}
.is-encima .tarjeta-video__velo { opacity: .8; }

/* La tarjeta que asoma se queda en penumbra: dice «hay más» sin competir con las completas. */
.tarjeta-video__sombra { background: var(--c-navy-900); opacity: 0; transition: opacity 360ms ease-out; }
.is-asoma .tarjeta-video__sombra { opacity: .55; }
.is-asoma .is-encima .tarjeta-video__sombra { opacity: 0; }

/* ---------- rótulo ---------- */

.tarjeta-video__rotulo {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
}
@media (min-width: 641px) { .tarjeta-video__rotulo { left: 20px; right: 20px; bottom: 20px; } }
/* Móvil (tarjeta ≈ 200 px): el rótulo cabe bajo los subtítulos quemados del video (≈ 40 % del alto desde abajo).
 * El antetítulo va en una línea; completo en el reproductor y en el aria-label. */
@media (max-width: 640px) {
  .tarjeta-video__rotulo { left: 12px; right: 12px; bottom: 12px; gap: 2px; }
  .tarjeta-video__procedimiento { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tarjeta-video__pildora { margin-top: 8px; padding: 5px 11px 5px 9px; }
}

.tarjeta-video__procedimiento {
  font-family: var(--f-cuerpo);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: var(--c-oro);
}

.tarjeta-video__padecimiento {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: var(--titulo);
  line-height: 1.08;
  letter-spacing: -.012em;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(2, 8, 20, .45);
}

.tarjeta-video__pildora {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 6px 13px 6px 11px;
  border-radius: 999px;
  background: var(--c-navy-800);
  box-shadow: inset 0 0 0 1px rgba(215, 181, 97, .24), 0 6px 16px -8px rgba(2, 8, 20, .7);
  font-family: var(--f-cuerpo);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.tarjeta-video__pildora svg { width: 11px; height: 11px; color: var(--c-oro); }

/* Destello: un arco de luz que recorre el borde de 1 px (rotación de un cónico enmascarado al anillo). */
.tarjeta-video__destello {
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1px;
  overflow: hidden;
  border-radius: inherit;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}
.tarjeta-video__destello::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: conic-gradient(from 0deg, transparent 0 290deg, rgba(240, 214, 150, .95) 330deg, transparent 360deg);
  animation: destello 5.2s linear infinite;
  animation-play-state: paused; /* corre solo con la tira en vista: .is-en-vista lo pone js/carrusel.js */
}
.carrusel.is-en-vista .tarjeta-video__destello::before { animation-play-state: running; }
@keyframes destello { to { transform: rotate(1turn); } }

/* Avance de la vista previa: hilo dorado al pie de la tarjeta. */
.tarjeta-video__avance {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c-oro);
  transform: scaleX(0); transform-origin: 0 50%; opacity: 0; pointer-events: none;
  transition: transform 250ms linear, opacity 200ms ease-out;
}
.is-previa .tarjeta-video__avance { opacity: 1; }

/* ---------- flechas y contador ---------- */

.carrusel__controles { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 30px; }

.carrusel__anterior,
.carrusel__siguiente,
.reproductor__boton {
  appearance: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-salida); /* el color del hover cambia sin animar: solo transform/opacity */
}
.carrusel__anterior svg, .carrusel__siguiente svg, .reproductor__boton svg { display: block; pointer-events: none; }

.carrusel__anterior,
.carrusel__siguiente {
  width: 48px;
  height: 48px;
  background: var(--c-navy-800);
  color: var(--c-oro);
  box-shadow: 0 10px 22px -12px rgba(2, 8, 20, .8);
}
.carrusel__anterior svg, .carrusel__siguiente svg { width: 22px; height: 22px; transition: transform 200ms var(--ease-salida); }
.carrusel__anterior:hover, .carrusel__siguiente:hover { background: var(--c-navy-700); }
.carrusel__anterior:hover svg { transform: translateX(-2px); }
.carrusel__siguiente:hover svg { transform: translateX(2px); }
.carrusel__anterior:active, .carrusel__siguiente:active,
.reproductor__boton:active { transform: scale(.92); }
.carrusel__anterior:focus-visible, .carrusel__siguiente:focus-visible,
.reproductor__boton:focus-visible, .reproductor__barra:focus-visible { outline: var(--anillo-foco); outline-offset: 3px; }

.carrusel__contador {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 64px;
  justify-content: center;
  font-family: var(--f-cuerpo);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .6);
}
.carrusel__contador-actual { font-family: var(--f-display); font-weight: 800; font-size: 22px; color: #fff; }

/* ---------- reproductor grande ---------- */

html.reproductor-abierto { overflow: hidden; padding-right: var(--ancho-barra, 0); }

.reproductor {
  --alto: min(86vh, 900px, calc((100vw - 32px) * 16 / 9), calc(100vh - 128px));
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
}
@supports (height: 1svh) {
  .reproductor { --alto: min(86svh, 900px, calc((100vw - 32px) * 16 / 9), calc(100svh - 128px)); }
}
.reproductor::backdrop { background: transparent; }

.reproductor__fondo {
  position: absolute;
  inset: 0;
  background: rgba(11, 31, 58, .8);
  -webkit-backdrop-filter: blur(16px) saturate(115%);
  backdrop-filter: blur(16px) saturate(115%);
}

.reproductor__escena {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none; /* lo vacío deja pasar el toque al fondo, que cierra */
}

.reproductor__marco {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: calc(var(--alto) * 9 / 16);
}
.reproductor__cabecera, .reproductor__panel { pointer-events: auto; }

.reproductor__cabecera { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.reproductor__info { min-width: 0; }
.reproductor__procedimiento,
.reproductor__titulo { margin: 0; }
.reproductor__procedimiento { font: 600 14px/1.3 var(--f-cuerpo); color: var(--c-oro); }
.reproductor__titulo {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.08;
  letter-spacing: -.012em;
}

.reproductor__cerrar { flex: none; width: 48px; height: 48px; background: var(--c-oro); color: var(--c-navy-900); border-color: transparent; box-shadow: 0 10px 24px -10px rgba(2, 8, 20, .8); }
.reproductor__cerrar svg { width: 20px; height: 20px; }
.reproductor__cerrar:hover { background: var(--c-oro-hondo); }

.reproductor__panel {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 28px;
  background: var(--c-navy-900);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
  transform-origin: 0 0;
}
.reproductor__panel video {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.reproductor__panel:fullscreen { border-radius: 0; background: #000; }
.reproductor__panel:fullscreen video { object-fit: contain; }

.reproductor__error {
  position: absolute; left: 16px; right: 16px; top: 16px; margin: 0; padding: 12px 16px;
  border-radius: 16px; background: #5A1E1E; font: 500 15px/1.4 var(--f-cuerpo);
}

.reproductor__controles {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 6px;
  padding: 56px 14px 14px;
  background: linear-gradient(to top, rgba(11, 31, 58, .92), rgba(11, 31, 58, .55) 55%, rgba(11, 31, 58, 0));
}

/* Barra dorada delgada; el área de toque es de 24 px de alto. */
.reproductor__barra { position: relative; height: 24px; margin-inline: 4px; cursor: pointer; touch-action: none; }
/* Área de toque de 44 px sin cambiar el dibujo: 14 px sobre el relleno vacío de arriba y 6 px del hueco de abajo. */
.reproductor__barra::before { content: ''; position: absolute; left: 0; right: 0; top: -14px; bottom: -6px; }
.reproductor__pista, .reproductor__relleno { position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 999px; }
.reproductor__pista { background: rgba(255, 255, 255, .24); }
.reproductor__relleno { background: var(--c-oro); transform: scaleX(0); transform-origin: 0 50%; }
.reproductor__perilla {
  position: absolute; left: -7px; top: 5px; width: 14px; height: 14px;
  border-radius: 999px; background: var(--c-oro); box-shadow: 0 0 0 4px rgba(215, 181, 97, .22);
}

.reproductor__fila { display: flex; align-items: center; gap: 8px; }
.reproductor__hueco { flex: 1; }
.reproductor__fila .reproductor__boton { width: 44px; height: 44px; background: var(--c-navy-800); color: #fff; }
.reproductor__fila .reproductor__boton svg { width: 20px; height: 20px; }
.reproductor__fila .reproductor__boton:hover { background: var(--c-navy-700); }
.reproductor__fila .reproductor__alternar { background: var(--c-oro); color: var(--c-navy-900); border-color: transparent; }
.reproductor__fila .reproductor__alternar:hover { background: var(--c-oro-hondo); }
.reproductor__tiempo { font: 600 14px/1 var(--f-cuerpo); font-variant-numeric: tabular-nums; color: var(--c-texto-2); white-space: nowrap; }

.reproductor .icono-play, .reproductor .icono-mudo { display: none; }
.reproductor[data-estado="pausa"] .icono-play { display: block; transform: translateX(1px); }
.reproductor[data-estado="pausa"] .icono-pausa { display: none; }
.reproductor__silencio[aria-pressed="true"] .icono-mudo { display: block; }
.reproductor__silencio[aria-pressed="true"] .icono-sonido { display: none; }

/* ---------- en la página: bloque de video dentro de #testimonios (encima de los escritos) ---------- */

.testi-videos { position: relative; z-index: 2; margin-bottom: clamp(3.5rem, 7vw, 5.5rem); } /* sobre .testi-bg-glow */
.testi-videos__titulo {
  margin: 0 0 24px;
  font-family: var(--font-display, 'Poppins', system-ui, sans-serif);
  font-weight: 800;
  font-size: clamp(24px, 1rem + 1.6vw, 34px);
  line-height: 1.12;
  letter-spacing: -.015em;
  color: #fff;
}
.testi-videos__titulo em { font-family: var(--font-serif, 'Source Serif Pro', Georgia, serif); font-style: italic; font-weight: 400; color: var(--gold-500, #D7B561); }
.testi-videos__nota {
  margin: 20px auto 0;
  max-width: 60ch;
  font: 400 14px/1.5 var(--font-body, 'Inter', system-ui, sans-serif);
  color: rgba(255, 255, 255, .72);
  text-align: center;
  text-wrap: balance; /* a 375 px dejaba «otra.» sola en la última línea */
}
.testi-videos__error {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 16px;
  background: #5A1E1E;
  font: 500 15px/1.4 var(--font-body, 'Inter', system-ui, sans-serif);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .tarjeta-video__marco,
  .tarjeta-video__velo,
  .tarjeta-video__avance,
  .carrusel__anterior svg,
  .carrusel__siguiente svg { transition: none; }
  .tarjeta-video__destello::before { animation: none; transform: rotate(200deg); }
}
