@charset "UTF-8";

/*
 * ts-lms-media.css
 * Shared LMS media grids, rich images and lightboxes.
 * Split from ts-lms-components.css in P15.183.
 */

.ts-media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.ts-media-item {
    margin: 0;
}

.ts-media-thumb {
    display: block;
    width: auto;
    max-width: 180px;
    padding: var(--spacing-xs);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-bg-card);
    cursor: zoom-in;
}

.ts-media-thumb img {
    display: block;
    width: auto;
    max-width: 170px;
    max-height: 120px;
    height: auto;
    border-radius: var(--radius-input);
    object-fit: contain;
}

.ts-rich-content img.ts-rich-image {
    display: block;
    max-width: 100%;
    max-height: 260px;
    height: auto;
    margin: var(--spacing-sm) 0;
    border-radius: var(--radius-card);
    object-fit: contain;
    cursor: zoom-in;
}

.test-question-images,
.test-explanation-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.test-question-images__item,
.test-explanation-images__item {
    overflow: hidden;
    margin: 0;
    padding: var(--spacing-xs);
    border: 1px solid color-mix(in srgb, var(--color-border) 86%, #ffffff 14%);
    border-radius: var(--radius-card-sm, 12px);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-soft, 0 1px 2px rgba(15, 23, 42, 0.04));
}

.test-question-images__item img,
.test-explanation-images__item img {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 440px;
    height: auto;
    border-radius: 12px;
    background: color-mix(in srgb, var(--color-bg-subtle) 82%, #ffffff 18%);
    object-fit: contain;
}

.test-question-images__item figcaption,
.test-explanation-images__item figcaption {
    margin-top: 6px;
    padding-inline: var(--spacing-xs);
    color: var(--color-text-secondary, #64748b);
    font-size: 0.9rem;
    line-height: 1.35;
    text-align: center;
}

.test-media-zoom {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.test-media-zoom img {
    pointer-events: none;
}

.ts-rich-content img,
.ts-explanation-html img,
.ts-rich-image,
.ts-runner-rich-content img,
#explanation-block img.ts-rich-image,
#learning-explanation img.ts-rich-image,
.explanation-content img.ts-rich-image {
    max-width: 100% !important;
    max-height: 320px !important;
    height: auto !important;
    object-fit: contain;
    cursor: zoom-in;
}

.ts-favorites-modal .ts-rich-content img,
.ts-favorites-modal .test-explanation-images__item img,
.ts-favorites-modal .test-question-images__item img {
    max-width: 100%;
    max-height: none;
    height: auto;
    object-fit: contain;
}

#explanation-block .test-explanation-images,
#learning-explanation .test-explanation-images {
    display: block;
    margin-top: 16px;
}

#explanation-block .test-explanation-images__item,
#learning-explanation .test-explanation-images__item {
    overflow: visible;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

#explanation-block .test-explanation-images__item .test-media-zoom,
#learning-explanation .test-explanation-images__item .test-media-zoom {
    width: auto;
    max-width: 100%;
    margin: 0;
    background: transparent;
    box-shadow: none;
}

#explanation-block .test-explanation-images__item img,
#learning-explanation .test-explanation-images__item img {
    width: auto;
    max-width: 100%;
    max-height: 520px;
    margin: 0;
    background: transparent;
    box-shadow: none;
}

body.test-media-lightbox-open {
    overflow: hidden;
}

.test-media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.test-media-lightbox.is-open {
    display: flex;
}

.test-media-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-backdrop-strong, rgba(15, 23, 42, 0.86));
}

.test-media-lightbox__dialog {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: min(100%, 1180px);
    max-height: calc(100vh - 48px);
}

.test-media-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 120px);
    margin: 0 auto;
    border-radius: 12px;
    background: #ffffff;
    object-fit: contain;
    box-shadow: var(--shadow-media, 0 24px 64px rgba(0, 0, 0, 0.35));
}

.test-media-lightbox__close,
.test-media-lightbox__nav {
    border: 0;
    color: #ffffff;
    background: var(--color-backdrop-control, rgba(15, 23, 42, 0.72));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.test-media-lightbox__close {
    position: absolute;
    top: -18px;
    right: 0;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    font-size: 1.8rem;
    line-height: 1;
}

.test-media-lightbox__nav {
    width: 46px;
    height: 64px;
    border-radius: 999px;
    font-size: 2.5rem;
    line-height: 1;
}

.test-media-lightbox__caption {
    grid-column: 1 / -1;
    color: #e2e8f0;
    font-size: 0.95rem;
    text-align: center;
}

.test-media-lightbox__nav[hidden] {
    visibility: hidden;
    display: block !important;
}

.test-media-lightbox--favorites {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100vw;
    height: 100vh;
    padding: 24px;
}

.test-media-lightbox--favorites.is-open {
    display: flex;
}

.test-media-lightbox--favorites .test-media-lightbox__dialog {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
}

.test-media-lightbox--favorites img,
.test-media-lightbox--favorites .test-media-lightbox__image {
    display: block;
    width: auto;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    height: auto;
    margin: auto;
    object-fit: contain;
}

.learning-article-reader-lightbox {
    position: absolute;
    inset: 0;
    z-index: 1090;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2.5rem);
    background: var(--color-backdrop-strong, rgba(15, 23, 42, 0.88));
}

.learning-article-reader-lightbox.is-open {
    display: flex;
}

body.learning-article-reader-lightbox-open {
    overflow: hidden;
}

.learning-article-reader-lightbox__figure {
    max-width: min(1120px, 96vw);
    max-height: 90vh;
    margin: 0;
    text-align: center;
}

.learning-article-reader-lightbox__image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 84vh;
    height: auto;
    margin: 0 auto;
    border-radius: 18px;
    box-shadow: var(--shadow-media-large, 0 24px 70px rgba(0, 0, 0, 0.35));
}

.learning-article-reader-lightbox__caption {
    margin-top: 0.75rem;
    color: #e5e7eb;
    font-size: 0.95rem;
}

.learning-article-reader-lightbox__close {
    position: absolute;
    top: max(0.8rem, env(safe-area-inset-top));
    right: max(0.8rem, env(safe-area-inset-right));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 999px;
    background: var(--color-backdrop-soft, rgba(15, 23, 42, 0.62));
    color: #ffffff;
    font-size: 1.4rem;
    cursor: pointer;
}

.learning-article-reader-lightbox__close:hover,
.learning-article-reader-lightbox__close:focus {
    background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 576px) {
    .ts-media-thumb,
    .ts-media-thumb img {
        max-width: 100%;
    }

    .test-question-images,
    .test-explanation-images {
        grid-template-columns: 1fr;
    }

    .test-media-lightbox {
        padding: 12px;
    }

    .test-media-lightbox__dialog {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .test-media-lightbox__nav {
        display: none !important;
    }

    .test-media-lightbox__image {
        max-height: calc(100vh - 96px);
    }
}
