/**
 * Responsive Woodmart Attribute Grid - Card Carousel Edition
 * A fun, modern approach to displaying product attributes
 */

/* Reset - Prevent conflicts with other elements */
.rwag-reset * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main container - clean and simple */
.rwag-attribute-grid {
    margin: 30px 0;
    width: 100%;
    font-family: inherit;
    line-height: 1.4;
    overflow: hidden;
    /* Prevent horizontal scrollbar from showing */
}

/* Section title styling - Modernized */
.rwag-section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(129, 129, 129, 0.2);
    color: #333;
    position: relative;
}

/* Add a subtle accent line under the section title */
.rwag-section-title:after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: #2271b1;
    /* WP blue accent color */
}

/* Center the Swatch Image */
a.rwag-swatch-link {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Attribute container */
.rwag-attribute-container {
    margin-bottom: 30px;
}

/* Attribute label - with icon support */
.rwag-attribute-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    display: flex;
    align-items: center;
}

/* Icon for attribute label if needed */
.rwag-attribute-label-icon {
    margin-right: 6px;
}

/* -------- CARD CAROUSEL STYLING -------- */

/* Horizontal scrolling container for cards */
.rwag-swatch-carousel {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping by default */
    gap: 12px;
    width: 100%;
    overflow-x: visible;
    /* Don't hide content */
    padding: 10px 5px 20px 5px;
    /* Extra padding for visibility */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    position: relative;
}

/* For mobile, enable horizontal scrolling */
@media (max-width: 767px) {
    .rwag-swatch-carousel {
        flex-wrap: nowrap;
        /* No wrapping on mobile - horizontal scroll */
        overflow-x: auto;
        /* Enable horizontal scrolling on mobile */

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

        /* Add some snap scrolling for a better mobile experience */
        scroll-snap-type: x mandatory;
    }
}

/* Hide scrollbar in WebKit browsers while keeping functionality */
.rwag-swatch-carousel::-webkit-scrollbar {
    display: none;
}

/* Optional - visual indicator that content is scrollable */
.rwag-swatch-carousel:after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    height: calc(100% - 20px);
    /* Match the padding-bottom */
    width: 30px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 100%);
    pointer-events: none;
    opacity: 0.7;
    display: none;
    /* Hidden by default, shown with JS when content overflows */
}

/* Enable wrapping for larger screens (optional) */
@media (min-width: 992px) {

    /* Responsive grid for desktop */
    .rwag-swatch-carousel.rwag-desktop-wrap {
        flex-wrap: wrap;
        overflow-x: visible;
        scroll-snap-type: none;
    }

    .rwag-swatch-carousel.rwag-desktop-wrap:after {
        display: none;
        /* Hide gradient on desktop wrapped view */
    }
}

/* Individual card styling */
.rwag-swatch-card {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 6px 12px rgba(0, 0, 0, 0.03);
    padding: 12px;
    min-width: 100px;
    /* Minimum card width */
    max-width: 120px;
    /* Maximum card width */
    flex: 0 0 auto;
    /* Don't grow or shrink by default */
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    scroll-snap-align: start;
    /* For snap scrolling */
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
    /* Add bottom margin for wrapped layout */
}

/* For desktop/wrapped layout, allow some flexibility but maintain consistent width */
@media (min-width: 768px) {
    .rwag-swatch-carousel.rwag-desktop-wrap .rwag-swatch-card {
        flex: 0 1 calc(20% - 12px);
        /* 5 cards per row with gap considered */
        max-width: calc(20% - 12px);
        min-width: 100px;
    }

    /* Adjust for different screen sizes */
    @media (max-width: 1200px) {
        .rwag-swatch-carousel.rwag-desktop-wrap .rwag-swatch-card {
            flex: 0 1 calc(25% - 12px);
            /* 4 cards per row */
            max-width: calc(25% - 12px);
        }
    }

    @media (max-width: 992px) {
        .rwag-swatch-carousel.rwag-desktop-wrap .rwag-swatch-card {
            flex: 0 1 calc(33.333% - 12px);
            /* 3 cards per row */
            max-width: calc(33.333% - 12px);
        }
    }

    @media (max-width: 768px) {
        .rwag-swatch-carousel .rwag-swatch-card {
            flex: 0 0 auto;
            /* Back to no grow/shrink for mobile scroll */
        }
    }
}

