/**
 * Awesome Header Plugin - Styles
 * Version: 10.0
 */

/* ========================================
   CSS Variables & Root Settings
   ======================================== */

:root {
    --ahp-header-height: 70px;
    --ahp-menu-width: 320px;
    --ahp-bg: #FFFFFF;
    --ahp-menu-bg: #F7F7F7;
    --ahp-submenu-bg: #FFFFFF;
    --ahp-text: #111111;
    --ahp-text-subtle: #666666;
    --ahp-accent: #D90429;
    --ahp-border: #E5E5E5;
    --ahp-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --ahp-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --ahp-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Prevent flash of invisible text */
@font-face {
    font-family: system-ui;
    font-display: swap;
}

/* ========================================
   Base Body Adjustments
   ======================================== */

body {
    font-family: var(--ahp-font);
    /* Improve text rendering across all browsers */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.ahp-active {
    padding-top: var(--ahp-header-height);
}

/* Hide theme headers when plugin is active */
body.ahp-active #page > header,
body.ahp-active .elementor-location-header {
    display: none !important;
}

/* Admin bar adjustments */
body.admin-bar #ahp-header {
    top: 32px;
}

body.admin-bar #ahp-off-canvas-menu,
body.admin-bar #ahp-overlay {
    top: 32px;
    height: calc(100% - 32px);
}

body.ahp-active.admin-bar {
    padding-top: calc(var(--ahp-header-height) + 32px);
}

/* ========================================
   Main Header
   ======================================== */

#ahp-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--ahp-header-height);
    background: var(--ahp-bg);
    box-shadow: var(--ahp-shadow);
    z-index: 9999;
    padding: 0 25px;
    border-bottom: 1px solid var(--ahp-border);
}

#ahp-header .ahp-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   Logo
   ======================================== */

.ahp-logo {
    flex-shrink: 0; /* Prevent logo from shrinking */
}

.ahp-logo a {
    display: inline-flex;
    align-items: center;
    height: 100%;
    text-decoration: none;
    color: var(--ahp-text);
    font-size: 1.8rem;
    font-weight: 700;
    transition: opacity 0.2s ease;
    /* Prevent text from disappearing during font load */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Ensure text is always visible */
    font-display: swap;
    /* Prevent layout shift */
    line-height: 1;
    white-space: nowrap;
}

.ahp-logo a:hover {
    opacity: 0.8;
}

.ahp-logo img {
    max-height: 40px;
    height: auto;
    width: auto;
    /* Prevent image flash */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ========================================
   Desktop Content (Categories/Tags)
   ======================================== */

.ahp-desktop-content {
    display: none; /* Hidden by default, shown on desktop */
    flex-grow: 1;
    margin: 0 30px;
    /* Prevent content shift */
    min-width: 0; /* Allow flex items to shrink */
}

.ahp-desktop-categories,
.ahp-desktop-tags,
.ahp-desktop-custom {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 25px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.ahp-desktop-categories li,
.ahp-desktop-tags li {
    margin: 0;
    padding: 0;
}

.ahp-desktop-categories a,
.ahp-desktop-tags a {
    text-decoration: none;
    color: var(--ahp-text-subtle);
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
    white-space: nowrap;
    /* Better text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.4; /* Better vertical alignment */
}

.ahp-desktop-categories a:hover,
.ahp-desktop-tags a:hover {
    color: var(--ahp-accent);
}

.ahp-desktop-custom ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 25px;
    flex-wrap: wrap;
}

.ahp-desktop-custom li {
    margin: 0;
    padding: 0;
}

.ahp-desktop-custom a {
    text-decoration: none;
    color: var(--ahp-text-subtle);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease;
    /* Better text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.4; /* Better vertical alignment */
}

.ahp-desktop-custom a:hover {
    color: var(--ahp-accent);
}

/* ========================================
   Menu Toggle Button
   ======================================== */

.ahp-menu-toggle {
    width: 28px;
    height: 22px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: transparent;
    border: none;
    padding: 0;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.ahp-menu-toggle:hover {
    opacity: 0.7;
}

.ahp-menu-toggle:focus {
    outline: 2px solid var(--ahp-accent);
    outline-offset: 3px;
}

.ahp-menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--ahp-text);
    border-radius: 3px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ========================================
   Off-Canvas Menu
   ======================================== */

#ahp-off-canvas-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ahp-menu-width);
    height: 100%;
    background-color: var(--ahp-menu-bg);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    transition: transform 0.4s var(--ahp-timing);
    transform: translateX(-100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#ahp-off-canvas-menu.is-open {
    transform: translateX(0);
}

/* ========================================
   Menu Top (Search & Close Icons)
   ======================================== */

#ahp-menu-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--ahp-border);
    flex-shrink: 0;
    background: var(--ahp-menu-bg);
}

