/**
 * Gallery Lightbox CSS - SmartHome & IT-Service Schulzendorf
 * Barrierefreies, responsives Modal-Overlay mit Gestensteuerung,
 * Thumbnail-Vorschauleiste, Bild-Captions und Vollbild-Modus.
 */

/* ==========================================================================
   1. Trigger & Interaktions-Styles (Praxis & Leistungen)
   ========================================================================== */
.praxis-card.js-gallery-trigger {
    cursor: pointer;
    outline: none;
}

.praxis-card.js-gallery-trigger:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-teal, #5DBCC3), 0 8px 24px rgba(0, 0, 0, 0.15);
}

.praxis-card.js-gallery-trigger .praxis-image {
    position: relative;
    overflow: hidden;
}

.praxis-card.js-gallery-trigger .praxis-image img {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.praxis-card.js-gallery-trigger:hover .praxis-image img {
    transform: scale(1.05);
}

.praxis-gallery-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    opacity: 0.85;
    transition: all 0.25s ease;
    pointer-events: none;
}

.praxis-gallery-badge svg {
    stroke: currentColor !important;
    fill: none !important;
}

.praxis-card.js-gallery-trigger:hover .praxis-gallery-badge,
.praxis-card.js-gallery-trigger:focus-visible .praxis-gallery-badge {
    background: var(--primary-teal, #5DBCC3);
    color: #ffffff;
    opacity: 1;
    transform: scale(1.1);
}

/* Service-Icon Trigger */
.service-icon.js-gallery-trigger {
    cursor: pointer;
    position: relative;
    outline: none;
    transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.service-icon.js-gallery-trigger:focus-visible {
    box-shadow: 0 0 0 3px var(--primary-teal, #5DBCC3), 0 6px 20px rgba(93, 188, 195, 0.4);
}

.service-icon-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--primary-teal, #5DBCC3);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--light-teal, #B8E5E8);
    pointer-events: none;
    transition: transform 0.25s ease, background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.service-icon-badge svg {
    width: 12px !important;
    height: 12px !important;
    stroke: currentColor !important;
    fill: none !important;
}

.service-card:hover .service-icon-badge,
.service-icon.js-gallery-trigger:hover .service-icon-badge,
.service-icon.js-gallery-trigger:focus-visible .service-icon-badge {
    background: var(--dark-gray, #2c3e50);
    color: #ffffff;
    border-color: #ffffff;
    transform: scale(1.15);
}

.service-card:hover .service-icon-badge svg,
.service-icon.js-gallery-trigger:hover .service-icon-badge svg,
.service-icon.js-gallery-trigger:focus-visible .service-icon-badge svg {
    stroke: #ffffff !important;
    fill: none !important;
}

/* ==========================================================================
   2. Lightbox Modal Overlay
   ========================================================================== */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(12, 18, 28, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    user-select: none;
    touch-action: pan-y;
}

.gallery-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Header */
.gallery-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    color: #ffffff;
    z-index: 20;
    background: linear-gradient(180deg, rgba(12, 18, 28, 0.8) 0%, rgba(12, 18, 28, 0) 100%);
}

.gallery-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.gallery-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-counter {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.85rem;
    font-weight: 500;
    color: #d1d5db;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Header Action Buttons (Fullscreen & Close) */
.gallery-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.gallery-btn-action,
.gallery-btn-close {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
    flex-shrink: 0;
}

.gallery-btn-action svg,
.gallery-btn-close svg {
    stroke: currentColor !important;
    fill: none !important;
}

.gallery-btn-action:hover,
.gallery-btn-action:focus-visible,
.gallery-btn-close:hover,
.gallery-btn-close:focus-visible {
    background: var(--primary-teal, #5DBCC3);
    border-color: var(--primary-teal, #5DBCC3);
    color: #ffffff;
    transform: scale(1.08);
}

.gallery-btn-action:focus-visible,
.gallery-btn-close:focus-visible {
    box-shadow: 0 0 0 3px rgba(93, 188, 195, 0.5);
}

/* Stage / Viewport */
.gallery-stage {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0 clamp(16px, 3vw, 40px);
}

.gallery-viewport {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.gallery-image-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.gallery-image {
    max-width: 90vw;
    max-height: calc(85vh - 180px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 42px rgba(0, 0, 0, 0.55);
    transition: opacity 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 1;
    transform: scale(1) translateX(0);
}

.gallery-image.is-loading {
    opacity: 0.2;
    transform: scale(0.98);
}

/* Directional Slide-Transitions */
.gallery-image.is-anim-out-next {
    opacity: 0;
    transform: translateX(-32px) scale(0.97);
}

.gallery-image.is-anim-out-prev {
    opacity: 0;
    transform: translateX(32px) scale(0.97);
}

.gallery-image.is-anim-in-next {
    transform: translateX(32px) scale(0.97);
}

.gallery-image.is-anim-in-prev {
    transform: translateX(-32px) scale(0.97);
}

/* Image Caption */
.gallery-caption {
    margin-top: 10px;
    padding: 6px 18px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.25px;
    text-align: center;
    max-width: 90vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.gallery-caption:empty {
    display: none;
}

/* Navigation Buttons (Fitts's Law Optimized) */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.gallery-nav-btn svg {
    stroke: currentColor !important;
    fill: none !important;
}

.gallery-nav-btn.btn-prev {
    left: clamp(14px, 3.5vw, 44px);
}

.gallery-nav-btn.btn-next {
    right: clamp(14px, 3.5vw, 44px);
}

.gallery-nav-btn:hover,
.gallery-nav-btn:focus-visible {
    background: var(--primary-teal, #5DBCC3);
    border-color: var(--primary-teal, #5DBCC3);
    color: #ffffff;
    transform: translateY(-50%) scale(1.12);
}

.gallery-nav-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(93, 188, 195, 0.6);
}

/* Thumbnail-Vorschauleiste */
.gallery-thumbnails-wrapper {
    position: relative;
    padding: 6px 16px 2px 16px;
    z-index: 15;
    background: linear-gradient(0deg, rgba(12, 18, 28, 0.85) 0%, rgba(12, 18, 28, 0) 100%);
}

.gallery-thumbnails {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 100%;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

.gallery-thumb-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 2px solid transparent;
    padding: 0;
    margin: 0;
    background: #000000;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.gallery-thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.gallery-thumb-btn:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.gallery-thumb-btn.is-active {
    opacity: 1;
    border-color: var(--primary-teal, #5DBCC3);
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(93, 188, 195, 0.6);
}

.gallery-thumb-btn:focus-visible {
    box-shadow: 0 0 0 2px #ffffff, 0 0 12px rgba(93, 188, 195, 0.8);
    opacity: 1;
}

/* Footer / Keyboard Hint */
.gallery-lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 24px 14px 24px;
    color: #9ca3af;
    font-size: 0.82rem;
    z-index: 10;
}

.gallery-keyboard-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gallery-key {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e5e7eb;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 600;
}

/* Spinner */
.gallery-spinner {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-teal, #5DBCC3);
    border-radius: 50%;
    animation: gallerySpin 0.7s linear infinite;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.gallery-spinner.is-active {
    opacity: 1;
}

@keyframes gallerySpin {
    to { transform: rotate(360deg); }
}

/* Responsive Anpassungen */
@media (max-width: 768px) {
    .gallery-lightbox-header {
        padding: 12px 16px;
    }

    .gallery-title {
        font-size: 1rem;
    }

    .gallery-btn-action,
    .gallery-btn-close {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .gallery-nav-btn {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .gallery-nav-btn.btn-prev {
        left: 8px;
    }

    .gallery-nav-btn.btn-next {
        right: 8px;
    }

    .gallery-thumb-btn {
        width: 46px;
        height: 46px;
    }

    .gallery-thumbnails {
        justify-content: flex-start;
        padding: 2px 8px;
    }

    .gallery-caption {
        font-size: 0.82rem;
        padding: 4px 12px;
        max-width: 94vw;
    }

    .gallery-keyboard-hint {
        display: none;
    }

    .gallery-image {
        max-width: 95vw;
        max-height: calc(85vh - 160px);
    }
}