/* Card hover effect */
.rwag-swatch-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08), 0 10px 25px rgba(0, 0, 0, 0.05);
}

/* Swatch container within card */
.rwag-swatch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 65px;
    /* Default, overridden by inline */
    height: 65px;
    /* Default, overridden by inline */
    border-radius: 8px;
    /* More rounded for modern look */
    overflow: hidden;
    margin-bottom: 10px;
    transition: transform 0.2s ease;
}

/* Swatch hover effect */
.rwag-swatch-card:hover .rwag-swatch {
    transform: scale(1.05);
}

/* Swatch types */
.rwag-swatch-image {
    background-size: cover;
    background-position: center;
}

.rwag-swatch-color {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rwag-swatch-text {
    background-color: #f7f7f7;
    font-size: 12px;
    padding: 5px;
}

/* Term label within card - Always two lines with ellipsis */
.rwag-swatch-label {
    font-size: 13px;
    color: #333;
    text-align: center;
    width: 100%;

    /* Two-line text with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8em;
    line-height: 1.4em;
}

/* Link styling */
.rwag-swatch-link {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
    height: 100%;
}

/* -------- ENHANCED TOOLTIP STYLING -------- */
.rwag-tooltip {
    position: fixed; /* Changed from absolute to fixed to break out of container constraints */
    bottom: auto; /* Remove bottom positioning */
    left: 0; /* This will be set dynamically with JS */
    top: 0; /* This will be set dynamically with JS */
    transform: translate(-50%, -100%); /* Position above the element */
    margin-top: -15px; /* Add some space between element and tooltip */
    background: #ffffff;
    color: #333333;
    padding: 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 999999; /* Very high z-index to ensure it appears above everything */
    min-width: 160px;
    max-width: 250px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rwag-tooltip-arrow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #ffffff;
    filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.05));
}

/* Make tooltips appear correctly on hover */
.rwag-swatch-card:hover .rwag-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Fix for tooltip on touch devices */
@media (hover: none) {
    .rwag-swatch-card:active .rwag-tooltip {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
}

/* Optional tooltip title */
.rwag-tooltip-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 14px;
}

/* Custom attributes - now in card style */
.rwag-custom-attribute-carousel {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    padding: 10px 5px 20px 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.rwag-custom-attribute-carousel::-webkit-scrollbar {
    display: none;
}

.rwag-custom-attribute-card {
    background-color: #f7f7f7;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 100px;
    text-align: center;
}

.rwag-custom-attribute-card:hover {
    background-color: #ebebeb;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.rwag-custom-attribute-link {
    text-decoration: none;
    color: inherit;
}

/* Notice styling */
.rwag-notice {
    padding: 15px;
    background-color: #f7f7f7;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.rwag-notice:before {
    content: "ℹ️";
    margin-right: 10px;
    font-size: 16px;
}

.rwag-error {
    background-color: #fff8f7;
    border-left: 4px solid #dc3232;
}

.rwag-error:before {
    content: "⚠️";
}

/* Prevent conflicts with variation buttons */
.variations .rwag-attribute-grid {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(129, 129, 129, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .rwag-swatch-carousel {
        gap: 10px;
    }

    .rwag-tooltip {
        min-width: 140px;
        max-width: 200px;
        padding: 12px;
        font-size: 12px;
    }

    .rwag-swatch-label {
        font-size: 12px;
    }

    .rwag-swatch-card {
        min-width: 90px;
        max-width: 110px;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .rwag-swatch-carousel {
        gap: 8px;
    }

    .rwag-tooltip {
        min-width: 120px;
        max-width: 180px;
        padding: 10px;
        font-size: 11px;
    }

    .rwag-swatch-card {
        min-width: 85px;
        max-width: 100px;
        padding: 8px;
    }

    .rwag-attribute-label {
        font-size: 14px;
    }

    .rwag-section-title {
        font-size: 16px;
    }
}