/**
 * Luxe Gallery Frontend Styles - Optimized Build
 * Includes custom slider + lightbox styles (replaces Swiper CSS + PhotoSwipe CSS)
 * @version 2.0.5
 */

/* =========================================================================
 * CSS Custom Properties
 * ========================================================================= */
:root {
    --luxe-gap: 8px;
    --luxe-radius: 12px;
    --luxe-radius-small: 8px;
    --luxe-transition: all 0.3s ease;
    --luxe-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --luxe-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --luxe-overlay-bg: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
    --luxe-caption-color: #ffffff;
    --luxe-caption-bg: rgba(0, 0, 0, 0.8);
    --luxe-button-bg: #ffffff;
    --luxe-button-text: #222222;
    --luxe-accent: #3b82f6;
    --luxe-skeleton-bg: #e5e7eb;
    --luxe-skeleton-shine: #f3f4f6;
}

/* =========================================================================
 * Main Container
 * ========================================================================= */
.luxe-gallery-container {
    max-width: 1280px;
    margin: 0 auto;
    font-family: sans-serif;
}

/* Gallery Title */
.luxe-gallery-title { margin: 0 0 16px 0; font-size: 28px; font-weight: 600; line-height: 1.3; color: inherit; }
.luxe-gallery-title.h1 { font-size: 36px; }
.luxe-gallery-title.h3 { font-size: 24px; }
.luxe-gallery-title.h4 { font-size: 20px; }
.luxe-gallery-title.h5 { font-size: 18px; }
.luxe-gallery-title.h6 { font-size: 16px; }

/* =========================================================================
 * Hero Grid Layout
 * ========================================================================= */
.luxe-gallery-hero-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    height: 55vh;
    min-height: 450px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.luxe-gallery-hero-grid .hero-image-item { overflow: hidden; }
.luxe-gallery-hero-grid .hero-image-item a { display: block; width: 100%; height: 100%; }
.luxe-gallery-hero-grid .hero-image-item .luxe-gallery-image-wrapper { width: 100%; height: 100%; }
.luxe-gallery-hero-grid .hero-image-item picture { display: block; width: 100%; height: 100%; }
.luxe-gallery-hero-grid .hero-image-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.luxe-gallery-hero-grid .hero-image-item a:hover img { transform: scale(1.05); }

/* Grid Item Positions */
.luxe-gallery-hero-grid .item-1 { grid-column: 1 / 3; grid-row: 1 / 3; }
.luxe-gallery-hero-grid .item-2 { grid-column: 3 / 4; grid-row: 1 / 2; }
.luxe-gallery-hero-grid .item-3 { grid-column: 4 / 5; grid-row: 1 / 2; }
.luxe-gallery-hero-grid .item-4 { grid-column: 3 / 4; grid-row: 2 / 3; }
.luxe-gallery-hero-grid .item-5 { grid-column: 4 / 5; grid-row: 2 / 3; }

