/*--------------------------------------------------------------
# AuthorPro Header, Navigation & Search Modal Architecture
# Description: Pure Vanilla CSS for Sticky Header, Multi-Level
#              Dropdowns, Mobile Accordion Drawer, and Search Modal
--------------------------------------------------------------*/

/* =============================================================
   1. Sticky Header & Branding
   ============================================================= */
.authorpro-header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 50;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--authorpro-color-slate-100);
    transition: background-color var(--authorpro-transition-base), border-color var(--authorpro-transition-base);
}

.authorpro-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 5rem;
    /* 80px */
}

/* Site Identity & Logo */
.authorpro-site-identity {
    display: flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
}

.authorpro-site-identity.authorpro-identity-inline {
    flex-direction: row;
    gap: 1rem;
    align-items: center;
}

.authorpro-site-identity.authorpro-identity-stacked {
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
    justify-content: center;
}

.custom-logo-link {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    text-decoration: none;
}

.custom-logo {
    max-width: 150px;
    height: auto;
    object-fit: contain;
    transition: opacity var(--authorpro-transition-base);
}

.custom-logo:hover {
    opacity: 0.9;
}

@media (min-width: 768px) {
    .custom-logo {
        max-width: 200px;
    }
}

.authorpro-site-identity-text {
    display: flex;
    flex-direction: column;
}

.authorpro-site-title {
    font-family: var(--authorpro-font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--authorpro-color-slate-900);
    letter-spacing: -0.025em;
    text-decoration: none;
    line-height: 1.2;
    transition: color var(--authorpro-transition-base);
}

.authorpro-site-title:hover {
    color: var(--authorpro-color-brand-600);
}

.authorpro-site-description {
    font-size: 0.875rem;
    color: var(--authorpro-color-slate-500);
    margin: 0;
    line-height: 1.4;
}

/* Header Action Buttons Container */
.authorpro-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

@media (max-width: 1023px) {
    .authorpro-header-actions-empty {
        display: none;
    }
}

/* Mini Cart Trigger & Badge */
.authorpro-mini-cart {
    position: relative;
    cursor: pointer;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.authorpro-cart-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--authorpro-color-slate-700);
    text-decoration: none;
    padding: 0.5rem;
    transition: color var(--authorpro-transition-base);
}

.authorpro-cart-link:hover {
    color: var(--authorpro-color-brand-600);
}

.authorpro-cart-icon {
    width: 1.5rem;
    height: 1.5rem;
    stroke-width: 2;
    color: var(--authorpro-color-slate-700);
    transition: color var(--authorpro-transition-base);
}

.authorpro-cart-link:hover .authorpro-cart-icon {
    color: var(--authorpro-color-brand-600);
}

.authorpro-cart-count {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.375rem;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    color: var(--authorpro-color-white);
    background-color: var(--authorpro-color-brand-600);
    border-radius: var(--authorpro-radius-full);
    transform: translate(0.25rem, -0.25rem);
    pointer-events: none;
    box-shadow: var(--authorpro-shadow-sm);
}

/* Search Trigger Button */
.authorpro-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--authorpro-color-slate-500);
    border-radius: var(--authorpro-radius-full);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--authorpro-transition-base), background-color var(--authorpro-transition-base);
}

.authorpro-search-trigger:hover {
    color: var(--authorpro-color-brand-600);
    background-color: var(--authorpro-color-slate-50);
}

.authorpro-search-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--authorpro-color-brand-600);
}

.authorpro-search-trigger-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* Mobile Menu Hamburger Button */
.authorpro-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--authorpro-radius-md);
    color: var(--authorpro-color-slate-600);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color var(--authorpro-transition-base), color var(--authorpro-transition-base);
}

.authorpro-mobile-toggle:hover {
    color: var(--authorpro-color-slate-900);
    background-color: var(--authorpro-color-slate-100);
}

.authorpro-mobile-toggle:focus-visible {
    outline: none;
    background-color: var(--authorpro-color-slate-100);
}

.authorpro-mobile-toggle-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* Default closed state */
.authorpro-mobile-toggle .authorpro-icon-close {
    display: none;
}

.authorpro-mobile-toggle .authorpro-icon-menu {
    display: block;
}

