/**
 * Dentalvarehuset Product Carousel Styles
 * Horizontal scroll carousel for homepage product sections
 *
 * Based on Porsgrund-inspired design system
 * Brand: rgb(204, 0, 98)
 */

/* ============================================================================
   CAROUSEL CONTAINER
   ============================================================================ */

.product-carousel {
    position: relative;
}

.product-carousel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md, 1rem);
    margin-bottom: var(--spacing-lg, 1.5rem);
}

/* Right-side actions: nav arrows + view-all link */
.product-carousel__header-actions {
    display: none;
    align-items: center;
    gap: var(--spacing-md, 1rem);
    flex-shrink: 0;
}

/* "Se alle" link styling */
.product-carousel__view-all {
    flex-shrink: 0;
    font-size: var(--text-sm, 0.875rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--color-brand, rgb(204, 0, 98));
    text-decoration: none;
    transition: color var(--transition-fast, 150ms ease);
    white-space: nowrap;
}

.product-carousel__view-all:hover {
    color: var(--color-brand-dark, rgb(150, 0, 70));
}

/* Navigation buttons in header - right side */
.product-carousel__header-nav {
    display: none;
    gap: var(--spacing-xs, 0.25rem);
}

.product-carousel__title-group {
    flex: 1;
    text-align: center;
}

/* ============================================================================
   SCROLL TRACK
   ============================================================================ */

.product-carousel__wrapper {
    position: relative;
}

.product-carousel__track {
    display: flex;
    gap: 1.25rem; /* 20px gap between cards */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;

    /* Hide scrollbar but keep functionality */
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE/Edge */
}

.product-carousel__track::-webkit-scrollbar {
    display: none;  /* Chrome/Safari/Opera */
}

/* ============================================================================
   PRODUCT CARDS
   ============================================================================ */

.product-carousel__card {
    flex: 0 0 calc((100% - 1.25rem * 3) / 4); /* 4 columns with gaps */
    scroll-snap-align: start;
    /* Make cards more square-ish - limit max height */
    max-width: 320px;
    align-self: flex-start;
}

/* Card internal spacing - make more compact */
.product-carousel__card .product-item-info {
    padding: 0.75rem;
}

.product-carousel__card .product-item-name {
    font-size: 0.875rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-carousel__card .product-item-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.product-carousel__card .product-item-photo {
    position: relative;
    padding-bottom: 100%; /* Square aspect ratio for image container */
    overflow: hidden;
    border-radius: var(--radius-md, 0.5rem);
    background-color: var(--color-stone-100, #F5F5F4);
}

.product-carousel__card .product-item-photo img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform var(--transition-normal, 300ms ease);
}

.product-carousel__card:hover .product-item-photo img {
    transform: scale(1.05);
}

/* Compact price display */
.product-carousel__card .price-wrapper {
    margin-top: 0.5rem;
}

.product-carousel__card .price-from {
    font-size: 0.75rem;
    color: var(--color-stone-500, #78716C);
}

.product-carousel__card .price {
    font-size: 1rem;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-charcoal, #1A1A1A);
}

/* Sale badge */
.product-carousel__card .sale-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: var(--color-brand, rgb(204, 0, 98));
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm, 0.25rem);
    z-index: 2;
}

/* New badge */
.product-carousel__card .new-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--color-stone-800, #292524);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm, 0.25rem);
    z-index: 2;
}

/* "Logg inn" link styling */
.product-carousel__card .tocart,
.product-carousel__card .actions-secondary {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

/* Swatch options (color/size) - hide in carousel for cleaner look */
.product-carousel__card .swatch-attribute-options,
.product-carousel__card .product-item-inner .swatch-attribute {
    display: none;
}

/* Mobile: 2 columns */
@media (max-width: 767px) {
    .product-carousel__card {
        flex: 0 0 calc((100% - 1rem) / 2); /* 2 columns */
    }

    .product-carousel__track {
        gap: 1rem;
    }
}

/* Tablet: 3 columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .product-carousel__card {
        flex: 0 0 calc((100% - 1.25rem * 2) / 3); /* 3 columns */
    }
}

/* Large desktop: 4 columns */
@media (min-width: 1024px) {
    .product-carousel__card {
        flex: 0 0 calc((100% - 1.25rem * 3) / 4); /* 4 columns */
    }
}

/* ============================================================================
   SCROLL FADE INDICATOR
   ============================================================================ */

