/**
 * MetaSlider Lightbox - Public/Frontend Styles
 *
 * All public-facing styles for the MetaSlider Lightbox plugin
 * Combines: icon styles and LightGallery customizations
 */

/* ==========================================================================
   FONT DECLARATIONS
   ========================================================================== */

@font-face {
    font-family: 'lg';
    src: url('https://spinoko-simply.anzmik.com/wp-content/plugins/ml-slider-lightbox/assets/fonts/lg.woff2') format('woff2'),
         url('https://spinoko-simply.anzmik.com/wp-content/plugins/ml-slider-lightbox/assets/fonts/lg.woff') format('woff'),
         url('https://spinoko-simply.anzmik.com/wp-content/plugins/ml-slider-lightbox/assets/fonts/lg.ttf') format('truetype'),
         url('https://spinoko-simply.anzmik.com/wp-content/plugins/ml-slider-lightbox/assets/fonts/lg.svg#lg') format('svg');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   CUSTOM POSITIONING
   ========================================================================== */

.lg-actions .lg-prev {
    left: 20px;
}

.lg-actions .lg-next {
    right: 20px;
}

/* ==========================================================================
   HIDE LIGHTBOX BUTTONS ON UI ELEMENTS
   ========================================================================== */

/* Hide lightbox buttons on MetaSlider thumbnails (backup in case JS cleanup hasn't run yet) */
.flex-control-nav .ml-lightbox-button,
.flex-control-thumbs .ml-lightbox-button {
    display: none !important;
}

/* Hide lightbox buttons on LightGallery UI thumbnails */
.lg-thumb .ml-lightbox-button,
.lg-thumb-item .ml-lightbox-button {
    display: none !important;
}

/* ==========================================================================
   CLOSE BUTTON POSITIONING (PHP will add specific positioning rules)
   ========================================================================== */

/* Default close button positioning */
.lg-toolbar .lg-close {
    position: absolute !important;
    right: 20px !important;
    top: 20px !important;
}

/* Top-left positioning */
.ml-close-top-left .lg-toolbar .lg-close {
    left: 20px !important;
    right: unset !important;
    top: 20px !important;
    bottom: unset !important;
}

.ml-close-top-left .lg-toolbar:has(.lg-counter) {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    position: absolute !important;
    left: 20px !important;
    right: unset !important;
    top: 20px !important;
    bottom: unset !important;
    width: auto !important;
}

.ml-close-top-left .lg-toolbar:has(.lg-counter) .lg-close {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 1 !important;
    margin-right: 10px !important;
}

.ml-close-top-left .lg-toolbar:has(.lg-counter) .lg-counter {
    position: relative !important;
    order: 2 !important;
    padding: 8px 12px !important;
}

/* Bottom-left positioning */
.ml-close-bottom-left .lg-toolbar {
    top: auto !important;
    bottom: 0 !important;
}

.ml-close-bottom-left .lg-toolbar .lg-close {
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    position: relative !important;
    float: left !important;
    margin: 20px !important;
}

.ml-close-bottom-left .lg-toolbar:has(.lg-counter) {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding-left: 20px !important;
    width: 100% !important;
}

.ml-close-bottom-left .lg-toolbar:has(.lg-counter) .lg-close {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 1 !important;
    margin-right: 10px !important;
    float: none !important;
    margin: 0 !important;
}

.ml-close-bottom-left .lg-toolbar:has(.lg-counter) .lg-counter {
    position: relative !important;
    order: 2 !important;
    padding: 8px 12px !important;
}

/* Bottom-right positioning */
.ml-close-bottom-right .lg-toolbar {
    position: absolute !important;
    left: 0 !important;
    top: auto !important;
    width: 100% !important;
    bottom: 0 !important;
}

.ml-close-bottom-right .lg-toolbar .lg-close {
    left: unset !important;
    right: 20px !important;
    top: auto !important;
    bottom: 20px !important;
    position: relative !important;
}

.ml-close-bottom-right .lg-toolbar:has(.lg-counter) {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding-right: 20px !important;
    width: 100% !important;
}

.ml-close-bottom-right .lg-toolbar:has(.lg-counter) .lg-close {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 1 !important;
    margin-left: 10px !important;
}

.ml-close-bottom-right .lg-toolbar:has(.lg-counter) .lg-counter {
    position: relative !important;
    order: 2 !important;
    padding: 8px 12px !important;
}

/* Top-right positioning (default, enhanced) */
.ml-close-top-right .lg-toolbar:has(.lg-counter) {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: flex-start !important;
    position: absolute !important;
    left: unset !important;
    right: 20px !important;
    top: 20px !important;
    bottom: unset !important;
    width: auto !important;
}

.ml-close-top-right .lg-toolbar:has(.lg-counter) .lg-close {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    order: 1 !important;
    margin-left: 10px !important;
}

.ml-close-top-right .lg-toolbar:has(.lg-counter) .lg-counter {
    position: relative !important;
    order: 2 !important;
    padding: 8px 12px !important;
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus states for keyboard navigation */
.lg-outer .lg-close:focus,
.lg-outer .lg-prev:focus,
.lg-outer .lg-next:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .lg-outer .lg-close,
    .lg-outer .lg-prev,
    .lg-outer .lg-next {
        background: rgba(0, 0, 0, 0.9);
        border: 2px solid #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .lg-outer .lg-close,
    .lg-outer .lg-prev,
    .lg-outer .lg-next {
        transition: none;
    }

    .lg-outer .lg-close:hover,
    .lg-outer .lg-prev:hover,
    .lg-outer .lg-next:hover {
        transform: none;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
    .lg-close:after,
    .lg-prev:after,
    .lg-next:after {
        background-size: 18px 18px;
        width: 36px;
        height: 36px;
    }

    .lg-close,
    .lg-prev,
    .lg-next {
        width: 36px;
        height: 36px;
    }
}

/* ==========================================================================
   THUMBNAIL STYLES
   ========================================================================== */
.lg-outer .lg-thumb-item.active, .lg-outer .lg-thumb-item:hover {
    border-color: #000;
}

.lg-thumb-item.active {
    border-color: #ffffff;
    opacity: 1;
}

/* Thumbnail images */
.lg-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

/* Video thumbnail overlay */
.lg-thumb-item[data-video] {
    background: #000;
}

.lg-thumb-item[data-video]:hover::after {
    background: rgba(255, 255, 255, 1);
}

/* Video thumbnail with poster */
.lg-thumb-item[data-video][data-poster] img {
    opacity: 0.8;
}

.lg-thumb-item[data-video][data-poster]:hover img {
    opacity: 1;
}



/* ==========================================================================
   LIGHTBOX BUTTON STYLES
   ========================================================================== */

/* Open in Lightbox button for all slide types */
.ml-lightbox-button,
.widget .ml-lightbox-enabled a.ml-lightbox-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    /* Background and color set by dynamic CSS in PHP */
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    text-decoration: none;
    line-height: 16px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background 0.3s ease;
    font-family: inherit;
    border: none;
    outline: none;
    text-align: center;
    height: auto!important;
}

.ml-lightbox-button:hover {
    /* Background and color set by dynamic CSS in PHP */
    text-decoration: none;
}

.ml-lightbox-button:focus {
    /* Background and color set by dynamic CSS in PHP */
    text-decoration: none;
    outline: 2px solid white;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
}

/* Enhanced focus for keyboard navigation */
.ml-lightbox-button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.4), 0 0 8px rgba(0, 0, 0, 0.5);
}