/* Active open state when aria-expanded="true" or drawer is open */
.authorpro-mobile-toggle[aria-expanded="true"] .authorpro-icon-menu,
.authorpro-drawer-open .authorpro-mobile-toggle .authorpro-icon-menu {
    display: none;
}

.authorpro-mobile-toggle[aria-expanded="true"] .authorpro-icon-close,
.authorpro-drawer-open .authorpro-mobile-toggle .authorpro-icon-close {
    display: block;
}

@media (min-width: 1024px) {
    .authorpro-mobile-toggle {
        display: none !important;
    }
}

/* =============================================================
   2. Desktop Multi-Level Navigation
   ============================================================= */
.authorpro-nav {
    display: none;
}

@media (min-width: 1024px) {
    .authorpro-nav {
        display: flex;
        align-items: center;
        gap: 2rem;
        font-size: 1rem;
    }
}

/* Base Nav Focus Ring */
.authorpro-nav a:focus-visible,
.authorpro-nav button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--authorpro-color-brand-600), 0 0 0 4px var(--authorpro-color-white);
    border-radius: var(--authorpro-radius-md);
}

/* Level 1 Nav Links */
.authorpro-menu-link,
.authorpro-nav>a,
.authorpro-nav>ul>li>a {
    color: var(--authorpro-color-slate-600);
    font-weight: 500;
    text-decoration: none;
    transition: color var(--authorpro-transition-base);
    padding: 0.5rem 0;
}

.authorpro-menu-link:hover,
.authorpro-nav>a:hover,
.authorpro-nav>ul>li>a:hover,
.authorpro-nav .current-menu-item>a {
    color: var(--authorpro-color-brand-600);
    /* font-weight: 600; */
}

/* Level 1 Parent Item Dropdown Wrapper */
.authorpro-menu-item-has-children {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Level 1 Parent Toggle Button */
.authorpro-menu-toggle {
    display: flex;
    align-items: center;
    color: var(--authorpro-color-slate-600);
    font-weight: 500;
    font-size: 1rem;
    padding: 1rem 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--authorpro-transition-base);
}

.authorpro-menu-icon {
    width: 1rem;
    height: 1rem;
    margin-left: 0.25rem;
    transition: transform var(--authorpro-transition-base);
}

/* Rotate Chevron on Hover / Focus */
.authorpro-menu-item-has-children:hover>.authorpro-menu-toggle,
.authorpro-menu-item-has-children:focus-within>.authorpro-menu-toggle {
    color: var(--authorpro-color-brand-600);
}

.authorpro-menu-item-has-children:hover>.authorpro-menu-toggle .authorpro-menu-icon,
.authorpro-menu-item-has-children:focus-within>.authorpro-menu-toggle .authorpro-menu-icon {
    transform: rotate(180deg);
}

/* Submenu Dropdown (Level 2) */
.authorpro-submenu {
    position: absolute;
    left: 0;
    top: 100%;
    width: 14rem;
    /* 224px */
    background-color: var(--authorpro-color-white);
    border: 1px solid var(--authorpro-color-slate-100);
    box-shadow: var(--authorpro-shadow-xl);
    border-radius: var(--authorpro-radius-lg);
    padding: 0.5rem 0;
    margin: 0;
    list-style: none;
    text-align: left;
    z-index: 50;

    /* Hidden State & Animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition: opacity var(--authorpro-transition-base), visibility var(--authorpro-transition-base), transform var(--authorpro-transition-base);
    pointer-events: none;
}

/* Hover Bridge: Invisible pseudo-element to prevent dropdown from closing on gap */
.authorpro-submenu::before {
    content: "";
    position: absolute;
    top: -0.75rem;
    left: 0;
    width: 100%;
    height: 0.75rem;
    display: block;
}

/* Open Level 2 Dropdown */
.authorpro-menu-item-has-children:hover>.authorpro-submenu,
.authorpro-menu-item-has-children:focus-within>.authorpro-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Dropdown Menu Item (Level 2+) */
.authorpro-submenu-item {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0;
}

.authorpro-submenu-link {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--authorpro-color-slate-600);
    text-decoration: none;
    transition: background-color var(--authorpro-transition-fast), color var(--authorpro-transition-fast);
}

.authorpro-submenu-link:hover,
.authorpro-submenu-item:hover>a,
.authorpro-submenu-item:focus-within>a {
    background-color: var(--authorpro-color-slate-50);
    color: var(--authorpro-color-brand-600);
}

