/**
 * Sparkles Carousel Components
 * Product carousels, sliders, and recommendation displays
 * Extends: sparkles-utilities.css, sparkles-animations.css, sparkles-tokens.css
 * All 3 optimization layers applied: keyframes consolidated, patterns extracted, component organization
 */

/* ========== BASE CAROUSEL ========== */
.sparkles-carousel {
    background-color: var(--white);
    border-radius: .5rem;
}

/* Container query anchors for carousel modules */
:where(.sparkles-carousel,
    .sparkles-product-carousel,
    .sparkles-recommendations,
    .sparkles-grid-carousel,
    .sparkles-infinite-carousel,
    #mainSlider) {
    container-type: inline-size;
}

.sparkles-carousel-container,
.sparkles-carousel-track-base {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Default carousel track for scroll/slide types */
.sparkles-carousel-track {
    display: flex;
    gap: 1rem;
    width: 100%;
}


.sparkles-carousel-item {
    flex: none;
    min-width: 0;
}


/* Carousel Navigation */
.sparkles-carousel-nav {
    top: 50%;
    position: absolute;
    z-index: var(--z-dropdown);
}

.sparkles-carousel-nav-btn,
.sparkles-carousel-button {
    width: 3rem;
    height: 3rem;
    background-color: var(--white);
    box-shadow: 0 10px 15px -3px #0000001a, 0 4px 6px -2px #0000000d;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: all .3s ease-out;
}

.sparkles-carousel-nav-btn:hover {
    box-shadow: 0 20px 25px -5px #0000001a, 0 10px 10px -5px #0000000a;
    color: var(--color-primary);
}

.sparkles-carousel-nav-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.sparkles-carousel-nav-prev {
    left: 1rem;
}

.sparkles-carousel-nav-next {
    right: 1rem;
}


/* ========== PRODUCT CAROUSEL ========== */
.sparkles-product-carousel {
    position: relative;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.sparkles-product-carousel-header {
    margin-bottom: 1.5rem;
}

.sparkles-product-carousel-title {
    color: var(--color-secondary);
    font-family: "Playfair Display", "Montserrat", serif;
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 600;
}

.sparkles-product-carousel-subtitle {
    color: var(--color-text-secondary);
    font-size: 1rem;
    line-height: 1.5rem;
    margin-top: .25rem;
}

.sparkles-product-carousel-actions {
    display: flex;
    gap: .5rem;
}

/* Product Item Sizing */
/* .sparkles-product-carousel .sparkles-carousel-item was fixed width */

/* ========== RECOMMENDATION SECTIONS ========== */
.sparkles-recommendations {
    background-color: var(--gray-50);
    padding: 3rem 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    border-radius: .5rem;
}

.sparkles-recommendations-header {
    text-align: center;
    margin-bottom: 2rem;
}

.sparkles-recommendations-title {
    color: var(--color-secondary);
    font-family: var(--font-display);
    font-size: 1.875rem;
    line-height: 2.25rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.sparkles-recommendations-description {
    color: var(--color-text-secondary);
    font-size: 1.125rem;
    line-height: 1.75rem;
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

/* Recommendation Types */
.sparkles-recommendations-viewed-together {
    background-color: var(--color-accent);
    border-color: var(--color-primary);
    border-left-width: 4px;
}

.sparkles-recommendations-bought-together {
    border-color: var(--color-success);
    background-color: var(--color-success-light);
    border-left-width: 4px;
}

.sparkles-recommendations-similar {
    border-color: var(--color-primary);
    background-color: rgb(var(--color-primary-rgb) / 0.1);
    border-left-width: 4px;
    --tw-bg-opacity: 0.1;
}

/* ========== CAROUSEL INDICATORS ========== */
.sparkles-carousel-indicators {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-top: 1.5rem;
}

.sparkles-carousel-indicator {
    width: .75rem;
    height: .75rem;
    background-color: var(--gray-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all .3s ease-out;
}

.sparkles-carousel-indicator-active {
    transform: scale(1.25);
    background-color: var(--color-primary);
}


/* ========== SCROLL CAROUSEL ========== */
.sparkles-scroll-carousel,
.sparkles-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
}

.sparkles-scroll-snap {
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}

.sparkles-scroll-snap>* {
    scroll-snap-align: start;
}

.sparkles-scroll-carousel::-webkit-scrollbar-track {
    background-color: var(--color-container-darker);
    border-radius: var(--radius-full);
}

.sparkles-scroll-carousel::-webkit-scrollbar-thumb {
    background-color: var(--color-primary);
    border-radius: var(--radius-full);
}

.sparkles-scroll-carousel-item {
    scroll-snap-align: start;
    flex: none;
}

/* ========== INFINITE CAROUSEL ========== */
.sparkles-infinite-carousel {
    background-color: var(--color-container);
    overflow: hidden;
    position: relative;
}

.sparkles-infinite-carousel-track,
.sparkles-infinite-scroll {
    display: flex;
    white-space: nowrap;
    animation: infinite-scroll 20s linear infinite;
}

.sparkles-infinite-carousel-track:hover {
    animation-play-state: paused;
}

.sparkles-infinite-carousel-item {
    flex: none;
    margin-right: 1rem;
}

/* infinite-scroll keyframe moved to sparkles-animations.css */

/* ========== CAROUSEL EFFECTS - MOVED TO UTILITIES ========== */
/* sparkles-carousel-fade patterns moved to sparkles-utilities.css */
/* sparkles-carousel-3d patterns moved to sparkles-utilities.css */

/* Responsive grid layouts */
.sparkles-grid-carousel-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sparkles-grid-carousel-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sparkles-grid-carousel-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sparkles-grid-carousel-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

@container (max-width: 1024px) {

    .sparkles-grid-carousel-4,
    .sparkles-grid-carousel-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@container (max-width: 768px) {

    .sparkles-grid-carousel-3,
    .sparkles-grid-carousel-4,
    .sparkles-grid-carousel-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container (max-width: 475px) {

    .sparkles-grid-carousel-2,
    .sparkles-grid-carousel-3,
    .sparkles-grid-carousel-4,
    .sparkles-grid-carousel-5 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

/* ========== CAROUSEL LOADING STATES ========== */
.sparkles-carousel-loading {
    position: relative;
}

.sparkles-carousel-loading::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sparkles-carousel-skeleton .sparkles-carousel-item {
    background-color: var(--gray-200);
    border-radius: .25rem;
    animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;
}

/* skeleton-pulse keyframe moved to sparkles-animations.css */

/* ========== RESPONSIVE DESIGN ========== */
@container (max-width: 768px) {
    .sparkles-carousel-nav-btn {
        width: 2.5rem;
        height: 2.5rem;
    }

    .sparkles-carousel-nav-prev {
        left: .5rem;
    }

    .sparkles-carousel-nav-next {
        right: .5rem;
    }

    .sparkles-recommendations {
        padding: 1.5rem;
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

/* ========== ACCESSIBILITY ========== */
.sparkles-carousel-nav-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 4px rgb(var(--color-primary-rgb)/.1);
}

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

    .sparkles-carousel-container,
    .sparkles-carousel-item,
    .sparkles-infinite-carousel-track {
        transition-property: none;
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .sparkles-carousel-nav-btn {
        border-width: 2px;
        border-style: solid;
    }
}

/* ========== HOMEPAGE HERO SLIDERS ========== */
/* Unified styles for all 3 site homepage sliders */

/* Hero slider containers */
.hero-slider,
.hero-slider-sparkles,
#mainSlider,
.hero-slider-rhinestones {
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* Hero slider track - stacked slides */
.hero-slider-sparkles .sparkles-carousel-track,
#mainSlider .sparkles-carousel-track {
    position: relative;
    display: block;
}

/* Hero slider items - absolute positioning for stacking */
.hero-slider-sparkles .sparkles-carousel-item,
#mainSlider .sparkles-carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    z-index: 1;
}

/* Active slide visible */
.hero-slider-sparkles .sparkles-carousel-item.active,
#mainSlider .sparkles-carousel-item.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

/* Slider-specific navigation buttons */
.slider-nav,
.slider-nav-prev,
.slider-nav-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid var(--color-primary, var(--color-magenta));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary, var(--color-magenta));
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
    user-select: none;
}

.slider-nav:hover,
.slider-nav-prev:hover,
.slider-nav-next:hover {
    background: var(--color-primary, var(--color-magenta));
    color: white;
    box-shadow: 0 4px 16px rgba(233, 30, 99, 0.3);
}

.slider-nav-prev {
    left: 20px;
}

.slider-nav-next {
    right: 20px;
}

/* Enhanced dot navigation for homepage sliders */
.slider-dots-sparkles,
.slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

/* Touch-friendly dots with visual indicator */
.slider-dot,
.slider-dot-rhinestones {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    cursor: pointer;
    background: transparent;
    border: none;
}

.slider-dot {
    margin: 0;
}

.slider-dot::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid white;
    transition: all 0.3s ease;
}

.slider-dot.active::before,
.slider-dot:hover::before {
    background: var(--color-primary, var(--color-magenta));
    transform: scale(1.2);
    box-shadow: 0 0 12px var(--color-primary, var(--color-magenta));
}

/* Overlay with dynamic glow effect */
.slide-overlay-sparkles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    transition: all 0.6s ease;
    --glow-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.slide-overlay-sparkles img {
    max-width: 100%;
    height: auto;
}

.slide-overlay-sparkles::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 60%);
    filter: blur(60px);
    z-index: -1;
    transition: all 0.6s ease;
}

/* Mobile-specific adjustments */
@container (max-width: 768px) {

    .slider-nav,
    .slider-nav-prev,
    .slider-nav-next {
        display: none;
    }

    body .slider-dots-sparkles,
    body .slider-dots {
        display: none;
    }

    body .slide-overlay-sparkles {
        width: 90%;
        max-width: none;
    }
}

/* Desktop overlay sizing */
@media (min-width: 769px) {
    .slide-overlay-sparkles {
        width: 650px;
        max-width: 80%;
    }
}

/* Studio square mobile slider */
@container (max-width: 767px) {
    body #mainSlider.studio-slider {
        height: 0;
        padding-bottom: 100%;
        position: relative;
    }

    #mainSlider.studio-slider .sparkles-carousel-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}