/* Article Carousel Styles */
.article-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin: 0 auto;
}

.carousel-viewport {
    width: 100%;
    overflow: hidden;
    position: relative;
    padding: 0 40px; /* Default padding to show partial items */
    margin: 0 -40px; /* Compensate for padding */
    cursor: grab;
}

.carousel-viewport:active {
    cursor: grabbing;
}

.carousel-container {
    display: flex;
    transition: transform 0.3s ease-in-out;
    transform: translateX(0);
}

/* Default: Large screens - 3 primary + 8% peek */
.carousel-slide {
    flex: 0 0 calc(92% / 3); /* 3 items with 8% peek */
    width: calc(92% / 3);
    position: relative;
    margin-right: 0; /* No gaps between images */
}

.carousel-slide:last-child {
    margin-right: 0;
}

.carousel-slide-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.carousel-slide-image {
    width: 100%;
    overflow: hidden;
}

.carousel-slide img {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: bottom; /* Remove bottom gap */
}

/* Navigation Arrows with SVG icons */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: opacity 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.carousel-arrow:hover {
    opacity: 0.8;
}

.carousel-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-prev {
    left: 10px;
}

.carousel-next {
    right: 10px;
}

/* Dots Navigation */
.carousel-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.carousel-dot.active {
    background: #fff;
}

/* Category Label Styles */
.carousel-slide-content {
    text-align: center;
    padding: 12px 10px 15px; /* Reduced top padding to close gap */
    background-color: #fff;
}

.carousel-slide-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    line-height: 1.4;
    text-align: center;
}

.carousel-slide-text {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Carousel Header */
.carousel-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 10px;
    min-height: 48px; /* Ensure minimum height for navigation */
}

/* Header with only navigation (no title) */
.carousel-header:empty,
.carousel-header:has(.carousel-nav:only-child) {
    justify-content: flex-end;
}

.carousel-header .carousel-nav:only-child {
    margin-left: auto;
}

/* You May Also Like Header */
.you-may-also-like-header {
    font-size: 24px;
    padding: 12px 0 0 0;
    text-align: center;
    font-family: georgia;
    letter-spacing: 1.1px;
    max-width: 65%;
    margin: 0 auto !important;
    color: #636262;
    text-transform: none;
}

/* Product page specific overrides */
#matching .article-carousel {
    overflow: visible; /* Allow navigation to be visible */
}

#matching .carousel-header {
    overflow: visible;
    padding: 10px 60px 10px 0; /* Add padding to ensure space for navigation */
    margin-bottom: 0;
}

#matching .carousel-viewport {
    margin-top: 10px;
}

/* Ensure arrows are visible in product context */
#matching .carousel-nav {
    right: 12px; /* Align with container padding */
}

/* Product carousel text alignment */
#matching .carousel-slide-content {
    text-align: center;
}

#matching .productName,
#matching .productPrice,
#matching .productRatings {
    text-align: center;
}

#matching .productName {
    font-size: 14px;
    margin-bottom: 5px;
}

#matching .productPrice {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

#matching .productRatings {
    font-size: 12px;
}

#p_article .carousel-title,
.embed_article .carousel-title { 
    font-size: 32px;
    font-weight: 300;
    color: #3a3a3a;
    margin: 0;
    text-align: center;
    flex: 1;
    padding: 0 0 8px 0;
}

.carousel-nav {
    display: flex;
    gap: 10px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
    z-index: 10; /* Ensure nav stays above other elements */
}

/* Update arrow styles for header positioning */
.carousel-header .carousel-arrow {
    position: static;
    transform: none;
    width: 48px;
    height: 48px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
}

.carousel-header .carousel-arrow:hover {
    background: #f5f5f5;
}

/* Tablet: 2 primary + 10% peek */
@media (max-width: 1024px) {
    .carousel-slide {
        flex: 0 0 calc(90% / 2); /* 2 items with 10% peek */
        width: calc(90% / 2);
    }
    
    .carousel-title {
        font-size: 36px;
    }
    
    .carousel-header .carousel-arrow {
        width: 40px;
        height: 40px;
    }
}

/* Mobile: 1 primary + 12% peek */
@media (max-width: 767px) {
    .carousel-slide {
        flex: 0 0 88vw; /* 88% of viewport width (1 item + 12% peek) */
        width: 88vw;
        margin-right: 0; /* No gaps */
    }
    
    .carousel-viewport {
        padding: 0;
        margin: 0;
    }
    
    .carousel-header {
        margin-bottom: 8px;
    }
    
    .carousel-title {
        font-size: 28px;
        margin-bottom: 0;
    }
    
    .carousel-nav {
        right: 0;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .carousel-header .carousel-arrow {
        width: 32px;
        height: 32px;
    }
    
    .carousel-slide-content {
        padding: 15px 10px;
    }
    
    .carousel-slide-title {
        font-size: 14px;
    }
    
    .carousel-slide-text {
        font-size: 12px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .carousel-title {
        font-size: 24px;
    }
    
    .carousel-header .carousel-arrow {
        width: 28px;
        height: 28px;
    }
    
    .carousel-nav {
        gap: 8px;
        margin-right: 4px;
    }
}