/* V126 R3 stream "shell" -- PB-UX-21 (GAP-01, page width and side gutters) + PB-UX-22 (GAP-02, footer at the bottom of a short page).
   Linked LAST in the head of Views/Shared/_Layout.cshtml on every page of the shared shell (Regular and Simple, every page policy:
   standard / focus / legal / admin / unlisted, guest and signed in). Presentation only: no content, permission, order or gate changes.

   1. ONE owner of the working width and the side gutters: #main-content. The gutter is the existing token --pb-gutter (pb-tokens.css):
      16px below a 768px window, 24px from 768 to < 1200, 32px from 1200 (CSS window thresholds). The width is the parent's: no shell
      cap (the focus / legal 1280 .pb-container cap, the workspace / space 1440 cap) and no centring margin. Each exposed PHYSICAL side
      keeps max(gutter, safe-area inset); from 768 the inline-start side is held by the site navigation rail (HE right, EN left), so
      its safe area is never counted twice. Below 768 the navigation is a drawer over the page (0 width). Older overrides that set
      their own side padding on main (Simple 24 at >= 1200 and 12 below 340, the guest-home 20) are removed at their source too.
   2. Shell consumers (the page-root wrappers mapped in the V126 layout hand-off ROUTE_TO_SOURCE.json): collections, lists, galleries,
      management and work pages take the full working width and add no second side padding; readable forms / documents keep their own
      measure (LOCAL_WIDTH_EXCEPTIONS_HE.csv) but start on the content start line instead of floating in the middle. Inner component
      layouts keep deciding by their container width (container queries), never by the window.
   3. PB-UX-22: the page column (#pbSbPage: header, main, footer) fills the usable height -- the window minus the bottom bar reserve
      that the body already pads for (Regular / Simple mobile bottom bar, V120 measured bar) -- and main grows, so on a short or empty
      page the footer reaches the bottom edge; on a long page the footer simply follows the content in the normal scroll. One footer,
      after main, no fixed positioning. */

/* ------------------------------------------------------------------ 1. the working area */
:root { --pb126-sl: env(safe-area-inset-left, 0px); --pb126-sr: env(safe-area-inset-right, 0px); --pb126-reserve: 0px; }
@media (min-width: 768px) {
    html[dir="rtl"] body.pb-sb-root { --pb126-sr: 0px; }   /* the rail holds the right edge (HE) */
    html[dir="ltr"] body.pb-sb-root { --pb126-sl: 0px; }   /* the rail holds the left edge (EN) */
}
html body main#main-content.pb-main {
    box-sizing: border-box;
    inline-size: auto;
    min-inline-size: 0;
    max-width: none;
    max-inline-size: none;
    margin-inline: 0;
    padding-left: max(var(--pb-gutter, 16px), var(--pb126-sl));
    padding-right: max(var(--pb-gutter, 16px), var(--pb126-sr));
}
/* a .pb-container inside the working area never adds a second gutter or cap (the focus / legal pattern nested one in main) */
html body main#main-content.pb-main .pb-container { max-width: none; max-inline-size: none; padding-inline: 0; }
/* the shared footer lines up with the working area (same gutters, no centred 1280 cap) in every shell */
html body.pb-sb-root .pb-footer > .pb-container { max-width: none; max-inline-size: none; }

