/* The portal's menu across the top of a page (stage 5): a row of up to five tabs, up to two pinned places, and More.
   Loaded after shell.css by base_shell.html. Rules for the row and the panel only, and ONLY from 768px up: below that the
   phone's bottom bar is the menu (stage 6) and shell.css hides the row, so nothing here may apply there.
   Colours are tokens, sides are logical properties, and the row never scrolls: it keeps its words as long as they fit and
   folds in a fixed order as the window narrows (the bands below, widest first).
   The widths of the four bands were MEASURED by scripts/qa/menu_measure.mjs (headed, 14 November, every account of the kit, English
   and Arabic, timer idle and running, 120 and 99 on the two bells, two pins carrying the longest labels): each is the lowest
   window width from which the state before it fits at every wider step too (the worst account, language and timer state),
   rounded up to the next 20px, less one pixel (the block is a max-width). Re-run it with --measure after any change to the
   bar's right side, and --check proves the shipped sheet fits at every step from 768 to 1800. */

@media (min-width: 768px) {
    .shell-tabs {
        flex-wrap: nowrap;
        min-width: 0;
        gap: 2px;
        align-items: center;
    }

    .shell-tabs .shell-tab {
        flex-shrink: 0;
    }

    .shell-tab__where {
        font-weight: 400;
        color: var(--ink-soft);
    }

    .shell-tab__where::before {
        content: "\00b7";
        margin-inline-end: var(--sp-1);
    }

    /* The More button is a <summary>: no native marker (it is drawn as a tab), and the browser's own focus ring is kept. */
    .shell-more {
        flex-shrink: 0;
    }

    .shell-more > summary {
        list-style: none;
        cursor: pointer;
    }

    .shell-more > summary::-webkit-details-marker {
        display: none;
    }

    .shell-more > summary:focus-visible {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
    }

    /* The panel hangs from the header (the nearest positioned ancestor is the fixed bar, not the row), under More:
       menu.js sets --more-x to More's own start edge; without it the panel opens at the bar's padding. z-index 110 sits
       inside the header's stacking context, above the bell's panel (100). */
    .shell-more__panel {
        position: absolute;
        inset-block-start: calc(100% + 6px);
        inset-inline-start: var(--more-x, var(--sp-4));
        width: min(560px, calc(100vw - 32px));
        max-height: calc(100vh - var(--header-height) - 24px);
        overflow: auto;
        z-index: 110;
        box-sizing: border-box;
        padding: var(--sp-3);
        background: var(--panel-drop-bg);
        border: 1px solid var(--line);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-modal);
    }

    .shell-more__find {
        display: block;
        width: 100%;
        box-sizing: border-box;
        min-height: 36px;
        padding-block: var(--sp-2);
        padding-inline: var(--sp-3);
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: var(--bg-1);
        color: var(--ink);
        font: inherit;
        font-size: var(--text-sm);
    }

    .shell-more__results {
        list-style: none;
        margin-block: var(--sp-2) 0;
        margin-inline: 0;
        padding: 0;
    }

    .shell-more__results[hidden] {
        display: none;
    }

    .shell-more__group {
        margin-block: var(--sp-3) var(--sp-1);
        margin-inline: 0;
        font-size: var(--text-xs);
        font-weight: 700;
        line-height: 1.3;
        color: var(--ink-soft);
    }

    .shell-more__grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--sp-1);
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .shell-more__entry {
        display: flex;
        align-items: center;
        gap: var(--sp-2);
        padding-block: var(--sp-2);
        padding-inline: var(--sp-3);
        border-radius: var(--radius-md);
        color: var(--ink);
        text-decoration: none;
        font-size: var(--text-sm);
        font-weight: 600;
    }

    .shell-more__entry:hover,
    .shell-more__entry:focus-visible {
        background: var(--bg-2);
    }

    .shell-more__entry--current {
        background: var(--bg-2);
        color: var(--brand-primary);
    }

    /* The result Enter will open (the focus stays in the box while the arrows move): a hovered entry's look plus an outline. */
    .shell-more__entry--active {
        background: var(--bg-2);
        outline: 2px solid var(--brand-primary);
        outline-offset: -2px;
    }

    /* "No page matches.": padded and muted like a group's small heading. */
    .shell-more__none {
        padding-block: var(--sp-2);
        padding-inline: var(--sp-3);
        font-size: var(--text-xs);
        font-weight: 700;
        line-height: 1.3;
        color: var(--ink-soft);
    }

    .shell-more__icon {
        flex-shrink: 0;
        font-size: 1.1rem;
        line-height: 1;
    }

    .shell-more__text {
        min-width: 0;
    }

    .shell-more__entry small {
        display: block;
        font-size: var(--text-xs);
        font-weight: 400;
        line-height: 1.35;
        color: var(--ink-soft);
    }

    /* The number stands right after the entry's name (it is inside `.shell-more__name`), not at the far edge of the cell:
       in Arabic, at the far edge, it read as the next entry's. */
    .shell-more__badge {
        margin-inline-start: var(--sp-2);
        vertical-align: middle;
        min-width: 20px;
        height: 20px;
        padding-inline: var(--sp-1);
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-full);
        background: var(--danger);
        color: var(--surface);
        font-size: var(--text-xs);
        font-weight: 700;
    }
}

