/**
 * Gutenberg Block Gallery Styles with Simple Lightbox
 * Responsive grid gallery for wp-block-gallery
 * Version: 2.0.0
 */

/* ===================================
   GALLERY GRID STYLES
   =================================== */

/* Base gallery container */
.wp-block-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    padding: 0;
    margin: 2rem 0;
    list-style: none;
}

/* Remove default Gutenberg spacing */
.wp-block-gallery.has-nested-images {
    gap: 1rem;
}

/* Individual gallery items */
.wp-block-gallery .wp-block-image {
    margin: 0;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Hover effect on images */
.wp-block-gallery .wp-block-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Image styling */
.wp-block-gallery .wp-block-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    cursor: pointer;
}

/* Default aspect ratio for consistent heights */
.wp-block-gallery .wp-block-image img {
    aspect-ratio: 4/3;
}

/* Caption styling */
.wp-block-gallery .wp-block-image figcaption,
.wp-block-gallery .wp-element-caption {
    padding: 0.75rem;
    font-size: 0.875rem;
    color: #666;
    background: #f9f9f9;
    text-align: center;
    margin: 0;
}

/* Handle cropped galleries */
.wp-block-gallery.is-cropped .wp-block-image img {
    object-fit: cover;
    height: 300px;
}

/* Column-specific overrides */
.wp-block-gallery.columns-1 {
    grid-template-columns: 1fr;
}

.wp-block-gallery.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.wp-block-gallery.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.wp-block-gallery.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.wp-block-gallery.columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.wp-block-gallery.columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Responsive breakpoints - Tablets */
@media (max-width: 768px) {
    .wp-block-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.75rem;
    }

    .wp-block-gallery.is-cropped .wp-block-image img {
        height: 200px;
    }

    .wp-block-gallery.columns-4,
    .wp-block-gallery.columns-5,
    .wp-block-gallery.columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .wp-block-gallery.columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive breakpoints - Mobile */
@media (max-width: 480px) {
    .wp-block-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .wp-block-gallery.is-cropped .wp-block-image img {
        height: 250px;
    }

    .wp-block-gallery.columns-2,
    .wp-block-gallery.columns-3,
    .wp-block-gallery.columns-4,
    .wp-block-gallery.columns-5,
    .wp-block-gallery.columns-6 {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   SIMPLE LIGHTBOX STYLES
   =================================== */

/* Lightbox container */
.gutenberg-simple-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    transition: opacity 0.3s ease;
}

/* Dark overlay */
.gutenberg-simple-lightbox .lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
}

/* Content container */
.gutenberg-simple-lightbox .lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
    box-sizing: border-box;
}

/* Image container */
.gutenberg-simple-lightbox .lightbox-image-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main image */
.gutenberg-simple-lightbox .lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    display: block;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

/* Close button */
.gutenberg-simple-lightbox .lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 48px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 50px;
    height: 50px;
    z-index: 100001;
    transition: opacity 0.2s ease;
    font-weight: 300;
}

.gutenberg-simple-lightbox .lightbox-close:hover {
    opacity: 0.7;
}

/* Navigation arrows */
.gutenberg-simple-lightbox .lightbox-prev,
.gutenberg-simple-lightbox .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    padding: 20px 15px;
    z-index: 100001;
    transition: background 0.2s ease;
    user-select: none;
}

.gutenberg-simple-lightbox .lightbox-prev {
    left: 20px;
}

.gutenberg-simple-lightbox .lightbox-next {
    right: 20px;
}

.gutenberg-simple-lightbox .lightbox-prev:hover,
.gutenberg-simple-lightbox .lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Caption */
.gutenberg-simple-lightbox .lightbox-caption {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    text-align: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    max-width: 80%;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
}

/* Counter */
.gutenberg-simple-lightbox .lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

/* Hide body scroll when lightbox is open */
body.lightbox-open {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gutenberg-simple-lightbox .lightbox-content {
        padding: 40px 60px;
    }

    .gutenberg-simple-lightbox .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 36px;
        width: 40px;
        height: 40px;
    }

    .gutenberg-simple-lightbox .lightbox-prev,
    .gutenberg-simple-lightbox .lightbox-next {
        font-size: 28px;
        padding: 15px 10px;
    }

    .gutenberg-simple-lightbox .lightbox-prev {
        left: 10px;
    }

    .gutenberg-simple-lightbox .lightbox-next {
        right: 10px;
    }

    .gutenberg-simple-lightbox .lightbox-image {
        max-height: 70vh;
    }

    .gutenberg-simple-lightbox .lightbox-caption {
        bottom: 50px;
        font-size: 0.9rem;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .gutenberg-simple-lightbox .lightbox-content {
        padding: 20px 40px;
    }

    .gutenberg-simple-lightbox .lightbox-close {
        top: 5px;
        right: 5px;
        font-size: 32px;
    }

    .gutenberg-simple-lightbox .lightbox-prev,
    .gutenberg-simple-lightbox .lightbox-next {
        font-size: 24px;
        padding: 10px 8px;
        background: rgba(255, 255, 255, 0.15);
    }

    .gutenberg-simple-lightbox .lightbox-image {
        max-height: 60vh;
    }

    .gutenberg-simple-lightbox .lightbox-caption {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .gutenberg-simple-lightbox .lightbox-counter {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}
