/**
 * Gallery Section Styles
 * Comprehensive styles for image galleries with multiple layouts
 *
 * @package Kadence_RSKisslegg_Child
 * @version 1.0.0
 */

/* ============================================
   GALLERY SECTION BASE
   ============================================ */

.rsk-gallery-section {
    padding: 40px 0;
}

.rsk-gallery-section .rsk-section-title {
    margin-bottom: 30px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--rsk-primary, #003DA5);
    text-align: center;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */

.rsk-gallery-grid {
    display: grid;
    gap: 20px;
    margin: 0 auto;
    max-width: 1400px;
}

/* Grid 2 Columns */
.rsk-gallery-grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Grid 3 Columns */
.rsk-gallery-grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Grid 4 Columns */
.rsk-gallery-grid-4 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Masonry Layout */
.rsk-gallery-masonry {
    --masonry-columns: 3;
    grid-template-columns: repeat(var(--masonry-columns), 1fr);
    grid-auto-flow: dense;
}

.rsk-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
    aspect-ratio: 4 / 3;
}

.rsk-gallery-item button.rsk-gallery-trigger {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
    display: block;
}

.rsk-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.rsk-gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(0.9);
}

.rsk-gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 20px;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.rsk-gallery-item:hover .rsk-gallery-item-overlay,
.rsk-gallery-item:focus-within .rsk-gallery-item-overlay {
    transform: translateY(0);
}

.rsk-gallery-item-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.rsk-gallery-item-caption {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

/* Single image in grid - limit size */
.rsk-gallery-item:only-child {
    max-width: 500px;
    margin: 0 auto;
}

/* Two images in grid - limit size */
.rsk-gallery-grid .rsk-gallery-item:first-child:nth-last-child(2),
.rsk-gallery-grid .rsk-gallery-item:first-child:nth-last-child(2) ~ .rsk-gallery-item {
    max-width: 450px;
}

/* ============================================
   SLIDER LAYOUT
   ============================================ */

.rsk-gallery-slider {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden;
}

.rsk-gallery-slider-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.rsk-gallery-slider-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.rsk-gallery-slide {
    flex: 0 0 100%;
    min-width: 100%;
}

.rsk-gallery-slide-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.rsk-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.rsk-gallery-slide-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6));
    padding: 30px;
    color: white;
}

.rsk-gallery-slide-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.rsk-gallery-slide-text {
    font-size: 1rem;
    opacity: 0.95;
    line-height: 1.6;
}

/* Slider Navigation Buttons */
.rsk-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rsk-gallery-nav:hover:not(:disabled) {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rsk-gallery-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rsk-gallery-prev {
    left: 20px;
}

.rsk-gallery-next {
    right: 20px;
}

.rsk-gallery-nav svg {
    color: var(--rsk-primary, #003DA5);
}

/* Slider Dots */
.rsk-gallery-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.rsk-gallery-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--rsk-primary, #003DA5);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.rsk-gallery-dot:hover {
    background: rgba(0, 61, 165, 0.3);
    transform: scale(1.2);
}

.rsk-gallery-dot.active {
    background: var(--rsk-primary, #003DA5);
    transform: scale(1.3);
}

/* ============================================
   LIGHTBOX
   ============================================ */

.rsk-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rsk-lightbox.active {
    display: flex;
}

.rsk-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.rsk-lightbox-content {
    position: relative;
    z-index: 10;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.rsk-lightbox-image-container {
    position: relative;
    max-width: 100%;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsk-lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: opacity 0.15s ease;
}

.rsk-lightbox-info {
    text-align: center;
    color: white;
    max-width: 800px;
    padding: 0 20px;
}

.rsk-lightbox-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.rsk-lightbox-caption {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.6;
    margin-bottom: 12px;
}

.rsk-lightbox-counter {
    font-size: 0.9rem;
    opacity: 0.7;
    font-weight: 500;
}

/* Lightbox Close Button */
.rsk-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.3s ease;
}

.rsk-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg) scale(1.1);
}

