﻿/* Media container: image and video preview area */
.media-container,
.media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    justify-content: center;
    align-items: stretch;
    margin: 20px 0;
}

.btn-primary {
    background-color: #2f89ff;
}

/* Box layout */
.media-box {
    flex: 1 1 calc(50% - 22px);
    max-width: calc(50% - 11px);
}

.media-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 15px;
    border-radius: 12px;
    background: linear-gradient(150deg, rgba(10, 25, 50, 0.86), rgba(12, 33, 62, 0.76));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 28px rgba(1, 10, 24, 0.3);
}

.media-item {
    width: 100%;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
}

.media-item-video {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.media-puzzle-host {
    position: relative;
    isolation: isolate;
}

.media-puzzle-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(var(--puzzle-cols, 6), minmax(0, 1fr));
    grid-template-rows: repeat(var(--puzzle-rows, 4), minmax(0, 1fr));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.media-puzzle-overlay.is-animating {
    opacity: 1;
}

.media-puzzle-tile {
    position: relative;
    opacity: 0;
    transform: scale(0.34) rotate(-7deg);
    border: 1px solid rgba(143, 214, 255, 0.09);
    background:
        linear-gradient(140deg, rgba(102, 200, 255, 0.26), rgba(21, 70, 140, 0.1)),
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 65%);
    filter: hue-rotate(calc(var(--tile-hue, 0) * 1deg)) blur(0);
}

.media-puzzle-overlay.is-animating .media-puzzle-tile {
    animation-name: mediaPuzzleTileBurst;
    animation-duration: var(--tile-duration, 820ms);
    animation-timing-function: cubic-bezier(0.19, 0.74, 0.23, 1);
    animation-fill-mode: both;
    animation-delay: calc(var(--tile-order, 0) * var(--tile-stagger, 24ms));
}

@keyframes mediaPuzzleTileBurst {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-8deg);
    }
    22% {
        opacity: 0.9;
        transform: scale(1.02) rotate(0deg);
    }
    56% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.54) rotate(8deg);
    }
}

.media-empty-note {
    margin: 0;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px dashed rgba(153, 211, 255, 0.35);
    background: rgba(8, 24, 48, 0.62);
    color: #d8e7f9;
    font-size: 0.93rem;
    line-height: 1.45;
}

.media-video-shell {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(160, 212, 255, 0.24);
    background: rgba(5, 16, 34, 0.9);
    cursor: default;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.media-video-inline {
    pointer-events: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.media-video-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to top, rgba(2, 9, 20, 0.42), rgba(2, 9, 20, 0.02) 45%);
}

.media-video-play {
    display: none !important;
}

.media-video-shell.is-playing .media-video-play {
    opacity: 0;
    pointer-events: none;
}

.media-video-shell:hover .media-video-play {
    transform: none;
    background: transparent;
}

.media-video-controls {
    display: none !important;
}

.media-video-controls[hidden] {
    display: flex !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.media-video-controls label {
    color: #d8e7f9;
    font-size: 0.84rem;
    font-weight: 700;
    margin: 0;
}

.media-video-volume {
    width: 100%;
    accent-color: #56b9ff;
}

.media-box h3 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.35rem;
    font-weight: 600;
    color: #eef6ff;
    letter-spacing: 0.5px;
    position: relative;
}

.media-box h3::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(to right, #4fd1c5, #56b9ff);
    margin: 10px auto 0;
    border-radius: 3px;
}

/* Image and video */
.media-item img,
.media-item video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    cursor: default;
    object-fit: cover;
    transition: filter 0.2s ease;
}

/* Hover effect */
.media-item img:hover {
    transform: none;
    filter: brightness(1.03);
}

.media-item video:hover {
    transform: none;
    filter: none;
}

.media-item-image .media-static-image {
    cursor: default;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: center;
    display: block;
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.65s ease, visibility 0.65s ease;
    pointer-events: none;
}

.media-item-image .media-static-image.is-active {
    opacity: 1;
    visibility: visible;
}

.media-item-image {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

/* Lightbox overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Lightbox media */
.lightbox-overlay img,
.lightbox-overlay video {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

/* View all buttons */
.media-button {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    justify-content: center;
}

.media-button .btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: min(100%, 320px);
    min-height: 46px;
    padding: 12px 28px;
    font-size: 12px;
    font-weight: 700;
    color: #f8fcff;
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid rgba(165, 221, 255, 0.52);
    background: linear-gradient(135deg, #56b9ff, #2f89ff 54%, #1f62e3);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.media-button .btn:hover {
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .media-box {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .media-button .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .media-puzzle-overlay,
    .media-puzzle-overlay.is-animating .media-puzzle-tile {
        animation: none !important;
        transition: none !important;
    }
}
