/**
 * Brand Pages Specific Styling
 *
 * This file contains all CSS specifically for product brand taxonomy pages
 * and the custom shortcode content injection functionality.
 *
 * File: /css/brand-pages.css
 * Loaded: Only on brand taxonomy pages (is_tax('product_brand'))
 * Version: 1.2
 */

/* ==========================================================================
   BRAND CSS VARIABLES
   ========================================================================== */

/*
 * Brand Content Max Width Variable
 * Change this value to adjust the maximum width of brand content elements
 * Used by: .wd-el-toggle, .wpb_text_column.wpb_content_element
 */

/* ==========================================================================
   BRAND CSS VARIABLES
   ========================================================================== */

/*
 * Brand Content Max Width Variable
 * Change this value to adjust the maximum width of brand content elements
 * Used by: .wd-el-toggle, .wpb_text_column.wpb_content_element
 */
:root {
    --brand-content-max-width: 960px;
}

/* ==========================================================================
   BRAND SHORTCODE CONTENT INTEGRATION
   ========================================================================== */

.description-section {
    display: none;
    /* hide the regular description section */
}


.brand-shortcode-content {
    margin-top: 16px;
    margin-bottom: 0px;
    position: relative;
}

.brand-shortcode-content .wd-el-toggle {
    max-width: var(--brand-content-max-width) !important;
}

.wpb_text_column.wpb_content_element {
    max-width: var(--brand-content-max-width);
    margin-bottom: 24px;
}