.rsk-lightbox-close svg {
    color: white;
}

/* Lightbox Navigation */
.rsk-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.3s ease;
}

.rsk-lightbox-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.15);
}

.rsk-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rsk-lightbox-nav svg {
    color: white;
}

.rsk-lightbox-prev {
    left: 30px;
}

.rsk-lightbox-next {
    right: 30px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .rsk-gallery-grid-4 {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .rsk-gallery-masonry {
        --masonry-columns: 2;
    }
}

@media (max-width: 768px) {
    .rsk-gallery-section {
        padding: 30px 0;
    }

    .rsk-gallery-section .rsk-section-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .rsk-gallery-grid {
        gap: 15px;
    }

    .rsk-gallery-grid-2,
    .rsk-gallery-grid-3,
    .rsk-gallery-grid-4 {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .rsk-gallery-masonry {
        --masonry-columns: 2;
    }

    .rsk-gallery-nav {
        width: 40px;
        height: 40px;
    }

    .rsk-gallery-prev {
        left: 10px;
    }

    .rsk-gallery-next {
        right: 10px;
    }

    .rsk-gallery-nav svg {
        width: 20px;
        height: 20px;
    }

    .rsk-lightbox-nav {
        width: 50px;
        height: 50px;
    }

    .rsk-lightbox-prev {
        left: 15px;
    }

    .rsk-lightbox-next {
        right: 15px;
    }

    .rsk-lightbox-close {
        top: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
    }

    .rsk-lightbox-title {
        font-size: 1.2rem;
    }

    .rsk-lightbox-caption {
        font-size: 0.9rem;
    }

    .rsk-gallery-slide-caption {
        padding: 20px;
    }

    .rsk-gallery-slide-title {
        font-size: 1.2rem;
    }

    .rsk-gallery-slide-text {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .rsk-gallery-grid-2,
    .rsk-gallery-grid-3,
    .rsk-gallery-grid-4,
    .rsk-gallery-masonry {
        grid-template-columns: 1fr;
        --masonry-columns: 1;
    }

    .rsk-gallery-item {
        aspect-ratio: 16 / 9;
    }

    .rsk-lightbox-content {
        max-width: 95vw;
    }

    .rsk-lightbox-image-container {
        max-height: 60vh;
    }

    .rsk-lightbox-nav,
    .rsk-lightbox-close {
        width: 40px;
        height: 40px;
    }

    .rsk-lightbox-nav svg,
    .rsk-lightbox-close svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   ACCESSIBILITY & FOCUS STATES
   ============================================ */

.rsk-gallery-trigger:focus-visible,
.rsk-gallery-nav:focus-visible,
.rsk-gallery-dot:focus-visible,
.rsk-lightbox-close:focus-visible,
.rsk-lightbox-nav:focus-visible {
    outline: 3px solid var(--rsk-primary, #003DA5);
    outline-offset: 3px;
}

.rsk-gallery-trigger:focus-visible {
    outline-offset: -3px;
}

/* ============================================
   LOADING STATES
   ============================================ */

.rsk-gallery-item img[data-src],
.rsk-gallery-slide img[data-src] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .rsk-lightbox,
    .rsk-gallery-nav,
    .rsk-gallery-dots {
        display: none !important;
    }

    .rsk-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .rsk-gallery-item {
        page-break-inside: avoid;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.rsk-lightbox.active .rsk-lightbox-image {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
    .rsk-gallery-item {
        border: 2px solid currentColor;
    }

    .rsk-gallery-nav,
    .rsk-lightbox-nav,
    .rsk-lightbox-close {
        border-width: 3px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .rsk-gallery-item img,
    .rsk-gallery-slider-track,
    .rsk-lightbox,
    .rsk-lightbox-image,
    .rsk-gallery-nav,
    .rsk-lightbox-nav,
    .rsk-lightbox-close,
    .rsk-gallery-dot {
        transition: none !important;
        animation: none !important;
    }
}