.ahp-search-icon,
.ahp-close-btn {
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.ahp-search-icon:hover,
.ahp-close-btn:hover {
    opacity: 0.7;
}

.ahp-search-icon:focus,
.ahp-close-btn:focus {
    outline: 2px solid var(--ahp-accent);
    outline-offset: 2px;
}

.ahp-search-icon svg,
.ahp-close-btn svg {
    fill: var(--ahp-text);
    transition: transform 0.2s ease;
    width: 100%;
    height: 100%;
}

.ahp-search-icon:hover svg,
.ahp-close-btn:hover svg {
    transform: scale(1.1);
}

/* ========================================
   Main Navigation
   ======================================== */

#ahp-main-nav {
    padding: 10px 0;
    overflow-y: auto;
    flex-grow: 1;
}

#ahp-main-nav ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

#ahp-main-nav > ul > li {
    border-bottom: 1px solid var(--ahp-border);
}

#ahp-main-nav li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 25px;
    text-decoration: none;
    color: var(--ahp-text);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: background-color 0.2s ease;
}

#ahp-main-nav > ul > li > a:hover {
    background-color: #EFEFEF;
}

/* No menu message */
.ahp-no-menu {
    padding: 25px;
    color: var(--ahp-text-subtle);
    text-align: center;
}

/* ========================================
   Active/Current Menu Items
   ======================================== */

#ahp-main-nav > ul > li.current-menu-item > a,
#ahp-main-nav > ul > li.current-menu-ancestor > a {
    background-color: #EFEFEF;
    color: var(--ahp-accent);
}

#ahp-main-nav .sub-menu li.current-menu-item > a {
    color: var(--ahp-text);
    padding-left: 50px;
}

#ahp-main-nav .sub-menu li.current-menu-item > a::before {
    transform: translateY(-50%) scaleX(1);
}

/* ========================================
   Submenu Expand Button
   ======================================== */

.ahp-expand-btn {
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
    color: var(--ahp-accent);
    transition: transform 0.3s var(--ahp-timing);
    padding: 5px;
    cursor: pointer;
    user-select: none;
}

.ahp-expand-btn:focus {
    outline: 2px solid var(--ahp-accent);
    outline-offset: 2px;
}

.ahp-expand-btn.is-open {
    transform: rotate(45deg);
}

/* ========================================
   Submenus
   ======================================== */

#ahp-main-nav .sub-menu {
    max-height: 0;
    overflow: hidden;
    background-color: var(--ahp-submenu-bg);
    transition: max-height 0.4s var(--ahp-timing), padding 0.4s var(--ahp-timing);
    padding: 0;
}

#ahp-main-nav .sub-menu.is-open {
    max-height: 500px;
    padding: 10px 0;
}

#ahp-main-nav .sub-menu li {
    border-bottom: none;
}

#ahp-main-nav .sub-menu li a {
    padding: 12px 25px 12px 45px;
    text-transform: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ahp-text-subtle);
    position: relative;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

#ahp-main-nav .sub-menu li a::before {
    content: '';
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%) scaleX(0);
    transform-origin: left;
    width: 4px;
    height: 20px;
    background-color: var(--ahp-accent);
    transition: transform 0.3s var(--ahp-timing);
}

#ahp-main-nav .sub-menu li a:hover {
    background-color: transparent;
    color: var(--ahp-text);
    padding-left: 50px;
}