/* Ensure parent slide is positioned for button placement */
.ml-lightbox-slide {
    position: relative;
}

/* High contrast mode support for lightbox buttons */
@media (prefers-contrast: high) {
    .ml-lightbox-button {
        background: rgba(0, 0, 0, 0.95);
        border: 2px solid #ffffff;
        font-weight: bold;
    }

    .ml-lightbox-button:focus,
    .ml-lightbox-button:focus-visible {
        outline: 4px solid #ffffff;
        outline-offset: 2px;
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.8);
    }
}

/* Reduced motion support for lightbox buttons */
@media (prefers-reduced-motion: reduce) {
    .ml-lightbox-button {
        transition: none;
    }

    .ml-lightbox-button:focus,
    .ml-lightbox-button:focus-visible {
        box-shadow: none;
        outline: 3px solid #ffffff;
    }
}

.lg-container .lg-counter {
	padding: 10px !important;
	border-radius: 0 !important;
}

/* Ensure proper z-index for toolbar elements */
.lg-toolbar {
    z-index: 1083 !important;
}

/* Fallback for browsers without :has() support */
@supports not selector(:has(*)) {
    .lg-toolbar.lg-group {
        display: flex !important;
        align-items: center !important;
    }

    .lg-toolbar.lg-group .lg-counter {
        margin-left: 10px !important;
    }
}

/* ==========================================================================
   METASLIDER INTEGRATION
   ========================================================================== */

/* MetaSlider container with lightbox enabled */
.ml-lightgallery-active {
    position: relative;
}

.ml-lightgallery-active a[data-src] {
    cursor: pointer;
}

