/**
 * Codlion Theme - Professional Header System
 * 
 * WordPress-compliant, maintainable header styling
 * - Mobile-first responsive design
 * - Clean CSS architecture with proper specificity
 * - Performance optimized
 * - Commercial-grade implementation
 * 
 * @package Codlion
 * @version 1.0.0
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ========================================================================== */

:root {
    --header-height: 60px;
    --header-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --header-transition: all 0.3s ease;
    --desktop-breakpoint: 992px;
    --mobile-breakpoint: 991px;
    --menu-gap: 40px;
    --header-padding: 20px;
    /* WordPress customizer variables are defined in header.php */
    /* --header-bg-color, --header-bg-color-scroll, --header-text-color, --header-text-color-scroll, --cart-count-bg-color */
}

/* ==========================================================================
   BASE HEADER STRUCTURE
   ========================================================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    z-index: 1000;
    background-color: var(--header-bg-color);
    transition: var(--header-transition);
}

/* Header positioning adjustments */
body.enable-top-bar .site-header {
    top: 30px;
}

body.scrolled .site-header {
    top: 0;
    background-color: var(--header-bg-color-scroll);
    box-shadow: var(--header-shadow);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--header-padding);
}

/* ==========================================================================
   RESPONSIVE LAYOUT SYSTEM
   ========================================================================== */

/* Mobile-first: Hide desktop elements, show mobile elements */
.desktop-navigation {
    display: none;
}

.header-left {
    display: flex;
    align-items: center;
}

/* Desktop: Show desktop elements, hide mobile elements */
@media (min-width: 992px) {
    .desktop-navigation {
        display: flex;
        flex: 1;
        justify-content: center;
        margin: 0 var(--menu-gap);
    }
    
    .header-left {
        display: none;
    }
    
    /* Hide all mobile menu elements on desktop - REMOVED CONFLICTING RULES */
}

/* ==========================================================================
   LOGO SECTION
   ========================================================================== */

.site-branding {
    flex: 0 0 auto;
    z-index: 1001;
}

.custom-logo-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.custom-logo-wrapper img {
    height: 40px;
    width: auto;
    object-fit: contain;
    transition: var(--header-transition);
}

.site-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 2px;
    line-height: 1;
}

.site-title a {
    text-decoration: none;
    color: var(--header-text-color);
    transition: var(--header-transition);
}

/* Site title scrolled state - use Header Section Scrolled Color */
body.scrolled .site-header .site-title a,
body:not(.home) .site-header .site-title a {
    color: var(--header-text-color-scroll);
}

/* Logo system - follows Header Section Color variables like menu, search, and cart icons */

/* Base logo styling */
.site-header .custom-logo-link img,
.site-branding .custom-logo-link img {
    max-height: 60px;
    width: auto;
    transition: filter 0.3s ease;
}

/* Logo color adaptation using Header Section Color variables */
/* For SVG logos - use color directly */
.site-header .custom-logo-link svg,
.site-branding .custom-logo-link svg {
    fill: var(--header-text-color);
    transition: fill 0.3s ease;
}

/* For PNG/JPG logos - use smart filters based on header text color */
/* Home page normal state - adapt to header text color */
body.home:not(.scrolled) .site-header .custom-logo-link img,
body.home:not(.scrolled) .site-branding .custom-logo-link img {
    /* Use header text color - if light text, invert dark logo */
    filter: var(--logo-filter-normal, none);
}

/* Scrolled state and other pages - adapt to scrolled header text color */
body.scrolled .site-header .custom-logo-link img,
body.scrolled .site-branding .custom-logo-link img,
body:not(.home) .site-header .custom-logo-link img,
body:not(.home) .site-branding .custom-logo-link img {
    /* Use scrolled header text color - if dark text, don't invert */
    filter: var(--logo-filter-scroll, brightness(0) invert(1));
}

/* SVG logo scrolled state */
body.scrolled .site-header .custom-logo-link svg,
body.scrolled .site-branding .custom-logo-link svg,
body:not(.home) .site-header .custom-logo-link svg,
body:not(.home) .site-branding .custom-logo-link svg {
    fill: var(--header-text-color-scroll);
}

/* Remove old dual-logo classes - no longer needed */
.default-logo,
.scrolled-logo {
    display: none;
}

/* Mobile logo centering */
@media (max-width: 991px) {
    .site-branding {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ==========================================================================
   DESKTOP NAVIGATION
   ========================================================================== */

.desktop-navigation .main-navigation {
    width: 100%;
}

.desktop-navigation .menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--menu-gap);
    align-items: center;
    justify-content: center;
}

.desktop-navigation .menu li {
    margin: 0;
    position: relative;
}

.desktop-navigation .menu a {
    display: block;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 0;
    color: inherit;
    transition: opacity 0.3s ease;
    position: relative;
}

.desktop-navigation .menu a:hover {
    opacity: 0.7;
}

/* ==========================================================================
   MOBILE MENU TOGGLE
   ========================================================================== */

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--header-transition);
    border-radius: 4px;
}

.menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.menu-toggle:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.menu-icon {
    width: 24px;
    height: 24px;
    transition: var(--header-transition);
}

/* ==========================================================================
   HEADER ACTIONS (Search & Cart)
   ========================================================================== */

.header-right {
    flex: 0 0 auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-toggle,
.cart-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    padding: 8px;
    border-radius: 4px;
    transition: var(--header-transition);
}

