.up-modal[hidden] {
  display: none;
}

/* Page scroll lock, set on <html> by the runtime while a screen-covering popup
   is open (see lockScroll in frontend.js). !important because themes routinely
   set overflow on html/body with high specificity, and a lock that silently
   loses that fight is worse than none — the backdrop would then dim a page
   that still scrolls under it. The padding fills the width the vanished
   scrollbar occupied, so the page doesn't jump sideways on open. */
html.up-scroll-lock,
html.up-scroll-lock body {
  overflow: hidden !important;
}
html.up-scroll-lock body {
  padding-right: var(--up-scrollbar-gap, 0px);
}

.up-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
}
.up-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

/* Video and hybrid layout */
.up-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--up-modal-max-width, min(960px, 92vw));
  max-height: min(90vh, 860px);
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

/* Video region keeps 16:9 area, then content scrolls below */
.up-modal__frame {
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  background: #000;
}
.up-modal__frame,
.up-modal__frame iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

/* Content placed under the video when in YouTube or Vimeo mode */
.up-video-after {
  flex: 1 1 auto;
  overflow: auto;
  background: #fff;
  color: #111;
}

/* Pure HTML mode wrapper */
.up-content-wrap {
  background: #fff;
  color: #111;
  width: 100%;
  max-width: var(--up-modal-max-width, min(960px, 92vw));
  max-height: min(86vh, 720px);
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.up-content__inner {
  overflow: auto;
  max-height: calc(min(86vh, 720px) - 48px);
  padding: 16px;
}

/* Close button floats above both regions */
.up-modal__close {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 34px;
  line-height: 1;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 10;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Popup Style Variants
   ========================================================================== */

/* ── Theater ── */
.up-style-theater .up-modal__dialog {
  width: var(--up-theater-max-width, 90%);
  max-width: var(--up-theater-max-width, 90%);
  height: var(--up-theater-max-height, 90vh);
  max-height: var(--up-theater-max-height, 90vh);
  border-radius: 8px;
}
.up-style-theater .up-modal__frame {
  flex: 1 1 auto;
  aspect-ratio: auto;
}
.up-style-theater .up-content-wrap {
  width: var(--up-theater-max-width, 90%);
  max-width: var(--up-theater-max-width, 90%);
  height: var(--up-theater-max-height, 90vh);
  max-height: var(--up-theater-max-height, 90vh);
  border-radius: 8px;
}
.up-style-theater .up-content__inner {
  max-height: calc(var(--up-theater-max-height, 90vh) - 48px);
}

/* ── Fullscreen takeover ── */
/* Self-anchoring: the inline shortcode thumbnail grows (FLIP transform) to fill
   the viewport when it scrolls into view, and shrinks back when scrolled past.
   The grow/shrink + backdrop fade are driven by JS (transform / opacity). */
.up-style-fullscreen .up-modal__backdrop {
  background: #000; /* fully opaque — nothing behind it shows through */
  will-change: opacity;
}
.up-style-fullscreen .up-modal__dialog,
.up-style-fullscreen .up-content-wrap {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  top: 0;
  transform: none;
  border-radius: 0;
  background: #000;
  will-change: transform;
}
.up-style-fullscreen .up-modal__dialog {
  justify-content: center; /* center the letterboxed video on the cover */
}
/* Video: largest 16:9 box that fits the viewport (contain / letterboxed). */
.up-style-fullscreen .up-modal__frame {
  flex: 0 0 auto;
  aspect-ratio: 16 / 9;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  margin: 0 auto;
}
.up-style-fullscreen .up-video-after {
  flex: 0 0 auto;
  max-height: 28vh;
}
.up-style-fullscreen .up-content__inner {
  max-height: calc(100vh - 48px);
}

/* ── Drawer (right) ── */
.up-style-drawer-right .up-modal__dialog,
.up-style-drawer-right .up-content-wrap {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(480px, 90vw);
  max-height: 100vh;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  transform: translateX(100%);
  animation: up-slide-left .3s ease forwards;
}
.up-style-drawer-right .up-content__inner {
  max-height: calc(100vh - 48px);
}
.up-style-drawer-right .up-modal__frame {
  aspect-ratio: auto;
  max-height: 50vh;
}

/* ── Drawer (left) ── */
.up-style-drawer-left .up-modal__dialog,
.up-style-drawer-left .up-content-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  bottom: 0;
  width: min(480px, 90vw);
  max-height: 100vh;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  transform: translateX(-100%);
  animation: up-slide-right .3s ease forwards;
}
.up-style-drawer-left .up-content__inner {
  max-height: calc(100vh - 48px);
}
.up-style-drawer-left .up-modal__frame {
  aspect-ratio: auto;
  max-height: 50vh;
}

/* ── Drawer (bottom) ── */
.up-style-drawer-bottom .up-modal__dialog,
.up-style-drawer-bottom .up-content-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: auto;
  width: 100%;
  max-height: 80vh;
  height: auto;
  margin: 0;
  border-radius: 12px 12px 0 0;
  transform: translateY(100%);
  animation: up-slide-up .3s ease forwards;
}
.up-style-drawer-bottom .up-content__inner {
  max-height: calc(80vh - 48px);
}

