/*
 * 3D Image Gallery CSS
 * Based on original gallery with WordPress compatibility
 */

:root {
    /* Use theme CTA color - fallback to default orange */
    --cta-orange: var(--wp--preset--color--cta-orange, #f39c12);
    --cta-orange-glow-1: rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.6);
    --cta-orange-glow-2: rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.3);
    /* Additional glow variations for enhanced effects */
    --cta-orange-glow-3: rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.7);
    --cta-orange-glow-4: rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.5);
    --cta-orange-glow-5: rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.4);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    font-size: 15px;
    overflow-y: scroll;
    background: #f5f5f5;
}

.gallery-3d-wrapper {
    width: 100%;
    position: relative;
    text-align: center;
    padding-top: 0%;
    padding-bottom: 0%;
}

.gallery-3d-wrapper section {
    display: block;
}

.gallery-3d-wrapper a {
    color: #ddd;
    text-decoration: none;
}

.gallery-3d-wrapper .img-wrapper {
    width: 100%;
    height: 440px;
    position: relative;
}

.gallery-3d-wrapper .imgBox {
    width: 400px;
    margin: 0 auto;
    position: relative;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    -ms-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-perspective: 1000px;
    -moz-perspective: 1000px;
    -o-perspective: 1000px;
    -ms-perspective: 1000px;
    perspective: 1000px;
}

.gallery-3d-wrapper .imgBox a {
    width: 400px;
    height: 400px;
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.4s ease, transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, box-shadow, opacity;
    backface-visibility: hidden;
}

.gallery-3d-wrapper .imgBox a:hover {
    box-shadow: 0px 15px 30px rgba(0, 0, 0, 0.4);
}

.gallery-3d-wrapper .imgBox a.bx-animate {
    -webkit-transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -moz-transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -o-transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -ms-transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backface-visibility: hidden;
}

.gallery-3d-wrapper .imgBox a img {
    display: block;
    width: 400px;
    height: 400px;
    object-fit: cover;
}

.gallery-3d-wrapper .imgBox a div {
    text-align: center;
    line-height: 50px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    bottom: 0;
    opacity: 0;
    position: absolute;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 20px 0 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: opacity 0.6s ease;
    will-change: opacity;
}

.gallery-3d-wrapper .imgBox a.dg-center div {
    opacity: 1;
}

/* Arrow hints for side images */
.gallery-3d-wrapper .imgBox a.dg-left::before,
.gallery-3d-wrapper .imgBox a.dg-right::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    font-family: FontAwesome;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.4s ease;
    z-index: 10;
    pointer-events: none;
    will-change: color, font-size;
    backface-visibility: hidden;
}

.gallery-3d-wrapper .imgBox a.dg-left::before {
    content: '\f053';
    left: 20px;
}

.gallery-3d-wrapper .imgBox a.dg-right::before {
    content: '\f054';
    right: 20px;
}

.gallery-3d-wrapper .imgBox a.dg-left:hover::before,
.gallery-3d-wrapper .imgBox a.dg-right:hover::before {
    color: rgba(255, 255, 255, 1);
    font-size: 36px;
    /* Enhanced under-glow effect using theme CTA color */
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 6px 12px var(--cta-orange-glow-3),
        0 10px 20px var(--cta-orange-glow-1),
        0 15px 30px var(--cta-orange-glow-2),
        0 20px 40px var(--cta-orange-glow-4),
        0 25px 50px var(--cta-orange-glow-5);
    /* Enhanced drop-shadow filter using theme CTA color */
    filter: drop-shadow(0 6px 6px var(--cta-orange-glow-1)) drop-shadow(0 12px 12px var(--cta-orange-glow-2)) drop-shadow(0 18px 18px var(--cta-orange-glow-4));
}

/* Navigation buttons - Direct vertical centering */
.gallery-3d-wrapper .img-wrapper {
    position: relative;
}

.gallery-3d-navigation {
    position: absolute;
    top: 200px;
    left: 0;
    width: 100%;
    height: 0;
    pointer-events: none;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    box-sizing: border-box;
}



.gallery-3d-nav {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    color: #333;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000000;
    flex-shrink: 0;
    will-change: transform, background-color, color, box-shadow;
    backface-visibility: hidden;
}

.gallery-3d-nav.prev {
    margin-left: -95px;
}

.gallery-3d-nav.next {
    margin-right: -95px;
}

/* Glow effect when hovering over gallery images - Uses theme CTA color */
.gallery-3d-wrapper .imgBox a:hover ~ .gallery-3d-navigation .gallery-3d-nav {
    background: var(--cta-orange);
    color: white;
    /* Enhanced under-glow effect positioned below the button - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 15px 45px var(--cta-orange-glow-3),
        0 20px 60px var(--cta-orange-glow-1),
        0 25px 75px var(--cta-orange-glow-2),
        0 30px 90px var(--cta-orange-glow-4);
    /* Enhanced drop-shadow filter using theme CTA color */
    filter: drop-shadow(0 15px 12px var(--cta-orange-glow-3)) drop-shadow(0 30px 20px var(--cta-orange-glow-1)) drop-shadow(0 45px 25px var(--cta-orange-glow-2));
}