/* Nested Submenus (Level 3 & Level 4 Flyouts) */
.authorpro-has-flyout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    cursor: pointer;
}

.authorpro-has-flyout>a {
    flex-grow: 1;
}

.authorpro-flyout-icon {
    width: 1rem;
    height: 1rem;
    margin-right: 1rem;
    color: var(--authorpro-color-slate-400);
    transform: rotate(-90deg);
    transition: color var(--authorpro-transition-fast), transform var(--authorpro-transition-fast);
}

.authorpro-has-flyout:hover>.authorpro-flyout-icon {
    color: var(--authorpro-color-brand-600);
}

/* Flyout Submenu List (Level 3 & 4) */
.authorpro-submenu-flyout {
    position: absolute;
    left: 100%;
    top: 0;
    width: 14rem;
    margin-left: 0.5rem;
    background-color: var(--authorpro-color-white);
    border: 1px solid var(--authorpro-color-slate-100);
    box-shadow: var(--authorpro-shadow-xl);
    border-radius: var(--authorpro-radius-lg);
    padding: 0.5rem 0;
    list-style: none;
    z-index: 55;

    /* Hidden State */
    opacity: 0;
    visibility: hidden;
    transform: translateX(-0.5rem);
    transition: opacity var(--authorpro-transition-base), visibility var(--authorpro-transition-base), transform var(--authorpro-transition-base);
    pointer-events: none;
}

/* Flyout Left Bridge */
.authorpro-submenu-flyout::before {
    content: "";
    position: absolute;
    top: 0;
    left: -0.5rem;
    width: 0.5rem;
    height: 100%;
    display: block;
}

/* Open Level 3 / Level 4 Flyout on Parent Hover or Focus */
.authorpro-has-flyout:hover>.authorpro-submenu-flyout,
.authorpro-has-flyout:focus-within>.authorpro-submenu-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

/* =============================================================
   3. Mobile Navigation Accordion Drawer
   ============================================================= */
.authorpro-mobile-drawer {
    display: none;
    position: absolute;
    left: 0;
    top: 5rem;
    /* 80px */
    width: 100%;
    height: calc(100vh - 5rem);
    background-color: var(--authorpro-color-white);
    border-top: 1px solid var(--authorpro-color-slate-100);
    box-shadow: var(--authorpro-shadow-lg);
    overflow-y: auto;
    padding-bottom: 5rem;
    z-index: 45;
}

.authorpro-mobile-drawer.authorpro-drawer-open {
    display: block;
}

@media (min-width: 1024px) {

    .authorpro-mobile-drawer,
    .authorpro-mobile-drawer.authorpro-drawer-open {
        display: none !important;
    }
}

.authorpro-mobile-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1rem 1.5rem 1rem;
}

/* Mobile Link Row */
.authorpro-mobile-link {
    display: block;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--authorpro-color-slate-700);
    border-radius: var(--authorpro-radius-md);
    text-decoration: none;
    transition: color var(--authorpro-transition-base), background-color var(--authorpro-transition-base);
    flex-grow: 1;
}

.authorpro-mobile-link:hover {
    color: var(--authorpro-color-brand-600);
    background-color: var(--authorpro-color-slate-50);
}

/* Mobile Parent Container (Link + Accordion Button) */
.authorpro-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--authorpro-radius-md);
    transition: background-color var(--authorpro-transition-base);
    padding-right: 0.25rem;
}

.authorpro-mobile-row:hover {
    background-color: var(--authorpro-color-slate-50);
}

/* Accordion Toggle Button */
.authorpro-mobile-accordion-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    color: var(--authorpro-color-slate-500);
    background: transparent;
    border: none;
    cursor: pointer;
    border-top-right-radius: var(--authorpro-radius-md);
    border-bottom-right-radius: var(--authorpro-radius-md);
    transition: color var(--authorpro-transition-base), background-color var(--authorpro-transition-base);
}

.authorpro-mobile-accordion-toggle:hover {
    color: var(--authorpro-color-brand-600);
}

.authorpro-mobile-accordion-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--authorpro-color-brand-600);
    background-color: var(--authorpro-color-slate-100);
}

.authorpro-mobile-accordion-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 200ms ease;
}