/* ── Fly-in (shared) ──
   No backdrop overlay, page stays interactive behind the popup.
   Must reset every base property from .up-modal, .up-content-wrap, .up-modal__dialog. */
.up-modal.up-style-flyin-bottom,
.up-modal.up-style-flyin-bottom-left,
.up-modal.up-style-flyin-bottom-right {
  pointer-events: none;
  background: transparent;
}
.up-modal.up-style-flyin-bottom > .up-modal__backdrop,
.up-modal.up-style-flyin-bottom-left > .up-modal__backdrop,
.up-modal.up-style-flyin-bottom-right > .up-modal__backdrop {
  display: none;
}
.up-modal.up-style-flyin-bottom .up-modal__dialog,
.up-modal.up-style-flyin-bottom .up-content-wrap,
.up-modal.up-style-flyin-bottom-left .up-modal__dialog,
.up-modal.up-style-flyin-bottom-left .up-content-wrap,
.up-modal.up-style-flyin-bottom-right .up-modal__dialog,
.up-modal.up-style-flyin-bottom-right .up-content-wrap {
  position: fixed;
  top: auto;
  bottom: 20px;
  width: var(--up-flyin-max-width, 400px);
  max-width: min(var(--up-flyin-max-width, 400px), calc(100vw - 40px));
  max-height: 80vh;
  height: auto;
  margin: 0;
  transform: translateY(calc(100% + 40px));
  animation: up-flyin-up .35s cubic-bezier(.22, .61, .36, 1) forwards;
  pointer-events: auto;
}
/* Video dialog keeps the card chrome (rounded, shadowed) + dark player bg */
.up-modal.up-style-flyin-bottom .up-modal__dialog,
.up-modal.up-style-flyin-bottom-left .up-modal__dialog,
.up-modal.up-style-flyin-bottom-right .up-modal__dialog {
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
}
/* HTML container: an empty, unstyled div — the content decides its own look.
   No bg, no padding, no border-radius, no shadow. overflow visible so the
   close button can hang off the corner. */
