/* ================================================
   VIDEO FACADE - Lite YouTube & Video Styles
   ================================================ */

/* Contenedor general de video */
.cf-video-wrap {
  position: relative;
  width: 100%;
  display: block;
  overflow: hidden;
  border-radius: 20px;
  background: #000;
}

.cf-video-wrap iframe,
.cf-video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

/* ================================================
   YOUTUBE FACADE (Lite YouTube)
   ================================================ */
.cf-yt-facade {
  position: relative;
  width: 100%;
  display: block;
  cursor: pointer;
  overflow: hidden;
  border-radius: 20px;
  background: #000;
  contain: content; /* performance: no re-layout del exterior */
}

/* Thumbnail */
.cf-yt-facade img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, filter 0.4s ease;
}

.cf-yt-facade:hover img {
  transform: scale(1.04);
  filter: brightness(0.75);
}

/* Overlay oscuro */
.cf-yt-facade-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
  pointer-events: none;
}

.cf-yt-facade:hover .cf-yt-facade-overlay {
  background: rgba(0, 0, 0, 0.35);
}

/* Botón Play (YouTube style) */
.cf-yt-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease;
  z-index: 2;
}

.cf-yt-facade:hover .cf-yt-play-btn {
  transform: translate(-50%, -50%) scale(1.12);
}

.cf-yt-play-bg {
  fill: #ff0000;
  transition: fill 0.2s ease;
}

.cf-yt-facade:hover .cf-yt-play-bg {
  fill: #cc0000;
}

.cf-yt-play-arrow {
  fill: #fff;
}

/* Título sobre la imagen (opcional) */
.cf-yt-facade-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 36px 16px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cf-yt-facade:hover .cf-yt-facade-title {
  opacity: 1;
}

/* Estado: cargando iframe */
.cf-yt-facade.cf-loading {
  cursor: wait;
}

.cf-yt-facade.cf-loading .cf-yt-play-btn {
  opacity: 0.5;
}

.cf-yt-facade.cf-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: cf-spin 0.8s linear infinite;
  z-index: 3;
}

/* Estado: iframe activo */
.cf-yt-facade.cf-active img,
.cf-yt-facade.cf-active .cf-yt-facade-overlay,
.cf-yt-facade.cf-active .cf-yt-play-btn,
.cf-yt-facade.cf-active .cf-yt-facade-title {
  display: none;
}

.cf-yt-facade iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: none;
}

.cf-yt-facade.cf-active iframe {
  display: block;
}

/* ================================================
   VIDEO SELF-HOSTED CON LAZY LOAD
   ================================================ */
video[data-lazy="1"] source[data-src] {
  /* El JS mueve data-src a src */
}

/* ================================================
   HERO BACKGROUND VIDEO
   ================================================ */
.hero-video-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.hero-video-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
}

/* ================================================
   MODAL DE VIDEO (cuando se hace clic en portafolio)
   ================================================ */
.cf-video-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: cf-fade-in 0.2s ease;
}

.cf-video-modal-inner {
  position: relative;
  width: 100%;
  max-width: 1000px;
}

.cf-video-modal-close {
  position: absolute;
  top: -52px;
  right: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.cf-video-modal-close:hover {
  color: #fff;
}

.cf-video-modal-video {
  aspect-ratio: 16/9;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

.cf-video-modal-video iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ================================================
   PORTFOLIO SLIDE CON FACADE
   ================================================ */
.portfolio-slide .cf-yt-facade {
  border-radius: 0;
}

/* ================================================
   ANIMACIONES
   ================================================ */
@keyframes cf-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes cf-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ================================================
   MP4 SELF-HOSTED PLAYER
   ================================================ */
.cf-mp4-wrap {
  position: relative;
  width: 100%;
  display: block;
  overflow: hidden;
  border-radius: 20px;
  background: #000;
}

.cf-mp4-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Custom play button for MP4 poster */
.cf-mp4-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.cf-mp4-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.12);
}

.cf-mp4-wrap:hover .cf-mp4-play-btn {
  opacity: 0.95;
}

/* Modal with MP4 video */
.cf-video-modal-video video {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0;
  background: #000;
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 767px) {
  .cf-yt-play-btn {
    width: 52px;
    height: 36px;
  }
  .cf-video-modal { padding: 12px; }
  .cf-video-modal-close { top: -44px; font-size: 2rem; }
}