.ml-lightgallery-active a[data-src]:hover {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* Loading indicator for images */
.ml-lightgallery-active .lg-loading {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

/* Caption styling */
.lg-sub-html {
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 50%, transparent 100%);
    color: white;
    padding: 20px;
    font-size: 14px;
    line-height: 1.4;
}

.lg-sub-html p {
    margin: 0;
}

/* Layer content in lightbox */
.lightbox-layer-wrapper {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 15px;
}

.lightbox-layer-content {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 4px;
    border-left: 3px solid rgba(255, 255, 255, 0.5);
}

.lightbox-layer-content p {
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.5;
}

.lightbox-layer-content h1,
.lightbox-layer-content h2,
.lightbox-layer-content h3,
.lightbox-layer-content h4,
.lightbox-layer-content h5,
.lightbox-layer-content h6 {
    margin: 8px 0 5px 0;
    color: white;
    font-weight: bold;
}

.lightbox-layer-content strong {
    color: #ffffff;
    font-weight: bold;
}

.lightbox-layer-content em {
    color: #cccccc;
    font-style: italic;
}

.lightbox-layer-content a {
    color: #66b3ff;
    text-decoration: underline;
}

.lightbox-layer-content a:hover {
    color: #99ccff;
}

/* ==========================================================================
   METASLIDER THEMES
   ========================================================================== */

.metaslider.ms-theme-bitono .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-draxler .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-revelio .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-databold .flexslider .slides > li > a.ml-lightbox-button {
	position: absolute;
	z-index: 9999;
}
.metaslider.ms-theme-cubic .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-blend .flexslider .slides > li > a.ml-lightbox-button ,
.metaslider.ms-theme-precognition .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-highway .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-hero .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-revelio .flexslider .slides > li > a.ml-lightbox-button{
    bottom: auto;
    top: 10px;
    z-index: 9999;
}
.metaslider.ms-theme-jenga .flexslider .slides > li > a.ml-lightbox-button,
.metaslider.ms-theme-radix .flexslider .slides > li > a.ml-lightbox-button {
	right: auto;
	left: 15px;
    z-index: 9999;
}

/* Specific positioning for Radix theme with flex-pauseplay */
.metaslider.ms-theme-radix .flex-pauseplay + * .ml-lightbox-button,
.metaslider.ms-theme-radix:has(.flex-pauseplay) .ml-lightbox-button {
    left: 90px!important;
    bottom: 5px;
}

/* Different positioning based on flex-pauseplay content type */
.metaslider.ms-theme-radix.ml-radix-icon-only .ml-lightbox-button {
    left: 60px!important;
    bottom: 5px;
}

.metaslider.ms-theme-radix.ml-radix-with-text .ml-lightbox-button {
    left: 100px!important;
    bottom: 5px;
}
.metaslider.ms-theme-disjoint .flexslider .slides > li > a.ml-lightbox-button {
    bottom: auto;
	right: auto;
	left: 15px;
    top: 10px;
    z-index: 9999;
}
.filmstrip .ms-thumb .ml-lightbox-button{
    display: none;
}

@media (max-width: 768px) {
    .metaslider.ms-theme-bitono .flexslider .slides > li > a.ml-lightbox-button,
    .metaslider.ms-theme-bubble .flexslider .slides > li > a.ml-lightbox-button {
        bottom: auto;
        top: 10px;
    }
    .metaslider.ms-theme-highway .flexslider .slides > li > a.ml-lightbox-button{
        bottom: 10px;
        top: auto;
    }
    .ms-is-small.metaslider.ms-theme-highway .flexslider ol.flex-control-nav:not(.flex-control-thumbs) {
        width: 60%;
    }
    .ms-is-small.metaslider.ms-theme-highway .flexslider:not(.filmstrip) ul.flex-direction-nav {
        top: 20%;
    }
    .metaslider.ms-theme-highway .flexslider:not(.filmstrip) ul.flex-direction-nav {
        height: 30%;
    }
    .metaslider.ms-theme-radix .flex-pauseplay + * .ml-lightbox-button, .metaslider.ms-theme-radix:has(.flex-pauseplay) .ml-lightbox-button {
        left: 80px!important;
        font-size: 11px;
    }
    .lightbox-layer-content span {
        font-size: 21px !important;
    }
}

/* ==========================================================================
   COLOR CUSTOMIZATION VARIABLES
   ========================================================================== */

:root {
    --ml-lightbox-bg-color: rgba(0, 0, 0, 0.5);
    --ml-lightbox-bg-hover-color: rgba(0, 0, 0, 0.8);
    --ml-lightbox-border-radius: 6px;
    --ml-lightbox-transition: all 0.2s ease;
}

/* ==========================================================================
   CUSTOM HTML RESPONSIVE STYLES
   ========================================================================== */

/* MetaSlider Custom HTML content wrapper in lightbox */
.ml-custom-html-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* MetaSlider Custom HTML content container */
.ml-custom-html-content {
    background: #ffffff;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 90vw;
    max-height: 80vh;
    overflow: auto;
    word-wrap: break-word;
    box-sizing: border-box;
}

/* Responsive typography for Custom HTML content */
.ml-custom-html-content h1,
.ml-custom-html-content h2,
.ml-custom-html-content h3 {
    margin-top: 0;
    margin-bottom: 1em;
    line-height: 1.2;
}

.ml-custom-html-content p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.ml-custom-html-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.ml-custom-html-content video {
    max-width: 100%;
    height: auto;
}

/* Responsive breakpoints for Custom HTML */
@media (max-width: 768px) {
    .ml-custom-html-wrapper {
        padding: 20px 10px;
    }

    .ml-custom-html-content {
        padding: 20px;
        max-width: 95vw;
        max-height: 85vh;
        font-size: 14px;
    }

    .ml-custom-html-content h1 {
        font-size: 1.5em;
    }

    .ml-custom-html-content h2 {
        font-size: 1.3em;
    }

    .ml-custom-html-content h3 {
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    .ml-custom-html-wrapper {
        padding: 15px 5px;
    }

    .ml-custom-html-content {
        padding: 15px;
        max-width: 98vw;
        max-height: 90vh;
        font-size: 13px;
    }
}

/* ==========================================================================
   LIGHTBOX OVERLAY STYLES
   ========================================================================== */

/* Base overlay styles for direct-click mode */
.ml-video-overlay,
.ml-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.05);
    z-index: 2;
    cursor: pointer;
    display: block;
    text-decoration: none;
    transition: background 0.2s ease;
}

