/* Shared PB navigation shell. The layout supplies html[data-pb120-nav="1"].
   Presentation only: the controls are the header's own elements (same ids, handlers, panels, counters); nothing is granted.
   1. Glyph boxes (INT-05): 22x22 for every navigation glyph (header, bottom bar, rail, drawer), 20x20 inside the search field.
   2. The search field (PB-C013): at least 48px tall, the 20px magnifier at the start, a 48x48 clear target kept even while empty.
   3. The mobile Regular header (NAV section 4): Menu, Search, Switch workspace, [display mode], Messages, Cart from the leading
      edge, 8px gaps; pb-v120-nav.js moves the search to its own full-width row (data-pb120-rows="2") when less than 144px remain.
   4. The Regular bottom bar follows the shared V101 direction and safe edges. This layer supplies the 16x2
      selection marker 4px above the target edge, the inner 2px focus ring, and the 36px round Create surface.
   5. ONE scroll inset (INT-04): body padding + scroll padding = the real bar height (pb-v120-nav.js measures it) including the bottom
      safe area once; bars lifted above the bottom bar drop their own safe-area padding (it is already under them).
   6. The notifications panel is anchored above the Simple bottom bar too (pb-v67n-notify.js, bar mode).
   Colours only from the existing header / site tokens (Light / Dark / System). */

/* ================================================================== 1. glyph boxes */
html[data-pb120-nav="1"] .pb-sb .pb-sb-icon,
html[data-pb120-nav="1"] .pb-sb-menu .pb-sb-icon { inline-size: 22px; block-size: 22px; }
html[data-pb120-nav="1"] #pbHeader.pb42 .pb42-searchgo .pb42-glyph { inline-size: 20px; block-size: 20px; }