/* Show All Photos Button */
.luxe-gallery-hero-grid .show-all-photos {
    position: absolute; bottom: 24px; right: 24px;
    padding: 8px 16px; background: var(--luxe-button-bg, #fff); color: var(--luxe-button-text, #222);
    border: 1px solid var(--luxe-button-text, #222); border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 600; transition: var(--luxe-transition);
    display: inline-flex; align-items: center; gap: 8px;
}
.luxe-gallery-hero-grid .show-all-photos:hover { transform: scale(1.02); box-shadow: var(--luxe-shadow); }

/* Virtual Tour Button */
.luxe-gallery-virtual-tour-btn {
    position: absolute; bottom: 24px; left: 24px;
    padding: 8px 16px; background: var(--luxe-button-bg, #fff); color: var(--luxe-button-text, #222);
    border: 1px solid var(--luxe-button-text, #222); border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none;
    display: inline-flex; align-items: center; gap: 8px; transition: var(--luxe-transition); z-index: 10;
}
.luxe-gallery-virtual-tour-btn:hover { transform: scale(1.02); box-shadow: var(--luxe-shadow); }
.luxe-gallery-virtual-tour-btn svg { width: 16px; height: 16px; }

/* =========================================================================
 * Custom Mobile Slider (replaces Swiper ~14KB CSS)
 * ========================================================================= */
.luxe-gallery-mobile-slider { display: none; position: relative; }

.luxe-slider { width: 100%; height: 50vh; border-radius: 12px; overflow: hidden; position: relative; }

.luxe-slider-track {
    display: flex; overflow-x: auto;
    -webkit-scroll-snap-type: x mandatory; scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; height: 100%;
}
.luxe-slider-track::-webkit-scrollbar { display: none; }

.luxe-slider-track > * {
    flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always;
}

.luxe-slider-track img { width: 100%; height: 100%; object-fit: cover; display: block; }

.luxe-slider-pagination {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    display: flex; z-index: 5; align-items: center;
    min-height: 12px;
}

.luxe-slider-dot {
    width: 8px; height: 8px; border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.5); cursor: pointer; padding: 0;
    margin: 0 3px;
    transition: width 0.25s ease, height 0.25s ease, opacity 0.25s ease,
                background 0.2s, transform 0.2s, margin 0.25s ease, border-width 0.25s ease;
    flex-shrink: 0; overflow: hidden; box-sizing: border-box;
}
.luxe-slider-dot.active { background: #fff; transform: scale(1.25); border-color: rgba(0, 0, 0, 0.6); }
.luxe-slider-dot.luxe-dot-hidden {
    width: 0; height: 0; opacity: 0; border-width: 0;
    margin: 0; padding: 0; pointer-events: none;
}

.luxe-gallery-mobile-slider .show-all-photos-mobile {
    position: absolute; bottom: 35px; left: 50%; transform: translateX(-50%);
    padding: 8px 16px; background: rgba(255, 255, 255, 0.9); border: 1px solid #222;
    border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; z-index: 10;
    display: inline-flex; align-items: center; gap: 8px;
}

/* =========================================================================
 * Full View Layout - Modal
 * ========================================================================= */
.luxe-gallery-full-view {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #fff; z-index: 1000; overflow-y: auto;
    padding: 250px 40px; box-sizing: border-box;
    visibility: hidden; opacity: 0; transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.luxe-gallery-full-view.is-visible { visibility: visible; opacity: 1; transform: translateY(0); }

.back-to-grid-view {
    position: absolute; top: 50%; left: 4px; transform: translateY(-50%);
    background: #f0f0f1; border: 1px solid #ddd; border-radius: 50%;
    width: 40px; height: 40px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0; z-index: 101;
}
.back-to-grid-view svg { color: #333; }

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

/* Category Navigation */
.luxe-gallery-category-nav {
    position: relative;
    background: #fff; border-bottom: 1px solid #ddd;
    margin-bottom: 16px; z-index: 100; padding-top: 16px;
}

.luxe-gallery-category-nav ul {
    list-style: none; padding: 0 0 8px 50px; margin: 0;
    display: flex; gap: 10px; overflow-x: auto; white-space: nowrap;
    -ms-overflow-style: none; scrollbar-width: none;
}
.luxe-gallery-category-nav ul::-webkit-scrollbar { display: none; }

.luxe-gallery-category-nav a {
    text-decoration: none; color: #777; padding: 8px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    border-bottom: 2px solid transparent; border-radius: 8px; min-width: 110px;
    transition: all 0.2s ease-in-out;
}
.luxe-gallery-category-nav a:hover { color: #222; transform: translateY(-2px); }
.luxe-gallery-category-nav a.active { color: #222; border-bottom-color: #222; background-color: transparent; }
.luxe-gallery-category-nav a:focus { outline: none; box-shadow: none; }
.luxe-gallery-category-nav img { width: 175px; height: 175px; border-radius: 8px; object-fit: cover; }
.luxe-gallery-category-nav span { font-weight: 600; font-size: 16px; }

/* Category Sections */
.luxe-gallery-category-section { padding-top: 32px; }
.luxe-gallery-category-section:first-of-type { padding-top: 8px; }
.luxe-gallery-category-section h2, .luxe-gallery-category-section h3,
.luxe-gallery-category-section h4, .luxe-gallery-category-section h5,
.luxe-gallery-category-section h6 { font-size: 24px; margin-bottom: 24px; }
.luxe-gallery-category-section .image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.luxe-gallery-category-section .grid-image-item { display: block; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; text-decoration: none; cursor: pointer; }
.luxe-gallery-category-section .grid-image-item:hover img { transform: scale(1.05); }
.luxe-gallery-category-section .grid-image-item img { transition: transform 0.3s ease; }
.luxe-gallery-category-section .grid-image-item .luxe-gallery-image-wrapper { width: 100%; height: 100%; }
.luxe-gallery-category-section .grid-image-item picture { display: block; width: 100%; height: 100%; }
.luxe-gallery-category-section .grid-image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* =========================================================================
 * Additional Layouts
 * ========================================================================= */
.luxe-gallery-columns-1 .luxe-gallery-hero-grid { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.luxe-gallery-columns-2 .luxe-gallery-hero-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: auto; }
.luxe-gallery-columns-3 .luxe-gallery-hero-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: auto; }
.luxe-gallery-columns-5 .luxe-gallery-hero-grid { grid-template-columns: repeat(5, 1fr); grid-template-rows: auto; }
.luxe-gallery-columns-6 .luxe-gallery-hero-grid { grid-template-columns: repeat(6, 1fr); grid-template-rows: auto; }

/* Reset grid positions for custom columns */
.luxe-gallery-columns-1 .item-1, .luxe-gallery-columns-1 .item-2, .luxe-gallery-columns-1 .item-3, .luxe-gallery-columns-1 .item-4, .luxe-gallery-columns-1 .item-5,
.luxe-gallery-columns-2 .item-1, .luxe-gallery-columns-2 .item-2, .luxe-gallery-columns-2 .item-3, .luxe-gallery-columns-2 .item-4, .luxe-gallery-columns-2 .item-5,
.luxe-gallery-columns-3 .item-1, .luxe-gallery-columns-3 .item-2, .luxe-gallery-columns-3 .item-3, .luxe-gallery-columns-3 .item-4, .luxe-gallery-columns-3 .item-5,
.luxe-gallery-columns-5 .item-1, .luxe-gallery-columns-5 .item-2, .luxe-gallery-columns-5 .item-3, .luxe-gallery-columns-5 .item-4, .luxe-gallery-columns-5 .item-5,
.luxe-gallery-columns-6 .item-1, .luxe-gallery-columns-6 .item-2, .luxe-gallery-columns-6 .item-3, .luxe-gallery-columns-6 .item-4, .luxe-gallery-columns-6 .item-5 {
    grid-column: auto; grid-row: auto;
}

/* Gallery Item */
.luxe-gallery-item {
    position: relative; overflow: hidden; border-radius: var(--luxe-radius-small);
    background: #f3f4f6; transition: var(--luxe-transition); cursor: pointer;
}
.luxe-gallery-item:hover { transform: translateY(-2px); box-shadow: var(--luxe-shadow-hover); }
.luxe-gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: var(--luxe-transition); }
.luxe-gallery-item:hover img { transform: scale(1.05); }

/* Captions */
.luxe-gallery-caption {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 1rem;
    color: var(--luxe-caption-color); background: var(--luxe-caption-bg);
    transform: translateY(100%); transition: transform 0.3s ease; font-size: 0.875rem; line-height: 1.4;
}
.luxe-gallery-item:hover .luxe-gallery-caption, .hero-image-item:hover .luxe-gallery-caption { transform: translateY(0); }

/* Masonry Layout */
.luxe-gallery-masonry { column-count: 3; column-gap: var(--luxe-gap); }
.luxe-gallery-masonry .luxe-gallery-item { break-inside: avoid; margin-bottom: var(--luxe-gap); aspect-ratio: auto; }

/* Justified Layout */
.luxe-gallery-justified { display: flex; flex-wrap: wrap; gap: var(--luxe-gap); }
.luxe-gallery-justified .luxe-gallery-item { flex: 1 1 auto; height: 200px; min-width: 150px; aspect-ratio: auto; }

/* =========================================================================
 * Loading States
 * ========================================================================= */
.luxe-gallery-skeleton { position: relative; overflow: hidden; background: var(--luxe-skeleton-bg); }
.luxe-gallery-skeleton::after {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--luxe-skeleton-shine), transparent);
    animation: luxe-skeleton-shimmer 1.5s infinite;
}
@keyframes luxe-skeleton-shimmer { 100% { left: 100%; } }


.luxe-gallery-loading { position: relative; min-height: 400px; }
.luxe-gallery-loading::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 40px; height: 40px; border: 3px solid var(--luxe-skeleton-bg);
    border-top-color: var(--luxe-accent); border-radius: 50%; animation: luxe-spin 1s linear infinite;
}
@keyframes luxe-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Zoom trigger icon */
.luxe-gallery-zoom {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 48px; height: 48px; background: rgba(255,255,255,0.9); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease; pointer-events: none; z-index: 10;
}
.luxe-gallery-item:hover .luxe-gallery-zoom, .hero-image-item:hover .luxe-gallery-zoom { opacity: 1; }
.luxe-gallery-zoom svg { width: 24px; height: 24px; fill: #1f2937; }

/* =========================================================================
 * Custom Lightbox (replaces PhotoSwipe ~7KB CSS)
 * ========================================================================= */
.luxe-lightbox {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease;
}
.luxe-lightbox.is-open { opacity: 1; visibility: visible; }

.luxe-lb-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.92); }

.luxe-lb-topbar {
    position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; color: #fff;
}
.luxe-lb-counter { font-size: 14px; font-weight: 500; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.luxe-lb-actions { display: flex; gap: 8px; }

.luxe-lb-btn {
    background: none; border: none; color: #fff; cursor: pointer;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.2s;
}
.luxe-lb-btn:hover { background: rgba(255, 255, 255, 0.15); }
.luxe-lb-close { font-size: 32px; line-height: 1; }

.luxe-lb-content {
    position: relative; z-index: 1; flex: 1; display: flex; align-items: center;
    justify-content: center; padding: 0 80px; min-height: 0;
}

.luxe-lb-image-wrap {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; overflow: hidden;
    -webkit-user-select: none; user-select: none;
}

.luxe-lb-image {
    max-width: 100%; max-height: calc(100vh - 100px); object-fit: contain;
    transition: opacity 0.2s ease, transform 0.15s ease;
    will-change: transform;
}

.luxe-lb-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(0, 0, 0, 0.35); border: none; color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, opacity 0.2s; opacity: 0.9;
}
.luxe-lb-arrow:hover { background: rgba(0, 0, 0, 0.55); opacity: 1; }
.luxe-lb-arrow:focus { outline: 2px solid #fff; outline-offset: 2px; }
.luxe-lb-prev { left: 16px; }
.luxe-lb-next { right: 16px; }

.luxe-lb-arrow svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }

/* Share Notification */
.luxe-gallery-share-notification {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85); color: #fff; padding: 12px 24px;
    border-radius: 8px; font-size: 14px; z-index: 100000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    animation: luxe-notif-in 0.3s ease;
}
.luxe-gallery-share-notification.fade-out { animation: luxe-notif-out 0.3s ease forwards; }
@keyframes luxe-notif-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes luxe-notif-out { from { opacity: 1; transform: translateX(-50%) translateY(0); } to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* =========================================================================
 * Alignment Support
 * ========================================================================= */
.alignwide .luxe-gallery-container { max-width: 1200px; margin-inline: auto; }
.alignfull .luxe-gallery-container { max-width: 100%; }

/* =========================================================================
 * Responsive
 * ========================================================================= */
@media (max-width: 768px) {
    .luxe-gallery-hero-grid { display: none; }
    .luxe-gallery-mobile-slider { display: block; }

    .luxe-gallery-columns-6 .luxe-gallery-hero-grid,
    .luxe-gallery-columns-5 .luxe-gallery-hero-grid,
    .luxe-gallery-columns-4 .luxe-gallery-hero-grid,
    .luxe-gallery-columns-3 .luxe-gallery-hero-grid,
    .luxe-gallery-columns-2 .luxe-gallery-hero-grid {
        display: grid; grid-template-columns: 1fr; height: auto; min-height: auto;
    }
    .luxe-gallery-masonry { column-count: 1; }

    /* Lightbox mobile adjustments */
    .luxe-lb-content { padding: 0 12px; }
    .luxe-lb-arrow { width: 42px; height: 42px; background: rgba(0,0,0,0.25); }
    .luxe-lb-prev { left: 8px; }
    .luxe-lb-next { right: 8px; }
}

@media (min-width: 1128px) {
    .luxe-gallery-full-view { padding-left: 120px; padding-right: 120px; }
}

@media (max-width: 480px) {
    .luxe-gallery-justified .luxe-gallery-item { width: 100%; height: 250px; }
}

/* =========================================================================
 * Print
 * ========================================================================= */
@media print {
    .luxe-gallery-category-nav, .luxe-gallery-zoom, .show-all-photos,
    .show-all-photos-mobile, .back-to-grid-view, .luxe-lightbox { display: none; }
    .luxe-gallery-item, .hero-image-item { break-inside: avoid; page-break-inside: avoid; }
}

/* =========================================================================
 * Accessibility
 * ========================================================================= */
.luxe-gallery-item:focus-within, .hero-image-item:focus-within { outline: 2px solid #3b82f6; outline-offset: 2px; }
.luxe-gallery-link:focus, .hero-image-item a:focus { outline: none; }

@media (prefers-contrast: high) {
    .luxe-gallery-item, .hero-image-item { border: 2px solid currentColor; }
    .show-all-photos, .show-all-photos-mobile { border-width: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    .luxe-gallery-item, .luxe-gallery-item img, .hero-image-item img,
    .luxe-gallery-caption, .luxe-gallery-zoom, .luxe-gallery-full-view,
    .luxe-lightbox, .luxe-lb-image { transition: none; }
    @keyframes luxe-spin { to { transform: none; } }
}

/* =========================================================================
 * Dark Mode
 * ========================================================================= */
@media (prefers-color-scheme: dark) {
    .luxe-gallery-full-view { background: #1a1a1a; color: #f0f0f0; }
    .luxe-gallery-category-nav { background: #1a1a1a; border-bottom-color: #333; }
    .luxe-gallery-category-nav a { color: #999; }
    .luxe-gallery-category-nav a:hover, .luxe-gallery-category-nav a.active { color: #fff; border-bottom-color: #fff; }
    .back-to-grid-view { background: #2a2a2a; border-color: #444; }
    .back-to-grid-view svg { color: #f0f0f0; }
    .luxe-gallery-item { background: #2a2a2a; }
    .luxe-gallery-skeleton, .hero-image-item.is-loading, .grid-image-item.is-loading { background: #2a2a2a; }
}
