/**
 * AA Media - Related Media Frontend Styles
 */

/* Section Container */
.aa-related-media-section {
    margin: 40px 0;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.aa-rm-heading {
    font-size: 1.25em;
    margin-bottom: 20px;
    color: #333;
}

/* Gallery Base */
.aa-related-gallery {
    display: grid;
    gap: 16px;
    margin: 20px 0;
}

/* Column Variations */
.aa-related-gallery.aa-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.aa-related-gallery.aa-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.aa-related-gallery.aa-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Gallery Item */
.aa-gallery-item {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
}

.aa-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.aa-gallery-item:hover img {
    transform: scale(1.05);
}

.aa-gallery-link {
    display: block;
    position: relative;
}

.aa-gallery-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.aa-gallery-link:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

/* Caption */
.aa-gallery-item figcaption {
    padding: 12px 15px;
    font-size: 0.9em;
    color: #555;
    background: #fff;
    line-height: 1.4;
}

/* Photo Credit */
.aa-photo-credit {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    font-size: 0.75em;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.aa-gallery-item:hover .aa-photo-credit {
    opacity: 1;
}

/* Style: Grid (default) */
.aa-style-grid .aa-gallery-item {
    aspect-ratio: 4/3;
}

.aa-style-grid .aa-gallery-item img {
    height: 100%;
    object-fit: cover;
}

/* Style: Masonry */
.aa-style-masonry {
    display: block;
    column-count: 3;
    column-gap: 16px;
}

.aa-style-masonry.aa-cols-2 {
    column-count: 2;
}

.aa-style-masonry.aa-cols-4 {
    column-count: 4;
}

.aa-style-masonry .aa-gallery-item {
    break-inside: avoid;
    margin-bottom: 16px;
}

/* Style: Carousel */
.aa-style-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding-bottom: 10px;
}

.aa-style-carousel .aa-gallery-item {
    flex: 0 0 auto;
    width: 300px;
    scroll-snap-align: start;
}

.aa-style-carousel::-webkit-scrollbar {
    height: 8px;
}

.aa-style-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.aa-style-carousel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.aa-style-carousel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Lightbox (basic overlay) */
.aa-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aaFadeIn 0.3s ease;
}

@keyframes aaFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.aa-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.aa-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.aa-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: #fff;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.aa-lightbox-close:hover {
    transform: scale(1.1);
}

.aa-lightbox-title {
    color: #fff;
    text-align: center;
    margin-top: 15px;
    font-size: 0.95em;
}

/* Responsive */
@media (max-width: 768px) {

    .aa-related-gallery.aa-cols-3,
    .aa-related-gallery.aa-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .aa-style-masonry.aa-cols-3,
    .aa-style-masonry.aa-cols-4 {
        column-count: 2;
    }

    .aa-style-carousel .aa-gallery-item {
        width: 260px;
    }
}

@media (max-width: 480px) {

    .aa-related-gallery.aa-cols-2,
    .aa-related-gallery.aa-cols-3,
    .aa-related-gallery.aa-cols-4 {
        grid-template-columns: 1fr;
    }

    .aa-style-masonry,
    .aa-style-masonry.aa-cols-2,
    .aa-style-masonry.aa-cols-3,
    .aa-style-masonry.aa-cols-4 {
        column-count: 1;
    }
}