/* ------------------------------------------------------------------ 2. shell consumers: one width, one gutter */
/* collections, lists, galleries, management and work pages: the full working width, no second side padding (VL-01 .. VL-13) */
html body main#main-content.pb-main :is(
    .pb-shop, .pb-buyer:not(.pb-buyer--narrow), .pb-seller, .pb-rsb,
    .pb46-area__in, .pb114a, .pb114a-stack.pb107-acct, .pb120a,
    .pb47-cr, .pb-v67m, .pb-acct-page:not(.pb44-task), .pb-w3-page, .pb104p, .pb-m67-profile,
    .pb113f-inner, .pb69h-inner, .pb-v113f-contact, .pb-cs-page, .pb-oc-page, .pb55p,
    .pb103f, .pb108c, .pb112at, .pb113g-page, .pb-fin-page, .pb-v68w, .cw-page, .pb48-page
) {
    max-width: none;
    max-inline-size: none;
    margin-inline: 0;
    padding-inline: 0;
}
html body main#main-content.pb-main .pb114a-content .pb46-area__in { max-width: none; max-inline-size: none; }
/* the notifications page carried its own 960 cap and 32px side padding */
html body main#main-content.pb-main #pb67nPage.pb67n-page { max-inline-size: none; margin-inline: 0; padding-inline: 0; }
/* Simple: the market (1200), management (1100) and purchases (760) caps of the page roots are lifted the same way */
html body.pb61s main#main-content.pb-main :is(.pb-buyer-shop, .pb-buyer-store, #pbHomeDiscover, .pb63h-guest, .pb-seller, .pb-v68w, #pbMessages, .pbuxb-orders) {
    max-inline-size: none;
    margin-inline: 0;
}
/* readable forms and documents keep their own measure (local width exceptions) and start on the content start line */
html body main#main-content.pb-main :is(.pb-cm, .pb-legal, .pb-legal-doc, .pb-buyer--narrow, .pb-acct-page.pb44-task) { margin-inline: 0; }
html body main#main-content.pb-main :is(.pb-cm, .pb-buyer--narrow) { padding-inline: 0; }
html body.pb61s main#main-content.pb-main :is(.pb-buyer--narrow, #pbReadyCheckout, #pbSellerEdit, #pbSellerCreate, .pb-account-form, #pbShopSettingsForm, .pbuxp-how) { margin-inline: 0; }
/* sign-in / sign-up keep the centred V119 unit (VL-12): .pb-auth-wrap, .pb-acct-auth and .pb119a are not touched here */

/* ------------------------------------------------------------------ 3. PB-UX-22: short page = footer at the bottom edge */
@media (max-width: 767.98px) {
    /* the bottom bar reserve the body already pads for (pb-v101-shell.css / pb-v101-simple-bottom.css / pb-v120-nav.css) */
    html[data-pb101-bottom="1"] body { --pb126-reserve: calc(64px + env(safe-area-inset-bottom, 0px)); }
    html[data-pb120-nav="1"][data-pb101-bottom="1"] body { --pb126-reserve: var(--pb120-bar-h, calc(64px + env(safe-area-inset-bottom, 0px))); }
}
html body.pb-sb-root > #pbSbPage.pb-sb-page {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-block-size: calc(100vh - var(--pb126-reserve, 0px));
    min-block-size: calc(100dvh - var(--pb126-reserve, 0px));
}
html body.pb-sb-root > #pbSbPage.pb-sb-page > * { flex: none; }
html body.pb-sb-root > #pbSbPage.pb-sb-page > main#main-content { flex: 1 0 auto; }
@media print {
    html body.pb-sb-root > #pbSbPage.pb-sb-page { display: block !important; min-block-size: 0 !important; }
}

/* Keep the same shell reserve on pilot pages that resolve without the sidebar wrapper. */
@media screen {
    html body.pb-shell:not(.pb-sb-root):has(> main#main-content > :is(#pbV116Discover, #pbShopProduct)) {
        /* The body already includes the mobile bar reserve in its padding. */
        box-sizing: border-box; display: flex; flex-direction: column;
        min-block-size: 100vh;
        min-block-size: 100dvh;
    }
    html[data-pb-qa-25="1"] body.pb-shell:not(.pb-sb-root):has(> main#main-content > :is(#pbMessages, #pb67nPage)) {
        box-sizing: border-box; display: flex; flex-direction: column;
        min-block-size: calc(100vh - var(--pb126-reserve, 0px));
        min-block-size: calc(100dvh - var(--pb126-reserve, 0px));
    }
    html body.pb-shell:not(.pb-sb-root):has(> main#main-content > :is(#pbV116Discover, #pbShopProduct)) > :is(#pbHeader, .pb-footer),
    html[data-pb-qa-25="1"] body.pb-shell:not(.pb-sb-root):has(> main#main-content > :is(#pbMessages, #pb67nPage)) > :is(#pbHeader, .pb-footer) { flex: none; }
    html body.pb-shell:not(.pb-sb-root) > main#main-content:has(> :is(#pbV116Discover, #pbShopProduct)),
    html[data-pb-qa-25="1"] body.pb-shell:not(.pb-sb-root) > main#main-content:has(> :is(#pbMessages, #pb67nPage)) { flex: 1 0 auto; }
}

/* Repeat price and type only while the mobile purchase controls are fixed above the site bar. */
#pbShopProduct .pb-shop-sticky-decision { display: none; }
@media screen and (max-width: 767.98px) {
    #pbShopProduct #pbShopBuy[data-pb48-mode="sticky"] .pb-shop-sticky-decision {
        display: block;
        margin-block: 0 4px;
        overflow-wrap: anywhere;
    }
}

/* V127-UX-03. Retain the stretched card link and native disclosure markers. */
@media (max-width: 767.98px) {
    html[data-pb-qa-22="1"] #main-content .pb123c-link {
        min-inline-size: 48px;
        min-block-size: 48px;
    }

    html[data-pb-qa-22="1"] #main-content :is(#pb124EditProfileLink, #pbPrinterAvailabilityLink, #pbPrinterReportLink, #pb124UnavailableDates, #pbFreeModelBack, #pbShopBack) {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        min-inline-size: 48px;
        min-block-size: 48px;
    }

    html[data-pb-qa-22="1"] #main-content :is(.pb113f-faq, .pb69h-faq, .pb40-faq__item) summary {
        box-sizing: border-box;
        min-inline-size: 48px;
        min-block-size: 48px;
        padding-block: 12px;
    }

    html[data-pb-qa-22="1"] #pbHeader.pb42 #pbHeaderBar .pb42-searchform { min-block-size: 50px; }
    html[data-pb-qa-22="1"] #pbHeader.pb42 #pbHeaderBar .pb42-searchform :is(#pbHeaderSearchQ, #pbHeaderSearch, #pb65mSearchClear) {
        min-inline-size: 48px;
        min-block-size: 48px;
    }
}

