/* ==========================================
   VIDEO MODAL OVERLAY STYLES
   ========================================== */

.yt-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              backdrop-filter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 20px;
  box-sizing: border-box;
}

.yt-modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.yt-modal-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin-top: 44px;
  overflow: visible;
  opacity: 0;
  transform: scale(0.82) translateY(24px);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  will-change: transform, opacity;
}

.yt-modal-overlay.is-active .yt-modal-container {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Exit / Closing Animation */
.yt-modal-overlay.is-closing {
  opacity: 0;
  visibility: hidden;
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              backdrop-filter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.yt-modal-overlay.is-closing .yt-modal-container {
  opacity: 0;
  transform: scale(0.88) translateY(18px);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating Close Button Above Video */
.yt-modal-close-btn {
  position: absolute;
  top: -46px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  outline: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.yt-modal-close-btn:focus-visible {
  outline: 2px solid #fb1650;
  outline-offset: 2px;
}

.yt-modal-close-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Navigation Controls Container */
.yt-modal-nav-bar {
  display: contents;
}

/* Left & Right Navigation Arrow Buttons */
.yt-modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  outline: none;
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}

.yt-modal-prev-btn {
  left: -64px;
}

.yt-modal-next-btn {
  right: -64px;
}

.yt-modal-nav-btn:focus-visible {
  outline: 2px solid #fb1650;
  outline-offset: 2px;
}

.yt-modal-nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hover & Active Feedback (Prevents Sticky Red State on Mobile Touch) */
@media (hover: hover) and (pointer: fine) {
  .yt-modal-close-btn:hover {
    background: #fb1650;
    border-color: #fb1650;
    transform: scale(1.08);
  }
  .yt-modal-nav-btn:hover {
    background: #fb1650;
    border-color: #fb1650;
    transform: translateY(-50%) scale(1.1);
  }
}

.yt-modal-close-btn:active,
.yt-modal-nav-btn:active {
  background: #fb1650;
  border-color: #fb1650;
}

/* Responsive 16:9 Aspect Ratio Video Frame Wrapper */
.yt-modal-video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background: #000000;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.yt-modal-video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Cursor indicator on cards that trigger video */
.vid-card[data-youtube-id],
.carousel-card-item[data-youtube-id] {
  cursor: pointer;
}

/* Responsive Adjustments for Tablets and Desktops with narrow margins */
@media (max-width: 1040px) and (min-width: 769px) {
  .yt-modal-prev-btn {
    left: -15px;
  }
  .yt-modal-next-btn {
    right: -15px;
  }
}

/* Mobile Devices: Place Nav Arrows BELOW the Video Container (No Overlap) */
@media (max-width: 768px) {
  .yt-modal-overlay {
    padding: 16px;
  }
  .yt-modal-container {
    margin-top: 42px;
  }
  .yt-modal-video-wrapper {
    border-radius: 12px;
  }
  .yt-modal-close-btn {
    top: -42px;
    right: 0;
    width: 34px;
    height: 34px;
  }
  .yt-modal-close-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Nav Bar Below Video on Mobile */
  .yt-modal-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 14px;
    padding: 0 4px;
    box-sizing: border-box;
  }

  .yt-modal-nav-btn {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 42px;
    height: 42px;
  }

  .yt-modal-prev-btn {
    margin-right: auto;
  }

  .yt-modal-next-btn {
    margin-left: auto;
  }

  @media (hover: hover) and (pointer: fine) {
    .yt-modal-nav-btn:hover {
      transform: scale(1.08);
    }
  }
}