/* pins lose their words */
@media (min-width: 768px) and (max-width: 1299px) {
    .shell-tab--pin .shell-tab__label,
    .shell-tab__where {
        display: none;
    }
}

/* pins leave the row */
@media (min-width: 768px) and (max-width: 1159px) {
    .shell-tab--pin {
        display: none;
    }

    /* The current place is pinned and its pin has just left the row: More holds the light, with the look of the active tab
       (`.shell-tab--active` in shell.css, in this sheet's tokens: the sheet holds no literal colour), and the panel's entry
       of that place with the look of the current entry. Above this band the pin is lit and these classes change nothing. */
    .shell-tab--more.shell-more--holds-pin {
        color: var(--brand-primary);
        background: var(--panel-drop-bg);
        font-weight: 600;
        box-shadow: var(--tab-lit-shadow);
        border: var(--tab-lit-border);
    }

    .shell-more__entry--pinned-here {
        background: var(--bg-2);
        color: var(--brand-primary);
    }
}

/* the five show icons */
@media (min-width: 768px) and (max-width: 1099px) {
    .shell-tabs .shell-tab:not(.shell-tab--more) .shell-tab__label {
        display: none;
    }

    .shell-tabs .shell-tab {
        padding: var(--sp-2);
    }
}

/* More shows its icon and the logo is smaller */
@media (min-width: 768px) and (max-width: 779px) {
    .shell-tabs .shell-tab--more .shell-tab__label {
        display: none;
    }

    .shell-logo__img {
        height: 56px;
    }
}

/* A finger: every control of the row and every entry of the panel is at least 44 by 44. */
@media (min-width: 768px) and (pointer: coarse) {
    .shell-tabs .shell-tab,
    .shell-more__entry {
        min-height: 44px;
        min-width: 44px;
    }

    .shell-more__find {
        min-height: 44px;
    }

    /* A finger, tighter row: the 44 px target is the tab's min-width and min-height, so the row's gap goes and each tab's own
       inline padding shrinks to a quarter of the line; the words and the icons are not touched. */
    .shell-tabs {
        gap: 0;
    }

    .shell-tabs .shell-tab {
        padding-inline: var(--sp-1);
    }
}

/* The folding bands again for a finger (measured with --coarse, every account, both languages, the timer idle and running): the
   row's tighter padding on touch makes the pins' words (1,239 px), the pins (1,159) and the five's words (1,059) fit as low as
   a mouse's bands or lower, so those three bands are the mouse's. Only the last two steps differ: a touch screen's bell, second
   bell and picture are 44 px, so More shows its icon from 859 px (a mouse: 779), and below 799 px the tabs keep a drawn size. */

/* More shows its icon and the logo is smaller, on a finger */
/* (the tabs keep their full 44 by 44 px boxes here: 800 to 859 px, an iPad upright and a little more) */
@media (min-width: 768px) and (max-width: 859px) and (pointer: coarse) {
    .shell-tabs .shell-tab--more .shell-tab__label {
        display: none;
    }

    .shell-logo__img {
        height: 56px;
    }
}

/* the icon-only tabs keep their drawn size, on a finger */
/* (from 799 px down the most folded row does not fit with 44 px boxes, measured with --coarse: the tabs keep the width a mouse
   draws, 36 px, and take their 44 by 44 px target from an invisible box centred on them, the way the timer's small buttons do:
   two neighbours' targets overlap by 8 px) */
@media (min-width: 768px) and (max-width: 799px) and (pointer: coarse) {
    .shell-tabs .shell-tab {
        min-width: 0;
        padding-inline: var(--sp-2);
    }

    .shell-tabs .shell-tab::after {
        content: "";
        position: absolute;
        inset-block-start: 50%;
        inset-inline-start: 50%;
        margin-block-start: -22px;
        margin-inline-start: -22px;
        width: 44px;
        height: 44px;
    }
}
