/**
 * Rollpix ProductGallery - Vertical Layout Styles
 *
 * @category  Rollpix
 * @package   Rollpix_ProductGallery
 */

/* ==============================================
   CSS Variables (defaults - overridden by config)
   ============================================== */

.rp-product-wrapper {
    --rp-col-1: 1fr;
    --rp-col-2: 1fr;
    --rp-gallery-order: 1;
    --rp-info-order: 2;
    --rp-sticky-offset: 20px;
    --rp-image-gap: 20px;
}

/* ==============================================
   Desktop: Grid Layout with CSS Variables
   ============================================== */

.rp-product-wrapper {
    display: grid;
    grid-template-columns: var(--rp-col-1) var(--rp-col-2);
    gap: 40px;
    align-items: start;
    margin-bottom: 40px;
}

/* Gallery column */
.rp-product-gallery {
    order: var(--rp-gallery-order);
}

.rp-gallery-images {
    display: flex;
    flex-direction: column;
    gap: var(--rp-image-gap);
}

.rp-gallery-item {
    display: block;
    position: relative;
    overflow: visible;
    border-radius: 4px;
    line-height: 0;
}

.rp-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    object-fit: cover;
}

/* Disable hover scale when zoom is active */
.rp-zoom-hover .rp-gallery-item:hover img {
    transform: none;
}

.rp-gallery-item:focus {
    outline: 2px solid #1979c3;
    outline-offset: 2px;
}

/* Product info column - sticky */
.rp-product-wrapper .product-info-main {
    order: var(--rp-info-order);
    position: sticky;
    top: var(--rp-sticky-offset);
    align-self: start;
    max-height: calc(100vh - var(--rp-sticky-offset) - 20px);
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}

/* Reset Luma's default width restrictions */
.catalog-product-view.page-layout-1column .rp-product-wrapper .product-info-main,
.catalog-product-view .rp-product-wrapper .product-info-main {
    width: 100%;
    float: none;
    padding-left: 0;
}

/* Hide original Fotorama gallery elements */
.catalog-product-view .gallery-placeholder,
.catalog-product-view .fotorama-item,
.catalog-product-view [data-gallery-role="gallery-placeholder"],
.catalog-product-view .product.media {
    display: none !important;
}

/* ==============================================
   Hover Zoom Styles
   ============================================== */

/* Zoom wrapper - contains item and result */
.rp-zoom-wrapper {
    position: relative;
    display: block;
}

/* Gallery item when zoom is enabled */
.rp-zoom-hover .rp-gallery-item {
    cursor: crosshair;
    overflow: visible;
}

/* Zoom Lens */
.rp-zoom-lens {
    position: absolute;
    border: 2px solid rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
}

.rp-zoom-lens.active {
    opacity: 1;
    visibility: visible;
}

/* Zoom Result */
.rp-zoom-result {
    background-repeat: no-repeat;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.rp-zoom-result.active {
    opacity: 1;
    visibility: visible;
}

/* Zoom result - right side position */
.rp-zoom-result-right {
    position: absolute;
    left: calc(100% + 20px);
    top: 0;
}

/* Zoom result - inside image */
.rp-zoom-result-inside {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: none;
    box-shadow: none;
    border-radius: 4px;
}

/* Disable hover effects on disabled mode */
.rp-zoom-disabled .rp-gallery-item {
    cursor: default;
}

.rp-zoom-disabled .rp-gallery-item:hover img {
    transform: none;
}

/* Lightbox mode cursor */
.rp-zoom-lightbox .rp-gallery-item {
    cursor: zoom-in;
}

.rp-zoom-lightbox .rp-gallery-item:hover img {
    transform: scale(1.02);
}

/* ==============================================
   Mobile: Vertical Stack Layout
   ============================================== */

@media screen and (max-width: 767px) {
    .rp-product-wrapper {
        display: flex;
        flex-direction: column;
        gap: 20px;
        margin-bottom: 20px;
    }

    .rp-product-gallery {
        order: 1 !important;
        width: 100%;
    }

    .rp-product-wrapper .product-info-main {
        order: 2 !important;
        position: static !important;
        max-height: none;
        overflow-y: visible;
        width: 100%;
    }

    .rp-gallery-images {
        gap: 10px;
    }

    .rp-gallery-item {
        border-radius: 0;
    }

    .rp-gallery-item:hover img {
        transform: none;
    }

    /* Hide zoom elements on mobile */
    .rp-zoom-lens,
    .rp-zoom-result {
        display: none !important;
    }
}

/* ==============================================
   Mobile Carousel Styles
   ============================================== */

.rp-carousel-active .rp-carousel-wrapper {
    overflow: hidden;
    position: relative;
}

.rp-carousel-track {
    display: flex;
    transition: transform 0.3s ease;
    touch-action: pan-y pinch-zoom;
}

.rp-carousel-slide {
    flex: 0 0 100%;
    width: 100%;
}

.rp-carousel-slide img {
    width: 100%;
    height: auto;
}

/* Carousel Indicators */
.rp-carousel-indicators {
    display: none;
    justify-content: center;
    gap: 8px;
    padding: 15px 0;
}

.rp-carousel-active .rp-carousel-indicators {
    display: flex;
}

.rp-carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #ccc;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.rp-carousel-dot:hover {
    background: #999;
}

.rp-carousel-dot.active {
    background: #333;
    transform: scale(1.2);
}

/* Stack mode (non-carousel) on mobile */
@media screen and (max-width: 767px) {
    .rp-mobile-stack .rp-gallery-images {
        display: flex;
        flex-direction: column;
    }

    .rp-mobile-stack .rp-carousel-indicators {
        display: none;
    }
}

/* ==============================================
   GLightbox Customizations
   ============================================== */

.glightbox-container .gslide-description {
    background: rgba(0, 0, 0, 0.75);
}

.glightbox-container .gslide-title {
    color: #fff;
    font-size: 14px;
    font-weight: 400;
}

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

@media (prefers-reduced-motion: reduce) {
    .rp-gallery-item img {
        transition: none;
    }

    .rp-gallery-item:hover img {
        transform: none;
    }

    .rp-carousel-track {
        transition: none;
    }

    .rp-carousel-dot {
        transition: none;
    }

    .rp-zoom-lens,
    .rp-zoom-result {
        transition: none;
    }
}

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

@media print {
    .rp-product-wrapper {
        display: block;
    }

    .rp-product-gallery {
        page-break-after: always;
    }

    .rp-product-wrapper .product-info-main {
        position: static;
    }

    .rp-carousel-indicators,
    .rp-zoom-lens,
    .rp-zoom-result {
        display: none;
    }
}
