/*
 * CADI video player: thumbnail ("facade") + modal window player with subtitle menu.
 * Loaded on every layout; see public/js/cadi-video.js.
 */

/* ---------- Thumbnail that opens the player ---------- */
.cadi-yt { position: relative; border-radius: .9rem; overflow: hidden; background: #0f1720; box-shadow: 0 8px 24px rgba(16, 42, 67, .18); }
.cadi-yt-facade { all: unset; cursor: pointer; position: absolute; inset: 0; display: block; }
.cadi-yt-facade img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, filter .3s; }
.cadi-yt-facade::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .45) 0%, transparent 35%, transparent 65%, rgba(0, 0, 0, .35) 100%); }
.cadi-yt-facade:hover img { transform: scale(1.03); filter: brightness(.9); }
.cadi-yt-facade:focus-visible { outline: 3px solid var(--cadi-accent, #70B967); outline-offset: -3px; }
.cadi-yt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; transition: transform .2s; }
.cadi-yt-play-bg { fill: var(--cadi-primary, #1E6B8E); fill-opacity: .92; transition: fill .2s; }
.cadi-yt-facade:hover .cadi-yt-play { transform: translate(-50%, -50%) scale(1.08); }
.cadi-yt-facade:hover .cadi-yt-play-bg { fill: #f00; fill-opacity: 1; }
.cadi-yt-title { position: absolute; top: 0; left: 0; right: 0; z-index: 1; padding: .9rem 1.1rem; color: #fff; font-weight: 600; font-size: .95rem; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadi-yt-cc { position: absolute; right: .7rem; bottom: .7rem; z-index: 1; font: 700 .68rem/1 system-ui, sans-serif; letter-spacing: .04em; color: #fff; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .5); border-radius: .3rem; padding: .25rem .4rem; }

/* ---------- Modal window ---------- */
html.cadi-vm-open { overflow: hidden; }
.cadi-vm { padding: 0; border: 0; background: transparent; width: min(1120px, 94vw); max-width: none; max-height: none; overflow: visible; color: #fff; }
.cadi-vm::backdrop { background: rgba(8, 15, 24, .86); backdrop-filter: blur(3px); }
.cadi-vm[open] { animation: cadi-vm-in .2s ease-out; }
@keyframes cadi-vm-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cadi-vm[open] { animation: none; } }

.cadi-vm-frame { display: flex; flex-direction: column; background: #0b1118; border-radius: 1rem; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.cadi-vm-bar { display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem .55rem 1rem; background: #111a24; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.cadi-vm-title { flex: 1 1 auto; min-width: 0; font: 600 .95rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadi-vm-cc { display: inline-flex; align-items: center; gap: .4rem; flex-shrink: 0; font: 600 .78rem/1 system-ui, sans-serif; color: rgba(255, 255, 255, .8); }
.cadi-vm-cc-icon { font-size: .66rem; font-weight: 800; letter-spacing: .03em; border: 1.5px solid currentColor; border-radius: .25rem; padding: .15rem .3rem; }
.cadi-vm-cc select { appearance: auto; background: #1d2935; color: #fff; border: 1px solid rgba(255, 255, 255, .2); border-radius: .5rem; padding: .3rem .45rem; font: 500 .82rem system-ui, sans-serif; max-width: 13rem; cursor: pointer; }
.cadi-vm-cc select:disabled { opacity: .6; cursor: default; }
.cadi-vm-cc select:focus-visible, .cadi-vm-btn:focus-visible { outline: 2px solid var(--cadi-accent, #70B967); outline-offset: 2px; }
.cadi-vm-btn { all: unset; cursor: pointer; flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: .55rem; display: inline-flex; align-items: center; justify-content: center; color: #fff; transition: background-color .15s; }
.cadi-vm-btn:hover { background: rgba(255, 255, 255, .12); }
.cadi-vm-btn svg { width: 1.15rem; height: 1.15rem; }
.cadi-vm-stage { position: relative; aspect-ratio: 16 / 9; width: 100%; background: #000; }
.cadi-vm-stage > div, .cadi-vm-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cadi-vm-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cadi-vm-loading::after { content: ""; width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: cadi-vm-spin .8s linear infinite; }
@keyframes cadi-vm-spin { to { transform: rotate(360deg); } }

/* Full screen keeps the window (title bar, subtitles, close) and lets the video fill the rest.
   .is-expanded is the fallback where the browser refuses real full screen (e.g. iPhone). */
.cadi-vm-frame:fullscreen { border-radius: 0; width: 100vw; height: 100vh; }
.cadi-vm-frame:fullscreen .cadi-vm-stage { aspect-ratio: auto; flex: 1 1 auto; }
.cadi-vm.is-expanded { width: 100vw; height: 100dvh; margin: 0; inset: 0; }
.cadi-vm.is-expanded .cadi-vm-frame { border-radius: 0; height: 100%; }
.cadi-vm.is-expanded .cadi-vm-stage { aspect-ratio: auto; flex: 1 1 auto; }

@media (max-width: 575.98px) {
    .cadi-vm { width: 100vw; }
    .cadi-vm-frame { border-radius: 0; }
    .cadi-vm-bar { flex-wrap: wrap; padding: .5rem; }
    .cadi-vm-title { flex: 1 1 0; }
    .cadi-vm-cc { order: 3; flex-basis: 100%; } /* subtitle menu gets its own row under the title */
    .cadi-vm-cc select { max-width: none; flex: 1; }
}
