/**
 * Dynamic Treatment Taxonomy Archive - Custom CSS
 *
 * Additional styling for dynamic treatment archive carousel rows.
 * Add this code via WordPress Code Snippets plugin as a CSS snippet.
 *
 * @package eRide
 * @version 1.0.0
 */

/* ===== CONCERN FILTER PILLS (Top Row) ===== */

/* Concern filter row - Horizontal scroll without background */
.treatment-concern-filters {
    display: flex;
    gap: 0; /* Individual pills handle spacing with margin */
    margin-bottom: 20px;
    padding: 4px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    flex-wrap: nowrap;
    align-items: center;
    max-width: 100%;
}

.treatment-concern-filters::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

/* Remove any br tags or empty elements from pill containers */
.treatment-concern-filters br,
.treatment-concern-filters p:empty {
    display: none;
    margin: 0;
    padding: 0;
}

/* Pills in concern filter inherit existing .treatment-pill styles */

/* Ensure consistent spacing between taxonomy rows - scoped to treatment archive only */
.post-type-archive-treatment .wp-block-columns {
    margin-bottom: 30px;
}

/* Reduce white space between outer container and carousel sections - target only the dynamic archive container */
.post-type-archive-treatment .wp-block-group.alignwide:has(.treatment-pill-filters) {
    margin-top: 32px !important;
}

/* Tighten spacing for taxonomy section headings */
.treatment-taxonomy-section .wp-block-heading {
    margin-bottom: -20px !important;
    margin-top: 20px !important;
}