/* Remove hover effects for search toggle */
.cart-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.search-toggle:focus,
.cart-link:focus {
    outline: none;
    border: none;
}

.search-toggle:active,
.cart-link:active {
    outline: none;
    border: none;
}

.search-icon,
.cart-icon {
    width: 20px;
    height: 20px;
    transition: var(--header-transition);
}

/* Professional cart system */
.cart-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Cart count badge - Professional positioning following WordPress standards - Enhanced specificity */
html body.home .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count,
html body:not(.home) .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count,
html body.scrolled .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count,
html body .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count {
    position: absolute;
    top: 6px;
    right: -6px;
    background-color: var(--cart-count-bg-color, #e94c39);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 8px;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-sizing: border-box;
}

/* Cart count badge uses scrolled color on other pages for consistency - High specificity */
body:not(.home) .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count {
    position: absolute;
    top: -1px;
    right: -12px;
    background-color: var(--header-text-color-scroll) !important;
    color: var(--header-bg-color-scroll) !important;
}

/* Cart count badge uses scrolled color when scrolled for consistency - High specificity */
body.scrolled .site-header .header-actions .cart-link .cart-icon-wrapper .cart-count {
    position: absolute;
    top: -1px;
    right: -12px;
    background-color: var(--header-text-color-scroll) !important;
    color: var(--header-bg-color-scroll) !important;
}

.cart-count-updated {
    animation: cartBounce 0.3s ease;
}

@keyframes cartBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Mobile header actions spacing */
@media (max-width: 991px) {
    .header-actions {
        gap: 15px;
    }
    
    .header-content {
        padding: 0 15px;
    }
}

/* ==========================================================================
   MOBILE NAVIGATION OVERLAY
   ========================================================================== */

.mobile-navigation {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 999;
    transition: left 0.3s ease;
    padding: var(--header-height) 20px 20px;
    overflow-y: auto;
}

.mobile-navigation.active {
    left: 0;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* REMOVED CONFLICTING MOBILE MENU CSS - Now using mobile-menu-panel.css */

/* ==========================================================================
   COLOR SCHEMES & THEME STATES
   ========================================================================== */

/* Home page default state (uses customizer background and text colors) */
body.home:not(.scrolled) .site-header {
    background-color: var(--header-bg-color);
}

body.home:not(.scrolled) .site-header,
body.home:not(.scrolled) .desktop-navigation .menu a,
body.home:not(.scrolled) .search-toggle,
body.home:not(.scrolled) .cart-link,
body.home:not(.scrolled) .menu-toggle,
body.home:not(.scrolled) .site-title a {
    color: var(--header-text-color);
}

body.home:not(.scrolled) .search-icon,
body.home:not(.scrolled) .cart-icon,
body.home:not(.scrolled) .menu-icon line {
    stroke: var(--header-text-color);
}

/* Other pages default state (uses customizer scrolled colors) */
body:not(.home) .site-header {
    background-color: var(--header-bg-color-scroll);
}

body:not(.home) .site-header,
body:not(.home) .desktop-navigation .menu a,
body:not(.home) .search-toggle,
body:not(.home) .cart-link,
body:not(.home) .menu-toggle,
body:not(.home) .site-title a {
    color: var(--header-text-color-scroll);
}

body:not(.home) .search-icon,
body:not(.home) .cart-icon,
body:not(.home) .menu-icon line {
    stroke: var(--header-text-color-scroll);
}

/* Scrolled state for all pages (uses customizer scrolled colors) */
body.scrolled .site-header,
body.scrolled .desktop-navigation .menu a,
body.scrolled .search-toggle,
body.scrolled .cart-link,
body.scrolled .menu-toggle,
body.scrolled .site-title a {
    color: var(--header-text-color-scroll);
}

body.scrolled .search-icon,
body.scrolled .cart-icon,
body.scrolled .menu-icon line {
    stroke: var(--header-text-color-scroll);
}

/* ==========================================================================
   ACCESSIBILITY & PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .site-header,
    .mobile-navigation,
    .menu-overlay,
    .desktop-navigation .menu a,
    .search-toggle,
    .cart-link,
    .menu-toggle {
        transition: none;
    }
    
    .cart-count-updated {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .site-header {
        border-bottom: 1px solid currentColor;
    }
    
    .mobile-navigation {
        border: 1px solid currentColor;
    }
}

/* Print styles */
@media print {
    .site-header {
        position: static;
        background: white;
        color: black;
        box-shadow: none;
    }
    
    .mobile-navigation,
    .menu-overlay,
    .header-left {
        display: none;
    }
    
    .desktop-navigation {
        display: block;
    }
}

/* ==========================================================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Mobile: Remove padding from header elements for tighter spacing */
@media (max-width: 991px) {
    .menu-toggle {
        padding: 0;
    }
    
    .search-toggle,
    .cart-link {
        padding: 0;
    }
    
    .header-content {
        padding: 0 12px;
    }
    
    /* Professional 1px gap between search and cart icons */
    .header-actions {
        gap: 1px;
    }
    
    /* Perfect logo centering on mobile */
    .site-branding {
        flex: 1;
        text-align: center;
        order: 2; /* Logo in middle */
    }
    
    .header-left {
        flex: 0 0 auto;
        order: 1; /* Burger menu on left */
    }
    
    .header-right {
        flex: 0 0 auto;
        order: 3; /* Search/cart on right */
    }
}

