/**
 * ACS Product Gallery Pro Styles
 *
 * Enhanced thumbnail carousel and zoom functionality for WooCommerce.
 *
 * @package ACS_Product_Gallery_Pro
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --acs-gallery-purple: #9333ea;
    --acs-gallery-purple-light: #a855f7;
    --acs-gallery-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --acs-gallery-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.2);
    --acs-gallery-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --acs-gallery-border-radius: 8px;
    --acs-gallery-gap: 12px;
    --acs-thumbnail-size: 80px;
}

/* ==========================================================================
   Enhanced Gallery Wrapper
   ========================================================================== */

.acs-gallery-enhanced {
    position: relative;
}

.acs-gallery-enhanced .woocommerce-product-gallery__wrapper {
    position: relative;
}

/* Main image container - ensure proper sizing */
.acs-gallery-enhanced .woocommerce-product-gallery__image {
    position: relative;
    overflow: hidden;
    border-radius: var(--acs-gallery-border-radius);
}

/* ==========================================================================
   Zoom Hint Overlay
   ========================================================================== */

.acs-zoom-hint {
    position: absolute;
    bottom: 110px;
    /* Raised to avoid overlapping thumbnails */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 26, 0.85);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.9;
    transition: var(--acs-gallery-transition);
    backdrop-filter: blur(8px);
}

.acs-zoom-hint svg {
    flex-shrink: 0;
}

.acs-zoom-hint__desktop {
    display: flex;
    align-items: center;
    gap: 8px;
}

.acs-zoom-hint__mobile {
    display: none;
    align-items: center;
    gap: 8px;
}

/* Show mobile hint on touch devices */
@media (hover: none) and (pointer: coarse) {
    .acs-zoom-hint__desktop {
        display: none;
    }

    .acs-zoom-hint__mobile {
        display: flex;
    }
}

/* Hide hint on hover (user is actively zooming) */
.acs-gallery-enhanced:hover .acs-zoom-hint {
    opacity: 0;
}

/* ==========================================================================
   Thumbnail Carousel Wrapper
   ========================================================================== */

.acs-thumbnail-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-top: 16px;
    padding: 0 40px;
}

/* ==========================================================================
   Navigation Arrows
   ========================================================================== */

.acs-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--acs-gallery-shadow);
    transition: var(--acs-gallery-transition);
    opacity: 0;
    visibility: hidden;
}

.acs-carousel-arrow--prev {
    left: 0;
}

.acs-carousel-arrow--next {
    right: 0;
}

/* Show arrows when carousel has overflow */
.acs-thumbnail-carousel-wrapper.has-overflow .acs-carousel-arrow {
    opacity: 1;
    visibility: visible;
}

/* Arrow hover states */
.acs-carousel-arrow:hover {
    background: var(--acs-gallery-purple);
    border-color: var(--acs-gallery-purple);
    color: #fff;
    box-shadow: var(--acs-gallery-shadow-hover);
    transform: translateY(-50%) scale(1.1);
}

.acs-carousel-arrow:hover svg {
    stroke: #fff;
}

.acs-carousel-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

/* Arrow disabled state (at scroll bounds) */
.acs-carousel-arrow:disabled,
.acs-carousel-arrow.is-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Thumbnail Carousel
   ========================================================================== */

.acs-thumbnail-carousel {
    display: flex;
    gap: var(--acs-gallery-gap);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    padding: 8px 0;
    width: 100%;
}

.acs-thumbnail-carousel::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

/* ==========================================================================
   Individual Thumbnail
   ========================================================================== */

.acs-thumbnail {
    flex-shrink: 0;
    width: var(--acs-thumbnail-size);
    height: var(--acs-thumbnail-size);
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--acs-gallery-border-radius);
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    box-shadow: var(--acs-gallery-shadow);
    transition: var(--acs-gallery-transition);
    position: relative;
}

.acs-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--acs-gallery-transition);
}

/* Thumbnail hover state */
.acs-thumbnail:hover {
    border-color: #444;
    box-shadow: var(--acs-gallery-shadow-hover);
    transform: translateY(-4px);
}

.acs-thumbnail:hover img {
    transform: scale(1.1);
}

/* Active thumbnail state */
.acs-thumbnail--active,
.acs-thumbnail[aria-selected="true"] {
    border-color: #000;
    box-shadow: var(--acs-gallery-shadow);
}

/* Focus state for accessibility */
.acs-thumbnail:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* ==========================================================================
   Zoom Functionality
   ========================================================================== */

/* Zoom lens container */
.acs-zoomable {
    cursor: zoom-in;
}

.acs-gallery-enhanced .woocommerce-product-gallery__image.is-zooming {
    cursor: zoom-out;
}

