/* ============================================================
   CMS GLOBAL VIDEO MODAL  (video-modal.css)

   HOW TO TRIGGER from any layout or element:
     Add these data attributes to any clickable element:
       data-video-modal="<video_url>"
       data-video-type="instagram|youtube|vimeo|facebook|selfhosted"  ← optional, auto-detected if omitted

   Example:
     <button data-video-modal="https://www.instagram.com/reel/ABC123/"
             data-video-type="instagram">Play</button>

   Or from JavaScript:
     window.CmsVideoModal.open('https://youtu.be/VIDEO_ID', 'youtube');
     window.CmsVideoModal.close();

   Video type behaviour:
     instagram   → portrait modal (9:16) -- embedded via Instagram embed URL
     youtube     → landscape modal (16:9) -- embedded via YouTube embed URL with autoplay
     vimeo       → landscape modal (16:9) -- embedded via Vimeo embed URL with autoplay
     facebook    → landscape modal (16:9) -- embedded via Facebook video plugin
     selfhosted  → landscape modal (16:9) -- HTML <video> element with controls
     (empty)     → auto-detected from URL pattern
   ============================================================ */

#cms-video-modal {
  position:        fixed;
  inset:           0;
  z-index:         9999;
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         24px;
  background:      rgba(0, 0, 0, 0);
  opacity:         0;
  pointer-events:  none;
  overflow:        hidden;
  transition:      background .3s ease, opacity .3s ease;
}

#cms-video-modal.is-open {
  background:              rgba(0, 0, 0, .45);
  opacity:                 1;
  pointer-events:          all;
  backdrop-filter:         blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Portrait window -- suits Instagram Reels (9:16) */
#cms-video-modal__window {
  position:      relative;
  width:         auto;
  height:        calc(100vh - 48px);
  max-height:    calc(100vh - 48px);
  aspect-ratio:  9 / 16;
  max-width:     calc((100vh - 48px) * 9 / 16);
  background:    #000;
  border-radius: 16px;
  overflow:      hidden;
  box-shadow:    0 32px 80px rgba(0, 0, 0, .9);
  transform:     scale(.92);
  transition:    transform .3s cubic-bezier(.25, .46, .45, .94);
  flex-shrink:   0;
}

/* Wide/landscape -- YouTube, Vimeo, Facebook, self-hosted (16:9) */
#cms-video-modal__window.--wide {
  aspect-ratio: 16 / 9;
  height:       auto;
  width:        min(90vw, 960px);
  max-width:    min(90vw, 960px);
  max-height:   calc(100vh - 48px);
}

#cms-video-modal.is-open #cms-video-modal__window {
  transform: scale(1);
}

#cms-video-modal__window iframe,
#cms-video-modal__window video {
  position: absolute;
  inset:    0;
  width:    100%;
  height:   100%;
  display:  block;
  border:   none;
}

#cms-video-modal__close {
  position:        absolute;
  top:             12px;
  right:           12px;
  z-index:         10;
  width:           36px;
  height:          36px;
  border-radius:   50%;
  background:      rgba(0, 0, 0, .75);
  border:          1px solid rgba(255, 255, 255, .3);
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         0;
  transition:      background .2s, transform .2s;
}

#cms-video-modal__close:hover {
  background:  rgba(0, 0, 0, .95);
  transform:   scale(1.1);
}

#cms-video-modal__close svg {
  width:          16px;
  height:         16px;
  fill:           #ffffff;
  pointer-events: none;
}
