/**
 * Gallery Frontend Styles
 * Styles for the gallery display on the frontend
 */

/* Main Gallery Grid */
.fssc-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--gallery-columns, 3), 1fr);
    column-gap: 1.5rem;
    row-gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
    padding: 0 0.5rem;
}

/* Gallery Item */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #f8f9fa;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

/* When captions are disabled, use square aspect ratio */
.fssc-gallery-grid:not(.has-captions) .gallery-item {
    aspect-ratio: 1;
}

/* When captions are enabled, images can have natural height */
.fssc-gallery-grid.has-captions .gallery-item {
    aspect-ratio: auto;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
}

/* Gallery Link */
.gallery-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* When no captions, link covers full item */
.fssc-gallery-grid:not(.has-captions) .gallery-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Image Wrapper */
.gallery-image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: block;
}

/* When captions are disabled, image wrapper fills the item */
.fssc-gallery-grid:not(.has-captions) .gallery-image-wrapper {
    height: 100%;
}

/* When captions are enabled, use square aspect for image area */
.fssc-gallery-grid.has-captions .gallery-image-wrapper {
    aspect-ratio: 1;
}

/* Gallery Image */
.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* Hover Effects */
.fssc-gallery-grid.has-hover-effects .gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

.fssc-gallery-grid.has-hover-effects .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

/* When captions are enabled, overlay only covers the image area */
.fssc-gallery-grid.has-captions.has-hover-effects .gallery-item::before {
    bottom: auto;
    height: 0;
    padding-bottom: 100%;
    /* Square aspect ratio */
}

.fssc-gallery-grid.has-hover-effects .gallery-item:hover::before {
    opacity: 1;
}

/* Gallery Caption - Visible below image when has-captions class is present */
.gallery-caption {
    display: none;
}

.fssc-gallery-grid.has-captions .gallery-caption {
    display: block;
    padding: 12px 15px;
    background: #fff;
    text-align: center;
}

.gallery-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
}

.gallery-description {
    display: none;
}

/* Lightbox Indicator */
.fssc-gallery-grid.has-lightbox .gallery-item::after {
    content: '\f179';
    /* dashicons-search (magnifying glass) */
    font-family: 'dashicons';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: white;
    background: rgba(0, 0, 0, 0.8);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 3;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.9);
    line-height: 1;
    text-align: center;
    font-weight: normal;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Font Awesome Alternative (when Font Awesome is loaded) */
.fssc-use-fontawesome .fssc-gallery-grid.has-lightbox .gallery-item::after {
    content: '\f002';
    /* Font Awesome magnifying-glass */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome', 'dashicons';
    font-weight: 900;
}

.fssc-gallery-grid.has-lightbox .gallery-item:hover::after {
    opacity: 1;
}

/* Empty Gallery State */
.fssc-gallery-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: #6c757d;
    font-size: 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 2rem 0;
}

.fssc-gallery-empty::before {
    content: '\f161';
    /* dashicons-format-gallery */
    font-family: 'dashicons';
    font-size: 48px;
    display: block;
    margin-bottom: 1rem;
    color: #adb5bd;
}

/* Gallery Page Styles */
.gallery-page {
    margin: 2rem 0;
    padding: 0 1rem;
}

.gallery-page-header {
    text-align: center;
    margin-bottom: 4rem;
    padding: 2rem 0;
}

.gallery-page-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #1d2327;
}

.gallery-page-description {
    font-size: 1.1rem;
    color: #6c757d;
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* Category Filter */
.gallery-category-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    padding: 0;
    list-style: none;
}

.gallery-category-filter li {
    margin: 0;
}

.gallery-category-filter a {
    display: block;
    padding: 10px 20px;
    background: #f8f9fa;
    color: #495057;
    text-decoration: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.gallery-category-filter a:hover,
.gallery-category-filter a.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.25);
}

/* Gallery Masonry Layout (for gallery page) */
.gallery-masonry {
    column-count: 3;
    column-gap: 2rem;
    column-fill: balance;
    padding: 0 1rem;
}

.gallery-masonry .gallery-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 2rem;
    aspect-ratio: auto;
    break-inside: avoid;
}

/* Pagination */
.gallery-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 3rem;
    padding: 2rem 0;
}

.gallery-pagination a,
.gallery-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    text-decoration: none;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    color: #495057;
    font-weight: 500;
    transition: all 0.3s ease;
}