/* Zoom lens overlay */
.acs-zoom-lens {
    position: absolute;
    border: 2px solid var(--acs-gallery-purple);
    background: rgba(147, 51, 234, 0.1);
    border-radius: 50%;
    width: 150px;
    height: 150px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.acs-gallery-enhanced .woocommerce-product-gallery__image:hover .acs-zoom-lens {
    opacity: 1;
}

/* Zoom result container (for drift-style zoom) */
.acs-zoom-result {
    position: absolute;
    top: 0;
    left: calc(100% + 20px);
    width: 400px;
    height: 400px;
    background-repeat: no-repeat;
    border-radius: var(--acs-gallery-border-radius);
    box-shadow: var(--acs-gallery-shadow-hover);
    opacity: 0;
    visibility: hidden;
    transition: var(--acs-gallery-transition);
    z-index: 1000;
    pointer-events: none;
}

.acs-gallery-enhanced .woocommerce-product-gallery__image:hover .acs-zoom-result {
    opacity: 1;
    visibility: visible;
}

/* Inner zoom (magnify within the image itself) */
.acs-gallery-enhanced .woocommerce-product-gallery__image.acs-inner-zoom img {
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

.acs-gallery-enhanced .woocommerce-product-gallery__image.acs-inner-zoom.is-zooming img {
    transform: scale(2);
}

/* ==========================================================================
   Image Transition Animation
   ========================================================================== */

.acs-gallery-enhanced .woocommerce-product-gallery__image img {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.acs-gallery-enhanced .woocommerce-product-gallery__image.is-transitioning img {
    opacity: 0;
    transform: scale(0.95);
}

/* ==========================================================================
   Full Screen Enhancement
   ========================================================================== */

/* Full screen button overlay */
.acs-fullscreen-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--acs-gallery-shadow);
    transition: var(--acs-gallery-transition);
    backdrop-filter: blur(8px);
}

.acs-fullscreen-btn:hover {
    background: var(--acs-gallery-purple);
    color: #fff;
    transform: scale(1.1);
}

.acs-fullscreen-btn svg {
    transition: stroke 0.3s ease;
}

.acs-fullscreen-btn:hover svg {
    stroke: #fff;
}

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

@media (max-width: 768px) {
    :root {
        --acs-thumbnail-size: 60px;
        --acs-gallery-gap: 8px;
    }

    .acs-thumbnail-carousel-wrapper {
        padding: 0 32px;
        margin-top: 12px;
    }

    .acs-carousel-arrow {
        width: 28px;
        height: 28px;
    }

    .acs-carousel-arrow svg {
        width: 16px;
        height: 16px;
    }

    .acs-zoom-hint {
        font-size: 11px;
        padding: 6px 12px;
    }

    /* Disable hover zoom on mobile - use tap instead */
    .acs-zoom-result {
        display: none;
    }

    .acs-zoom-lens {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --acs-thumbnail-size: 50px;
    }

    .acs-thumbnail-carousel-wrapper {
        padding: 0 28px;
    }
}

/* ==========================================================================
   PhotoSwipe Enhancements
   ========================================================================== */

/* Enhanced PhotoSwipe styling to match theme */
.pswp__bg {
    background: rgba(0, 0, 0, 0.95) !important;
}

.pswp__button--close,
.pswp__button--zoom,
.pswp__button--fs {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-radius: 50%;
    transition: var(--acs-gallery-transition);
}

.pswp__button--close:hover,
.pswp__button--zoom:hover,
.pswp__button--fs:hover {
    background-color: var(--acs-gallery-purple) !important;
}

.pswp__button--arrow--left,
.pswp__button--arrow--right {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-radius: 50%;
    width: 50px !important;
    height: 50px !important;
}

.pswp__button--arrow--left:hover,
.pswp__button--arrow--right:hover {
    background-color: var(--acs-gallery-purple) !important;
}

/* Counter styling */
.pswp__counter {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.acs-thumbnail.is-loading {
    position: relative;
}

.acs-thumbnail.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(147, 51, 234, 0.2);
    border-top-color: var(--acs-gallery-purple);
    border-radius: 50%;
    animation: acs-spinner 0.8s linear infinite;
}

@keyframes acs-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Prefers Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    .acs-thumbnail,
    .acs-carousel-arrow,
    .acs-zoom-hint,
    .acs-fullscreen-btn,
    .acs-thumbnail-carousel {
        transition: none !important;
    }

    .acs-thumbnail-carousel {
        scroll-behavior: auto;
    }

    .acs-thumbnail:hover img {
        transform: none;
    }

    .acs-thumbnail:hover {
        transform: none;
    }
}

