/* CSS Custom Properties for theming and reusability */
:root {
    --luxe-gallery-max-width: 1280px;
    --luxe-gallery-gap: clamp(0.5rem, 2vw, 1rem);
    --luxe-gallery-border-radius: 12px;
    --luxe-gallery-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --luxe-gallery-hero-height: clamp(450px, 55vh, 800px);
    --luxe-gallery-modal-padding: clamp(1.5rem, 5vw, 3rem);
    --luxe-gallery-z-modal: 9999;
    --luxe-gallery-z-controls: 10;
    
    /* Colors - inherit from theme or use fallbacks */
    --luxe-gallery-bg: var(--wp-admin-theme-color, #007cba);
    --luxe-gallery-text: var(--wp-admin-theme-color-darker-10, #005a87);
    --luxe-gallery-border: #ddd;
    --luxe-gallery-overlay: oklch(100% 0 0 / 0.95);
    --luxe-gallery-shadow: 0 2px 8px oklch(0% 0 0 / 0.1);
}

/* Prevent body scroll when modal is open */
body.luxe-gallery-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.luxe-gallery-container {
    max-width: var(--luxe-gallery-max-width);
    margin-inline: auto;
    font-family: system-ui, -apple-system, sans-serif;
}

/* Hero Grid Layout with modern grid */
.luxe-gallery-hero-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: var(--luxe-gallery-gap);
    min-height: var(--luxe-gallery-hero-height);
    position: relative;
    border-radius: var(--luxe-gallery-border-radius);
    overflow: hidden;
    container-type: inline-size;
}

.luxe-gallery-hero-grid .hero-image-item {
    overflow: hidden;
    border-radius: calc(var(--luxe-gallery-border-radius) * 0.5);
}

.luxe-gallery-hero-grid .hero-image-item a {
    display: block;
    width: 100%;
    height: 100%;
}

.luxe-gallery-hero-grid .hero-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--luxe-gallery-transition);
    will-change: transform;
}

.luxe-gallery-hero-grid .hero-image-item a:hover img,
.luxe-gallery-hero-grid .hero-image-item a:focus-visible img {
    transform: scale(1.05);
}

/* Button styling that inherits from theme */
.luxe-gallery-hero-grid .show-all-photos,
.luxe-gallery-mobile-slider .show-all-photos-mobile {
    position: absolute;
    padding: 0.75em 1.5em;
    background: var(--wp-admin-theme-color, var(--luxe-gallery-bg));
    color: var(--wp-admin-theme-color-contrast, white);
    border: none;
    border-radius: calc(var(--luxe-gallery-border-radius) * 0.5);
    cursor: pointer;
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-weight: 600;
    transition: var(--luxe-gallery-transition);
    box-shadow: var(--luxe-gallery-shadow);
}

.luxe-gallery-hero-grid .show-all-photos {
    inset-block-end: 1.5rem;
    inset-inline-end: 1.5rem;
}

.luxe-gallery-hero-grid .show-all-photos:hover,
.luxe-gallery-hero-grid .show-all-photos:focus-visible,
.luxe-gallery-mobile-slider .show-all-photos-mobile:hover,
.luxe-gallery-mobile-slider .show-all-photos-mobile:focus-visible {
    box-shadow: 0 4px 12px oklch(0% 0 0 / 0.15);
}

/* Mobile Slider */
.luxe-gallery-mobile-slider {
    display: none;
    position: relative;
}

.luxe-gallery-mobile-slider .swiper {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--luxe-gallery-border-radius);
}

.luxe-gallery-mobile-slider .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.luxe-gallery-mobile-slider .show-all-photos-mobile {
    inset-block-end: 2rem;
    inset-inline: 50%;
    transform: translateX(-50%);
    z-index: var(--luxe-gallery-z-controls);
    min-width: 180px;
}

.luxe-gallery-mobile-slider .swiper-pagination-bullet {
    background-color: oklch(100% 0 0 / 0.8);
    width: 10px;
    height: 10px;
    opacity: 1;
}

.luxe-gallery-mobile-slider .swiper-pagination-bullet-active {
    background-color: oklch(100% 0 0 / 1);
    transform: scale(1.2);
}

