/**
 * NAVIGATION STICKY - Sticky Header Behavior
 * 
 * Pure sticky navigation behavior - no desktop styles, no mobile styles
 * Focus on position: fixed, scroll effects, and sticky state management
 * 
 * @package RentAssistenz  
 * @version 3.0.0 - Modular Split Architecture
 * @priority 4 (loads early for critical positioning)
 */

/* =============================================================================
   STICKY NAVIGATION BEHAVIOR
   ============================================================================= */

/* CSS Custom Properties */
:root {
    /* Sticky Navigation Settings */
    --rent-nav-sticky-z-index: 999;
    --rent-nav-sticky-height: 70px;
    --rent-nav-sticky-height-admin: 102px; /* With WordPress admin bar */
    --rent-nav-sticky-bg: rgba(255, 255, 255, 0.95);
    --rent-nav-sticky-bg-scrolled: rgba(255, 255, 255, 0.98);
    --rent-nav-sticky-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --rent-nav-sticky-shadow-scrolled: 0 4px 25px rgba(0, 0, 0, 0.15);
    --rent-nav-sticky-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== STICKY POSITIONING - CRITICAL WORDPRESS OVERRIDES ===== */

/* GLOBAL STICKY GUARANTEE - Works on all page types + THEME FRAMEWORK OVERRIDE */
html body .site-header,
html body.page .site-header,
html body.single .site-header,
html body.archive .site-header,
html body.home .site-header,
html body.front-page .site-header,
body .site-header,
body header.site-header,
html body .site-header.header-transparent,
body .site-header.header-transparent {
    position: fixed !important; /* CRITICAL: Must override theme CSS */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    margin: 0 !important; /* Ensure no margins from theme */
    z-index: var(--rent-nav-sticky-z-index);
    background: var(--rent-nav-sticky-bg) !important; /* Override theme background */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    transition: var(--rent-nav-sticky-transition);
    isolation: isolate;
    will-change: transform;
    transform: translateZ(0); /* GPU acceleration */
    box-shadow: var(--rent-nav-sticky-shadow);
}

/* WordPress Admin Bar Compensation */
.admin-bar html body .site-header,
.admin-bar body .site-header {
    top: 32px !important; /* Compensate for WordPress admin bar */
}

/* ===== BODY PADDING COMPENSATION ===== */

/* Prevent content overlap with sticky header */
html body,
body.page,
body.single,
body.home {
    padding-top: var(--rent-nav-sticky-height) !important; /* Must override theme */
}

/* WordPress Admin Bar + Header compensation */
html body.admin-bar {
    padding-top: var(--rent-nav-sticky-height-admin) !important;
}

/* ===== STICKY SCROLL STATE BEHAVIOR ===== */

/* Scrolled state - Enhanced backdrop and shadow */
.site-header.scrolled {
    background: var(--rent-nav-sticky-bg-scrolled) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--rent-nav-sticky-shadow-scrolled) !important;
}

/* Logo size adjustment when scrolled */
.site-header.scrolled .nav-desktop__logo img,
.site-header.scrolled .logo-header img,
.site-header.scrolled .navbar-brand img {
    height: 40px;
    transition: var(--rent-nav-sticky-transition);
}

/* Navigation padding adjustment when scrolled */
.site-header.scrolled .nav-desktop,
.site-header.scrolled .main-bar {
    min-height: 60px;
    padding: 0.75rem 1.5rem;
}

/* ===== THEME SPECIFIC OVERRIDES ===== */

/* Clear conflicting theme transforms but keep sticky */
.main-bar-wraper,
.main-bar {
    box-shadow: none;
    transition: var(--rent-nav-sticky-transition);
}

.header-transparent {
    transform: none;
}

/* Ensure theme sticky classes work with our system - NO HEIGHT to prevent double navbar */
.sticky-header,
.main-bar-wraper.sticky-header,
.sticky-header.main-bar-wraper {
    position: fixed !important;
    top: 0 !important;
    z-index: var(--rent-nav-sticky-z-index);
    background: var(--rent-nav-sticky-bg) !important;
    /* NO min-height here! Only .site-header should define height! */
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Optimize sticky header for performance */
.site-header,
.sticky-header {
    contain: layout style;
    will-change: transform, background-color, box-shadow;
}

/* Smooth scroll behavior for anchor links */
html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--rent-nav-sticky-height) + 20px);
}

.admin-bar html {
    scroll-padding-top: calc(var(--rent-nav-sticky-height-admin) + 20px);
}

/* ===== RESPONSIVE STICKY BEHAVIOR ===== */

/* Mobile sticky adjustments */
@media (max-width: 768px) {
    :root {
        --rent-nav-sticky-height: 60px;
        --rent-nav-sticky-height-admin: 92px;
    }
    
    /* MOBILE STICKY GUARANTEE - Extra specificity for mobile devices */
    html body .site-header,
    html body .site-header.header-transparent,
    body .site-header,
    body .site-header.header-transparent {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        z-index: var(--rent-nav-sticky-z-index);
        background: var(--rent-nav-sticky-bg) !important;
    }
    
    .site-header.scrolled .nav-desktop__logo img,
    .site-header.scrolled .logo-header img,
    .site-header.scrolled .navbar-brand img {
        height: 35px;
    }
    
    .site-header.scrolled .nav-desktop,
    .site-header.scrolled .main-bar {
        min-height: 50px;
        padding: 0.5rem 1rem;
    }
}

/* ===== ACCESSIBILITY & REDUCED MOTION ===== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .site-header,
    .sticky-header,
    .site-header.scrolled {
        transition: none;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .site-header.scrolled .nav-desktop__logo img,
    .site-header.scrolled .logo-header img,
    .site-header.scrolled .navbar-brand img {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .site-header,
    .sticky-header {
        border-bottom: 2px solid var(--rent-nav-sticky-z-index);
    }
    
    .site-header.scrolled {
        border-bottom-color: #333333;
    }
}

/* ===== PRINT STYLES ===== */

@media print {
    .site-header,
    .sticky-header {
        position: static !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }
    
    html body,
    body.page,
    body.single,
    body.home {
        padding-top: 0 !important;
    }
}