/* Submenu Accordion Drawer */
.authorpro-mobile-submenu {
    display: none;
    padding-left: 1rem;
    border-left: 1px solid var(--authorpro-color-slate-100);
    margin-left: 0.75rem;
    margin-bottom: 0.5rem;
    flex-direction: column;
    gap: 0.25rem;
}

.authorpro-mobile-submenu.authorpro-submenu-open {
    display: flex;
}

/* =============================================================
   4. Search Modal Popup & Overlay
   ============================================================= */
.authorpro-search-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 200ms ease;
}

.authorpro-search-modal.authorpro-modal-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal Content Dialog */
.authorpro-search-dialog {
    position: relative;
    z-index: 50;
    margin-top: 6rem;
    margin-left: auto;
    margin-right: auto;
    max-width: 42rem;
    /* 672px */
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 200ms cubic-bezier(0.16, 1, 0.3, 1), transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
    .authorpro-search-dialog {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.authorpro-search-modal.authorpro-modal-active .authorpro-search-dialog {
    opacity: 1;
    transform: scale(1);
}

/* Search Form Component */
.authorpro-search-form {
    position: relative;
    background-color: var(--authorpro-color-white);
    border-radius: var(--authorpro-radius-xl);
    box-shadow: var(--authorpro-shadow-2xl);
    border: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
    display: flex;
    align-items: center;
    width: 100%;
}

.authorpro-search-icon-wrap {
    padding-left: 1.5rem;
    color: var(--authorpro-color-slate-400);
    display: flex;
    align-items: center;
}

.authorpro-search-form-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.authorpro-search-input {
    width: 100%;
    height: 4rem;
    /* 64px */
    background-color: transparent;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--authorpro-color-slate-900);
    font-size: 1.125rem;
    padding: 0 1rem;
}

.authorpro-search-input::placeholder {
    color: var(--authorpro-color-slate-400);
}

.authorpro-search-actions {
    padding-right: 1.5rem;
    display: flex;
    align-items: center;
}

/* ESC Key Badge */
.authorpro-search-esc {
    display: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--authorpro-color-slate-400);
    border: 1px solid var(--authorpro-color-slate-200);
    border-radius: var(--authorpro-radius-sm);
    padding: 0.125rem 0.375rem;
    margin-right: 0.5rem;
}

@media (min-width: 640px) {
    .authorpro-search-esc {
        display: inline-block;
    }
}

/* Search Close Button */
.authorpro-search-close-btn,
.authorpro-search-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.5rem;
    color: var(--authorpro-color-slate-400);
    border-radius: var(--authorpro-radius-full);
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--authorpro-transition-base), background-color var(--authorpro-transition-base), transform var(--authorpro-transition-base);
}

.authorpro-search-close-btn:hover,
.authorpro-search-close:hover {
    color: var(--authorpro-color-brand-600);
    background-color: var(--authorpro-color-slate-100);
}

.authorpro-search-close-btn:focus-visible,
.authorpro-search-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--authorpro-color-brand-600);
    background-color: var(--authorpro-color-slate-100);
}

.authorpro-search-close-icon,
.authorpro-search-close-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* =============================================================
   5. Custom Header Media Image Banner
   ============================================================= */
.authorpro-custom-header {
    width: 100%;
    position: relative;
}

.authorpro-custom-header-image {
    width: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom: 1px solid var(--authorpro-color-slate-200);
    box-shadow: var(--authorpro-shadow-inner);
    min-height: 300px;
    height: 40vh;
    max-height: 600px;
}

/* =============================================================
   6. Documentation Sidebar (Optional Nav Location)
   ============================================================= */
.authorpro-docs-sidebar h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--authorpro-color-slate-900);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    margin-top: 2rem;
}

.authorpro-docs-sidebar h3:first-child {
    margin-top: 0;
}

.authorpro-docs-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.authorpro-docs-sidebar a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--authorpro-radius-md);
    color: var(--authorpro-color-slate-600);
    text-decoration: none;
    border: 1px solid transparent;
    transition: all var(--authorpro-transition-base);
}

.authorpro-docs-sidebar a:hover {
    background-color: var(--authorpro-color-slate-100);
    color: var(--authorpro-color-slate-900);
    border-color: var(--authorpro-color-slate-200);
}