/* Individual Slide */
.slide {
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Modern browsers override fallback */
  width: 100%;
  
  /* GSAP controls opacity & visibility — initial hidden state */
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  visibility: hidden;
  z-index: 1;

  /* Center slide content */
  display: flex;
  justify-content: center;
  align-items: center;

  /* Prevent text selection during swipe */
  user-select: none;
  -webkit-user-select: none;
}

/* Active slide: GSAP animates these in, CSS just marks z-index */
.slide.active {
  z-index: 2;
}

.slide-content {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;

  /* Re-enable text selection for actual content */
  user-select: auto;
  -webkit-user-select: auto;
}

/* Fullscreen Image Enhancements (PDF Slides) */
.slide-content img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* ensures PDF slide image doesn't get cropped but fills safely */
  box-shadow: none !important;
  border-radius: 0 !important;
  aspect-ratio: 16 / 9; /* Fallback for CLS prevention if dimensions not set */
}

/* Picture element should not affect layout */
.slide-content picture {
  display: contents; /* Let img handle sizing */
}

/* Fullscreen Video Enhancements */
.video-slide {
  padding: 0;
  max-width: 100%;
  height: 100%;
  display: flex;
}

.video-slide .local-video-player {
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  object-fit: cover;
}

/* For Lite Youtube fullscreen cover styling */
.video-slide lite-youtube {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  background-size: cover;
  background-position: center center;
  overflow: hidden;
  position: relative;
}

/* Remove default aspect ratio padding from lite-yt-embed */
.video-slide lite-youtube::after {
  content: none;
  display: none;
}

/* Make iframe cover the container using center crop trick */
.video-slide lite-youtube > iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw; /* 100vw * 9/16 */
  min-height: 100vh;
  min-width: 177.77vh; /* 100vh * 16/9 */
  transform: translate(-50%, -50%);
  border: 0;
  pointer-events: none; /* PREVENT IFRAME FROM STEALING FOCUS */
}

/* Make lite-youtube always show pointer so user knows they can click to pause/play */
.video-slide lite-youtube,
.video-slide .local-video-player {
  cursor: pointer !important;
}

/* Hide lite-youtube's default big play button to use our custom bottom-left one */
.video-slide lite-youtube > .lyt-playbtn,
.grid-item lite-youtube > .lyt-playbtn {
  display: none !important;
}

/* Custom video indicator placed at bottom left */
.video-indicator {
  position: absolute;
  bottom: 3rem;
  left: 3rem;
  width: 54px; /* Slightly scaled YouTube icon */
  height: 38px;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through */
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

.video-container.is-playing .video-indicator {
  opacity: 0;
  transform: scale(0.9);
}

/* ------------------------------------- */
/* Multi-Video Grid Layouts (Phase 6)    */
/* ------------------------------------- */
.video-grid {
  width: 100vw;
  height: 100vh;
  display: grid;
  gap: 3px; /* Thin elegant separator */
  padding: 0;
  background-color: var(--color-bg-dark); /* acts as borders */
  box-sizing: border-box;
}

.grid-item {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  container-type: size; /* Container queries for iframe scaling */
}

/* Reset padding and standard layout inside grid item */
.grid-item lite-youtube {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  background-size: cover;
  background-position: center center;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
}

.grid-item lite-youtube::after {
  content: none;
  display: none;
}

/* Center crop iframe to cover any aspect ratio using container query units (cqi) */
.grid-item lite-youtube > iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100cqi;
  height: 56.25cqi; /* 100cqi * 9/16 */
  min-height: 100cqb;
  min-width: 177.77cqb; /* 100cqb * 16/9 */
  transform: translate(-50%, -50%);
  border: 0;
  pointer-events: none; /* PREVENT IFRAME FROM STEALING FOCUS */
}

/* Scaled down indicator for smaller grid cells */
.grid-item .video-indicator {
  bottom: 1.5rem; /* Closer to edge */
  left: 1.5rem;
  transform: scale(0.6);
  transform-origin: bottom left;
}
.grid-item.video-container.is-playing .video-indicator {
  transform: scale(0.5); /* Scale logic for play hide */
}

/* Layout 1: 1 Left Big, 6 Right Small (7 Videos) */
.grid-layout-1-6 {
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
}
.grid-layout-1-6 .grid-item:nth-child(1) {
  grid-column: 1 / 2;
  grid-row: 1 / 4;
}

/* Layout 2: 1 Top Big, 2 Bottom Small (3 Videos) */
.grid-layout-1-2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 2fr 1fr;
}
.grid-layout-1-2 .grid-item:nth-child(1) {
  grid-column: 1 / 3;
}

/* Layout 3: 4 Equal Parts (2x2) */
.grid-layout-2x2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* Layout 4: 3 Vertical Columns */
.grid-layout-3-vertical {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}

/* ------------------------------------- */

/* Text Layer Custom Stylings */
.text-layer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.text-layer h1 {
  font-size: 4rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.1;
  color: var(--color-text-light);
}

.text-layer p {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--color-text-muted);
  max-width: 800px;
  margin: 0 auto;
}

/* ------------------------------------- */
/* Image & Video CLS Prevention          */
/* ------------------------------------- */

/* Video container aspect ratio for consistent sizing */
.video-container {
  aspect-ratio: 16 / 9;
  width: 100%;
}

/* Images with explicit width/height maintain their aspect ratio */
.slide-content img[width][height] {
  aspect-ratio: auto; /* Let width/height attributes define ratio */
}
