/*
 * The navigation bar.
 *
 * A row of named groups, each opening a short menu of destinations with a line
 * of description under each, rather than one dropdown holding every page in the
 * site. Below 940px the whole thing becomes a single panel with every group
 * already expanded: a dropdown inside a dropdown is no way to navigate.
 *
 * The same markup serves both. There is no separate mobile menu to keep in step.
 */

/*
 * Written against the id as well as the class so it lands on top of the older
 * `#doc-menu` rules elsewhere in the stylesheets. The light theme is left to
 * those: there the bar takes the page's own main colour, as it always has.
 */
#doc-menu.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(12, 15, 19, .88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 10px 20px;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------------- brand */

.topbar .brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
}
.topbar .brand:hover { color: #fff; text-decoration: none; }

.topbar .brand-mark {
    height: 40px;
    width: 40px;
    object-fit: contain;
}

.topbar .logo-text { line-height: 1.05; }
.topbar .logo-text .maintext { display: block; font-size: 20pt; font-family: 'Dancing Script', cursive; }
.topbar .logo-text .subtext {
    display: block;
    font-size: 10px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
}
/* Nothing to say under the wordmark on the main site, and an empty element
   still takes the line height, which pushed the mark off centre. */
.topbar .logo-text .subtext:empty { display: none; }

/* --------------------------------------------------------------------- bar */

.sitenav { display: flex; gap: 2px; align-items: center; }

.navgroup { position: relative; }

/* `.navlink` is a top-level destination with no menu under it. It matches
   `.navtrigger` exactly so the bar reads as one row rather than as a menu with
   something else stuck on the end. */
.navtrigger,
.navlink {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .82);
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    padding: 9px 13px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s ease, color .12s ease;
}
.navtrigger:hover,
.navlink:hover,
.navgroup.open .navtrigger {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    text-decoration: none;
}
.navchev { transition: transform .15s ease; opacity: .75; }
.navgroup.open .navchev { transform: rotate(180deg); }

/* ------------------------------------------------------------------- menus */

.navmenu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    min-width: 290px;
    background: #1b222c;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
    padding: 8px;
    display: none;
    z-index: 40;
    /* The documentation menu has groups running to fifteen entries. Scroll
       rather than let one run past the bottom of the window. */
    max-height: 76vh;
    overflow-y: auto;
}
.navgroup.open .navmenu { display: block; }
/* Keep the menus nearest the right edge from opening off the screen. */
.navmenu.navmenu-right { left: auto; right: 0; }

.navmenu a {
    display: block;
    padding: 9px 11px;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    text-decoration: none;
}
.navmenu a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.navitem-title { display: block; font-weight: 600; font-size: 14.5px; }
.navitem-blurb { display: block; font-size: 12.5px; color: rgba(255, 255, 255, .55); margin-top: 1px; }

/* ------------------------------------------------------------------ search */

.navsearch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: 8px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid transparent;
    transition: background .12s ease, border-color .12s ease, width .12s ease;
}
.navsearch:focus-within {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .28);
}
.navsearch-icon { flex: none; opacity: .7; color: #fff; }

.navsearch-field {
    width: 132px;
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font: inherit;
    font-size: 14px;
    padding: 8px 0;
    transition: width .14s ease;
}
.navsearch-field::placeholder { color: rgba(255, 255, 255, .55); }
/* Widens once it has the focus, so the bar is not carrying a search box the
   size of a search box nobody is using. */
.navsearch:focus-within .navsearch-field { width: 196px; }
/* The browser's own clear affordance sits badly on the tinted pill. */
.navsearch-field::-webkit-search-cancel-button { -webkit-appearance: none; }

.navsearch-results {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 330px;
    max-width: 420px;
    max-height: 62vh;
    overflow-y: auto;
    background: #1b222c;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
    padding: 6px;
    display: none;
    z-index: 45;
}
.navsearch-results.open { display: block; }

.navsearch-result {
    display: block;
    padding: 8px 11px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
}
.navsearch-result:hover,
.navsearch-result.active { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.navsearch-result-title { display: block; font-weight: 600; font-size: 14px; }
/* Which site the hit is on. Only present when it is not this one. */
.navsearch-result-source {
    display: inline-block;
    margin-left: 7px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .13);
    color: rgba(255, 255, 255, .72);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    vertical-align: 1px;
}
/* The matched phrase comes back wrapped in <b>. Lit up rather than bolded,
   because the whole line is already small and quiet. */
.navsearch-result-preview {
    display: block;
    font-size: 12.5px;
    color: rgba(255, 255, 255, .55);
    margin-top: 1px;
}
.navsearch-result-preview b { color: #fff; font-weight: 600; }

.navsearch-note {
    display: block;
    padding: 9px 11px;
    font-size: 12.5px;
    color: rgba(255, 255, 255, .5);
}

/* --------------------------------------------------------------- hamburger */

/* Hidden until the row no longer fits. */
.navtoggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 38px;
    padding: 0 9px;
    background: rgba(255, 255, 255, .1);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.navtoggle span {
    display: block;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .18s ease, opacity .18s ease;
}
.navtoggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navtoggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.navtoggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 940px) {
    .navtoggle { display: flex; }

    .sitenav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        width: 100%;
        margin-top: 12px;
        padding: 10px;
        background: #1b222c;
        border: 1px solid rgba(255, 255, 255, .1);
        border-radius: 12px;
        max-height: 74vh;
        overflow-y: auto;
    }
    .sitenav.open { display: flex; }

    .navgroup { position: static; }
    /* In the panel the group label is a heading over its links, not a control:
       the links below it are already showing. */
    .navtrigger {
        width: 100%;
        justify-content: flex-start;
        color: rgba(255, 255, 255, .5);
        font-size: 11.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .08em;
        padding: 12px 8px 4px;
        cursor: default;
    }
    .navtrigger:hover, .navgroup.open .navtrigger { background: none; color: rgba(255, 255, 255, .5); }
    .navlink {
        width: 100%;
        font-size: 14.5px;
        padding: 10px 11px;
    }
    .navchev { display: none; }

    .navmenu {
        position: static;
        display: block;
        min-width: 0;
        border: none;
        box-shadow: none;
        padding: 0;
        background: none;
        /* The panel scrolls as a whole; the groups inside it must not. */
        max-height: none;
        overflow: visible;
    }

    /* In the panel the field is full width and stays that way -- there is no
       hover-to-reveal on a touch screen, and nothing to save room for. */
    .navsearch {
        order: -1;
        width: 100%;
        margin: 0 0 8px;
        background: rgba(255, 255, 255, .07);
    }
    .navsearch-field,
    .navsearch:focus-within .navsearch-field { width: 100%; }
    .navsearch-results {
        position: static;
        min-width: 0;
        max-width: none;
        border: none;
        box-shadow: none;
        padding: 6px 0 0;
        background: none;
        max-height: none;
    }
}
