/* ==========================================================================
   Premium Header Menu — stylesheet
   Scoped under .phm- to avoid colliding with the active theme's styles.
   Colors are driven by CSS custom properties, set inline from plugin settings.
   ========================================================================== */

:root {
    --phm-bg: #ffffff;
    --phm-text: #14141a;
    --phm-accent: #14141a;
    --phm-muted: #6b6b76;
    --phm-border: #ececed;
}

.phm-header,
.phm-header * {
    box-sizing: border-box;
}

.phm-header {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--phm-bg);
    color: var(--phm-text);
    border-bottom: 1px solid var(--phm-border);
    position: relative;
    top: 0;
    width: 100%;
    z-index: 9999;
    transition: box-shadow 0.35s ease;
}

.phm-header.phm-sticky {
    position: sticky;
}

.phm-header.phm-scrolled {
    box-shadow: 0 8px 24px -12px rgba(20, 20, 26, 0.18);
}

.phm-container {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 20px 28px;
    transition: padding 0.35s ease;
}

.phm-header.phm-scrolled .phm-container {
    padding: 12px 28px;
}

/* Logo */
.phm-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    color: var(--phm-text);
}

.phm-logo-img {
    max-height: 38px;
    width: auto;
    display: block;
}

.phm-logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--phm-text);
}

/* Nav */
.phm-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.phm-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 6px;
}

.phm-menu > li {
    position: relative;
}

.phm-menu li a {
    position: relative;
    display: block;
    padding: 8px 14px;
    color: var(--phm-text);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    white-space: nowrap;
}

.phm-menu li a::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 2px;
    height: 1.5px;
    background: var(--phm-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.phm-menu li a:hover::after,
.phm-menu li.current-menu-item > a::after {
    transform: scaleX(1);
}

/* Dropdown submenus */
.phm-menu li ul {
    position: absolute;
    top: 100%;
    left: 0;
    margin: 10px 0 0;
    padding: 6px;
    min-width: 200px;
    list-style: none;
    background: var(--phm-bg);
    border: 1px solid var(--phm-border);
    border-radius: 3px;
    box-shadow: 0 16px 32px -16px rgba(20, 20, 26, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.phm-menu li:hover > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.phm-menu li ul li a {
    padding: 9px 12px;
}

.phm-menu li ul li a::after {
    display: none;
}

.phm-menu li ul li a:hover {
    background: rgba(20, 20, 26, 0.04);
}

/* Actions */
.phm-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.phm-search-toggle {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--phm-border);
    border-radius: 50%;
    color: var(--phm-text);
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease;
    padding: 0;
}

.phm-search-toggle:hover {
    background: rgba(20, 20, 26, 0.04);
    border-color: var(--phm-text);
}

.phm-cta {
    display: inline-flex;
    align-items: center;
    background: var(--phm-accent);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 3px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.phm-cta:hover {
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -8px rgba(20, 20, 26, 0.45);
}

.phm-mobile-toggle {
    display: none;
    width: 38px;
    height: 38px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.phm-mobile-toggle span {
    width: 20px;
    height: 1.5px;
    background: var(--phm-text);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.phm-mobile-toggle.active span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.phm-mobile-toggle.active span:nth-child(2) { opacity: 0; }
.phm-mobile-toggle.active span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Search box */
.phm-search-box {
    max-height: 0;
    overflow: hidden;
    border-top: 1px solid transparent;
    transition: max-height 0.3s ease, border-color 0.3s ease;
}

.phm-search-box.active {
    max-height: 84px;
    border-top-color: var(--phm-border);
}

.phm-search-form {
    max-width: 1240px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    gap: 10px;
}

.phm-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--phm-border);
    border-radius: 3px;
    font-size: 14px;
    outline: none;
    color: var(--phm-text);
    transition: border-color 0.2s ease;
}

.phm-search-input:focus {
    border-color: var(--phm-text);
}

.phm-search-submit {
    padding: 10px 20px;
    background: var(--phm-accent);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
}

/* Accessible focus states */
.phm-menu li a:focus-visible,
.phm-cta:focus-visible,
.phm-search-toggle:focus-visible,
.phm-mobile-toggle:focus-visible,
.phm-search-input:focus-visible {
    outline: 2px solid var(--phm-accent);
    outline-offset: 2px;
}

/* Overlay for mobile drawer */
.phm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 26, 0.45);
    z-index: 9998;
}

.phm-overlay.active {
    display: block;
}

/* Mobile */
@media (max-width: 860px) {
    .phm-container {
        padding: 14px 20px;
    }

    .phm-nav {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        max-width: 82vw;
        height: 100vh;
        background: var(--phm-bg);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 84px 24px 24px;
        transition: right 0.35s ease;
        box-shadow: -20px 0 40px -20px rgba(20, 20, 26, 0.3);
        z-index: 9999;
        overflow-y: auto;
    }

    .phm-nav.active {
        right: 0;
    }

    .phm-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        width: 100%;
    }

    .phm-menu li a {
        padding: 12px 4px;
        font-size: 15.5px;
    }

    .phm-menu li a::after {
        display: none;
    }

    .phm-menu li ul {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        display: none;
        margin: 0 0 0 12px;
        padding: 0;
    }

    .phm-menu li.phm-submenu-open > ul {
        display: block;
    }

    .phm-mobile-toggle {
        display: flex;
    }

    .phm-cta {
        padding: 8px 14px;
        font-size: 12.5px;
    }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .phm-header,
    .phm-container,
    .phm-menu li a::after,
    .phm-cta,
    .phm-nav,
    .phm-mobile-toggle span,
    .phm-search-box {
        transition: none !important;
    }
}