/* Remove unwanted spacing in post cards */
.er-slick .wp-block-post {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.er-slick .wp-block-post > p:empty {
    display: none;
    margin: 0;
    padding: 0;
}

.er-slick .wp-block-post-featured-image {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.er-slick .wp-block-post-featured-image a {
    display: block;
    line-height: 0;
}

.er-slick .wp-block-post-featured-image img {
    display: block;
    margin: 0;
    padding: 0;
}

/* Carousel dots positioning and visibility override */
.er-slick.has-3-columns .slick-dots {
    bottom: 0;
    position: relative;
    margin-top: 8px;
}

/* Override theme's desktop dot hiding for treatment archive */
@media (min-width: 768px) {
    .home-weekly-posts.er-slick .slick-slider .slick-dots {
        display: block !important;
    }
}

/* Match existing treatment archive card styling */
.er-slick .wp-block-post-featured-image img {
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.er-slick .wp-block-post-featured-image:hover img {
    transform: scale(1.02);
}

/* Treatment concern terms styling consistency */
.er-slick .wp-block-post-terms a {
    transition: color 0.3s ease;
}

.er-slick .wp-block-post-terms a:hover {
    color: var(--wp--preset--color--gray-100) !important;
}

/* Post title link styling */
.er-slick .wp-block-post-title a {
    transition: color 0.3s ease;
}

.er-slick .wp-block-post-title a:hover {
    color: var(--wp--preset--color--primary);
}

/* Prevent title truncation - show full title */
.er-slick .wp-block-post-title {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
}

/* ===================================================================
   SITE-WIDE: Fix Product/Treatment Title Ellipsis
   =================================================================== */

/**
 * Product Title Ellipsis Fix - Site-wide
 *
 * ISSUE: style.css lines 2957-2973 apply -webkit-line-clamp: 1 which
 * truncates titles to one line with ellipsis, but titles wrap to line 2 anyway
 * Result: "Dynamic Skin..." continues on next line as "Recovery SPF50"
 *
 * SOLUTION:
 * - Force ALL titles to take exactly 2 lines of space (min-height = max-height)
 * - Use -webkit-line-clamp: 2 for ellipsis on long titles
 * - Short titles get 2 lines of space but only use 1 line
 * RESULT: Perfect equal card heights regardless of title length
 */
.products-block-post-template .wp-block-post-title,
.wp-block-woocommerce-related-products .wp-block-post-title,
.wc-block-product-template .wp-block-post-title,
ul.products .wp-block-post-title,
.wc-block-grid__products .wp-block-post-title,
.cross-sells-product .wp-block-post-title {
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.2 !important;
    min-height: calc(1.2em * 2) !important; /* Always reserve 2 lines of space */
    height: calc(1.2em * 2) !important; /* Force exactly 2 lines of space */
    max-height: calc(1.2em * 2) !important; /* Cap at 2 lines */
}

/* Force line-height on anchor tags inside product titles */
.products-block-post-template .wp-block-post-title a,
.wp-block-woocommerce-related-products .wp-block-post-title a,
.wc-block-product-template .wp-block-post-title a,
ul.products .wp-block-post-title a,
.wc-block-grid__products .wp-block-post-title a,
.cross-sells-product .wp-block-post-title a {
    line-height: 1.2 !important;
}

/* Remove 8px padding-top from titles after category (gives more vertical space) */
ul.products .taxonomy-product_cat + .wp-block-post-title,
.wc-block-grid__products .taxonomy-product_cat + .wp-block-post-title,
.wp-block-woocommerce-related-products .taxonomy-product_cat + .wp-block-post-title,
.products-block-post-template .taxonomy-product_cat + .wp-block-post-title,
.cross-sells-product .taxonomy-product_cat + .wp-block-post-title {
    padding-top: 0 !important;
}

/* ===== PILL FILTER STYLES (Matching treatment-features-tabs) ===== */

/* Filter container - Horizontal scroll without background */
.treatment-pill-filters {
    display: flex;
    gap: 0; /* Individual pills handle spacing with margin */
    margin-bottom: 32px;
    padding: 4px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    flex-wrap: nowrap;
    align-items: center;
    max-width: 100%;
}

.treatment-pill-filters::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

/* Remove any br tags or empty elements from pill containers */
.treatment-pill-filters br,
.treatment-pill-filters p:empty {
    display: none;
    margin: 0;
    padding: 0;
}

/* Individual pill button - Each pill has dark background */
.treatment-pill {
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-family: sans-serif;
    font-size: 14px;
    padding: 8px 15px;
    margin: 0 5px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s ease, font-weight 0.3s ease;
    outline: none;
    width: auto;
    min-width: fit-content;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    line-height: 1.2;
}

/* Pill hover state - Slightly lighter */
.treatment-pill:hover:not(.active) {
    background-color: rgba(0, 0, 0, 0.85);
}

/* Active pill state - Matching .treatment-feature-tab.active */
.treatment-pill.active {
    background-color: white;
    color: black;
    font-weight: bold;
    outline: 2px solid var(--wp--preset--color--primary, #64c5b2);
    outline-offset: 2px;
}

/* Pill focus state (accessibility) */
.treatment-pill:focus {
    outline: 2px solid var(--wp--preset--color--primary, #64c5b2);
    outline-offset: 2px;
}

/* Mobile responsive pills */
@media (max-width: 768px) {
    .treatment-pill-filters {
        gap: 2px;
        margin-bottom: 24px;
    }

    .treatment-pill {
        font-size: 14px;
        padding: 8px 15px;
        margin: 0 5px;
    }
}

/* Smooth fade animation for sections */
.treatment-taxonomy-section {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.treatment-taxonomy-section.hidden {
    display: none;
    opacity: 0;
}

/* ===== TOGGLE-BASED FILTER UI ===== */

/* Filter Control Row - Two column layout: badges | toggle */
.filter-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: clamp(8px, 2vw, 20px);
    margin-bottom: 20px;
    padding: 12px 0;
    flex-wrap: nowrap;
}

/* Column 1: Active Filters Container */
.active-filters-container {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 12px);
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Active Filter Badges Container */
.active-filters-badges {
    display: flex;
    gap: clamp(4px, 1vw, 8px);
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.active-filters-badges::-webkit-scrollbar {
    display: none;
}

/* Individual Filter Badge - Transparent with teal border */
.filter-badge {
    background-color: transparent;
    color: black;
    border: 2px solid var(--wp--preset--color--primary, #64c5b2);
    font-size: clamp(11px, 2vw, 14px);
    padding: clamp(4px, 1vw, 6px) clamp(8px, 1.5vw, 10px) clamp(4px, 1vw, 6px) clamp(10px, 2vw, 13px);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: clamp(4px, 1vw, 8px);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.filter-badge:hover {
    background-color: rgba(100, 197, 178, 0.1);
    border-color: var(--wp--preset--color--primary, #64c5b2);
    transform: scale(1.02);
}

.filter-badge:active {
    transform: scale(0.98);
}

/* Badge remove button (×) */
.filter-badge-remove {
    background: none;
    border: none;
    color: black;
    font-size: clamp(14px, 3vw, 18px);
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: clamp(14px, 3vw, 16px);
    height: clamp(14px, 3vw, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.filter-badge-remove:hover {
    transform: scale(1.2);
    color: var(--wp--preset--color--primary, #64c5b2);
}

/* Column 2: Filter Toggle Container (40% width) - Matching .treatment-features-tabs-nav */
.filter-toggle-container {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    background-color: rgba(0, 0, 0, 0.7);
    padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 10px);
    border-radius: 25px;
    width: fit-content;
    margin-left: auto;
    flex-shrink: 0;
}

/* Remove any br tags or empty elements from toggle container */
.filter-toggle-container br,
.filter-toggle-container p:empty {
    display: none;
    margin: 0;
    padding: 0;
}

/* Toggle Button - Exact match to .treatment-feature-tab */
.filter-toggle-btn {
    background-color: transparent;
    border: none;
    color: white;
    font-family: sans-serif;
    font-size: clamp(12px, 2vw, 14px);
    padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2vw, 15px);
    margin: 0 clamp(3px, 1vw, 5px);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s ease, font-weight 0.3s ease;
    outline: none;
    width: auto;
    min-width: fit-content;
}

.filter-toggle-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Active Toggle Button - White background, black text, bold */
.filter-toggle-btn.active {
    background-color: white;
    color: black;
    font-weight: bold;
}

.filter-toggle-btn:focus {
    outline: 1px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Filter Pills Row - Show/hide based on toggle */
.filter-pills-row {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filter-pills-row.active {
    display: flex;
    opacity: 1;
}

/* Mobile Responsive - Keep on one row with horizontal scroll */
@media (max-width: 768px) {
    .filter-control-row {
        gap: clamp(6px, 1.5vw, 12px);
        padding: 8px 0;
    }

    .active-filters-label {
        font-size: 11px;
    }

    .filter-badge {
        font-size: 11px;
        padding: 3px 7px 3px 9px;
        border-width: 1px;
    }

    .filter-badge-remove {
        font-size: 14px;
        width: 12px;
        height: 12px;
    }

    .filter-toggle-btn {
        font-size: 11px;
        padding: 5px 8px;
        margin: 0 3px;
    }

    .filter-toggle-container {
        padding: 5px 7px;
    }
}

/* Tablet adjustments - smaller sizing */
@media (max-width: 1024px) and (min-width: 769px) {
    .active-filters-label {
        font-size: 13px;
    }

    .filter-badge {
        font-size: 12px;
        padding: 5px 8px 5px 11px;
    }

    .filter-toggle-btn {
        font-size: 13px;
        padding: 7px 12px;
    }
}

/* ===== LOADING STATES & TRANSITIONS ===== */

/* Pill loading state - clicked pill */
.treatment-pill.pill-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.treatment-pill.pill-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: pill-spinner 0.6s linear infinite;
}

/* Dimmed pills - unclicked pills during load */
.treatment-pill.pill-dimmed {
    opacity: 0.4;
    pointer-events: none;
}

/* Badge removing state */
.filter-badge.badge-removing {
    opacity: 0.5;
    pointer-events: none;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Loading overlay - covers page during transition */
.filter-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.filter-loading-overlay.active {
    opacity: 1;
}

/* Loading spinner */
.filter-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--wp--preset--color--primary, #64c5b2);
    border-radius: 50%;
    animation: loading-spinner 0.8s linear infinite;
}

/* Spinner animations */
@keyframes loading-spinner {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pill-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Smooth transitions for treatment sections */
.treatment-taxonomy-section {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Fade-in animation for sections on page load */
@keyframes section-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Polish: Smooth hover transitions */
.treatment-pill,
.filter-badge,
.filter-toggle-btn {
    transition: all 0.3s ease;
}

/* Polish: Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .treatment-pill,
    .filter-badge,
    .filter-toggle-btn,
    .treatment-taxonomy-section,
    .filter-loading-overlay {
        transition: none !important;
        animation: none !important;
    }
}

/* ===================================================================
   HOME PAGE TREATMENTS SLIDER FIX
   =================================================================== */

/**
 * Treatments Slider - Empty Excerpt Fix
 *
 * Fixes extra white space created by empty wp-block-post-excerpt elements
 * in the "Posts of The Week" treatments slider on desktop view.
 *
 * ISSUE: Empty wp-block-post-excerpt blocks create unwanted white space
 * Pattern file: patterns/home-v1-weekly-posts.php doesn't include excerpt block,
 * but WordPress automatically inserts empty excerpt divs which inherit
 * margin-bottom: 16px from style.css line 1271-1272
 *
 * SOLUTION: Hide excerpt blocks ONLY in the treatments slider section
 * Target: .home-weekly-posts (from pattern file line 25)
 */
.home-weekly-posts .products-block-post-template .wp-block-post-excerpt {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
}
