/*
 * Custom Doxygen overrides to match the MNE-CPP Docusaurus navbar.
 * Responsive breakpoint raised from 768px → 996px to match Docusaurus.
 * Height ≈ 3.75rem (60px), system-ui font stack, semibold (500) nav links.
 *
 * DOM structure produced by menu.js:
 *   #top
 *     #titlearea          (logo + project name — static HTML)
 *     div.sm.sm-dox       (checkbox + hamburger + searchBoxPos1 — injected)
 *     #main-nav
 *       ul#main-menu      (nav items + searchBoxPos2)
 *
 * KEY: #main-menu-state and #main-menu are NOT siblings, so CSS ~ selectors
 *      cannot control visibility.  All menu toggling uses JS.
 */

/* ── Font & variable overrides ─────────────────────────────────── */
html {
    --font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
        Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, "Segoe UI",
        Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
        "Segoe UI Symbol";
    --navigation-font-size: 1rem;
    --title-font-size: 1.25rem;
}

/* ══════════════════════════════════════════════════════════════════
   #top — ALWAYS flex so titlearea + hamburger-div share a row.
   Only border is #top's own border-bottom (from doxygen-awesome).
   ══════════════════════════════════════════════════════════════════ */
#top {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    min-height: 3.75rem;
}

/* ── Hamburger wrapper div (div.sm.sm-dox child of #top) ───────── *
 *  Contains the checkbox, hamburger label, and searchBoxPos1.
 */
#top>div.sm.sm-dox {
    margin-left: auto;
    display: flex !important;
    align-items: center;
    padding: 0 1rem;
    border: none !important;
    background: none !important;
    line-height: 1;
}

/* ── Title area: logo + project name ───────────────────────────── */
#titlearea {
    padding: 0.25rem 1rem;
    border-bottom: none !important;
    flex-shrink: 0;
}

#titlearea table tbody tr {
    height: auto !important;
}

#projectlogo img {
    max-height: 2rem;
    margin-right: 0.5rem;
}

/* ── Dark / light mode logo switching ──────────────────────────── */
#projectlogo .logo-dark {
    display: none;
}

html.dark-mode #projectlogo .logo-light {
    display: none;
}

html.dark-mode #projectlogo .logo-dark {
    display: inline;
}

#projectname {
    font-size: var(--title-font-size);
    font-weight: 600;
    line-height: 1.25;
}

#projectnumber {
    display: none;
}

/* ── Version badge (doxygen-awesome blue accent) ──────────────── */
.version-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.55rem;
    border-radius: 12px;
    background: rgba(23, 121, 196, 0.1);
    border: 1px solid rgba(23, 121, 196, 0.25);
    color: var(--primary-color);
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    white-space: nowrap;
}

html.dark-mode .version-badge {
    background: rgba(25, 130, 210, 0.12);
    border-color: rgba(25, 130, 210, 0.25);
    color: var(--primary-color);
}

/* ── Navigation links: Docusaurus-style semibold ───────────────── */
.sm-dox a,
.sm-dox a:hover,
.sm-dox a:focus,
.tablist li,
.tablist li a,
.tablist li.current a {
    font-family: var(--font-family) !important;
    font-weight: 500 !important;
    font-size: var(--navigation-font-size) !important;
    letter-spacing: 0.01em;
}

/* Active / current tab – subtle bottom highlight like Docusaurus */
.tablist li.current a {
    border-bottom: 2px solid var(--primary-color);
    border-radius: 0 !important;
}

/* ── Tab bar spacing to match Docusaurus padding ───────────────── */
.tabs,
.tabs2,
.tabs3 {
    padding: 0 1rem;
    border-bottom: none !important;
}

.tablist li {
    padding: 0.375rem 0.75rem;
}

.sm-dox>li>a {
    padding: 0.5rem 0.75rem !important;
}

/* ── #main-nav: NO extra borders ──────────────────────────────── */
#main-nav {
    padding: 0.25rem 1rem;
    border-bottom: none !important;
    border-top: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   DESKTOP (≥ 997px) — horizontal flex bar
   ══════════════════════════════════════════════════════════════════ */