.product-carousel__fade {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 3.5rem; /* Leave space for pagination dots */
    width: 64px;
    background: linear-gradient(to right, transparent, var(--color-stone-50, #FAFAF9));
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--transition-normal, 300ms ease);
    z-index: 10;
}

.product-carousel__fade.is-hidden {
    opacity: 0;
}

/* Fade for white background sections */
.product-carousel__fade.on-white {
    background: linear-gradient(to right, transparent, rgb(255, 255, 255));
}

/* ============================================================================
   NAVIGATION ARROWS (In Header - Not Overlaying Products)
   ============================================================================ */

/* Hide old overlay nav */
.product-carousel__wrapper .product-carousel__nav {
    display: none !important;
}

/* Header navigation arrows - show on desktop */
@media (min-width: 1024px) {
    .product-carousel__header-actions {
        display: flex;
    }

    .product-carousel__header-nav {
        display: flex;
    }

    .product-carousel__nav-button {
        width: 44px;
        height: 44px;
        border-radius: var(--radius-md, 0.5rem);
        background-color: var(--color-stone-100, #F5F5F4);
        border: 1px solid var(--color-stone-200, #E7E5E4);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all var(--transition-fast, 150ms ease);
        color: var(--color-stone-700, #44403C);
    }

    .product-carousel__nav-button:hover:not(:disabled) {
        background-color: var(--color-brand, rgb(204, 0, 98));
        border-color: var(--color-brand, rgb(204, 0, 98));
        color: rgb(255, 255, 255);
        transform: translateY(-1px);
    }

    .product-carousel__nav-button:active:not(:disabled) {
        transform: translateY(0);
    }

    .product-carousel__nav-button:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        background-color: var(--color-stone-100, #F5F5F4);
    }

    .product-carousel__nav-button:focus-visible {
        outline: 2px solid var(--color-brand, rgb(204, 0, 98));
        outline-offset: 2px;
    }

    .product-carousel__nav-button svg {
        width: 20px;
        height: 20px;
        stroke-width: 2.5;
    }
}

/* Tablet: show arrows on right side */
@media (min-width: 768px) and (max-width: 1023px) {
    .product-carousel__header-actions {
        display: flex;
    }

    .product-carousel__header-nav {
        display: flex;
    }

    .product-carousel__nav-button {
        width: 40px;
        height: 40px;
        border-radius: var(--radius-md, 0.5rem);
        background-color: var(--color-stone-100, #F5F5F4);
        border: 1px solid var(--color-stone-200, #E7E5E4);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all var(--transition-fast, 150ms ease);
        color: var(--color-stone-700, #44403C);
    }

    .product-carousel__nav-button:hover:not(:disabled) {
        background-color: var(--color-brand, rgb(204, 0, 98));
        border-color: var(--color-brand, rgb(204, 0, 98));
        color: rgb(255, 255, 255);
    }

    .product-carousel__nav-button:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .product-carousel__nav-button svg {
        width: 18px;
        height: 18px;
        stroke-width: 2.5;
    }
}

/* Mobile: hide header arrows, keep swipe */
@media (max-width: 767px) {
    .product-carousel__header-nav {
        display: none;
    }

    .product-carousel__title-group {
        text-align: center;
        width: 100%;
    }

    .product-carousel__header {
        flex-direction: column;
        align-items: center;
    }
}

/* ============================================================================
   PAGINATION DOTS
   ============================================================================ */

.product-carousel__pagination {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm, 0.5rem);
    margin-top: var(--spacing-md, 1rem);
}

.product-carousel__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full, 9999px);
    background-color: var(--color-stone-300, #D6D3D1);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast, 150ms ease);
    padding: 0;
}

.product-carousel__dot:hover {
    background-color: var(--color-stone-400, #A8A29E);
}

.product-carousel__dot.is-active {
    background-color: var(--color-brand, rgb(204, 0, 98));
    width: 24px;
}

.product-carousel__dot:focus-visible {
    outline: 2px solid var(--color-brand, rgb(204, 0, 98));
    outline-offset: 2px;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.product-carousel__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm, 0.5rem);
    padding: var(--spacing-xl, 2rem);
}

.product-carousel__spinner-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full, 9999px);
    background-color: var(--color-brand, rgb(204, 0, 98));
    animation: carousel-pulse 1.2s cubic-bezier(0.23, 1, 0.32, 1) infinite;
}

.product-carousel__spinner-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.product-carousel__spinner-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes carousel-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
.product-carousel__card a:focus-visible {
    outline: 2px solid var(--color-brand, rgb(204, 0, 98));
    outline-offset: 2px;
    border-radius: var(--radius-lg, 0.75rem);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .product-carousel__track {
        scroll-behavior: auto;
    }

    .product-carousel__nav-button,
    .product-carousel__dot,
    .product-carousel__view-all {
        transition: none;
    }

    .product-carousel__spinner-dot {
        animation: none;
        opacity: 1;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .product-carousel__nav-button {
        border-width: 2px;
    }

    .product-carousel__dot {
        border: 1px solid var(--color-stone-600, #57534E);
    }
}

/* ============================================================================
   SECTION BACKGROUND VARIANTS
   ============================================================================ */

/* Stone background (default) */
.product-carousel .bg-stone-50 {
    background-color: var(--color-stone-50, #FAFAF9);
}

/* White background */
.product-carousel .bg-white {
    background-color: rgb(255, 255, 255);
}

/* Gradient background (for sale section) */
.product-carousel .bg-gradient-pink {
    background: linear-gradient(135deg, rgba(204, 0, 98, 0.05) 0%, rgba(204, 0, 98, 0.02) 100%);
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.product-carousel__empty {
    text-align: center;
    padding: var(--spacing-2xl, 3rem) var(--spacing-md, 1rem);
}

.product-carousel__empty-icon {
    width: 64px;
    height: 64px;
    color: var(--color-stone-300, #D6D3D1);
    margin: 0 auto var(--spacing-md, 1rem);
}

.product-carousel__empty-text {
    color: var(--color-stone-500, #78716C);
    font-size: var(--text-base, 1rem);
}

.product-carousel__empty-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs, 0.25rem);
    margin-top: var(--spacing-md, 1rem);
    color: var(--color-brand, rgb(204, 0, 98));
    font-weight: var(--font-weight-medium, 500);
    text-decoration: none;
}

.product-carousel__empty-link:hover {
    color: var(--color-brand-dark, rgb(150, 0, 70));
    text-decoration: underline;
}