@media (max-width: 359.98px) {
    html[data-pb-qa-22="1"][data-pb101-shell="1"]:not([data-pb120-nav="1"]) #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-bar {
        flex-wrap: wrap;
        block-size: auto;
        row-gap: 4px;
        padding-block: 6px;
    }
    html[data-pb-qa-22="1"][data-pb101-shell="1"]:not([data-pb120-nav="1"]) #pbHeader.pb42[data-pb42-layout="mobile"] .pb42-search {
        order: 99;
        flex: 0 0 100%;
    }
}

.pb-qa-mode-label { display: none; }

/* V127-UX-04 (V139, owner 3/12: always on, no QA switch). Keep the same switch and localized accessible names. */
@media (max-width: 767.98px) {
    #pbHeader.pb42[data-pb42-layout="mobile"] #pbV51ModeBtn {
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding-inline: 2px;
    }

    #pbHeader.pb42[data-pb42-layout="mobile"] #pbV51ModeBtn:not([data-pb64m-state="unverified"]) .pb-qa-mode-label--verified,
    #pbHeader.pb42[data-pb42-layout="mobile"] #pbV51ModeBtn[data-pb64m-state="unverified"] .pb-qa-mode-label--unverified {
        display: block;
        max-inline-size: 100%;
        font-size: 11px;
        font-weight: 600;
        line-height: 1;
        text-align: center;
    }

    #pbHeader.pb42[data-pb42-layout="mobile"] #pbV51ModeBtn[data-pb64m-state="unverified"] .pb65m-pill { display: none; }
}

/* V127-UX-05. Let the icon mirror with the UI, even when the return label contains a mixed-direction store name. */
html[data-pb-qa-24="1"] #main-content :is(#pbFreeModelBack, #pbShopBack) {
    display: inline-flex;
    align-items: center;
    column-gap: 6px;
}
html[data-pb-qa-24="1"] #main-content :is(#pbFreeModelBack, #pbShopBack) .pb-icon-directional {
    flex: 0 0 auto;
    inline-size: 16px;
    block-size: 16px;
}
html[data-pb-qa-24="1"][dir="rtl"] #main-content :is(#pbFreeModelBack, #pbShopBack) .pb-icon-directional { transform: scaleX(-1); }

/* V127-UX-08. The existing input name covers the visible search prompt. */
@media (min-width: 768px) {
    html[data-pb-qa-27="1"] body[data-pb-choice-mode="regular"] #pbHeader.pb42 #pbHeaderBar .pb42-searchlabel {
        inset: auto;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        padding: 0;
        border: 0;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    html[data-pb-qa-27="1"] body[data-pb-choice-mode="regular"] #pbHeader.pb42 #pbHeaderBar .pb42-search { padding-block-start: 0; }
}