/* Full View Modal with modern positioning */
.luxe-gallery-full-view {
    position: fixed;
    inset: 0;
    background: white;
    z-index: var(--luxe-gallery-z-modal);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-block: 15rem var(--luxe-gallery-modal-padding);
    padding-inline: var(--luxe-gallery-modal-padding);
    
    visibility: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.luxe-gallery-full-view.is-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.back-to-grid-view {
    position: fixed;
    inset-block-start: 50%;
    inset-inline-start: 1rem;
    transform: translateY(-50%);
    background: var(--luxe-gallery-overlay);
    border: 1px solid var(--luxe-gallery-border);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: calc(var(--luxe-gallery-z-modal) + 1);
    transition: var(--luxe-gallery-transition);
}

.back-to-grid-view:hover,
.back-to-grid-view:focus-visible {
    background: oklch(95% 0 0);
    transform: translateY(-50%) translateX(-2px);
}

.back-to-grid-view svg {
    color: oklch(20% 0 0);
}

.luxe-gallery-full-view .luxe-gallery-categories-wrapper {
    margin-inline: auto;
}

/* Category Navigation with modern styling */
.luxe-gallery-category-nav {
    position: relative;
    border-block-end: 1px solid var(--luxe-gallery-border);
    margin-block-end: 2rem;
}

.luxe-gallery-category-nav ul {
    list-style: none;
    padding: 0.5rem 0 0.5rem 3rem;
    margin: 0;
    display: flex;
    gap: 0.625rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.luxe-gallery-category-nav ul::-webkit-scrollbar {
    display: none;
}

.luxe-gallery-category-nav a {
    text-decoration: none;
    color: oklch(50% 0 0);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    border-block-end: 2px solid transparent;
    border-radius: calc(var(--luxe-gallery-border-radius) * 0.5);
    min-width: 110px;
    transition: var(--luxe-gallery-transition);
}

.luxe-gallery-category-nav a:hover,
.luxe-gallery-category-nav a:focus-visible {
    color: oklch(20% 0 0);
    transform: translateY(-2px);
}

.luxe-gallery-category-nav a.active {
    color: oklch(20% 0 0);
    border-block-end-color: var(--luxe-gallery-bg);
}

.luxe-gallery-category-nav a:focus-visible {
    outline: 2px solid var(--luxe-gallery-bg);
    outline-offset: 2px;
}

.luxe-gallery-category-nav img {
    width: clamp(150px, 20vw, 175px);
    aspect-ratio: 1;
    border-radius: calc(var(--luxe-gallery-border-radius) * 0.5);
    object-fit: cover;
}

.luxe-gallery-category-nav span {
    font-weight: 600;
    font-size: clamp(0.875rem, 2vw, 1rem);
}

/* Category Sections with modern grid */
.luxe-gallery-category-section {
    padding-block-start: 3rem;
    margin-block-start: -1.5rem;
}

.luxe-gallery-category-section:first-of-type {
    padding-block-start: 1.5rem;
}

.luxe-gallery-category-section h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    margin-block-end: 1.5rem;
}

.luxe-gallery-category-section .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1rem;
}

.luxe-gallery-category-section .grid-image-item {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: calc(var(--luxe-gallery-border-radius) * 0.5);
    cursor: pointer;
    transition: var(--luxe-gallery-transition);
}

.luxe-gallery-category-section .grid-image-item:hover,
.luxe-gallery-category-section .grid-image-item:focus-visible {
    transform: scale(1.02);
    box-shadow: var(--luxe-gallery-shadow);
}

.luxe-gallery-category-section .grid-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Container queries for responsive design */
@container (max-width: 768px) {
    .luxe-gallery-hero-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Media queries for non-container support */
@media (max-width: 768px) {
    .luxe-gallery-hero-grid {
        display: none;
    }
    
    .luxe-gallery-mobile-slider {
        display: block;
    }
    
    .luxe-gallery-full-view {
        padding-inline: 1rem;
    }
    
    .luxe-gallery-category-nav ul {
        padding-inline-start: 1rem;
    }
    
    .back-to-grid-view {
        inset-inline-start: 0.5rem;
    }
}

@media (min-width: 1128px) {
    .luxe-gallery-full-view {
        padding-inline: calc(var(--luxe-gallery-modal-padding) * 2);
    }
}

/* Photoswipe Customization */
.pswp__img {
    object-fit: contain;
}

/* Focus visible for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--luxe-gallery-bg);
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}