.up-modal.up-style-flyin-bottom .up-content-wrap,
.up-modal.up-style-flyin-bottom-left .up-content-wrap,
.up-modal.up-style-flyin-bottom-right .up-content-wrap {
  background: transparent;
  color: inherit;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* ── Fly-in (bottom center) ── */
.up-modal.up-style-flyin-bottom .up-modal__dialog,
.up-modal.up-style-flyin-bottom .up-content-wrap {
  left: 50%;
  right: auto;
  transform: translate(-50%, calc(100% + 40px));
  animation: up-flyin-up-center .35s cubic-bezier(.22, .61, .36, 1) forwards;
}

/* ── Fly-in (bottom left) ── */
.up-modal.up-style-flyin-bottom-left .up-modal__dialog,
.up-modal.up-style-flyin-bottom-left .up-content-wrap {
  left: 20px;
  right: auto;
}

/* ── Fly-in (bottom right) ── */
.up-modal.up-style-flyin-bottom-right .up-modal__dialog,
.up-modal.up-style-flyin-bottom-right .up-content-wrap {
  right: 20px;
  left: auto;
}

.up-modal.up-style-flyin-bottom .up-modal__frame,
.up-modal.up-style-flyin-bottom-left .up-modal__frame,
.up-modal.up-style-flyin-bottom-right .up-modal__frame {
  aspect-ratio: auto;
  max-height: 40vh;
}

.up-modal.up-style-flyin-bottom .up-content__inner,
.up-modal.up-style-flyin-bottom-left .up-content__inner,
.up-modal.up-style-flyin-bottom-right .up-content__inner {
  max-height: calc(80vh - 48px);
  padding: 0;
}

/* Fly-in close button: a circle that hangs on the top-right corner of the
   content — absolutely positioned, nudged 50% out on both axes, locked to a
   1:1 aspect ratio, fully rounded, with its own default background. */
.up-modal.up-style-flyin-bottom .up-content-wrap .up-modal__close,
.up-modal.up-style-flyin-bottom-left .up-content-wrap .up-modal__close,
.up-modal.up-style-flyin-bottom-right .up-content-wrap .up-modal__close {
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 30px;
  height: auto;
  aspect-ratio: 1 / 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  background: #111;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-shadow: none;
}

/* ── Animations ── */
@keyframes up-slide-left {
  to { transform: translateX(0); }
}
@keyframes up-slide-right {
  to { transform: translateX(0); }
}
@keyframes up-slide-up {
  to { transform: translateY(0); }
}
@keyframes up-flyin-up {
  to { transform: translateY(0); }
}
@keyframes up-flyin-up-center {
  to { transform: translate(-50%, 0); }
}

/* ==========================================================================
   Video Card (shortcode-rendered clickable card)
   ========================================================================== */

.up-video-card {
  /* Theme colors - Dark (default) */
  --up-bg: transparent;
  --up-bg-hover: transparent;
  --up-text: #f1f5f9;
  --up-text-muted: #94a3b8;
  --up-border: #334155;
  --up-play-bg: rgba(255, 255, 255, 0.9);
  --up-play-color: #0f172a;

  display: inline-block;
  width: 100%;
  cursor: pointer;
  border-radius: var(--up-card-radius, 12px);
  overflow: hidden;
  background: transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Theme: Light */
.up-theme-light .up-video-card,
.up-theme-light.up-video-card {
  --up-play-bg: rgba(15, 23, 42, 0.85);
  --up-play-color: #ffffff;
}

/* Theme: Auto */
@media (prefers-color-scheme: light) {
  .up-theme-auto .up-video-card,
  .up-theme-auto.up-video-card {
    --up-play-bg: rgba(15, 23, 42, 0.85);
    --up-play-color: #ffffff;
  }
}

.up-video-card:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

.up-video-card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: var(--up-card-ratio, 16 / 9);
  background-size: cover;
  background-position: center;
  background-color: #1e293b;
  overflow: hidden;
  border-radius: var(--up-card-radius, 12px);
}

.up-video-card__play {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.up-video-card:hover .up-video-card__play,
.up-video-card:focus .up-video-card__play {
  opacity: 1;
  transform: scale(1.1);
}

.up-video-card__play svg {
  width: 20%;
  max-width: 150px;
  height: auto;
  color: var(--up-play-bg);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.up-video-card__meta {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: none;
}

/* Position variants */
.up-meta-bottom-left   { bottom: 0; left: 0; right: 0; text-align: left; }
.up-meta-bottom-center { bottom: 0; left: 0; right: 0; text-align: center; }
.up-meta-bottom-right  { bottom: 0; left: 0; right: 0; text-align: right; }
.up-meta-top-left      { top: 0; left: 0; right: 0; text-align: left; background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%); }
.up-meta-top-center    { top: 0; left: 0; right: 0; text-align: center; background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%); }
.up-meta-top-right     { top: 0; left: 0; right: 0; text-align: right; background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%); }
.up-meta-center        { position: static; text-align: center; background: none; max-width: 80%; margin-top: 6px; }

