/**
 * HNMC Gallery Frontend Styles
 * Moderne Galerie-Vorschau und Lightbox
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --hnmc-gallery-radius: 8px;
    --hnmc-gallery-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --hnmc-gallery-shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
    --hnmc-gallery-transition: 0.3s ease;
    --hnmc-gallery-overlay-bg: rgba(0, 0, 0, 0.7);
    --hnmc-gallery-text-color: #ffffff;
    --hnmc-lightbox-bg: rgba(0, 0, 0, 0.95);
}

/* ==========================================================================
   Gallery Container
   ========================================================================== */

.hnmc-gallery-container {
    margin: 1em 0;
    max-width: 100%;
}

/* ==========================================================================
   Gallery Preview (Vorschaubild)
   ========================================================================== */

.hnmc-gallery-preview {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--hnmc-gallery-radius);
    box-shadow: var(--hnmc-gallery-shadow);
    cursor: pointer;
    margin: 0;
    transition: transform var(--hnmc-gallery-transition),
                box-shadow var(--hnmc-gallery-transition);
}

.hnmc-gallery-preview:hover {
    transform: translateY(-3px);
    box-shadow: var(--hnmc-gallery-shadow-hover);
}

.hnmc-gallery-preview:focus {
    outline: 3px solid #0073aa;
    outline-offset: 3px;
}

/* Image Wrapper */
.hnmc-gallery-image-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f0f0f0;
}

.hnmc-gallery-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--hnmc-gallery-transition);
}

.hnmc-gallery-preview:hover .hnmc-gallery-preview-image {
    transform: scale(1.05);
}

/* Overlay */
.hnmc-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 0, 0, 0.4) 60%,
        transparent 100%
    );
    color: var(--hnmc-gallery-text-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: background var(--hnmc-gallery-transition);
}

.hnmc-gallery-preview:hover .hnmc-gallery-overlay {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.6) 60%,
        rgba(0, 0, 0, 0.2) 100%
    );
}

/* Overlay Text */
.hnmc-gallery-overlay-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Bildanzahl */
.hnmc-gallery-image-count {
    font-size: 0.875rem;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.hnmc-gallery-image-count::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h4v4H4V4zm6 0h4v4h-4V4zm6 0h4v4h-4V4zM4 10h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4zM4 16h4v4H4v-4zm6 0h4v4h-4v-4zm6 0h4v4h-4v-4z'/%3E%3C/svg%3E");
    background-size: contain;
    opacity: 0.9;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.hnmc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hnmc-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

/* Backdrop */
.hnmc-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: var(--hnmc-lightbox-bg);
}

/* Container */
.hnmc-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
}

/* Content */
.hnmc-lightbox-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Image */
.hnmc-lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 160px);
    object-fit: contain;
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.hnmc-lightbox-image.is-fading {
    opacity: 0;
}

/* Caption */
.hnmc-lightbox-caption {
    margin-top: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    text-align: center;
    max-width: 600px;
}

/* Loading Spinner */
.hnmc-lightbox-spinner {
    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-color: #fff;
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    animation: hnmc-spin 0.8s linear infinite;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.hnmc-lightbox-content.is-loading .hnmc-lightbox-spinner {
    opacity: 1;
    visibility: visible;
}

@keyframes hnmc-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Counter */
.hnmc-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    backdrop-filter: blur(10px);
}

/* ==========================================================================
   Lightbox Buttons
   ========================================================================== */

.hnmc-lightbox-close,
.hnmc-lightbox-prev,
.hnmc-lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    backdrop-filter: blur(10px);
    transition: background 0.2s ease, transform 0.2s ease;
}

.hnmc-lightbox-close:hover,
.hnmc-lightbox-prev:hover,
.hnmc-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hnmc-lightbox-close:focus,
.hnmc-lightbox-prev:focus,
.hnmc-lightbox-next:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Close Button */
.hnmc-lightbox-close {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    z-index: 10;
}

/* Navigation Buttons */
.hnmc-lightbox-prev,
.hnmc-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 80px;
    font-size: 36px;
    font-weight: 300;
}

.hnmc-lightbox-prev {
    left: 20px;
}

.hnmc-lightbox-next {
    right: 20px;
}

.hnmc-lightbox-prev:hover,
.hnmc-lightbox-next:hover {
    transform: translateY(-50%) scale(1.05);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .hnmc-gallery-overlay-text {
        font-size: 1.1rem;
    }

    .hnmc-gallery-image-count {
        font-size: 0.8rem;
    }

    .hnmc-lightbox-container {
        padding: 50px 15px;
    }

    .hnmc-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .hnmc-lightbox-prev,
    .hnmc-lightbox-next {
        width: 44px;
        height: 60px;
        font-size: 28px;
    }

    .hnmc-lightbox-prev {
        left: 10px;
    }

    .hnmc-lightbox-next {
        right: 10px;
    }

    .hnmc-lightbox-counter {
        bottom: 15px;
        font-size: 0.8rem;
    }

    .hnmc-lightbox-image {
        max-height: calc(100vh - 140px);
    }
}

@media (max-width: 480px) {
    .hnmc-gallery-overlay {
        padding: 1rem;
    }

    .hnmc-gallery-overlay-text {
        font-size: 1rem;
    }

    .hnmc-lightbox-prev,
    .hnmc-lightbox-next {
        display: none;
    }
}

/* ==========================================================================
   Accessibility & Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .hnmc-gallery-preview,
    .hnmc-gallery-preview-image,
    .hnmc-gallery-overlay,
    .hnmc-lightbox,
    .hnmc-lightbox-image,
    .hnmc-lightbox-close,
    .hnmc-lightbox-prev,
    .hnmc-lightbox-next {
        transition: none;
    }

    .hnmc-gallery-preview:hover {
        transform: none;
    }

    .hnmc-gallery-preview:hover .hnmc-gallery-preview-image {
        transform: none;
    }

    .hnmc-lightbox-spinner {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .hnmc-gallery-preview {
        border: 2px solid #000;
    }

    .hnmc-gallery-preview:focus {
        outline: 3px solid #000;
    }

    .hnmc-lightbox-close,
    .hnmc-lightbox-prev,
    .hnmc-lightbox-next {
        border: 2px solid #fff;
    }
}

/* ==========================================================================
   Error State
   ========================================================================== */

.hnmc-gallery-error {
    padding: 1rem;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: var(--hnmc-gallery-radius);
    color: #721c24;
    font-style: normal;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .hnmc-lightbox {
        display: none !important;
    }

    .hnmc-gallery-overlay {
        background: rgba(0, 0, 0, 0.5) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
