/* ─── TM Media Gallery ─── */

.tm-media-gallery {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 0.5rem;
}

.tm-media-gallery__title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #fff;
}

.tm-media-gallery__empty {
    text-align: center;
    color: #999;
    padding: 3rem 0;
}

/* ─── Grid ─── */

.tm-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ─── Item ─── */

.tm-media-item {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tm-media-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Image */

.tm-media-item__image-wrap {
    position: relative;
    cursor: pointer;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.tm-media-item__image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.tm-media-item__image-wrap:hover img {
    transform: scale(1.05);
}

.tm-media-item__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #fff;
}

.tm-media-item__image-wrap:hover .tm-media-item__overlay {
    opacity: 1;
}

/* Video thumbnail */

.tm-media-item__video-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.tm-media-item__video-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.tm-media-item__video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tm-media-item__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.tm-media-item__play svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.tm-media-item__video-thumb:hover .tm-media-item__play svg {
    transform: scale(1.1);
}

/* Caption */

.tm-media-item__caption {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ─── Lightbox ─── */

.tm-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.tm-lightbox.active {
    display: flex;
}

.tm-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.tm-lightbox__content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tm-lightbox__img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.tm-lightbox__iframe-wrap {
    width: 80vw;
    max-width: 900px;
    aspect-ratio: 16 / 9;
}

.tm-lightbox__iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 4px;
}

.tm-lightbox__close,
.tm-lightbox__prev,
.tm-lightbox__next {
    position: absolute;
    z-index: 2;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 2.5rem;
    line-height: 1;
    padding: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tm-lightbox__close:hover,
.tm-lightbox__prev:hover,
.tm-lightbox__next:hover {
    opacity: 1;
}

.tm-lightbox__close {
    top: 1rem;
    right: 1.5rem;
    font-size: 3rem;
}

.tm-lightbox__prev {
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3.5rem;
}

.tm-lightbox__next {
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3.5rem;
}

.tm-lightbox__caption {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    text-align: center;
    max-width: 80vw;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.tm-lightbox__caption:empty {
    display: none;
}

/* ─── Responsive ─── */

@media (max-width: 640px) {
    .tm-media-grid {
        grid-template-columns: 1fr;
    }

    .tm-media-gallery__title {
        font-size: 1.5rem;
    }

    .tm-lightbox__prev,
    .tm-lightbox__next {
        font-size: 2.5rem;
    }
}

/* ─── Pagination ─── */

.tm-media-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 2.5rem;
    padding: 1rem 0;
}

.tm-media-pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #333;
    transition: background 0.2s, border-color 0.2s;
}

.tm-media-pagination__link:hover {
    background: #444;
    border-color: var(--c-primary);
    color: #fff;
    text-decoration: none;
}

.tm-media-pagination__current {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
    font-weight: 600;
}

.tm-media-pagination__link .fa + .fa {
    margin-left: -4px;
}
