/**
 * Header Styles - ResourceBoy Match
 * Clean, simple header design matching ResourceBoy.com
 */

/* ===================================
   HEADER BASE - Fixed at top so menu stays visible when scrolling
   =================================== */
.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #F1F1F1;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    width: 100%;
}

/* When WordPress admin bar is visible (logged in), sit header below it */
body.admin-bar .site-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .site-header {
        top: 46px;
    }
}

/* Prevent content from hiding under the fixed header */
body {
    padding-top: 80px;
}

@media (max-width: 1023px) {
    body {
        padding-top: 70px;
    }
}

@media (max-width: 767px) {
    body {
        padding-top: 60px;
    }
}

body.admin-bar {
    padding-top: 112px; /* 32px admin bar + 80px header */
}

@media screen and (max-width: 782px) {
    body.admin-bar {
        padding-top: 106px; /* 46px admin bar + 60px header */
    }
}

.header-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

@media (min-width: 1200px) {
    .header-container {
        padding: 0 24px;
    }
}

@media (min-width: 1280px) {
    .header-container {
        padding: 0 5%;
    }
}

.header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    gap: 24px;
}

/* Responsive header layout */
@media (min-width: 1200px) {
    .header-wrapper {
        gap: 32px;
    }
}

@media (min-width: 1280px) {
    .header-wrapper {
        gap: 40px;
    }
}

@media (max-width: 1023px) {
    .header-wrapper {
        gap: 16px;
        justify-content: space-between;
    }
    
    /* On tablet/mobile: Logo left, icons right */
    .header-logo {
        flex: 0 0 auto;
    }
    
    .header-nav {
        display: none !important; /* Force hide on smaller screens */
    }
    
    .header-search-toggle {
        order: 1;
    }
    
    .mobile-menu-toggle {
        order: 2;
    }
}

/* ===================================
   LOGO
   =================================== */
.header-logo {
    flex-shrink: 0;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #131314;
    font-size: 22px;
    font-weight: 700;
    transition: opacity 0.2s ease;
}

.logo-link:hover {
    opacity: 0.85;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: #131314;
    letter-spacing: -0.03em;
}

/* Theme logo (assets/images/logo.webp) */
.theme-logo {
    max-height: 44px;
    width: auto;
    display: block;
}

.custom-logo-link {
    display: flex;
    align-items: center;
}

.custom-logo {
    max-height: 44px;
    width: auto;
}

/* ===================================
   NAVIGATION (Desktop) - WITH END ARROW
   =================================== */
.header-nav {
    flex: 1;
    display: none; /* Hidden on mobile by default */
    position: relative;
    max-width: 100%;
    overflow: visible; /* allow dropdown submenu to show below */
}

@media (min-width: 1024px) {
    .header-nav {
        display: flex; /* Show on desktop */
        align-items: center;
        justify-content: center;
    }
}

/* Navigation wrapper: horizontal scroll only; no vertical scrollbar so dropdown isn't trapped */
.nav-menu-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    flex: 1;
    min-width: 0;
    max-width: 100%;
    transition: margin 0.2s ease;
}

.nav-menu-wrapper::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* When scrollable: margin for both arrows */
.nav-menu-wrapper.has-scroll {
    margin-left: 40px;
    margin-right: 40px;
}

.nav-menu-wrapper.has-scroll-left-only {
    margin-left: 40px;
    margin-right: 0;
}

.nav-menu-wrapper.has-scroll-right-only {
    margin-left: 0;
    margin-right: 40px;
}

.nav-menu {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0 4px;
    min-width: min-content;
}

.nav-item {
    display: block;
    flex-shrink: 0;
}

.nav-link {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
    padding: 6px 4px;
}

.nav-link:hover {
    color: #111827;
}

/* Dropdown: Resources – trigger is same as other nav links; arrow is sibling, fixed at bottom edge of item.
   Use .site-header scope so behavior is consistent on homepage and all other pages. */