@media screen and (min-width: 997px) {

    /* ── Hamburger wrapper: just contains the (hidden) hamburger */
    #top>div.sm.sm-dox {
        order: 2;
        display: none !important;
        /* Nothing to show on desktop */
    }

    #main-nav {
        order: 1;
        display: flex;
        flex-grow: 5;
        align-items: center;
    }

    /* Horizontal nav list */
    #main-menu {
        flex: 1;
        display: flex !important;
        align-items: center;
        flex-wrap: wrap;
    }

    /* Float items horizontally — override tabs.css rules */
    .sm-dox li,
    .tablist li {
        display: var(--menu-display);
    }

    /* Search / badge / toggle pushed to the right inside nav.
       CSS order controls the visual sequence:
       version(1) → GitHub(2) → dark-toggle(3) → search(4) */
    #searchBoxPos2 {
        margin-left: auto !important;
        float: none !important;
        display: flex !important;
        align-items: center;
        gap: 0.375rem;
    }

    #searchBoxPos2 .version-badge {
        order: 1;
    }

    #searchBoxPos2 .github-link {
        order: 2;
    }

    #searchBoxPos2 doxygen-awesome-dark-mode-toggle {
        order: 3;
    }

    #searchBoxPos2 #MSearchBox {
        order: 4;
    }

    /* Hide hamburger button on desktop */
    .main-menu-btn {
        position: absolute !important;
        top: -99999px !important;
    }

    /* Hide the mobile-only search slot */
    #searchBoxPos1 {
        display: none !important;
    }

    /* Dropdown sub-arrows */
    .sm-dox a span.sub-arrow,
    .sm-dox ul a span.sub-arrow {
        display: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE (≤ 996px) — Docusaurus-style hamburger + vertical dropdown
   Menu visibility is controlled entirely by JS (mneResetNav).
   ══════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 996px) {

    /* ── Hamburger button — inline-block inside its container,
         natural flex-item position (NOT absolute) ─────────────── */
    .main-menu-btn {
        display: inline-block !important;
        position: relative !important;
        top: auto !important;
        width: 36px;
        height: 36px;
    }

    /* ── Hide the secondary search position to avoid duplicates ── */
    #searchBoxPos1 {
        display: none !important;
    }

    /* ── #main-nav: wraps to its own full-width row ───────────── */
    #main-nav {
        flex-basis: 100%;
        order: 2;
        padding: 0;
    }

    /* ── Menu list: vertical column.
         JS sets display:none / display:block / slideDown/slideUp.
         Do NOT override display with !important here. ─────────── */
    #main-menu {
        flex-direction: column;
        width: 100%;
        padding: 0.25rem 0;
        background: var(--page-background-color);
        border-top: 1px solid var(--separator-color);
    }

    /* Override tabs.css @media(min-width:768px) float:left */
    .sm-dox li {
        float: none !important;
        display: block !important;
    }

    .sm-dox>li>a {
        display: block !important;
        padding: 0.625rem 1.25rem !important;
        white-space: normal !important;
    }

    .sm-dox>li>a:hover {
        background: var(--menu-selected-background) !important;
    }

    /* Hide sub-arrows in mobile */
    .sm-dox a span.sub-arrow {
        display: none !important;
    }

    /* ── Submenu: full-width stacked ──────────────────────────── */
    .sm-dox ul {
        position: static !important;
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: var(--page-background-color) !important;
        padding: 0 !important;
    }

    .sm-dox ul a {
        padding-left: 2.5rem !important;
    }

    /* ── Search box + toolbar inside menu: flex-wrap so
         the search box takes the full width ─────────────────────── */
    #searchBoxPos2 {
        float: none !important;
        display: flex !important;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.5rem 1rem;
        margin-left: 0 !important;
    }

    /* Badge, GitHub, dark toggle are now in the hamburger wrapper
       (not in #searchBoxPos2) — hide any strays that might remain */
    #searchBoxPos2 .version-badge,
    #searchBoxPos2 .github-link {
        display: none !important;
    }

    /* Search takes full width */
    #searchBoxPos2 #MSearchBox {
        flex-basis: 100%;
        width: 100% !important;
        margin: 0 !important;
    }

    #searchBoxPos2 #MSearchField {
        width: calc(100% - 64px) !important;
    }

    /* ── Mobile toolbar: badge + GitHub + dark-toggle in
         the hamburger wrapper row, visible next to the logo ───── */
    #top>div.sm.sm-dox .version-badge,
    #top>div.sm.sm-dox .github-link,
    #top>div.sm.sm-dox doxygen-awesome-dark-mode-toggle {
        display: inline-flex !important;
        align-items: center;
    }

    #top>div.sm.sm-dox .version-badge {
        order: -3;
        margin-right: 0.25rem;
    }

    #top>div.sm.sm-dox .github-link {
        order: -2;
        margin-right: 0.25rem;
    }

    #top>div.sm.sm-dox doxygen-awesome-dark-mode-toggle {
        order: -1;
        margin-right: 0.5rem;
    }

    /* ── Override doxygen-awesome's 768px rules ───────────────── */
    .sm-dox {
        padding: 0 !important;
        background: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════════
   SHARED / ALL-WIDTHS styles
   ══════════════════════════════════════════════════════════════════ */

/* Search box base styling */
#MSearchBox {
    display: inline-flex !important;
    align-items: center;
    vertical-align: middle;
    position: relative !important;
    right: auto !important;
}

/* Center text vertically inside search input */
#MSearchField {
    line-height: var(--searchbar-height) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box;
}

/* Dark mode toggle & GitHub link: vertical centering */
doxygen-awesome-dark-mode-toggle,
.github-link {
    vertical-align: middle;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

/* ── GitHub link in header (matches Docusaurus style) ──────────── */
.github-link {
    width: auto;
    height: auto;
    border-radius: var(--border-radius-small, 4px);
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.github-link:hover {
    opacity: 0.7;
    text-decoration: none !important;
    background: none !important;
    color: inherit !important;
}

.github-link svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px;
    min-height: 24px;
    fill: var(--header-foreground);
    flex-shrink: 0;
}

/* ── Dark mode toggle: match Docusaurus look ───────────────────── */
doxygen-awesome-dark-mode-toggle {
    width: 2rem !important;
    height: 2rem !important;
    font-size: 20px !important;
    border-radius: 50% !important;
    transition: background var(--animation-duration) ease-in-out;
}

doxygen-awesome-dark-mode-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1) !important;
}

html.dark-mode doxygen-awesome-dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

doxygen-awesome-dark-mode-toggle>svg {
    width: 24px;
    height: 24px;
}
}