/* Scoped lesson posters: preserve every part of the source image. */
body .ns-lesson-poster {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background: #0b1727;
    border-radius: 12px;
    overflow: hidden;
}
body .ns-lesson-poster[data-video-orientation="1"] {
    aspect-ratio: 9 / 16;
    width: min(100%, 300px, calc((100svh - 160px) * .5625));
    margin-inline: auto;
}
body .ns-lesson-poster.varea > img,
body .ns-lesson-poster.blk-img > img,
body .ns-lesson-poster > img.file-img,
body .ns-lesson-poster > img.file-img-big {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}
body .ns-lesson-poster.varea > a {
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    display: block;
    width: 64px;
    height: 64px;
}
body .ns-lesson-poster.varea > a img {
    width: 100%;
    height: 100%;
}
body .ns-lesson-thumb {
    flex: 0 0 auto;
    width: 140px;
    max-width: 30%;
    aspect-ratio: 16 / 9;
    background: #0b1727;
    border-radius: 12px;
    overflow: hidden;
}
body .ns-lesson-thumb[data-video-orientation="1"] {
    width: 78px;
    aspect-ratio: 9 / 16;
}
body .ns-lesson-thumb img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}
body .ns-lesson-poster.file-img-big-container,
body .ns-lesson-poster.file-img-container { height: auto; }
.ns-video-orientation-editor { display: grid; gap: 6px; margin: 12px 0; direction: rtl; }
.ns-video-orientation-editor select {
    width: min(100%, 320px);
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px;
    min-height: 44px;
    border: 1px solid #cad5e2;
    border-radius: 7px;
    background: #fff;
    font-size: 14px;
    appearance: auto;
}
.ns-video-orientation-editor small { color: #46566a; }
body #grid-container.ns-lesson-grid {
    width: 100%;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
    align-items: start;
}
body .ns-lesson-grid .ns-lesson-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    max-width: none;
    max-height: none;
    height: auto;
    aspect-ratio: auto;
}
body .ns-lesson-grid .ns-lesson-poster { flex-shrink: 0; }
body .ns-lesson-grid .file-img-big { filter: none; }
body.ns-admin .ns-lesson-editor {
    position: static;
    width: 100%;
    max-width: none;
    padding: 20px;
}
body .ns-lesson-editor .part-container,
body .ns-lesson-editor .files-container {
    min-width: 0;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
}
body .ns-lesson-editor .files-container { padding: 0; }
body .ns-lesson-editor #app { width: 100%; max-width: 100%; margin: 0; }
body .ns-lesson-editor .filters-container,
body .ns-lesson-editor .filters-elements {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}
body .ns-lesson-editor .filters-elements .v-input { flex: 1 1 140px; }
body .ns-lesson-grid .file-txt,
body .ns-lesson-grid .file-txt-small { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 600px) {
    body .ns-lesson-grid .grid-item-big { grid-column: 1 / -1; }
    body.ns-admin .ns-lesson-editor { padding: 8px; }
    body .ns-lesson-editor .elements-line { flex-wrap: wrap; }
    body .ns-lesson-editor .full-element { width: 100% !important; }
    body .ns-lesson-grid .line,
    body .ns-lesson-grid .select-heb-date { flex-wrap: wrap; }
}

/* Override the old fixed 16:9 iframe shell only while this player is open. */
#video-popup-container.ns-media-dialog {
    --ns-ratio: 1.7777777778;
    position: fixed;
    z-index: 10051;
    left: 50%;
    top: 50%;
    margin: 0;
    transform: translate(-50%, -50%);
    width: min(1000px, calc(100vw - 32px), calc((100dvh - 96px) * var(--ns-ratio)));
    aspect-ratio: var(--ns-ratio);
    background: #000;
}
#video-popup-iframe-container.ns-media-frame {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
}
#video-popup-container.ns-media-dialog iframe,
#video-popup-container.ns-media-dialog video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: contain;
    background: #000;
}
#video-popup-container.ns-media-dialog [hidden] { display: none; }
#video-popup-container.ns-media-dialog #video-popup-close {
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    border: 0;
}
#video-popup-overlay.ns-media-overlay { z-index: 10050; left: 0; height: 100dvh; }
#video-popup-container.ns-media-dialog[data-media-kind="youtube"] {
    min-width: 200px;
    min-height: 200px;
    max-height: calc(100dvh - 96px);
}
@media (max-height: 450px) and (min-width: 600px) {
    #video-popup-container.ns-media-dialog[data-media-kind] {
        width: min(1000px, calc(100vw - 128px), calc((100dvh - 32px) * var(--ns-ratio)));
        max-height: calc(100dvh - 32px);
    }
    #video-popup-container.ns-media-dialog #video-popup-close { top: 0; right: -44px; }
}
@media (max-width: 600px) {
    body .ns-lesson-thumb { width: 96px; }
    body .ns-lesson-thumb[data-video-orientation="1"] { width: 64px; }
}