.site-header .nav-item.has-dropdown,
.nav-item.has-dropdown {
    position: relative !important;
    display: block;
}

/* Trigger: same as other nav links; extra padding-right for the arrow on the right */
.nav-link-dropdown-trigger,
a.nav-link-dropdown-trigger,
button.nav-link-dropdown-trigger {
    display: block !important;
    cursor: pointer;
    background: none;
    border: none;
    margin: 0;
    font: inherit;
    color: inherit;
    padding: 6px 18px 6px 4px !important;
    line-height: 1.2 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

a.nav-link-dropdown-trigger {
    text-decoration: none;
}

.nav-link-dropdown-trigger:hover {
    color: #111827;
}

/* Arrow: on the right side of the nav item, pointing down. */
.site-header .nav-link-dropdown-arrow,
.header-nav .nav-link-dropdown-arrow,
.nav-link-dropdown-arrow {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    left: auto !important;
    bottom: auto !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 0;
    pointer-events: none;
}

.site-header .nav-link-dropdown-arrow .nav-chevron,
.header-nav .nav-chevron,
.nav-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    display: block !important;
    width: 12px !important;
    height: 12px !important;
    stroke-width: 3 !important;
}

/* Chevron points down by default; rotate up when dropdown is open */
.site-header .nav-item.has-dropdown:hover .nav-link-dropdown-arrow .nav-chevron,
.site-header .nav-item.has-dropdown[aria-expanded="true"] .nav-link-dropdown-arrow .nav-chevron,
.nav-item.has-dropdown:hover .nav-link-dropdown-arrow .nav-chevron,
.nav-item.has-dropdown[aria-expanded="true"] .nav-link-dropdown-arrow .nav-chevron {
    transform: rotate(180deg);
}

/* Extra hover area so mouse doesn't leave .nav-item when moving to submenu; don't block clicks on the trigger link */
.nav-item.has-dropdown .nav-submenu::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 8px;
    pointer-events: none;
}

/* Submenu: fixed so it isn't trapped in the scrollable nav wrapper; position set by JS */
.nav-submenu {
    position: fixed !important;
    left: 0;
    top: 0;
    min-width: 200px;
    list-style: none;
    margin: 0;
    padding: 10px 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 10002 !important;
    display: block;
    transform: translateX(-50%) translateY(4px);
}

/* Show dropdown: hover, focus, JS class .nav-dropdown-open */
.nav-item.has-dropdown:hover .nav-submenu,
.nav-item.has-dropdown:focus-within .nav-submenu,
.nav-item.has-dropdown.nav-dropdown-open .nav-submenu {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(-50%) translateY(6px) !important;
    display: block !important;
}

.nav-submenu .nav-sublink {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.nav-submenu .nav-sublink:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Scroll Arrow Buttons - ResourceBoy style (both left and right) */
.nav-scroll-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.nav-scroll-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}

.nav-scroll-btn.visible {
    display: flex;
}

.nav-scroll-left {
    left: 0;
}

.nav-scroll-right {
    right: 0;
}

@media (min-width: 1024px) {
    .nav-scroll-left,
    .nav-scroll-right {
        display: none; /* Hidden by default, shown by JS when scrollable */
    }
    
    .nav-scroll-left.visible,
    .nav-scroll-right.visible {
        display: flex;
    }
}

/* ===================================
   SEARCH TOGGLE BUTTON
   =================================== */
.header-search-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.header-search-toggle:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.search-icon {
    width: 22px;
    height: 22px;
}

/* ===================================
   MOBILE MENU TOGGLE
   =================================== */
.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.mobile-menu-toggle:hover {
    background-color: #f3f4f6;
}

.menu-icon,
.close-icon {
    width: 24px;
    height: 24px;
    transition: opacity 0.2s ease;
}

