/* ============================================================
   AM RECORTES — Carrusel + Lightbox
   Tema hijo: kadence-child
   ============================================================ */

/* ---------- Variables locales ---------- */
:root {
  --am-card-w: 220px;
  --am-card-h: 390px;
  --am-gap: 16px;
  --am-radius: 14px;
  --am-badge-bg: rgba(255, 255, 255, 0.15);
  --am-overlay: rgba(0, 0, 0, 0.85);
  --am-accent: #e8593c;
  --am-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   SECCIÓN RECORTES
   ============================================================ */
.am-recortes-section {
  position: relative;
  padding: var(--space-12) var(--space-6);
  overflow: hidden;
}

/* Forzar títulos en blanco sobre el fondo animado */
#am-recortes-section .seccion-titulo {
  color: #ffffff !important;
  border-left: 4px solid rgba(255, 255, 255, 0.3) !important;
}

.am-recortes-section .am-section-title {
  color: #ffffff;
}

.am-section-header {
  margin-bottom: 24px;
  text-align: left;
}

.am-section-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

/* ---------- Wrapper del titulo principal ---------- */
.am-recortes-header-wrap {
  padding: 0 56px;
}

/* ---------- Carrusel wrapper ---------- */
.am-recortes-carousel {
  position: relative;
  padding: 0 56px;
  /* espacio para botones nav */
}

/* ---------- Track (el riel desplazable) ---------- */
.am-recortes-track {
  display: flex;
  gap: var(--am-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* Firefox */
  padding-bottom: 8px;
  cursor: grab;
  user-select: none;
}

.am-recortes-track::-webkit-scrollbar {
  display: none;
}

.am-recortes-track.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

/* ---------- Cada card ---------- */
.am-recorte-card {
  flex: 0 0 var(--am-card-w);
  height: var(--am-card-h);
  border-radius: var(--am-radius);
  overflow: hidden;
  background: #111;
  position: relative;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.2s var(--am-easing), box-shadow 0.2s var(--am-easing);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.am-recorte-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

.am-recorte-card:focus-visible {
  outline: 2px solid var(--am-accent);
  outline-offset: 3px;
}

/* ---------- Thumbnail / placeholder ---------- */
.am-recorte-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.am-recorte-thumb-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-recorte-thumb-placeholder::after {
  content: '';
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.3);
  /* ícono play con clip-path */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px;
}

/* ---------- Overlay degradado + meta ---------- */
.am-recorte-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
      rgba(0, 0, 0, 0.85) 0%,
      rgba(0, 0, 0, 0.3) 40%,
      transparent 70%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 14px;
  pointer-events: none;
}

.am-recorte-programa-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  background: var(--am-badge-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 2px 7px;
  margin-bottom: 6px;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.am-recorte-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* ---------- Botones de navegación del carrusel ---------- */
.am-recortes-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  line-height: 1;
}

.am-recortes-nav:hover {
  background: rgba(0, 0, 0, 0.85);
}

.am-recortes-nav:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.am-recortes-nav--prev {
  left: 4px;
}

.am-recortes-nav--next {
  right: 4px;
}

/* SVG icons en botones */
.am-recortes-nav svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* ============================================================
   LIGHTBOX / MODAL
   ============================================================ */
.am-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--am-overlay);
  align-items: center;
  justify-content: center;
}

.am-lightbox.is-open {
  display: flex;
  flex-direction: column; /* Apilar en móviles por defecto */
  animation: am-lb-in 0.22s var(--am-easing) both;
}

.am-lightbox__header-mobile {
  flex: 0 0 auto;
  width: 100%;
  height: 60px;
  padding: 0 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

@media (min-width: 681px) {
  .am-lightbox.is-open {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
  .am-lightbox__header-mobile {
    display: none; /* En desktop usamos el botón sobre el modal o el clic fuera */
  }
}

@keyframes am-lb-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---------- Inner wrapper (apaisado tipo TikTok) ---------- */
.am-lightbox__inner {
  position: relative;
  display: flex;
  align-items: stretch;
  width: min(92vw, 960px);
  max-height: 92vh;
  border-radius: 18px;
  overflow: hidden;
  background: #0d0d0d;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

/* ---------- Columna video (izquierda) ---------- */
.am-lightbox__video-col {
  flex: 0 0 auto;
  width: min(400px, 55vw);
  aspect-ratio: 9/16;
  position: relative;
  background: #000;
}

.am-lightbox__video-col iframe,
.am-lightbox__video-col video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain; /* Asegura que el video se vea completo siempre */
}

/* badge del programa (sobre el video) */
.am-lightbox__programa-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 3px 9px;
  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Columna info (derecha) ---------- */
.am-lightbox__info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 24px;
  color: #fff;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  min-width: 0;
}

.am-lightbox__info-col::-webkit-scrollbar {
  width: 4px;
}

.am-lightbox__info-col::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.am-lightbox__badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cat-recortes);
  margin-bottom: 10px;
}

.am-lightbox__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
  color: #fff;
}

.am-lightbox__excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 auto;
}

/* ---------- Controles de navegación del lightbox ---------- */
.am-lightbox__nav {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  align-items: center;
}

.am-lightbox__nav-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.am-lightbox__nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.am-lightbox__nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.am-lightbox__nav-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.am-lightbox__counter {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  white-space: nowrap;
}

/* ---------- Botón cerrar ---------- */
.am-lightbox__close {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 2147483647 !important; /* Valor máximo de z-index */
  width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background 0.18s, transform 0.2s;
  line-height: 1 !important;
}

.am-lightbox__close:hover {
  background: rgba(0, 0, 0, 0.9) !important;
  transform: scale(1.05);
}

/* Optimización móvil: Ajuste de header */
@media (max-width: 768px) {
  .am-lightbox__header-mobile {
    background: rgba(0,0,0,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  .am-lightbox__close {
    width: 44px !important;
    height: 44px !important;
  }
}

.am-lightbox__close svg {
  width: 18px !important;
  height: 18px !important;
  fill: currentColor !important;
  display: block !important;
}

/* ---------- Spinner de carga ---------- */
.am-lightbox__spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 3;
  transition: opacity 0.3s;
}

.am-lightbox__spinner.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.am-lightbox__spinner::after {
  content: '';
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--am-accent);
  border-radius: 50%;
  animation: am-spin 0.7s linear infinite;
}

@keyframes am-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 680px) {
  .am-recortes-header-wrap {
    padding: 0;
  }

  .am-recortes-carousel {
    padding: 0;
    --am-card-w: 170px;
    --am-card-h: 300px;
  }

  .am-lightbox__inner {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .am-lightbox__video-col {
    width: 100%;
    aspect-ratio: 9 / 16;
    max-height: 68vh; /* Aumentado para evitar recortes en pantallas largas */
    background: #000;
  }

  .am-lightbox__programa-badge {
    top: 16px;
    left: 16px;
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6); /* Más contraste */
  }

  .am-lightbox__info-col {
    flex: 1;
    padding: 24px 20px 30px;
  }

  .am-lightbox__nav-btn {
    padding: 14px 20px; /* Mayor área táctil */
  }

  .am-lightbox__title {
    font-size: 18px;
    margin-bottom: 16px;
  }
}

@media (max-width: 400px) {

  .am-recortes-header-wrap,
  .am-recortes-carousel {
    padding: 0;
  }
}