/**
 * AA Media - Related Media Frontend Styles
 */

/* Section Container */
.related-media-section {
    margin: 40px 0;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.rm-heading {
    font-size: 1.25em;
    margin-bottom: 20px;
    color: #333;
}

/* Inline article images inserted by AA Media */
figure.content-image {
    margin: 28px 0;
}

figure.content-image img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}

/* Post-level attribution block (rendered at bottom of content) */
.post-attribution {
    margin: 36px 0 16px;
    padding: 16px 18px;
    border: 1px solid #e4e7eb;
    border-radius: 10px;
    background: #f8fafc;
    color: #2b3440;
    font-size: 0.95em;
    line-height: 1.55;
}

.post-attribution h4 {
    margin: 0 0 8px;
    font-size: 1em;
    font-weight: 600;
    color: #1c2530;
}

.post-attribution p {
    margin: 0 0 8px;
    color: #4a5563;
}

.post-attribution ul {
    margin: 0;
    padding-left: 18px;
}

.post-attribution li {
    margin: 0 0 6px;
}

.post-attribution a {
    color: #215f96;
    text-decoration: underline;
}

.post-attribution a:hover,
.post-attribution a:focus {
    color: #163f66;
}

/* Gallery Base */
.related-gallery {
    display: grid;
    gap: 16px;
    margin: 20px 0;
}

/* Column Variations */
.related-gallery.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.related-gallery.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.related-gallery.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Gallery Item */
.gallery-item {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-link {
    display: block;
    position: relative;
}

.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;
}

.gallery-link:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

/* Caption */
.gallery-item figcaption {
    padding: 12px 15px;
    font-size: 0.9em;
    color: #555;
    background: #fff;
    line-height: 1.4;
}

/* Photo Credit */
.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;
}

.gallery-item:hover .photo-credit {
    opacity: 1;
}

/* Style: Grid (default) */
.style-grid .gallery-item {
    aspect-ratio: 4/3;
}

.style-grid .gallery-item img {
    height: 100%;
    object-fit: cover;
}

/* Style: Masonry */
.style-masonry {
    display: block;
    column-count: 3;
    column-gap: 16px;
}

.style-masonry.cols-2 {
    column-count: 2;
}

.style-masonry.cols-4 {
    column-count: 4;
}

.style-masonry .gallery-item {
    break-inside: avoid;
    margin-bottom: 16px;
}

/* Style: Carousel */
.style-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding-bottom: 10px;
}

.style-carousel .gallery-item {
    flex: 0 0 auto;
    width: 300px;
    scroll-snap-align: start;
}

.style-carousel::-webkit-scrollbar {
    height: 8px;
}

.style-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.style-carousel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.style-carousel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.style-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.style-list .gallery-item {
    display: flex;
    gap: 16px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 10px;
    background: #fff;
    align-items: flex-start;
}

.style-list .gallery-item img {
    width: 160px;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
}

.style-list .gallery-item figcaption {
    padding: 0;
    background: none;
}

.style-list .photo-credit {
    position: static;
    padding: 0;
    background: none;
    color: #888;
    opacity: 1;
}

.style-list .list-body {
    flex: 1;
}

.style-list .list-title {
    margin: 0 0 6px 0;
    font-size: 1rem;
    color: #222;
}

.style-list .list-caption {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 0.92em;
    line-height: 1.5;
}

.style-list .list-credit {
    display: inline-flex;
    align-items: center;
    font-size: 0.75em;
    color: #888;
    gap: 6px;
}

/* Lightbox (basic overlay) */
.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;
    }
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.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);
}

.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;
}

.lightbox-close:hover {
    transform: scale(1.1);
}

.lightbox-title {
    color: #fff;
    text-align: center;
    margin-top: 15px;
    font-size: 0.95em;
}

/* Responsive */
@media (max-width: 768px) {

    .related-gallery.cols-3,
    .related-gallery.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .style-masonry.cols-3,
    .style-masonry.cols-4 {
        column-count: 2;
    }

    .style-carousel .gallery-item {
        width: 260px;
    }

    .style-list .gallery-item {
        flex-direction: column;
    }

    .style-list .gallery-item img {
        width: 100%;
        height: auto;
    }

    .post-attribution {
        margin-top: 28px;
        padding: 14px 14px;
        font-size: 0.92em;
    }
}

@media (max-width: 480px) {

    .related-gallery.cols-2,
    .related-gallery.cols-3,
    .related-gallery.cols-4 {
        grid-template-columns: 1fr;
    }

    .style-masonry,
    .style-masonry.cols-2,
    .style-masonry.cols-3,
    .style-masonry.cols-4 {
        column-count: 1;
    }
}