.up-video-card__title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.up-video-card__channel {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.up-video-card__duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Hover Effects
   ========================================================================== */

/* Hover: Lift */
.up-hover-lift.up-video-card:hover,
.up-hover-lift.up-video-card:focus {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  outline: none;
}

/* Hover: Zoom */
.up-hover-zoom .up-video-card__thumb {
  transition: transform 0.3s ease;
}

.up-hover-zoom.up-video-card:hover .up-video-card__thumb,
.up-hover-zoom.up-video-card:focus .up-video-card__thumb {
  transform: scale(1.05);
}

/* Hover: Glow */
.up-hover-glow.up-video-card:hover,
.up-hover-glow.up-video-card:focus {
  box-shadow: 0 0 0 3px var(--up-border), 0 8px 25px rgba(0, 0, 0, 0.3);
  outline: none;
}

/* Hover: None */
.up-hover-none.up-video-card:hover,
.up-hover-none.up-video-card:focus {
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   Play Button Styles
   ========================================================================== */

/* Play style: Circle (default) */
.up-play-circle .up-video-card__play svg {
  color: var(--up-play-bg);
}

/* Play style: YouTube */
.up-play-youtube .up-video-card__play svg {
  width: 18%;
  max-width: 136px;
  height: auto;
}

/* Play style: Minimal */
.up-play-minimal .up-video-card__play svg {
  width: 16%;
  max-width: 120px;
  height: auto;
  color: rgba(255, 255, 255, 0.95);
}

/* Play style: Square */
.up-play-square .up-video-card__play svg {
  width: 16%;
  max-width: 120px;
  height: auto;
  color: var(--up-play-bg);
}

/* ==========================================================================
   Tile Styles
   ========================================================================== */

/* Style: Card (default) - base styles above */

/* Style: Minimal — no gradient on meta overlay */
.up-tiles-minimal .up-video-card__meta {
  background: none;
}

/* Style: Overlay — heavier gradient */
.up-tiles-overlay .up-video-card__meta.up-meta-bottom-left,
.up-tiles-overlay .up-video-card__meta.up-meta-bottom-center,
.up-tiles-overlay .up-video-card__meta.up-meta-bottom-right {
  padding-top: 40px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
}

/* Style: Cinematic */
.up-tiles-cinematic.up-video-card {
  background: #000;
}

/* Style: Row — thumbnail left, title and subtitle right. Colours come from the
   surrounding page unless the site sets the --up-row-* variables. */
.up-tiles-row.up-video-card {
  display: grid;
  grid-template-columns: var(--up-row-thumb, 40%) minmax(0, 1fr);
  gap: var(--up-row-gap, 16px);
  align-items: center;
  padding: var(--up-row-padding, 0);
  background: var(--up-row-bg, transparent);
  border: var(--up-row-border, 0);
  color: var(--up-row-text, inherit);
  font-family: inherit;
  text-align: left;
}
.up-tiles-row .up-video-card__play svg {
  width: 30%;
}
.up-video-card__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.up-tiles-row .up-video-card__title {
  color: inherit;
  font-size: var(--up-row-title-size, 16px);
  font-weight: 600;
  line-height: 1.3;
  text-shadow: none;
  -webkit-line-clamp: 3;
}
.up-video-card__subtitle {
  color: var(--up-row-muted, inherit);
  font-size: var(--up-row-subtitle-size, 13px);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* "When the video ends" = fade out and close (frontend.js fadeOutAndClose). */
.up-modal.up-modal--ending {
  opacity: 0;
  transition: opacity var(--up-end-fade, 600ms) ease;
}

/* Entrance effect (frontend.js revealModal / closeModal). The modal starts in
   .up-modal--pre and transitions out of it; closing transitions back. Uses the
   individual scale/translate properties so the dialog's centring transform
   (translateY(-50%)) is left alone. */
.up-modal[class*="up-enter-"] .up-modal__backdrop,
.up-modal[class*="up-enter-"] .up-modal__dialog,
.up-modal[class*="up-enter-"] .up-content-wrap {
  transition: opacity .32s ease, scale .32s cubic-bezier(.22, .61, .36, 1), translate .32s cubic-bezier(.22, .61, .36, 1);
}
.up-modal[class*="up-enter-"].up-modal--pre .up-modal__backdrop,
.up-modal[class*="up-enter-"].up-modal--pre .up-modal__dialog,
.up-modal[class*="up-enter-"].up-modal--pre .up-content-wrap {
  opacity: 0;
}
.up-modal.up-enter-zoom.up-modal--pre .up-modal__dialog,
.up-modal.up-enter-zoom.up-modal--pre .up-content-wrap {
  scale: .94;
}
.up-modal.up-enter-slide-up.up-modal--pre .up-modal__dialog,
.up-modal.up-enter-slide-up.up-modal--pre .up-content-wrap {
  translate: 0 28px;
}
@media (prefers-reduced-motion: reduce) {
  .up-modal[class*="up-enter-"] .up-modal__backdrop,
  .up-modal[class*="up-enter-"] .up-modal__dialog,
  .up-modal[class*="up-enter-"] .up-content-wrap {
    transition: none;
  }
}
