/* Video Gallery Style for YotuWP — framed lightbox based on Folks & Facts v6.
   Popup is mounted under <body> by YotuWP, hence :has() scoping. */

/* Size includes a cap based on viewport HEIGHT, not only width. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox {
  --vgs-popup-width: min(1090px, calc(100vw - 40px), calc((100dvh - 128px) * 16 / 9));
}

/* Keep the plugin's display:none when closed. Grid only WHEN open. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox[style*="display: block"] {
  display: grid !important;
  grid-template-columns: var(--vgs-popup-width) !important;
  grid-template-rows: auto !important;
  place-content: center !important;
}

/* Dim the page rather than using solid black. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-overlay {
  background: rgba(5, 13, 24, .86) !important;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

/* Framed navy 'screen' with a thin warm gold trim. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-body {
  grid-area: 1 / 1 !important;
  justify-self: stretch !important;
  align-self: center !important;
  box-sizing: border-box !important;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  width: 100% !important;
  max-height: calc(100dvh - 32px) !important;
  margin: 0 !important;
  padding: 7px !important;
  border: 1px solid rgba(255, 255, 255, .16) !important;
  border-top: 3px solid var(--vgs-gold, #eea738) !important;
  border-radius: 17px !important;
  background: var(--vgs-popup-bg, #0f2238) !important;
  box-shadow: 0 35px 95px rgba(0, 0, 0, .60), 0 0 0 1px rgba(255,255,255,.04) !important;
  overflow: hidden !important;
}

/* Built-in branding, no image/logo upload required. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-body::before {
  content: var(--vgs-popup-title, "VIDEO PODCAST");
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 100%;
  height: 53px;
  padding: 0 118px 0 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  font-family: inherit;
  font-size: clamp(12px, 1.25vw, 16px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .055em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Make the VIDEO use the frame's width; keep proper 16:9. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-content {
  box-sizing: border-box !important;
  display: block !important;
  position: relative !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 11px !important;
  background: #07111c !important;
  overflow: hidden !important;
}
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-player {
  display: block !important;
  position: relative !important;
  width: 100% !important;
  height: 0 !important;
  padding: 0 0 56.25% !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  overflow: hidden !important;
}
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-player iframe {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 10px !important;
}

/* REAL clickable close control, aligned with frame's top-right.
   It remains YotuWP's original close link, so its JS still works. */
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close {
  grid-area: 1 / 1 !important;
  justify-self: end !important;
  align-self: start !important;
  box-sizing: border-box !important;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-19px, 18px) !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 102px !important;
  height: 37px !important;
  min-width: 102px !important;
  margin: 0 !important;
  padding: 0 12px !important;
  background: #f4f7fa !important;
  color: var(--vgs-navy, #10243a) !important;
  border: 1px solid rgba(255,255,255,.7) !important;
  border-radius: 9px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.2) !important;
  font-size: 19px !important;
  line-height: 1 !important;
  text-decoration: none !important;
  cursor: pointer !important;
  z-index: 10 !important;
  transition: background .18s ease, transform .18s ease;
}
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close::before {
  content: var(--vgs-close-label, "CLOSE");
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close span {
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 18px !important;
  line-height: 1 !important;
}
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close:hover,
:is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close:focus-visible {
  background: var(--vgs-gold, #eea738) !important;
  color: var(--vgs-navy, #10243a) !important;
  outline: 2px solid #fff !important;
  outline-offset: 2px !important;
}

/* Smaller padding/header on mobile and landscape devices. */
@media (max-width: 600px), (max-height: 510px) {
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox {
    --vgs-popup-width: min(calc(100vw - 22px), calc((100dvh - 94px) * 16 / 9));
  }
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-body {
    padding: 4px !important;
    border-radius: 12px !important;
  }
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-body::before {
    height: 43px;
    padding: 0 87px 0 11px;
    font-size: 11px;
    letter-spacing: .02em;
  }
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close {
    width: 77px !important;
    min-width: 77px !important;
    height: 31px !important;
    padding: 0 7px !important;
    gap: 4px !important;
    transform: translate(-10px, 12px) !important;
  }
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close::before {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(body.vgs-sitewide, body:has(.vgs-gallery), body:has(.ff-video-gallery)) .yotu-lightbox .yotu-lightbox-close {
    transition: none !important;
  }
}


/* ========== VGS enforced modal (self-contained; scoped and accessible) ========== */
.vgs-modal[hidden] { display: none !important; }
.vgs-modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: grid !important;
  grid-template-columns: min(1090px, calc(100vw - 40px), calc((100dvh - 128px) * 16 / 9)) !important;
  place-content: center !important;
  isolation: isolate;
}
.vgs-modal__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(5, 13, 24, .86);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.vgs-modal__frame {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.16);
  border-top: 3px solid var(--vgs-gold, #eea738);
  border-radius: 17px;
  background: var(--vgs-popup-bg, #0f2238);
  box-shadow: 0 35px 95px rgba(0,0,0,.60);
  overflow: hidden;
}
.vgs-modal__header {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 53px;
  padding: 0 12px 0 20px;
}
.vgs-modal__title {
  min-width: 0;
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(12px, 1.25vw, 16px);
  letter-spacing: .055em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.vgs-modal__close {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 7px 12px;
  min-width: 102px;
  min-height: 37px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 9px;
  background: #f4f7fa;
  color: var(--vgs-navy, #10243a);
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.vgs-modal__close:hover, .vgs-modal__close:focus-visible {
  background: var(--vgs-gold, #eea738);
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.vgs-modal__close-x { font-size: 19px; line-height: 1; }
.vgs-modal__video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 11px; overflow: hidden; background: #07111c; }
.vgs-modal__video iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
@media (max-width: 600px), (max-height: 510px) {
  .vgs-modal { grid-template-columns: min(calc(100vw - 22px), calc((100dvh - 94px) * 16 / 9)) !important; }
  .vgs-modal__frame { padding: 4px; border-radius: 12px; }
  .vgs-modal__header { min-height: 43px; padding: 0 7px 0 11px; }
  .vgs-modal__title { font-size: 11px; letter-spacing: .02em; }
  .vgs-modal__close { min-width: 77px; min-height: 31px; padding: 5px 7px; gap: 4px; font-size: 9px; }
}
