/**
 * ProductCarousel Block Styles
 *
 * @package RdiCore\Acf\Blocks\ProductCarousel
 */

.product-carousel-block {
    position: relative;
    width: 100%;
}

/**
 * Pre-initialization styles to prevent layout shift (CLS)
 * These styles constrain the carousel before Splide loads,
 * showing only the visible slides based on perPage settings.
 */
.product-carousel-block:not(.is-initialized) .pc-splide-main {
    overflow: hidden;
}

.product-carousel-block:not(.is-initialized) .splide__list {
    flex-wrap: nowrap;
}

.product-carousel-block:not(.is-initialized) .splide__slide {

    /* Desktop: Show 4 slides (25% each with gap consideration) */
    min-width: calc((100% - 90px) / 4);
    max-width: calc((100% - 90px) / 4);
}

@media (max-width: 1200px) {
    .product-carousel-block:not(.is-initialized) .splide__slide {

        /* Show 3 slides */
        min-width: calc((100% - 48px) / 3);
        max-width: calc((100% - 48px) / 3);
    }
}

@media (max-width: 992px) {
    .product-carousel-block:not(.is-initialized) .splide__slide {

        /* Tablet: Show 2 slides */
        min-width: calc((100% - 20px) / 2);
        max-width: calc((100% - 20px) / 2);
    }
}

@media (max-width: 576px) {
    .product-carousel-block:not(.is-initialized) .splide__slide {
        
        /* Mobile: Show 1 slide */
        min-width: 100%;
        max-width: 100%;
    }
}

.product-carousel-block.alignwide {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.product-carousel-block.alignfull {
    width: 100%;
    max-width: none;
}

/* Container */
.pc-container {
    position: relative;
}

/* Main Slider */
.pc-main-slider {
    position: relative;
}

.pc-splide-main {
    overflow: hidden;
}

.pc-splide-main .splide__track {
    overflow: visible;
}

.pc-splide-main .splide__list {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pc-splide-main .splide__slide {
    flex-shrink: 0;
}

/* Product Card */
.pc-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pc-product-gallery a {
    display: block;
    width: 100%;
    height: 100%;
}

.pc-product-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border-radius: 0;
}

/* Product Badge */
.pc-product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.pc-product-badge .product-badge-display-shortcode,
.pc-product-badge .listing-card__badge {
    display: inline-block;
}

/* Product Excerpt */
.pc-product-excerpt {
    margin-bottom: 16px;
    font-size: var(--wp--preset--font-size--small);
    line-height: 1.5;
    color: #666;
}

.pc-product-excerpt p {
    margin: 0;
}

/* Product Tags */
.pc-product-tags {
    margin-top: auto;
    padding-top: 12px;
}

/* Header with Arrows */
.pc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body h2.pc-header-text {
    margin: 0;
}

@media (max-width: 767px) {
    body h2.pc-header-text {
        margin-bottom: 20px;
    }
}

/* Slider Arrows */
.pc-slider-arrows {
    display: flex;
    gap: 8px;
    margin-bottom: var(--wp--preset--spacing--lg);
}

@media screen and (min-width: 768px) {
    .pc-header-text + .pc-slider-arrows {
        margin-bottom: 0;
    }
}

.pc-slider-arrows .splide__arrow {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    padding: 0;
    background: transparent;
    border-color: var(--global-palette1);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 1;
    transform: none;
}

.pc-slider-arrows .splide__arrow:hover {
    background-color: var(--global-palette1);
}

.pc-slider-arrows .splide__arrow svg {
    display: none;
}

.pc-slider-arrows .splide__arrow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 16px;
}

.pc-slider-arrows .splide__arrow--prev::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='16' viewBox='0 0 18 16' fill='none'%3E%3Cpath d='M1.3125 7.28125L6.3125 2.28125L7 1.59375L8.4375 3C8.375 3.03125 7.0625 4.375 4.4375 7H17V9H4.4375C7.0625 11.625 8.375 12.9688 8.4375 13L7 14.4062L6.3125 13.7188L1.3125 8.71875L0.59375 8L1.3125 7.28125Z' fill='%23254749'/%3E%3C/svg%3E");
}

.pc-slider-arrows .splide__arrow--prev:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='16' viewBox='0 0 18 16' fill='none'%3E%3Cpath d='M1.3125 7.28125L6.3125 2.28125L7 1.59375L8.4375 3C8.375 3.03125 7.0625 4.375 4.4375 7H17V9H4.4375C7.0625 11.625 8.375 12.9688 8.4375 13L7 14.4062L6.3125 13.7188L1.3125 8.71875L0.59375 8L1.3125 7.28125Z' fill='%23fff'/%3E%3C/svg%3E")
}

.pc-slider-arrows .splide__arrow--next::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='13' viewBox='0 0 17 13' fill='none'%3E%3Cpath d='M15.7188 7.125L10.7188 12.125L10 12.8125L8.59375 11.4062C8.625 11.375 9.96875 10.0312 12.5938 7.40625H0V5.40625H12.5938C9.96875 2.78125 8.625 1.4375 8.59375 1.40625L10 0L10.7188 0.6875L15.7188 5.6875L16.4375 6.40625L15.7188 7.125Z' fill='%23254749'/%3E%3C/svg%3E");
}

.pc-slider-arrows .splide__arrow--next:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='13' viewBox='0 0 17 13' fill='none'%3E%3Cpath d='M15.7188 7.125L10.7188 12.125L10 12.8125L8.59375 11.4062C8.625 11.375 9.96875 10.0312 12.5938 7.40625H0V5.40625H12.5938C9.96875 2.78125 8.625 1.4375 8.59375 1.40625L10 0L10.7188 0.6875L15.7188 5.6875L16.4375 6.40625L15.7188 7.125Z' fill='%23fff'/%3E%3C/svg%3E");
}

.pc-slider-arrows .splide__arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Responsive Styles */
@media (max-width: 767px) {
    .pc-slider-arrows .splide__arrow {
        width: 36px;
        height: 36px;
    }

    .pc-header {
        display: block;
    }
}

/* Admin Preview Styles */
.block-editor .pc-splide-main .splide__slide {
    opacity: 1;
}
