/**
 * CM Lightbox Frontend Styles
 *
 * Custom styles for CM Lightbox plugin to enhance Fancybox
 * with WordPress-specific styling and responsive improvements.
 *
 * @package CmLightbox
 * @since 1.0.0
 */

/* ==========================================================================
   WordPress Gallery Integration
   ========================================================================== */

/**
 * Gallery container styling
 */
.gallery {
    position: relative;
}

/**
 * Gallery items with lightbox
 */
.gallery a[data-fancybox] {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border-radius: 4px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery a[data-fancybox]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/**
 * Gallery images
 */
.gallery a[data-fancybox] img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s ease;
}

.gallery a[data-fancybox]:hover img {
    opacity: 0.9;
}

/**
 * Lightbox indicator overlay
 */
.gallery a[data-fancybox]:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.gallery a[data-fancybox]:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9 3v6L5 5l4-2zm3 9V3l8 5-8 5zm3 9V12l8 5-8 5z"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
}

.gallery a[data-fancybox]:hover:before,
.gallery a[data-fancybox]:hover:after {
    opacity: 1;
}

/* ==========================================================================
   Video Links
   ========================================================================== */

/**
 * Video link indicators
 */
a[data-fancybox][data-type="iframe"] {
    position: relative;
    display: inline-block;
}

a[data-fancybox][data-type="iframe"]:before {
    content: '▶';
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
    border-radius: 0 0 0 4px;
    z-index: 2;
}

/**
 * YouTube link styling
 */
a[href*="youtube.com"][data-fancybox]:before,
a[href*="youtu.be"][data-fancybox]:before {
    background: #ff0000;
}

/**
 * Vimeo link styling
 */
a[href*="vimeo.com"][data-fancybox]:before {
    background: #1ab7ea;
}

/* ==========================================================================
   Custom Elements
   ========================================================================== */

/**
 * Elements with cm-lightbox class
 */
.cm-lightbox {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.cm-lightbox:hover {
    opacity: 0.8;
}

/**
 * Disabled lightbox elements
 */
.cm-no-lightbox,
.cm-no-lightbox * {
    cursor: default !important;
}

/* ==========================================================================
   Fancybox Customizations
   ========================================================================== */

/**
 * Custom toolbar styling
 */
.fancybox__toolbar {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

/**
 * Custom button styling
 */
.fancybox__button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.fancybox__button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/**
 * Custom navigation arrows
 */
.fancybox__nav .fancybox__button {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
}

.fancybox__nav .fancybox__button:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/**
 * Loading spinner customization
 */
.fancybox__spinner {
    border-color: #007cba transparent #007cba transparent;
}

/**
 * Caption styling
 */
.fancybox__caption {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 30px 20px 20px;
    font-size: 14px;
    line-height: 1.4;
}

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

@media (max-width: 768px) {
    /**
     * Mobile gallery adjustments
     */
    .gallery a[data-fancybox]:before {
        width: 40px;
        height: 40px;
        margin: -20px 0 0 -20px;
    }

    .gallery a[data-fancybox]:after {
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
    }

    /**
     * Mobile fancybox adjustments
     */
    .fancybox__nav .fancybox__button {
        width: 50px;
        height: 50px;
    }

    .fancybox__caption {
        font-size: 13px;
        padding: 20px 15px 15px;
    }

    /**
     * Mobile toolbar
     */
    .fancybox__toolbar {
        padding: 8px;
    }

    .fancybox__button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    /**
     * Small mobile adjustments
     */
    .fancybox__caption {
        font-size: 12px;
        padding: 15px 10px 10px;
    }

    .fancybox__toolbar {
        padding: 5px;
    }

    .fancybox__button {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/**
 * Focus states for keyboard navigation
 */
.gallery a[data-fancybox]:focus,
.cm-lightbox:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/**
 * Reduced motion support
 */
@media (prefers-reduced-motion: reduce) {
    .gallery a[data-fancybox],
    .gallery a[data-fancybox] img,
    .gallery a[data-fancybox]:before,
    .gallery a[data-fancybox]:after,
    .cm-lightbox,
    .fancybox__button,
    .fancybox__nav .fancybox__button {
        transition: none;
    }

    .gallery a[data-fancybox]:hover {
        transform: none;
    }

    .fancybox__nav .fancybox__button:hover {
        transform: none;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
    .gallery a[data-fancybox]:before {
        background: rgba(0, 0, 0, 0.9);
    }

    .fancybox__toolbar {
        background: rgba(0, 0, 0, 0.95);
    }

    .fancybox__button {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.5);
    }
}

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

@media print {
    .gallery a[data-fancybox]:before,
    .gallery a[data-fancybox]:after,
    a[data-fancybox][data-type="iframe"]:before {
        display: none;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .gallery a[data-fancybox]:after {
    transform: scaleX(-1);
}

[dir="rtl"] a[data-fancybox][data-type="iframe"]:before {
    left: 0;
    right: auto;
    border-radius: 0 0 4px 0;
}