.ml-video-overlay:hover,
.ml-image-overlay:hover {
    background: rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.ml-lightbox-enabled {
	cursor: pointer;
}
img.ml-lightbox-enabled {
	cursor: default;
}
.ml-lightbox-enabled:has(.ml-lightbox-button) {
	cursor: default !important;
}

/* Disabled container styling when lightbox button is present */
.ml-lightbox-container-disabled {
    cursor: default !important;
    text-decoration: none !important;
    color: inherit !important;
}

.ml-lightbox-container-disabled:hover {
    text-decoration: none !important;
    color: inherit !important;
}

/* Visual indicator for containers with lightbox buttons */
.ml-has-lightbox-button {
    position: relative;
}

/* Focus states for accessibility */
.ml-video-overlay:focus,
.ml-image-overlay:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ml-video-overlay,
    .ml-image-overlay {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.5);
    }

    .ml-video-overlay:hover,
    .ml-image-overlay:hover {
        background: rgba(0, 0, 0, 0.3);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ml-video-overlay,
    .ml-image-overlay {
        transition: none;
    }
}

/* ==========================================================================
   VIDEO LIGHTBOX STYLES
   ========================================================================== */

/* Only fix specific issues without overriding WordPress video sizing */
.wp-block-embed .wp-block-embed__wrapper {
    position: relative !important;
    overflow: visible !important;
}

/* Ensure WordPress embed wrapper with lightbox maintains proper structure */
.wp-block-embed .wp-block-embed__wrapper.ml-lightbox-enabled {
    position: relative !important;
}

/* Only fix videos that have max-height: 0 issue */
.wp-block-embed iframe[style*="max-height: 0"],
.wp-block-embed iframe[style*="max-height:0"],
.wp-block-embed iframe[style*="max-height: 0px"],
.wp-block-embed iframe[style*="max-height:0px"] {
    max-height: none !important;
    height: auto !important;
}

/* WordPress video block positioning for lightbox overlay */
.wp-block-video {
    position: relative;
}

.wp-block-video video {
    position: relative;
    z-index: 1;
}

.lg-initialized.wp-lightbox-container img {
	cursor: default;
}

/* ==========================================================================
   LIGHTGALLERY LAYOUT AND PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Prevent layout shifts during loading */
.lg-outer .lg-item {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lg-outer .lg-item img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
}

/* Adjust image height when thumbnails are visible */
.lg-outer.lg-thumbnail .lg-item img {
    max-height: calc(100vh - 160px);
}

/* Smooth fade transitions */
.lg-outer .lg-item {
    transition: opacity 0.3s ease-in-out;
}

/* Layer slides styling for direct-click mode */
.lg-outer .lg-item .ms-layer .msDefaultImage {
    width: 1400px !important;
    height: 600px !important;
    max-width: 80% !important;
    margin: 0 auto !important;
    object-fit: cover !important;
}

.lg-outer .lg-item .ms-layer .msHtmlOverlay {
    position: absolute !important;
    top: 0 !important;
    left: 50% !important;
    width: 80% !important;
    height: 100% !important;
    transform: translateX(-50%) !important;
}

.lg-outer .lg-item .ms-layer .msHtmlOverlay .content {
    font-size: 1.8em !important;
    line-height: 1.2 !important;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.ml-lightbox-fade-in {
    animation: ml-lightbox-fadeIn 0.3s ease-in-out;
}

@keyframes ml-lightbox-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ml-lightbox-hidden {
    display: none !important;
}

.ml-lightbox-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .lg-outer,
    .lg-backdrop {
        display: none !important;
    }
}