/* =========================================================
   Phase 130 V148 — canonical site rail

   One source of truth for the visible desktop/mobile page axis.
   The header already established --container-wide as the approved wide rail.
   This late-loaded layer aligns every theme-owned outer page container and
   every footer row to that same rail, while leaving inner/readability widths
   and full-bleed auth screens alone.
   ========================================================= */

:root {
    --nb-site-rail: var(--container-wide, 1380px);
    --nb-site-rail-gutter: 32px;
}

/* Global chrome: Header and all three Footer rows always share one axis. */
html body:not(.nb-auth-page)[class] .site-header .nb-container,
html body:not(.nb-auth-page)[class] .site-footer .nb-container {
    width: min(calc(100% - var(--nb-site-rail-gutter)), var(--nb-site-rail)) !important;
    max-width: none !important;
    margin-inline: auto !important;
    box-sizing: border-box !important;
}

/* Homepage — every section uses the same physical rail as Header/Footer. */
html body:not(.nb-auth-page)[class] #main-content.nb-home-page .nb-container {
    width: min(calc(100% - var(--nb-site-rail-gutter)), var(--nb-site-rail)) !important;
    max-width: none !important;
    margin-inline: auto !important;
    box-sizing: border-box !important;
}

/* Blog listing / taxonomy / date / search. */
html body:not(.nb-auth-page)[class] #main-content.nb-blog > .nb-blog__container,
/* Single article. */
html body:not(.nb-auth-page)[class] #main-content.nb-article > .nb-article__container,
/* Custom page templates. */
html body:not(.nb-auth-page)[class] #main-content.nb-about > .nb-about__container,
html body:not(.nb-auth-page)[class] #main-content.nb-contact > .nb-contact__container,
html body:not(.nb-auth-page)[class] #main-content.nb-bug > .nb-bug__container,
html body:not(.nb-auth-page)[class] #main-content.nb-learning-page > .nb-learning-page__container,
html body:not(.nb-auth-page)[class] #main-content.nb-learning-hub > .nb-learning-hub__container,
html body:not(.nb-auth-page)[class] #main-content.nb-learning-lesson > .nb-learning-lesson__container,
html body:not(.nb-auth-page)[class] #main-content.nb-legal > .nb-legal__container,
html body:not(.nb-auth-page)[class] #main-content.nb-guide > .nb-guide__container,
html body:not(.nb-auth-page)[class] #main-content.nb-wiki-hub > .nb-wiki-hub__container,
/* Minimal 404 keeps its 760px content card inside a rail-aligned outer box. */
html body:not(.nb-auth-page)[class] #main-content.nb-404 .nb-404__inner,
/* Generic pages + WooCommerce page endpoints (cart/checkout/account/thank-you/order-pay). */
html body:not(.nb-auth-page)[class] #main-content.content-shell > .content-shell__inner.nb-container,
/* Shop archive/category/tag — each top-level section container. */
html body:not(.nb-auth-page)[class] #main-content.nb-shop-page > .nb-container,
/* Product page has section-level containers rather than one page wrapper. */
html body:not(.nb-auth-page)[class] #main-content.nb-product-page .nb-container {
    width: min(calc(100% - var(--nb-site-rail-gutter)), var(--nb-site-rail)) !important;
    max-width: none !important;
    margin-inline: auto !important;
    box-sizing: border-box !important;
}

/*
 * Cart owns an inner .nb-container inside the already rail-aligned page shell.
 * Keep that inner layer fluid so we do not create a second 32px inset.
 */
html body.woocommerce-cart:not(.nb-auth-page)[class] #main-content .nb-cart-page > .nb-container {
    width: 100% !important;
    max-width: none !important;
    margin-inline: 0 !important;
}

/* Logged-out auth is intentionally full-bleed and has no Header/Footer. */
html body.nb-auth-page .content-shell__inner,
html body.nb-auth-page .content-shell__inner--narrow {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
}

@media (max-width: 760px) {
    :root {
        --nb-site-rail-gutter: 24px;
    }
}