.gallery-pagination a:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.gallery-pagination .current {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* Plugin Block Pagination */
.fssc-gallery-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 3rem;
    padding: 2rem 0;
}

.fssc-gallery-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    text-decoration: none;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    color: #495057;
    font-weight: 500;
    background: white;
    transition: all 0.3s ease;
}

.fssc-gallery-pagination .page-numbers:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.fssc-gallery-pagination .page-numbers.current {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.fssc-gallery-pagination .page-numbers.prev,
.fssc-gallery-pagination .page-numbers.next {
    padding: 0 16px;
}

.fssc-gallery-pagination .page-numbers.dots {
    border: none;
    background: transparent;
}


/* Lightbox Styles */
.fssc-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.fssc-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.fssc-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fssc-lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.fssc-lightbox-caption {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 4px;
    margin-top: 15px;
    text-align: center;
    max-width: 500px;
}

.fssc-lightbox-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 5px 0;
}

.fssc-lightbox-description {
    font-size: 14px;
    margin: 0;
    opacity: 0.9;
}

/* Lightbox Controls */
.fssc-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fssc-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fssc-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fssc-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.fssc-lightbox-prev {
    left: 20px;
}

.fssc-lightbox-next {
    right: 20px;
}

/* Loading Spinner */
.fssc-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: fssc-spin 1s linear infinite;
}

@keyframes fssc-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .fssc-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        column-gap: 1.2rem;
        row-gap: 1.2rem;
        padding: 0 0.75rem;
    }

    .gallery-masonry {
        column-count: 2;
        column-gap: 1.5rem;
        padding: 0 0.75rem;
    }

    .gallery-masonry .gallery-item {
        margin-bottom: 1.5rem;
    }

    .gallery-page-title {
        font-size: 2rem;
    }

    .gallery-category-filter {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .fssc-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        column-gap: 1rem;
        row-gap: 1rem;
        padding: 0 0.5rem;
        margin: 1.5rem 0;
    }

    .gallery-masonry {
        column-count: 1;
        column-gap: 0;
        padding: 0 0.5rem;
    }

    .gallery-masonry .gallery-item {
        margin-bottom: 1.25rem;
    }

    .gallery-page-title {
        font-size: 1.8rem;
    }

    .gallery-title {
        font-size: 14px;
    }

    .gallery-description {
        font-size: 12px;
    }

    .gallery-category-filter {
        flex-direction: column;
        align-items: center;
    }

    .gallery-category-filter a {
        padding: 10px 20px;
        width: 200px;
        text-align: center;
    }

    /* Mobile lightbox adjustments */
    .fssc-lightbox-content {
        max-width: 95%;
        max-height: 95%;
    }

    .fssc-lightbox-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .fssc-lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }

    .fssc-lightbox-prev {
        left: 10px;
    }

    .fssc-lightbox-next {
        right: 10px;
    }

    .fssc-lightbox-caption {
        padding: 10px 15px;
        margin-top: 10px;
    }

    .fssc-lightbox-title {
        font-size: 16px;
    }

    .fssc-lightbox-description {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .fssc-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        column-gap: 0.75rem;
        row-gap: 0.75rem;
        padding: 0 0.25rem;
    }

    .gallery-page {
        padding: 0 0.5rem;
    }

    .gallery-page-title {
        font-size: 1.5rem;
    }

    .gallery-caption {
        padding: 20px 10px 10px;
    }

    .gallery-title {
        font-size: 13px;
    }

    .gallery-description {
        font-size: 11px;
    }
}

/* Print Styles */
@media print {

    .fssc-lightbox,
    .gallery-category-filter,
    .gallery-pagination {
        display: none !important;
    }

    .fssc-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .gallery-caption {
        position: static;
        background: #f8f9fa;
        color: #1d2327;
        padding: 10px;
        margin-top: 5px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .gallery-item {
        border: 2px solid #1d2327;
    }

    .gallery-caption {
        background: #1d2327;
        color: #ffffff;
    }

    .fssc-lightbox {
        background: #000000;
    }

    .gallery-category-filter a {
        border: 2px solid #1d2327;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {

    .gallery-item,
    .gallery-image,
    .gallery-caption,
    .fssc-lightbox,
    .gallery-category-filter a {
        transition: none;
    }

    .fssc-gallery-grid.has-hover-effects .gallery-item:hover .gallery-image {
        transform: none;
    }

    .fssc-lightbox-loading {
        animation: none;
        border: 3px solid white;
    }
}