/* ==========================================================================
   Restructured Layout (Floating Card Effect)
   ========================================================================== */

/* Center the main product container and create a modern split layout */
@media (min-width: 992px) {
    body.single-product div.product {
        display: flex;
        flex-wrap: wrap;
        /* Allow content to wrap */
        justify-content: center;
        align-items: flex-start;
        gap: 60px;
        max-width: 1400px;
        margin: 40px auto;
        padding: 0 40px;
    }

    body.single-product .woocommerce-product-gallery {
        flex: 1 1 50%;
        /* Adjusted for better spacing */
        max-width: 700px;
        margin-right: 0 !important;
        width: auto !important;
        float: none !important;
    }

    body.single-product .entry-summary {
        flex: 1 1 40%;
        max-width: 500px;
        width: auto !important;
        float: none !important;
        background: #fff;
        padding: 40px;
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
        z-index: 5;
        /* Ensure it stays above other elements if needed */
    }

    /* Force Related Products and Upsells to take full width on a new line */
    body.single-product .related.products,
    body.single-product .upsells.products,
    body.single-product .woocommerce-tabs {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        margin-top: 60px;
        padding-top: 40px;
        border-top: 1px solid #eee;
        clear: both;
    }
}

/* ==========================================================================
   Essential Artwork Info Styling
   ========================================================================== */

.acs-essential-info {
    margin: 32px 0;
    padding: 24px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.acs-info-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.acs-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.acs-info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95em;
    border-bottom: 1px dashed #f0f0f0;
}

.acs-info-item:last-child {
    border-bottom: none;
}

.acs-label {
    color: #666;
    font-weight: 500;
}

.acs-value {
    color: #1a1a1a;
    font-weight: 600;
    text-align: right;
}

/* Description preview within sidebar */
.acs-description-preview {
    margin-top: 20px;
    font-size: 0.95em;
    color: #555;
    line-height: 1.6;
}

/* ==========================================================================
   Shipping & Policies Styling
   ========================================================================== */

.acs-shipping-policies {
    display: grid;
    gap: 16px;
    margin-top: 24px;
    background: #f9fafb;
    padding: 20px;
    border-radius: 12px;
}

.acs-policy-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 0.9em;
    color: #444;
}

.acs-policy-icon {
    flex-shrink: 0;
    color: var(--acs-gallery-purple);
    margin-top: 2px;
}

.acs-policy-item strong {
    color: #1a1a1a;
    display: block;
    margin-bottom: 2px;
}

.acs-policy-item a {
    color: var(--acs-gallery-purple);
    text-decoration: underline;
}

.acs-policy-item a:hover {
    color: var(--acs-gallery-purple-light);
}

/* ==========================================================================
   Related Products Enhancement
   ========================================================================== */

section.related.products {
    max-width: 1400px;
    margin: 60px auto;
    padding: 0 40px;
    clear: both;
}

section.related.products h2 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2em;
}

/* Base product item */
.related.products ul.products li.product {
    position: relative;
    /* Context for overlay and button */
    transition: transform 0.3s ease;
    overflow: hidden;
    /* Ensure overlay stays within bounds */
    border-radius: var(--acs-gallery-border-radius);
    padding-bottom: 0 !important;
    /* Remove any default padding that might affect overlay */
}

.related.products ul.products li.product:hover {
    transform: translateY(-4px);
    box-shadow: var(--acs-gallery-shadow-hover);
}

/* Image Styling */
.related.products ul.products li.product img {
    border-radius: var(--acs-gallery-border-radius);
    box-shadow: var(--acs-gallery-shadow);
    transition: all 0.4s ease;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

/* 1. Transparent White Overlay on Hover */
.related.products ul.products li.product .woocommerce-LoopProduct-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    /* Above image, below button */
    border-radius: var(--acs-gallery-border-radius);
    pointer-events: none;
    /* Let clicks pass through */
}

.related.products ul.products li.product:hover .woocommerce-LoopProduct-link::before {
    opacity: 1;
}

/* 2. Center the CTA Button */
.related.products ul.products li.product .button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Elegant Button Styling */
    background: #000;
    color: #fff;
    border-radius: 30px;
    padding: 10px 24px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-top: 0 !important;
    /* Reset WC default */
    white-space: nowrap;
}

.related.products ul.products li.product:hover .button,
.related.products ul.products li.product:focus-within .button {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    top: 50%;
    /* Ensure it centers vertically relative to the entire card */
}

/* Hide price on hover to keep it clean? Optional, but often looks better */
.related.products ul.products li.product .price {
    transition: opacity 0.3s ease;
}

.related.products ul.products li.product:hover .price {
    opacity: 0.2;
    /* Fade out slightly to focus on button */
}