/* Paragraph styling for brand content */
.brand-shortcode-content p {
    color: var(--new-light-green, #D8FFB4);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 8px 0;
    font-weight: 300;
    text-wrap-style: pretty;
}

/* Heading styling for brand content */
.brand-shortcode-content h3,
.brand-shortcode-content h4,
.brand-shortcode-content h5 {
    color: var(--new-light-green, #D8FFB4);
    font-family: Biryani, sans-serif;
    font-weight: 700;
    margin: 20px 0 16px 0;
    text-wrap: pretty;
    font-size: 18px;
    line-height: 1.3;
    /* Prevent font loading jumps */
    font-display: swap;
}

/* List styling for brand content */
.brand-shortcode-content ol,
.brand-shortcode-content ul {
    color: var(--new-light-green, #D8FFB4);
    margin: 16px 0;
    padding-left: 24px;
    font-weight: 300;
    /* Light weight for overall list */
}

.brand-shortcode-content li {
    color: var(--new-light-green, #D8FFB4);
    margin-bottom: 8px;
    line-height: 1.3;
    font-weight: 300;
    /* Light weight for list item text */
}

/* Style list markers (bullets/numbers) with medium weight */
.brand-shortcode-content ol li::marker,
.brand-shortcode-content ul li::marker {
    color: var(--new-light-green, #D8FFB4);
    font-weight: 500;
    /* Medium weight for bullets/numbers */
}

/* Strong/bold text within brand content paragraphs */
.brand-shortcode-content p strong,
.brand-shortcode-content p b {
    font-weight: 700;
}

/* ==========================================================================
   WOODMART TOGGLE ELEMENT STYLING
   ========================================================================== */

/* Toggle head container styling */
.wd-el-toggle-head {
    justify-content: flex-start !important;
    margin-bottom: 20px;
}

/* Toggle head title styling */
.wd-el-toggle-head>.wd-el-toggle-title {
    color: var(--power-lime, #ADFF60);
    display: flex;
    align-items: center;
    flex: 1;
    gap: 5px;
    font-family: Biryani;
    font-size: 18px !important;
    font-style: normal;
    font-weight: 700;
    line-height: 110%;
    transition: inherit;
    max-width: 440px;
}

/* Accordion opener styling */
.wd-accordion-opener {
    color: var(--power-lime, #ADFF60);
    text-align: center;
    font-size: 18px;
    font-weight: 400;
    margin-right: 10px;
}

/* Toggle icon styling */
.wd-el-toggle-icon {
    color: var(--power-lime, #ADFF60) !important;
    text-align: center;
    font-size: 18px !important;
    line-height: 1 !important;
    font-weight: 400 !important;
    margin-right: 20px;
}

/* Navigation pagination styling */
.brand-shortcode-content .wd-nav-pagin {
    align-items: baseline;
}

ul.wd-nav-pagin.wd-clickable.wd-type-bullets.wd-horizontal {
    margin: -4px 0;
    padding-left: 0;
}

.brand-shortcode-content .wd-el-video-overlay::after {
    background: linear-gradient(to top, rgba(173, 255, 47, 0) 0%, rgba(173, 255, 47, 0) 100%) !important;
}

/* ==========================================================================
   LINK STYLING - BRAND CONTENT
   ========================================================================== */

/* CSS Custom Properties for link styling */
@property --brand-link-decoration-color {
    syntax: '<color>';
    inherits: false;
    initial-value: var(--new-light-green, #D8FFB4);
}

@property --brand-link-decoration-thickness {
    syntax: '<length>';
    inherits: false;
    initial-value: 1px;
}

/* Base link styling for brand content */
.brand-shortcode-content a,
.brand-shortcode-content p a,
.brand-shortcode-content h1 a,
.brand-shortcode-content h2 a,
.brand-shortcode-content h3 a,
.brand-shortcode-content h4 a,
.brand-shortcode-content h5 a,
.brand-shortcode-content h6 a,
.brand-shortcode-content ul a,
.brand-shortcode-content ol a,
.brand-shortcode-content li a {
    color: var(--new-light-green, #D8FFB4);
    text-decoration-line: underline;
    text-decoration-thickness: var(--brand-link-decoration-thickness);
    text-decoration-color: var(--brand-link-decoration-color);
    text-underline-offset: 2px;
    transition: --brand-link-decoration-color 0.3s ease-out, --brand-link-decoration-thickness 0.2s ease-out;
    will-change: text-decoration-color, text-decoration-thickness;
    contain: layout style paint;
}

/* Hover effects for links (only on devices that support hover) */
@media (hover: hover) and (pointer: fine) {

    .brand-shortcode-content a:hover,
    .brand-shortcode-content p a:hover,
    .brand-shortcode-content h1 a:hover,
    .brand-shortcode-content h2 a:hover,
    .brand-shortcode-content h3 a:hover,
    .brand-shortcode-content h4 a:hover,
    .brand-shortcode-content h5 a:hover,
    .brand-shortcode-content h6 a:hover,
    .brand-shortcode-content ul a:hover,
    .brand-shortcode-content ol a:hover,
    .brand-shortcode-content li a:hover {
        --brand-link-decoration-color: var(--power-lime, #ADFF60);
        --brand-link-decoration-thickness: 2px;
    }
}

/* Fallback for older browsers that don't support @property */
@supports not (@property --brand-link-decoration-color) {

    .brand-shortcode-content a,
    .brand-shortcode-content p a,
    .brand-shortcode-content h1 a,
    .brand-shortcode-content h2 a,
    .brand-shortcode-content h3 a,
    .brand-shortcode-content h4 a,
    .brand-shortcode-content h5 a,
    .brand-shortcode-content h6 a,
    .brand-shortcode-content ul a,
    .brand-shortcode-content ol a,
    .brand-shortcode-content li a {
        text-decoration-thickness: 1px;
        text-decoration-color: var(--new-light-green, #D8FFB4);
    }

    @media (hover: hover) and (pointer: fine) {

        .brand-shortcode-content a:hover,
        .brand-shortcode-content p a:hover,
        .brand-shortcode-content h1 a:hover,
        .brand-shortcode-content h2 a:hover,
        .brand-shortcode-content h3 a:hover,
        .brand-shortcode-content h4 a:hover,
        .brand-shortcode-content h5 a:hover,
        .brand-shortcode-content h6 a:hover,
        .brand-shortcode-content ul a:hover,
        .brand-shortcode-content ol a:hover,
        .brand-shortcode-content li a:hover {
            text-decoration-color: var(--power-lime, #ADFF60);
            text-decoration-thickness: 2px;
        }


        /* Ensure seamless integration with existing WPBakery/Visual Composer content */
        .brand-shortcode-content .wpb-content-wrapper {
            width: 100%;
        }

        .brand-shortcode-content .vc_row {
            margin-left: -15px;
            margin-right: 0;
        }

        /* Match existing content styling */
        .brand-shortcode-content .wd-entry-content {
            line-height: inherit;
            font-size: inherit;
            color: inherit;
        }

        /* ==========================================================================
   BRAND HERO GALLERY
   ========================================================================== */

        .brand-hero-gallery {
            margin-top: -120px;
        }

        /* ==========================================================================
   BRAND PAGE SPECIFIC LAYOUT
   ========================================================================== */

        /* Brand page title styling */

        /* Brand description section */

        /* Brand content injection container */
        .brand-content-injection {
            margin-top: 16px;
            position: relative;
        }

        /* Brand archive hero wrapper */
        .brand-archive-hero {
            position: relative;
        }

        /* Brand product grid adjustments */
        .tax-product_brand .products-loop {
            /* Custom product grid styling for brand pages */
        }

        /* Brand bottom content (after products section) */
        .brand-bottom-content {
            padding-top: 12px;
        }

        /* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

        /* Tablet styles */
        @media (max-width: 1024px) {
            .brand-hero-gallery {
                margin-top: -100px;
            }
        }

        /* Mobile landscape */
        @media (max-width: 768px) {
            .brand-hero-gallery {
                margin-top: -80px;
            }

            .brand-shortcode-content .vc_row {
                margin-left: -10px;
            }
        }

        /* Mobile portrait */
        @media (max-width: 480px) {
            .brand-hero-gallery {
                margin-top: -60px;
            }

            .brand-shortcode-content .vc_row {
                margin-left: -5px;
            }

            .brand-shortcode-content {
                margin-top: 10px;
                margin-bottom: 10px;
            }
        }

        /* ==========================================================================
   UTILITIES AND HELPERS
   ========================================================================== */

        /* Brand shortcode content - show immediately (no loading state needed for [hero_brands] shortcode) */
        .brand-shortcode-content {
            opacity: 1;
            transform: translateY(0);
            /* Prevent layout shifts */
            min-height: 20px;
            contain: layout style;
        }

        /* Legacy loaded class (for backward compatibility) */
        .brand-shortcode-content.loaded {
            opacity: 1;
            transform: translateY(0);
        }

        /* Prevent layout shifts in toggle content */
        .wd-el-toggle-content {
            contain: layout style;
            min-height: 0;
            /* Allow natural height but prevent jumps */
            margin-top: 0px !important;
            /* Override WoodMart default 20px margin */
        }

        /* Improve toggle animation smoothness */
        .wd-el-toggle-head {
            contain: layout style;
        }

        /* Stabilize content during toggle opening/closing */
        .wd-el-toggle-content[style*="display: block"] {
            animation: fadeInContent 0.15s ease-out;
        }

        @keyframes fadeInContent {
            from {
                opacity: 0;
                transform: translateY(-5px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Performance optimizations */
        .brand-shortcode-content img {
            max-width: 100%;
            height: auto;
            
        }

        .brand-shortcode-content video {
            max-width: 100%;
            height: auto;
        }

        /* Accessibility improvements */

        .screen-reader-text {
            position: absolute !important;
            left: -9999px !important;
            width: 1px !important;
            height: 1px !important;
            overflow: hidden !important;
            clip: rect(1px, 1px, 1px, 1px) !important;
        }

        /* Error state styling */
        .brand-shortcode-content.error {
            opacity: 0.5;
            border: 1px solid #dc3232;
            background: rgba(220, 50, 50, 0.1);
            padding: 15px;
            border-radius: 4px;
        }

        .brand-shortcode-content.error::before {
            content: "⚠️ Content loading failed";
            display: block;
            font-weight: bold;
            color: #dc3232;
            margin-bottom: 10px;
        }

        /* Debug styling (remove in production) */
        .brand-shortcode-content.debug {
            border: 2px dashed #ccc;
            background: rgba(255, 255, 0, 0.1);
            position: relative;
        }

        .brand-shortcode-content.debug::after {
            content: "DEBUG: Brand Content";
            position: absolute;
            top: -25px;
            left: 0;
            background: #ffeb3b;
            color: #333;
            padding: 2px 8px;
            font-size: 12px;
            font-weight: bold;
            border-radius: 3px;
        }
    }
}