.close-icon {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mobile-menu-toggle.active .menu-icon {
    opacity: 0;
}

.mobile-menu-toggle.active .close-icon {
    opacity: 1;
}

/* ===================================
   SEARCH OVERLAY (ResourceBoy Style)
   =================================== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ffffff;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.search-overlay-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.search-overlay-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 20px 0;
}

.search-overlay-header .header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: auto;
}

.search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: #374151;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.search-close:hover {
    background-color: #f3f4f6;
}

.search-overlay-content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    padding-top: 80px;
}

.search-overlay-form {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.search-overlay-input {
    width: 100%;
    height: 60px;
    padding: 0 60px 0 24px;
    font-size: 18px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-overlay-input:focus {
    border-color: #ED1C24;
}

.search-overlay-submit {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: #ED1C24;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-overlay-submit:hover {
    background-color: #4f46e5;
}

/* ===================================
   MOBILE MENU - Now handled by inline styles in header.php
   =================================== */

/* ===================================
   RESPONSIVE BREAKPOINTS
   =================================== */

/* Tablet (768px - 1023px) - Show menu icon, hide full nav */
@media (min-width: 768px) and (max-width: 1023px) {
    .header-search-toggle {
        display: flex;
    }

    .mobile-menu-toggle {
        display: flex; /* Show on tablet */
    }

    .header-nav {
        display: none; /* Hide full nav on tablet */
    }
}

/* Desktop (1024px+) - Show full nav, hide menu icon */
@media (min-width: 1024px) {
    .header-nav {
        display: flex; /* Show on desktop */
    }

    .header-search-toggle {
        display: flex;
    }

    .mobile-menu-toggle {
        display: none; /* Hide on desktop */
    }

    .mobile-menu-overlay {
        display: none;
    }
}

/* Desktop (1024px–1200px): compact for scrollable nav like ResourceBoy */
@media (min-width: 1024px) and (max-width: 1279px) {
    .header-wrapper {
        height: 70px;
    }

    .nav-menu {
        gap: 18px;
        padding: 0 2px;
    }

    .nav-link,
    .nav-link-dropdown-trigger {
        font-size: 14px;
        padding: 6px 6px !important;
    }
    .nav-link-dropdown-trigger {
        padding: 6px 20px 6px 6px !important;
    }
}

/* Desktop 1200px+: full menu fits */
@media (min-width: 1200px) {
    .header-wrapper {
        height: 76px;
    }

    .nav-menu {
        gap: 22px;
    }

    .nav-link,
    .nav-link-dropdown-trigger {
        font-size: 14px;
        padding: 6px 8px !important;
    }
    .nav-link-dropdown-trigger {
        padding: 6px 22px 6px 8px !important;
    }
}

/* Large Desktop (1280px+) */
@media (min-width: 1280px) {
    .header-wrapper {
        height: 80px;
    }

    .nav-menu {
        gap: 28px;
        padding: 0 4px;
    }

    .nav-link,
    .nav-link-dropdown-trigger {
        font-size: 15px;
        padding: 6px 10px !important;
    }
    .nav-link-dropdown-trigger {
        padding: 6px 24px 6px 10px !important;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .header-wrapper {
        height: 60px;
        gap: 16px;
    }

    .logo-text {
        font-size: 18px;
    }

    .custom-logo {
        max-height: 32px;
    }

    .mobile-menu-overlay {
        top: 60px;
    }
}

/* ===================================
   ACCESSIBILITY
   =================================== */
.header-search-toggle:focus,
.mobile-menu-toggle:focus,
.search-close:focus {
    outline: 2px solid #ED1C24;
    outline-offset: 2px;
}

.nav-link:focus,
.mobile-nav-link:focus {
    outline: 2px solid #ED1C24;
    outline-offset: 4px;
}

/* Skip Navigation */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #ED1C24;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ===================================
   PRINT STYLES
   =================================== */
@media print {
    .site-header {
        position: static;
        border-bottom: 1px solid #000;
    }

    .header-search-toggle,
    .mobile-menu-toggle,
    .search-overlay,
    .mobile-menu-overlay {
        display: none !important;
    }
}