/* ================================================================== 2. the search field (mobile composition) */
html[data-pb120-nav="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-searchform { min-block-size: 48px; }
html[data-pb120-nav="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-searchform input[type="search"] { min-block-size: 46px; padding-inline: 0 4px; }
html[data-pb120-nav="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-searchgo { inline-size: 40px; min-inline-size: 40px; block-size: 46px; min-block-size: 46px; padding-inline-start: 12px; padding-inline-end: 8px; box-sizing: border-box; }
html[data-pb120-nav="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb65m-clear { inline-size: 48px; block-size: 46px; }
/* the clear target keeps its room while the field is empty (no jump when the first character is typed); it is not focusable then */
html[data-pb120-nav="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb65m-clear[hidden] { display: inline-flex; visibility: hidden; }
html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb42-search .pb42-searchform { min-block-size: 48px; }

/* ================================================================== 3. the header workspace switch (Regular) */
html[data-pb120-nav="1"] #pb120Ws { position: relative; display: inline-flex; margin: 0; }
html[data-pb120-nav="1"] #pb120WsBtn { list-style: none; cursor: pointer; }
html[data-pb120-nav="1"] #pb120WsBtn::-webkit-details-marker { display: none; }
html[data-pb120-nav="1"] .pb120-ws__panel { border: 1px solid var(--pb44-line); border-radius: 12px; box-shadow: 0 12px 32px var(--pb44-shadow); padding: 8px; }
html[data-pb120-nav="1"] .pb120-ws__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
html[data-pb120-nav="1"] .pb120-ws__item {
    display: flex; align-items: center; min-block-size: 48px; padding-inline: 12px; border-radius: 8px;
    color: var(--pb44-ink); font-size: 16px; line-height: 1.4; text-decoration: none; overflow-wrap: anywhere;
}
html[data-pb120-nav="1"] .pb120-ws__item:hover { background: var(--pb44-press); }
html[data-pb120-nav="1"] .pb120-ws__item[aria-current="page"] { background: var(--pb44-soft); color: var(--pb44-accent-text); font-weight: 700; }
html[data-pb120-nav="1"] .pb120-ws__item:focus-visible { outline: 2px solid var(--pb44-focus); outline-offset: -2px; }
/* wide (>= 1200, the V101 one-row bar): right after the search */
html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb42-layout="wide"] #pb120Ws { order: 2; }

/* ================================================================== 3b. the mobile Regular header row */
@media (max-width: 767.98px) {
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb42-bar {
        gap: 8px;
        padding-left: max(8px, var(--pb120-sl));
        padding-right: max(8px, var(--pb120-sr));
    }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) #pb120Ws { order: 3; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) #pb120WsBtn { inline-size: 44px; block-size: 44px; min-inline-size: 44px; min-block-size: 44px; padding: 0; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) #pbModeSwitchSlot { order: 4; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb101-msg { order: 5; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb101-cart,
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb101-cart[data-pb77-empty="1"] { order: 6; }
    /* V132-NAV-01. Keep the search submit target at the shell minimum (QA 22 can enlarge it). */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-searchgo { min-inline-size: 44px; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-searchform input[type="search"] { text-align: start; }
    /* The same native details, summary and authorized links run inside the drawer. */
    html[data-pb120-nav="1"] #pbSbNav > #pb120Ws { display: block; }
    html[data-pb120-nav="1"] #pbSbNav #pb120WsBtn { display: flex; width: 100%; min-block-size: 48px; }
    html[data-pb120-nav="1"] #pbSbNav #pb120WsBtn::after { content: attr(aria-label); }
    html[data-pb120-nav="1"] #pbSbNav #pb120WsBtn svg { inline-size: 22px; block-size: 22px; flex: none; }
    html[data-pb120-nav="1"] #pbSbNav .pb120-ws__panel { padding: 0; border: 0; box-shadow: none; }
    html[data-pb120-nav="1"] #pbSbNav .pb120-ws__item { color: var(--pb-text-primary); }
    html[data-pb120-nav="1"] #pbSbNav .pb120-ws__item:hover { background: var(--pb-surface-hover); }
    html[data-pb120-nav="1"] #pbSbNav .pb120-ws__item[aria-current="page"] { color: var(--pb-action-soft-text); background: var(--pb-surface-selected); }
    html[data-pb120-nav="1"] #pbSbNav :is(#pb120WsBtn, .pb120-ws__item):focus-visible { outline: 2px solid var(--pb110-focus, var(--pb-focus)); outline-offset: -2px; }
    /* the moved bell (pb-v120-nav.js: DOM = reading order) keeps the commsitem geometry it had inside the communication cell */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeaderBar > .pb101-bell { flex: 0 0 auto; }
    /* two rows: the action row, then the ONE search field at full width (the same input element, the query and the selection kept) */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb120-rows="2"]:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb42-bar {
        flex-wrap: wrap; block-size: auto; min-block-size: 64px; row-gap: 8px; padding-block: 10px 8px;
    }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb120-rows="2"]:is([data-pb42-layout="mobile"], [data-pb42-layout="xs"]) .pb42-search { order: 99; flex: 1 1 100%; inline-size: 100%; }
}

/* ================================================================== 4. the Regular bottom bar */
@media (max-width: 767.98px) {
    html[data-pb120-nav="1"][data-pb101-shell="1"] {
        --pb120-sl: env(safe-area-inset-left, 0px); --pb120-sr: env(safe-area-inset-right, 0px);
    }
    /* panels opened from the bar keep the net width (side safe areas) */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar .pb42-acct .pb42-panel,
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pbCreateNonePanel {
        left: calc(8px + var(--pb120-sl));
        right: calc(8px + var(--pb120-sr));
        bottom: var(--pb120-bar-h, calc(64px + env(safe-area-inset-bottom, 0px)));
    }

    /* the selection marker: 16x2, centred, its bottom 4px above the target edge; reserved (transparent) in the destination cells */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pb101Home::after {
        content: ""; position: absolute; left: calc(50% - 8px); bottom: 4px; inline-size: 16px; block-size: 2px; border-radius: 1px;
        background: transparent; pointer-events: none;
    }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pb101Home[aria-current="page"] { color: var(--pb44-accent-text, var(--pb-action-primary)); }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pb101Home[aria-current="page"]::after { background: currentColor; }
    /* focus: a 2px ring INSIDE the target (the bar touches the screen edge, an outside ring could be cut); separate from the marker */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar :is(#pb101Home, #pbGlobeTrigger, #pbNotifBell, #pb65mGuestNotif, #pbAccountLogin, #pbCreateTriggerDesktop):focus-visible,
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar .pb42-acct summary:focus-visible,
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar .pb42-create summary:focus-visible {
        outline: 2px solid var(--pb44-focus, var(--pb-focus)); outline-offset: -2px;
    }
    /* Create: the 36px round action surface inside its 48px target (the dark hairline keeps its contrast) */
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42[data-pb42-layout="mobile"] #pbHeaderBar .pb42-createbtn::before { inset: 6px; border-radius: 50%; }
}
/* below five targets of net width (240px at the 48px variant) the five equal cells cannot hold: the bar keeps its order and grows
   a second row of up to three cells (the reading order wins over the central Create) */
@media (max-width: 239.98px) {
    html[data-pb120-nav="1"][data-pb101-shell="1"] { --pb101-bottom-cell: calc(var(--pb101-bottom-net-width) / 3); }
    html[data-pb120-nav="1"][data-pb101-shell="1"] .pb101-bottombar { block-size: calc(128px + env(safe-area-inset-bottom, 0px)); }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar :is(#pb101Home, .pb42-create > :not(style):not(script)),
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pbGlobeTrigger { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar .pb101-bell { --pb101-bottom-slot: 0.5; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar .pb42-acct > :not(style):not(script) { --pb101-bottom-slot: 1.5; }
}

/* ================================================================== 5. ONE scroll inset for the bottom bar (Regular and Simple) */
@media (max-width: 767.98px) {
    html[data-pb120-nav="1"][data-pb101-bottom="1"] { scroll-padding-block-end: calc(var(--pb120-bar-h, calc(64px + env(safe-area-inset-bottom, 0px))) + 8px); }
    html[data-pb120-nav="1"][data-pb101-bottom="1"] body { padding-bottom: var(--pb120-bar-h, calc(64px + env(safe-area-inset-bottom, 0px))); }
    html[data-pb120-nav="1"][data-pb101-shell="1"] :is(.pb48-actionbar[data-pb48-mode="sticky"], .pb-wiz-sticky, .pb-v32-ave-bar) {
        inset-block-end: var(--pb120-bar-h, calc(64px + env(safe-area-inset-bottom, 0px)));
    }
    /* A bar lifted above the bottom bar already clears the safe area. */
    html[data-pb120-nav="1"][data-pb101-bottom="1"] .pb-v32-ave-bar { padding-block-end: 12px; }
}
@media (max-width: 767.98px) {
    @container (max-width: 599.98px) {
        html[data-pb120-nav="1"][data-pb101-shell="1"] .pb48-actionbar[data-pb48-mode="sticky"] { padding-block-end: 12px; }
    }
}

/* ================================================================== 6. the notifications panel above the Simple bottom bar */
html[data-pb120-nav="1"][data-pb101-bottom="1"] body #pbNotifPanel.pb67n-panel[data-pb67n-mode="bar"] { border-radius: 16px; z-index: 49; }
html[data-pb120-nav="1"][data-pb101-bottom="1"] body #pbNotifPanel.pb67n-panel[data-pb67n-mode="bar"] .pb67n-body { max-block-size: none; }

/* ================================================================== 6b. V122 R2 WS-F (NAV-T08 / T27): the crowded counter as an 8px dot
   pb-v120-nav.js sets data-pb120-dot when the digits would reach more than 4px past the glyph's centre line; the dot keeps the corner,
   the surface ring (separate from the glyph), and stays clear of the inner focus ring and the bottom selection marker. The digits stay
   in the aria-hidden badge; the exact count stays in the control's accessible name. */
html[data-pb120-nav="1"] #pbHeader .pb40-hbadge[data-pb120-dot="1"] {
    min-width: 8px; min-height: 8px; inline-size: 8px; block-size: 8px; padding: 0; top: 6px; inset-inline-end: 6px;
    font-size: 0; line-height: 0; color: transparent; overflow: hidden;
}

/* ================================================================== 7. V122 R2 WS-F (NAV-T04): the on-screen keyboard (Regular mobile)
   pb-v120-nav.js sets html[data-pb120-kb="1"] while a text control has the focus and the keyboard is open: the bottom bar steps away
   (hidden = no Tab stop, nothing covers the focused field) and the end scroll inset is 8px; it comes back when the keyboard closes. */
@media (max-width: 767.98px) {
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb120-kb="1"] .pb101-bottombar,
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb120-kb="1"] #pbHeader.pb42 #pbHeaderBar :is(#pb101Home, #pbGlobeTrigger, .pb101-bell),
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb120-kb="1"] #pbHeader.pb42 #pbHeaderBar .pb42-create > :not(style):not(script),
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb120-kb="1"] #pbHeader.pb42 #pbHeaderBar .pb42-acct > :not(style):not(script) { visibility: hidden; }
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb101-bottom="1"][data-pb120-kb="1"],
    html[data-pb120-nav="1"][data-pb101-shell="1"][data-pb120-kb="1"] { scroll-padding-block-end: 8px; }
}

@media (forced-colors: active) {
    html[data-pb120-nav="1"] #pbHeader .pb40-hbadge[data-pb120-dot="1"] { forced-color-adjust: none; background: Highlight; box-shadow: 0 0 0 2px Canvas; }
    html[data-pb120-nav="1"][data-pb101-shell="1"] #pbHeader.pb42 #pbHeaderBar #pb101Home[aria-current="page"]::after { background: Highlight; forced-color-adjust: none; }
    html[data-pb120-nav="1"] .pb120-ws__item[aria-current="page"] { outline: 2px solid Highlight; }
}
