/*
 * Desktop header (>= 769px): compact 64px blue bar, uniform text+icon nav items,
 * ghost icon buttons, search as a command panel, one dropdown style.
 * Everything here is scoped to min-width: 769px — the mobile header
 * (mobile-header.css / js/mobile-header.js) is untouched.
 */

@media (min-width: 769px) {
    :root { --header-height: 64px; }
    body { padding-top: 64px; }

    .main-header {
        height: 64px;
        background: #2450f1;
        border-bottom: 1px solid rgba(255, 255, 255, .14);
        box-shadow: none;
        transition: box-shadow .2s ease;
    }
    .main-header.scrolled { box-shadow: 0 6px 20px -8px rgba(15, 23, 42, .35); }
    body.theme-dark .main-header,
    body.theme-dark .main-header.scrolled {
        background: #14215a;
        border-bottom-color: rgba(255, 255, 255, .08);
    }

    .main-header .header-content { gap: 4px; }
    .main-header .header-divider { display: none; }

    /* Logo: smaller, tagline hidden */
    .main-header .logo { gap: 10px; flex-shrink: 0; margin-right: 12px; }
    .main-header .custom-logo { height: 34px; filter: none; }
    .main-header .logo-text { font-size: 19px; letter-spacing: -0.01em; }
    .main-header .logo-tagline { display: none; }

    /* ---------- Primary nav: identical items ---------- */
    .hdr-nav {
        display: flex;
        align-items: center;
        gap: 2px;
        height: 100%;
        min-width: 0;
    }
    body .main-header .hdr-nav .hdr-item {
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        height: 40px;
        margin: 0;
        padding: 0 11px;
        border: 0;
        border-radius: 8px;
        background: transparent !important;
        box-shadow: none;
        color: rgba(255, 255, 255, .86) !important;
        font: 500 14px/1 var(--wp--preset--font-family--inter, 'Inter', system-ui, sans-serif);
        letter-spacing: 0;
        text-transform: none;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        transition: background-color .15s ease, color .15s ease;
    }
    body .main-header .hdr-nav .hdr-item .w3-icon { opacity: .9; }
    body .main-header .hdr-nav .hdr-item .w3-caret { margin-left: -2px; opacity: .7; }
    body .main-header .hdr-nav .hdr-item:hover,
    body .main-header .hdr-nav .hdr-item[aria-expanded="true"] {
        background: rgba(255, 255, 255, .12) !important;
        color: #fff !important;
    }
    /* Active page: full-opacity text + 2px white underline at the bar's bottom edge */
    body .main-header .hdr-nav .hdr-item[aria-current="page"],
    body .main-header .hdr-nav .hdr-item.is-current { color: #fff !important; font-weight: 600; }
    body .main-header .hdr-nav .hdr-item[aria-current="page"]::after,
    body .main-header .hdr-nav .hdr-item.is-current::after {
        content: "";
        position: absolute;
        left: 11px;
        right: 11px;
        bottom: -12px;
        height: 2px;
        border-radius: 2px;
        background: #fff;
    }
    body .main-header .hdr-nav .hdr-item:focus-visible { outline: 2px solid #fff; outline-offset: 0; }

    /* ---------- Right side: ghost icon buttons ---------- */
    .main-header .header-actions { gap: 4px; margin-left: auto; }
    .main-header .header-actions .header-icon-btn,
    .main-header .header-actions .theme-toggle-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        padding: 0;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: rgba(255, 255, 255, .9);
        cursor: pointer;
        transition: background-color .15s ease, color .15s ease;
    }
    .main-header .header-actions .mobile-menu-toggle { display: none !important; }
    .main-header .header-actions .header-icon-btn:hover,
    .main-header .header-actions .theme-toggle-btn:hover,
    .main-header .header-actions .header-icon-btn[aria-expanded="true"] {
        background: rgba(255, 255, 255, .14);
        color: #fff;
    }

    /* ---------- Search: command panel under the search button ---------- */
    .main-header .header-search-container { display: none; }
    .main-header.search-open .header-search-container {
        display: block;
        position: absolute;
        top: calc(100% + 8px);
        right: max(16px, calc((100vw - 1200px) / 2 + 24px));
        width: min(440px, calc(100vw - 32px));
        padding: 12px;
        background: #fff;
        border: 1px solid rgba(15, 23, 42, .08);
        border-radius: 12px;
        box-shadow: 0 2px 4px rgba(15, 23, 42, .04), 0 12px 24px -6px rgba(15, 23, 42, .14), 0 24px 48px -12px rgba(36, 80, 241, .16);
        z-index: 1002;
    }
    .main-header.search-open .header-search-container .header-search-input {
        width: 100% !important;
        height: 42px;
        padding: 0 12px 0 38px;
        border: 1px solid rgba(15, 23, 42, .12);
        border-radius: 8px;
        background: #f5f6f8;
        color: #111827;
        font-size: 14px;
    }
    .main-header.search-open .header-search-container .header-search-input::placeholder { color: #6b7280; }
    .main-header.search-open .header-search-container .header-search-input:focus-visible { outline: 2px solid #2450f1; outline-offset: 1px; }
    .main-header.search-open .header-search-container .header-search-icon { left: 24px; top: 33px; color: #6b7280; }
    .main-header.search-open .search-results-dropdown {
        position: static;
        width: auto;
        margin-top: 8px;
        max-height: min(60vh, 420px);
        overflow: auto;
        box-shadow: none;
        border: 0;
        background: transparent;
    }
    body.theme-dark .main-header.search-open .header-search-container {
        background: #141b2d;
        border-color: rgba(255, 255, 255, .08);
        box-shadow: 0 12px 24px -6px rgba(0, 0, 0, .5), 0 24px 48px -12px rgba(0, 0, 0, .6);
    }
    body.theme-dark .main-header.search-open .header-search-container .header-search-input {
        background: #0f1524;
        border-color: rgba(255, 255, 255, .1);
        color: #e5e9f0;
    }
    @media (min-width: 1600px) {
        .main-header.search-open .header-search-container { right: max(16px, calc((100vw - 1320px) / 2 + 24px)); }
    }

    /* ---------- Dropdowns: one visual language ---------- */
    .w3-mega { padding-top: 8px; }
    .w3-mega__panel { border-radius: 12px; padding: 16px; gap: 6px 20px; }
    .w3-mega__panel--categories { width: min(1040px, 100%); }
    .w3-mega__panel--chains { width: min(720px, 100%); padding: 14px; }
    .w3-mega__title,
    .w3-mega__lead { font-size: 11px; margin-bottom: 6px; padding: 0 8px; }
    .w3-mega__item { min-height: 38px; padding: 7px 8px; border-radius: 8px; gap: 10px; }
    .w3-mega__list--card .w3-mega__item { padding: 8px; gap: 10px; }
    .w3-mega__icon,
    .w3-mega__list--card .w3-mega__icon { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
    .w3-mega__name,
    .w3-mega__list--card .w3-mega__name { font-family: inherit; font-size: 14px; font-weight: 500; }
    .w3-mega__desc { font-size: 12.5px; }
    .w3-mega__group + .w3-mega__group { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(15, 23, 42, .06); }
    body.theme-dark .w3-mega__group + .w3-mega__group { border-top-color: rgba(255, 255, 255, .06); }

    /* Projects panel header row */
    .w3-mega__head {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin: -4px -4px 6px;
        padding: 10px 12px;
        border-radius: 10px;
        background: rgba(36, 80, 241, .06);
        color: inherit;
        text-decoration: none;
    }
    .w3-mega__head:hover { background: rgba(36, 80, 241, .1); }
    .w3-mega__head-text { display: flex; flex-direction: column; }
    .w3-mega__head-title { font-size: 14px; font-weight: 600; }
    .w3-mega__head-cta { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #1e3fd0; white-space: nowrap; }
    body.theme-dark .w3-mega__head { background: rgba(255, 255, 255, .04); }
    body.theme-dark .w3-mega__head:hover { background: rgba(255, 255, 255, .07); }
    body.theme-dark .w3-mega__head-cta { color: #9db2ff; }

    /* Small list menu (More) anchored under its button */
    .w3-mega[data-anchor] { justify-content: flex-end; padding-right: var(--anchor-right, 16px); }
    .w3-mega__panel--list { width: 300px; padding: 6px; display: block; }
    .w3-mega__list--rows { grid-template-columns: 1fr; gap: 0; }
    .w3-mega__list--rows .w3-mega__item { min-height: 44px; }
    .w3-mega__list--rows .w3-mega__icon { background: transparent; color: #5b6474; width: 24px; height: 24px; }
    .w3-mega__list--rows .w3-mega__item:hover .w3-mega__icon { background: transparent; color: #2450f1; }
    body.theme-dark .w3-mega__list--rows .w3-mega__icon { background: transparent; color: #9aa6b8; }
    body.theme-dark .w3-mega__list--rows .w3-mega__item:hover .w3-mega__icon { background: transparent; color: #9db2ff; }
    .w3-mega__sep { height: 1px; margin: 6px 8px; background: rgba(15, 23, 42, .07); }
    body.theme-dark .w3-mega__sep { background: rgba(255, 255, 255, .07); }

    /* One icon treatment in every dropdown: plain glyph, muted, accent on hover */
    .w3-mega__icon,
    .w3-mega__list--card .w3-mega__icon { background: transparent; color: #5b6474; }
    .w3-mega__item:hover .w3-mega__icon,
    .w3-mega__item:focus-visible .w3-mega__icon { background: transparent; color: #2450f1; }
    body.theme-dark .w3-mega__icon { background: transparent; color: #9aa6b8; }
    body.theme-dark .w3-mega__item:hover .w3-mega__icon { background: transparent; color: #9db2ff; }
    .w3-mega__list--card .w3-mega__icon { font-size: 15px; }

    /* Search results inside the command panel */
    .main-header.search-open .search-result-item { border-radius: 8px; }
    .main-header.search-open .search-result-logo { width: 36px; height: 36px; }
    .search-result-logo--placeholder {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #eef0f3;
        color: #2450f1;
        font-weight: 700;
    }
    body.theme-dark .search-result-logo--placeholder { background: rgba(255, 255, 255, .06); color: #9db2ff; }

    /* Chains: compact tile grid */
    .w3-mega__list--chains { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
    .w3-mega__list--chains .w3-mega__item { min-height: 36px; padding: 5px 8px; }
    .w3-mega__list--chains .w3-mega__name { font-size: 13.5px; }
}

/* Narrow desktops: icons go first, then labels stay */
@media (min-width: 769px) and (max-width: 1120px) {
    body .main-header .hdr-nav .hdr-item > .w3-icon:not(.w3-caret) { display: none; }
    body .main-header .hdr-nav .hdr-item { padding: 0 9px; gap: 4px; }
    body .main-header .hdr-nav .hdr-item[aria-current="page"]::after,
    body .main-header .hdr-nav .hdr-item.is-current::after { left: 9px; right: 9px; }
    .main-header .logo-text { font-size: 17px; }
}
@media (min-width: 769px) and (max-width: 900px) {
    .main-header .logo-text-link { display: none; }
    body .main-header .hdr-nav .hdr-item { padding: 0 7px; font-size: 13.5px; }
}

/* Mobile: the desktop nav is not part of the compact header */
@media (max-width: 768px) {
    .hdr-nav,
    .main-header .more-toggle { display: none !important; }
}
