/* The lesson preview in a modal. Same look as the virtual whiteboard modal in
   the classroom (classroom/templates/classroom/modals/whiteboard.html and
   core/static/css/tasks/pdf-viewer-modal.css): a large card with a compact
   header and a close button. Those rules hang on #whiteboardModal and the app
   stylesheet that carries them is not loaded on the public pages, so the
   same values live here. */

#lessonPreviewModal {
    z-index: 1060;
    --wb-safe-top: env(safe-area-inset-top, 0px);
    --wb-safe-right: env(safe-area-inset-right, 0px);
    --wb-safe-bottom: env(safe-area-inset-bottom, 0px);
    --wb-safe-left: env(safe-area-inset-left, 0px);
}

#lessonPreviewModal .modal-dialog {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: none;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100vw;
    width: 100dvw;
    padding:
        max(8px, var(--wb-safe-top))
        max(8px, var(--wb-safe-right))
        max(8px, var(--wb-safe-bottom))
        max(8px, var(--wb-safe-left));
}

#lessonPreviewModal .modal-content {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    width: min(calc(100dvw - (var(--wb-safe-left) + var(--wb-safe-right) + 16px)), 1400px);
    max-width: calc(100dvw - (var(--wb-safe-left) + var(--wb-safe-right) + 16px));
    height: min(calc(100dvh - (var(--wb-safe-top) + var(--wb-safe-bottom) + 16px)), 900px);
    max-height: calc(100dvh - (var(--wb-safe-top) + var(--wb-safe-bottom) + 16px));
    transform: translate3d(0, 0, 0);
}

#lessonPreviewModal .modal-header {
    height: 48px;
    padding: 4px 16px;
    align-items: center;
    justify-content: space-between;
}

#lessonPreviewModal .modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

#lessonPreviewModal .lesson-preview-modal__close {
    width: 28px;
    height: 28px;
    border: 1px solid var(--fc-color-palette-d6e1ef);
    border-radius: 8px;
    background: var(--fc-color-surface);
    color: var(--fc-color-palette-334155);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

#lessonPreviewModal .lesson-preview-modal__close:hover {
    background: var(--fc-color-surface-soft);
}

/* The public shell styles every .modal-body with side padding through
   `.modal:not(#whiteboardModal) .modal-body`; that selector carries an extra
   class and wins over #lessonPreviewModal .modal-body. Keep the iframe flush
   with the card on every breakpoint. */
#lessonPreviewModal.modal .modal-content > .modal-body {
    height: calc(100% - 48px);
    padding: 0;
}

#lessonPreviewModal iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--fc-color-surface);
}

@media (min-width: 992px) {
    #lessonPreviewModal .modal-content {
        width: min(80vw, 1600px);
        height: min(calc(100dvh - (var(--wb-safe-top) + var(--wb-safe-bottom) + 16px)), 980px);
    }
}

@media (max-width: 768px) {
    #lessonPreviewModal .modal-dialog {
        padding:
            max(4px, var(--wb-safe-top))
            max(4px, var(--wb-safe-right))
            max(4px, var(--wb-safe-bottom))
            max(4px, var(--wb-safe-left));
    }

    #lessonPreviewModal .modal-content {
        width: calc(100dvw - (var(--wb-safe-left) + var(--wb-safe-right) + 8px));
        max-width: calc(100dvw - (var(--wb-safe-left) + var(--wb-safe-right) + 8px));
        height: calc(100dvh - (var(--wb-safe-top) + var(--wb-safe-bottom) + 8px));
        max-height: calc(100dvh - (var(--wb-safe-top) + var(--wb-safe-bottom) + 8px));
        border-radius: 14px;
    }
}