#ahp-main-nav .sub-menu li a:hover::before {
    transform: translateY(-50%) scaleX(1);
}

/* ========================================
   Search Container
   ======================================== */

#ahp-search-container {
    display: none;
    padding: 20px 25px;
    flex-direction: column;
    height: 100%;
    background: var(--ahp-menu-bg);
}

#ahp-off-canvas-menu.search-active #ahp-main-nav {
    display: none;
}

#ahp-off-canvas-menu.search-active #ahp-search-container {
    display: flex;
}

.ahp-search-form-wrapper {
    position: relative;
    flex-shrink: 0;
}

.ahp-search-field {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 1px solid var(--ahp-border);
    border-radius: 5px;
    font-size: 1.1rem;
    font-family: var(--ahp-font);
    background: #fff;
    transition: border-color 0.2s ease;
}

.ahp-search-field:focus {
    outline: none;
    border-color: var(--ahp-accent);
}

/* ========================================
   Search Loader
   ======================================== */

.ahp-loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--ahp-accent);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: ahp-spin 1s linear infinite;
    position: absolute;
    right: 15px;
    top: 50%;
    margin-top: -10px;
}

@keyframes ahp-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   Search Results
   ======================================== */

.ahp-search-results {
    margin-top: 20px;
    flex-grow: 1;
    overflow-y: auto;
}

.ahp-search-result-item {
    display: block;
    padding: 12px 15px;
    background: #fff;
    border-bottom: 1px solid var(--ahp-border);
    text-decoration: none;
    color: var(--ahp-text);
    transition: background-color 0.2s ease;
    position: relative;
}

.ahp-search-result-item:hover {
    background-color: #f0f0f0;
}

.ahp-search-result-item:focus {
    outline: 2px solid var(--ahp-accent);
    outline-offset: -2px;
}

.ahp-post-type-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 0.75rem;
    background: var(--ahp-accent);
    color: #fff;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
}

.ahp-no-results,
.ahp-search-message {
    padding: 15px;
    color: var(--ahp-text-subtle);
    text-align: center;
}

/* ========================================
   Back to Menu Button
   ======================================== */

.ahp-back-to-menu {
    display: inline-block;
    margin-top: auto;
    padding-top: 20px;
    color: var(--ahp-text-subtle);
    text-decoration: none;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.ahp-back-to-menu:hover {
    color: var(--ahp-text);
}

.ahp-back-to-menu:focus {
    outline: 2px solid var(--ahp-accent);
    outline-offset: 2px;
}

/* ========================================
   Overlay
   ======================================== */

#ahp-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#ahp-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Responsive Styles
   ======================================== */

/* Desktop - Show desktop content */
@media (min-width: 1024px) {
    .ahp-desktop-content {
        display: flex;
    }
}

/* Tablet and below - Adjust admin bar */
@media screen and (max-width: 782px) {
    body.admin-bar #ahp-header {
        top: 46px;
    }
    
    body.admin-bar #ahp-off-canvas-menu,
    body.admin-bar #ahp-overlay {
        top: 46px;
        height: calc(100% - 46px);
    }
    
    body.ahp-active.admin-bar {
        padding-top: calc(var(--ahp-header-height) + 46px);
    }
}

/* Mobile - Full width menu */
@media (max-width: 600px) {
    :root {
        --ahp-menu-width: 85%;
    }
    
    #ahp-header {
        padding: 0 15px;
    }
    
    .ahp-logo a {
        font-size: 1.5rem;
    }
    
    .ahp-logo img {
        max-height: 35px;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    :root {
        --ahp-menu-width: 90%;
    }
    
    .ahp-logo a {
        font-size: 1.3rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    #ahp-header,
    #ahp-off-canvas-menu,
    #ahp-overlay {
        display: none !important;
    }
    
    body.ahp-active {
        padding-top: 0 !important;
    }
}

/* ========================================
   Accessibility Improvements
   ======================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --ahp-border: #000000;
        --ahp-text-subtle: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--ahp-accent);
    outline-offset: 2px;
}
