/*
 * MCMS2 YouTube widget [youtube]. Themes adjust it with these variables on .mcms-yt:
 *   --mcms-yt-accent   play button background on hover, focus ring   (default: #fff)
 *   --mcms-yt-radius   corner rounding of the player / thumbnail
 */
.mcms-yt { --mcms-yt-accent: #fff; --mcms-yt-radius: 6px; margin: 1.8em auto; max-width: 100%; }
.mcms-yt-large { max-width: 800px; }
.mcms-yt-medium { max-width: 560px; }
.mcms-yt-small { max-width: 360px; }
.mcms-yt figcaption { margin-top: .5em; font-size: .9em; text-align: center; opacity: .8; }

/* player in the page */
.mcms-yt-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--mcms-yt-radius); overflow: hidden; background: #000; }
.mcms-yt-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* thumbnail */
.mcms-yt-thumb {
    position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--mcms-yt-radius);
    background: #000; color: #fff !important; text-decoration: none !important; border: 0 !important;
}
.mcms-yt-thumb img {                       /* object-fit crops the black bars of 4:3 YouTube pictures */
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; margin: 0 !important; max-width: none;
    transition: transform .4s ease, filter .3s;
}
.mcms-yt-thumb::after {                    /* gentle shade so the button stands out on any picture */
    content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, .28), rgba(0, 0, 0, .05) 60%);
    transition: opacity .3s;
}
.mcms-yt-play {
    position: absolute; z-index: 1; top: 50%; left: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%;
    background: rgba(12, 10, 8, .62); color: #fff; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .75), 0 8px 26px rgba(0, 0, 0, .45);
    transition: transform .2s, background-color .2s, color .2s;
}
.mcms-yt-play svg { margin-left: 3px; }
.mcms-yt-thumb:hover img, .mcms-yt-thumb:focus-visible img { transform: scale(1.03); filter: brightness(1.05); }
.mcms-yt-thumb:hover .mcms-yt-play, .mcms-yt-thumb:focus-visible .mcms-yt-play { transform: scale(1.08); background: var(--mcms-yt-accent); color: #111; }
.mcms-yt-thumb:focus-visible { outline: 2px solid var(--mcms-yt-accent); outline-offset: 3px; }
.mcms-yt-badge {
    position: absolute; z-index: 1; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 3px; background: rgba(0, 0, 0, .7); color: #fff; font: 600 12px/1.4 system-ui, sans-serif; letter-spacing: .02em;
}
.mcms-yt-small .mcms-yt-play { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
@media (prefers-reduced-motion: reduce) { .mcms-yt-thumb img, .mcms-yt-play { transition: none; } }

/* playback window (mode=modal) */
html.mcms-yt-lock { overflow: hidden; }
.mcms-yt-window {
    position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 56px 20px 28px; background: rgba(0, 0, 0, .9); opacity: 0; transition: opacity .2s;
}
.mcms-yt-window.is-open { opacity: 1; }
.mcms-yt-window-box { position: relative; width: min(100%, calc((100vh - 120px) * 16 / 9), 1280px); aspect-ratio: 16 / 9; background: #000; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.mcms-yt-window-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mcms-yt-window-title { margin: 14px 0 0; max-width: min(100%, 1280px); color: rgba(255, 255, 255, .85); font: 15px/1.4 system-ui, sans-serif; text-align: center; }
.mcms-yt-window-title:empty { display: none; }
.mcms-yt-close {
    position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer;
}
.mcms-yt-close:hover, .mcms-yt-close:focus-visible { background: rgba(255, 255, 255, .24); outline: none; }
