/**
 * Tieu Hao Pro navigation components.
 *
 * WordPress menu markup is intentionally styled through native menu classes
 * plus the theme's stable thp-nav__list wrapper. Menu state/ARIA behavior
 * remains owned by WordPress/PHP and the native <details> mobile control.
 */

.thp-nav__list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--thp-space-1);
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
}

.thp-nav__list > .menu-item,
.thp-nav__list .menu-item {
    position: relative;
    margin: 0;
    list-style: none;
}

.thp-nav__list > .menu-item > a,
.thp-nav__list .menu-item > a {
    display: inline-flex;
    align-items: center;
    min-height: var(--thp-nav-height);
    padding: 0 var(--thp-space-3);
    border-radius: var(--thp-radius-sm);
    color: var(--thp-nav-link-color);
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    transition:
        color var(--thp-duration-fast) var(--thp-ease-standard),
        background-color var(--thp-duration-fast) var(--thp-ease-standard);
}

.thp-nav__list > .menu-item > a:hover,
.thp-nav__list > .menu-item.current-menu-item > a,
.thp-nav__list > .menu-item.current_page_item > a,
.thp-nav__list > .menu-item.current-menu-ancestor > a,
.thp-nav__list > .menu-item > a[aria-current="page"] {
    background: var(--thp-color-brand-soft);
    color: var(--thp-nav-link-hover);
}

.thp-nav__list .sub-menu {
    position: absolute;
    z-index: 200;
    top: calc(100% + var(--thp-space-2));
    left: 0;
    display: none;
    min-width: 220px;
    margin: 0;
    padding: var(--thp-space-2);
    border: 1px solid var(--thp-color-border);
    border-radius: var(--thp-radius-md);
    background: var(--thp-color-surface);
    box-shadow: var(--thp-shadow-md);
    list-style: none;
}

.thp-nav__list .menu-item-has-children:hover > .sub-menu,
.thp-nav__list .menu-item-has-children:focus-within > .sub-menu {
    display: block;
}

.thp-nav__list .sub-menu > .menu-item > a {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    padding-inline: var(--thp-space-3);
    border-radius: var(--thp-radius-sm);
    color: var(--thp-color-text);
    font-size: .76rem;
    font-weight: 700;
    text-decoration: none;
}

.thp-nav__list .sub-menu > .menu-item > a:hover,
.thp-nav__list .sub-menu > .menu-item.current-menu-item > a {
    background: var(--thp-color-brand-soft);
    color: var(--thp-color-brand-deep);
}

.thp-header__mobile-menu {
    display: none;
    position: relative;
}

.thp-header__mobile-toggle {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--thp-color-border);
    border-radius: var(--thp-radius-sm);
    background: var(--thp-color-surface);
    color: var(--thp-color-text);
    cursor: pointer;
    list-style: none;
}

.thp-header__mobile-toggle::-webkit-details-marker {
    display: none;
}

.thp-header__mobile-toggle:focus-visible {
    outline: 2px solid var(--thp-color-action);
    outline-offset: 2px;
}

.thp-header__mobile-toggle-lines,
.thp-header__mobile-toggle-lines::before,
.thp-header__mobile-toggle-lines::after {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    content: "";
}

.thp-header__mobile-toggle-lines {
    position: relative;
}

.thp-header__mobile-toggle-lines::before,
.thp-header__mobile-toggle-lines::after {
    position: absolute;
    left: 0;
}

.thp-header__mobile-toggle-lines::before { top: -6px; }
.thp-header__mobile-toggle-lines::after { top: 6px; }

.thp-header__mobile-panel {
    position: absolute;
    z-index: 300;
    top: calc(100% + var(--thp-space-2));
    right: 0;
    width: min(320px, calc(100vw - (var(--thp-space-4) * 2)));
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: var(--thp-space-2);
    border: 1px solid var(--thp-color-border);
    border-radius: var(--thp-radius-md);
    background: var(--thp-color-surface);
    box-shadow: var(--thp-shadow-lg);
}

.thp-header__mobile-panel .thp-nav__list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--thp-space-1);
}

.thp-header__mobile-panel .menu-item > a {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    padding-inline: var(--thp-space-3);
    border-radius: var(--thp-radius-sm);
    color: var(--thp-color-text);
    font-weight: 750;
    text-decoration: none;
}

.thp-header__mobile-panel .menu-item > a:hover,
.thp-header__mobile-panel .menu-item.current-menu-item > a {
    background: var(--thp-color-brand-soft);
    color: var(--thp-color-brand-deep);
}

.thp-header__mobile-panel .sub-menu {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 0 var(--thp-space-3);
    border: 0;
    box-shadow: none;
}

@media (max-width: 1023px) {
    .thp-nav__list > .menu-item > a,
    .thp-nav__list .menu-item > a {
        min-height: 56px;
        padding-inline: var(--thp-space-2);
        font-size: .74rem;
    }

    .thp-header__inner {
        gap: var(--thp-space-4);
    }

    .thp-header__search {
        min-width: 180px;
    }
}

@media (max-width: 767px) {
    .thp-header__nav {
        display: none;
    }

    .thp-header__mobile-menu {
        display: block;
        flex: 0 0 auto;
    }

    .thp-header__search {
        min-width: 0;
        flex: 1 1 auto;
    }

    .thp-header__tools {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .thp-nav__list > .menu-item > a,
    .thp-nav__list .menu-item > a {
        transition: none;
    }
}

.thp-nav__list::-webkit-scrollbar {
    display: none;
}

@media (min-width: 1024px) {
    .thp-nav__list > .menu-item > a,
    .thp-nav__list .menu-item > a {
        min-height: var(--thp-nav-height);
        padding-inline: var(--thp-space-2);
        font-size: .72rem;
    }
}

@media (min-width: 768px) and (max-width: 1200px) {
    .thp-header__brand .custom-logo {
        max-width: 150px;
    }

    .thp-header__search {
        width: 180px;
        min-width: 160px;
    }
}