/* Specific hover effects for side images - Uses theme CTA color */
.gallery-3d-wrapper .imgBox a.dg-left:hover ~ .gallery-3d-navigation .gallery-3d-nav.prev,
.gallery-3d-wrapper .imgBox a.dg-right:hover ~ .gallery-3d-navigation .gallery-3d-nav.next {
    transform: scale(1.05);
    /* Enhanced under-glow effect for side image navigation - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 15px 45px var(--cta-orange-glow-3),
        0 20px 60px var(--cta-orange-glow-1),
        0 25px 75px var(--cta-orange-glow-2),
        0 30px 90px var(--cta-orange-glow-4);
    filter: drop-shadow(0 15px 12px var(--cta-orange-glow-3)) drop-shadow(0 30px 20px var(--cta-orange-glow-1)) drop-shadow(0 45px 25px var(--cta-orange-glow-2));
    background: var(--cta-orange);
    color: white;
}

/* Hover effect for center image - Uses theme CTA color */
.gallery-3d-wrapper .imgBox a.dg-center:hover ~ .gallery-3d-navigation .gallery-3d-nav {
    transform: scale(1.05);
    /* Enhanced under-glow effect for center image navigation - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 15px 45px var(--cta-orange-glow-3),
        0 20px 60px var(--cta-orange-glow-1),
        0 25px 75px var(--cta-orange-glow-2),
        0 30px 90px var(--cta-orange-glow-4);
    filter: drop-shadow(0 15px 12px var(--cta-orange-glow-3)) drop-shadow(0 30px 20px var(--cta-orange-glow-1)) drop-shadow(0 45px 25px var(--cta-orange-glow-2));
    background: var(--cta-orange);
    color: white;
}

.gallery-3d-nav:hover {
    background: var(--cta-orange);
    color: white;
    transform: scale(1.1);
    /* Enhanced under-glow effect for direct button hover - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 10px 30px rgba(0, 0, 0, 0.4),
        0 15px 45px var(--cta-orange-glow-3),
        0 20px 60px var(--cta-orange-glow-1),
        0 25px 75px var(--cta-orange-glow-2),
        0 30px 90px var(--cta-orange-glow-4),
        0 35px 105px var(--cta-orange-glow-5),
        0 40px 120px rgba(var(--wp--preset--color--cta-orange-rgb, 243, 156, 18), 0.3);
    filter: drop-shadow(0 15px 12px var(--cta-orange-glow-3)) drop-shadow(0 30px 20px var(--cta-orange-glow-1)) drop-shadow(0 50px 30px var(--cta-orange-glow-2)) drop-shadow(0 70px 35px var(--cta-orange-glow-4));
}

/* Responsive design */
@media (max-width: 768px) {
    .gallery-3d-wrapper {
        padding-top: 1.5%;
        padding-bottom: 0.5%;
    }

    .gallery-3d-wrapper .img-wrapper {
        height: 600px;
    }

    .gallery-3d-wrapper .imgBox {
        width: 90%;
        max-width: 400px;
    }

    .gallery-3d-wrapper .imgBox a {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .gallery-3d-wrapper {
        padding-top: 1%;
        padding-bottom: 0.5%;
    }

    .gallery-3d-wrapper .img-wrapper {
        height: 500px;
    }

    .gallery-3d-wrapper .imgBox a div {
        font-size: 14px;
        line-height: 40px;
    }
}

/* Loading animation */
.gallery-3d-loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Theme compatibility */
.mediana-clean .gallery-3d-wrapper {
    /* Specific styles for Mediana Clean theme */
    background: transparent;
}

.mediana-clean .gallery-3d-wrapper .imgBox a {
    border-radius: 4px;
}

.mediana-clean .gallery-3d-wrapper .imgBox a div {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
}

/* WordPress admin bar compatibility */
.admin-bar  {
    padding-top: calc(2% + 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .gallery-3d-wrapper {
        padding-top: calc(2% + 46px);
    }
}

/* Gallery 3D Modal Styles - Updated for Theme Consistency */
.gallery-3d-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, visibility;
    backface-visibility: hidden;
}

.gallery-3d-modal-container.gallery-3d-modal-active {
    opacity: 1;
    visibility: visible;
}

.gallery-3d-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 1;
    /* Ensure blur effect is applied to the content behind */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.gallery-3d-modal-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.gallery-3d-modal-display {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    will-change: transform;
    backface-visibility: hidden;
    pointer-events: all;
}

.gallery-3d-modal-container.gallery-3d-modal-active .gallery-3d-modal-display {
    transform: scale(1);
}

.gallery-3d-modal-container.gallery-3d-modal-active {
    /* Enhanced blur effect when modal is active */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.gallery-3d-modal-exit {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    will-change: transform, background-color, color, box-shadow;
    backface-visibility: hidden;
}

.gallery-3d-modal-exit:hover {
    background: var(--cta-orange);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 8px 20px var(--cta-orange-glow-2);
}

.gallery-3d-modal-caption {
    text-align: center;
    line-height: 24px;
    color: #000;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.8));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    padding: 10px 0 5px;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.5);
}

.gallery-3d-modal-picture {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    transition: all 0.3s ease;
    position: relative;
    width: auto;
    height: auto;
}



.gallery-3d-modal-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 -5px;
    pointer-events: none;
    z-index: 4;
}

/* Glow effect when hovering over modal gallery images - Uses theme CTA color */
.gallery-3d-modal-picture:hover ~ .gallery-3d-modal-controls .gallery-3d-modal-button:not(:disabled) {
    /* Enhanced under-glow effect for modal navigation buttons - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 8px 25px rgba(0, 0, 0, 0.4),
        0 12px 35px var(--cta-orange-glow-2),
        0 16px 45px var(--cta-orange-glow-4),
        0 20px 55px var(--cta-orange-glow-5);
    filter: drop-shadow(0 10px 8px var(--cta-orange-glow-2)) drop-shadow(0 20px 15px var(--cta-orange-glow-4));
    background: var(--cta-orange);
    color: white;
}

/* Specific hover effects for modal navigation buttons based on image hover */
.gallery-3d-modal-picture:hover ~ .gallery-3d-modal-controls .gallery-3d-modal-previous,
.gallery-3d-modal-picture:hover ~ .gallery-3d-modal-controls .gallery-3d-modal-next {
    transform: scale(1.05);
}

.gallery-3d-modal-button {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    color: #333;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.4s ease;
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    will-change: transform, background-color, color, box-shadow;
    backface-visibility: hidden;
}

.gallery-3d-modal-button:hover:not(:disabled) {
    background: var(--cta-orange);
    color: white;
    transform: scale(1.1);
    /* Enhanced under-glow effect for modal button direct hover - Uses theme CTA color */
    box-shadow: 
        /* Base shadow for depth */
        0 5px 15px rgba(0, 0, 0, 0.3),
        /* Strong CTA color glow under the button */
        0 8px 25px rgba(0, 0, 0, 0.4),
        0 12px 35px var(--cta-orange-glow-2),
        0 16px 45px var(--cta-orange-glow-4),
        0 20px 55px var(--cta-orange-glow-5);
    filter: drop-shadow(0 10px 8px var(--cta-orange-glow-2)) drop-shadow(0 20px 15px var(--cta-orange-glow-4));
}

.gallery-3d-modal-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gallery-3d-modal-previous {
    margin-left: 16%
}

.gallery-3d-modal-next {
    margin-right: 16%;
}

/* Modal animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes backdropFadeIn {
    from {
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
        background: transparent;
    }
    to {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        background: transparent;
    }
}

.gallery-3d-modal-container.gallery-3d-modal-active {
    animation: backdropFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-3d-modal-container.gallery-3d-modal-active .gallery-3d-modal-display {
    animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modal loading indicator */
.gallery-3d-modal-loading .gallery-3d-modal-picture {
    opacity: 0;
}

.gallery-3d-modal-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--cta-orange);
    border-radius: 50%;
    animation: modalLoadingSpin 1s linear infinite;
    z-index: 1000;
}

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

/* Body scroll lock when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Responsive modal styles */
@media (max-width: 768px) {
    .gallery-3d-modal-display {
        max-width: 98vw;
        max-height: 98vh;
    }

    .gallery-3d-modal-exit {
        width: 35px;
        height: 35px;
        font-size: 1rem;
        top: 15px;
        right: 15px;
    }

    .gallery-3d-modal-picture {
        max-height: 85vh;
    }

    .gallery-3d-modal-caption {
        font-size: 14px;
        line-height: 20px;
        padding: 8px 0 4px;
    }

    .gallery-3d-modal-button {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        z-index: 5;
    }

    .gallery-3d-modal-previous {
        margin-left: -5px;
    }

    .gallery-3d-modal-next {
        margin-right: -5px;
    }

    /* Enhanced mobile backdrop blur */
    .gallery-3d-modal-overlay {
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
}

@media (max-width: 480px) {
    .gallery-3d-modal-display {
        max-width: 99vw;
        max-height: 99vh;
    }

    .gallery-3d-modal-exit {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
        top: 12px;
        right: 12px;
    }

    .gallery-3d-modal-picture {
        max-height: 80vh;
    }

    .gallery-3d-modal-caption {
        font-size: 12px;
        line-height: 18px;
        padding: 6px 0 3px;
    }

    .gallery-3d-modal-button {
        width: 45px;
        height: 45px;
        font-size: 1rem;
        z-index: 5;
    }

    .gallery-3d-modal-previous {
        margin-left: -3px;
    }

    .gallery-3d-modal-next {
        margin-right: -3px;
    }

    .gallery-3d-modal-controls {
        padding: 0 2px;
    }

    /* Enhanced small mobile backdrop blur */
    .gallery-3d-modal-overlay {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
}