/* ================================================================
   BASE.CSS - LexRay Foundation Styles

   Loads after ss-main.css to provide LexRay-specific branding
   and common layout styles used across all pages.

   Merged from: base.css + branding.css
   ================================================================ */

/* ====== SIMMONS & SIMMONS BRANDING ====== */

/* Note: Font imports and core S&S design system variables are in ss-main.css
   ss-main.css has been modified to use :root instead of .ce for global variable access */

/* Design tokens (colour, spacing, radius, fonts, type scale) live in
   tokens.css — the single source of truth (issue #1211). This :root only
   carries page-layout dimensions plus the Bootstrap font-variable overrides,
   which MUST be declared after bootstrap.min.css (tokens.css loads before it,
   so Bootstrap's own :root would win there). */
:root {
    /* Layout dimensions for legislation pages */
    --header-height: 80px;             /* Height of fixed header */
    --viewport-margin: 20px;           /* Standard margin from viewport edges */
    --toc-width: 66px;                 /* TOC sidebar width */
    --content-max-width: 1320px;       /* S&S container--large default */

    /* Override Bootstrap font variables to use S&S fonts */
    --bs-font-sans-serif: var(--font-stack-1);
    --bs-body-font-family: var(--font-stack-3);
}

/* ====== FONTS ====== */

/* Self-hosted JetBrains Mono (latin subset). Defined here in the globally-loaded
   base.css so the monospace badge/chip treatment (and the STRIDE /launch +
   home-feature decrypt aesthetic) is available on every page, not just the
   homepage. Previously lived in home_features.css (homepage-only). (#716) */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/jetbrains-mono-latin.woff2) format('woff2');
}

/* Merriweather's metric-matched fallback (#3580). Merriweather is the body
   text of an act and `font-display: swap`, so until its file arrives the text
   is drawn in the next family of the stack. Times New Roman, the usual one,
   sets act text 14.5% narrower than Merriweather's 300 reading weight, so the
   late swap rewrapped every paragraph on screen. These faces
   draw the local Times New Roman (or Liberation Serif, which has its metrics)
   scaled to Merriweather's average advance and given Merriweather's ascent,
   descent and line gap: a paragraph in the fallback wraps where Merriweather
   will, and the swap repaints the glyphs without moving the lines. The italic
   is `font-display: optional` (ss-main.css), so a late italic is never swapped
   in at all: its fallback face below is what that page view keeps.

   One face per Merriweather weight in use, since the variable font widens with
   weight and the fallback has only a regular and a bold (500 matches the 400
   face). The numbers come from scripts/merriweather_fallback_metrics.py; rerun
   it if the Merriweather files change. The unicode-range is Merriweather's own,
   so a character Merriweather cannot draw still falls through to `serif`
   unscaled, as before. No local font, no face: the stack goes on to `serif`. */
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: normal;
    font-weight: 300;
    src: local('Times New Roman'), local('TimesNewRomanPSMT'),
        local('Liberation Serif'), local('LiberationSerif');
    size-adjust: 117.00%;
    ascent-override: 84.10%;
    descent-override: 23.33%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: normal;
    font-weight: 400;
    src: local('Times New Roman'), local('TimesNewRomanPSMT'),
        local('Liberation Serif'), local('LiberationSerif');
    size-adjust: 119.17%;
    ascent-override: 82.57%;
    descent-override: 22.91%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: normal;
    font-weight: 600;
    src: local('Times New Roman Bold'), local('TimesNewRomanPS-BoldMT'),
        local('Liberation Serif Bold'), local('LiberationSerif-Bold');
    size-adjust: 113.36%;
    ascent-override: 86.80%;
    descent-override: 24.08%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: normal;
    font-weight: 700;
    src: local('Times New Roman Bold'), local('TimesNewRomanPS-BoldMT'),
        local('Liberation Serif Bold'), local('LiberationSerif-Bold');
    size-adjust: 115.31%;
    ascent-override: 85.34%;
    descent-override: 23.68%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: italic;
    font-weight: 400;
    src: local('Times New Roman Italic'), local('TimesNewRomanPS-ItalicMT'),
        local('Liberation Serif Italic'), local('LiberationSerif-Italic');
    size-adjust: 111.31%;
    ascent-override: 88.40%;
    descent-override: 24.53%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Merriweather Fallback';
    font-style: italic;
    font-weight: 700;
    src: local('Times New Roman Bold Italic'), local('TimesNewRomanPS-BoldItalicMT'),
        local('Liberation Serif Bold Italic'), local('LiberationSerif-BoldItalic');
    size-adjust: 110.55%;
    ascent-override: 89.01%;
    descent-override: 24.69%;
    line-gap-override: 0%;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
        U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ====== TYPOGRAPHY OVERRIDES ====== */

/* ss-main.css sets `p { font-family: Merriweather }` with no fallback of its
   own, so a paragraph before Merriweather arrived was drawn in the browser's
   default font and rewrapped at the swap. The same face through the token, which
   carries the metric-matched fallback above (#3580). */
p {
    font-family: var(--ss-font-serif);
}

body {
    /* Override Bootstrap's use of --bs-font-sans-serif with serif font for body text */
    font-family: var(--ss-font-serif);
    color: var(--ss-dark);
    background-color: var(--background-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Canonical badge typography + the environment badges moved to
   components.css (issue #1211). */

/* Fix Font Awesome icons - override body font-family inheritance
   See: https://github.com/prisonblues/lexray/issues/252 */
.fas, .fa-solid {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}

.far, .fa-regular {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 400 !important;
}

.fab, .fa-brands {
    font-family: "Font Awesome 6 Brands" !important;
    font-weight: 400 !important;
}

/* The canonical h1–h6 scale lives in components.css (issue #1211). */

/* Heading content styles */
.heading-content .heading-title {
    /* The legislation title is set in the serif, the act's own voice, like the text it
       heads: the one heading tier that is not the brand sans (design_system.md, h1 tiers). */
    font-family: var(--ss-font-serif);
    /* Light display weight; 500 read too heavy next to the brand (#1235). */
    font-weight: 300;
    color: var(--ss-dark);
    /* The application h1 tier (tokens.css §5) — legislation titles ARE that scale. */
    font-size: var(--lx-h1);
    position: relative;
    z-index: 1;
    padding: 1rem 0;
    margin-bottom: 0.5rem;
}

/* ====== HEADER BRANDING ====== */

.header {
    background-color: var(--color-coral-base) !important;
    border-bottom: none;
    box-shadow: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050 !important; /* Above TOC (1030), isotope grids, below Bootstrap modals (1055) and UI overlays (1070+) */
    height: 80px;
}

/* The .header above is an ABSOLUTE coral overlay pinned over the top
   --header-height px of the document, and <main> (layouts/base.html) has NO
   default top padding — so a standard container page renders its first row
   UNDER the nav unless it reserves that space itself. That is the recurring
   "content hidden behind the navbar" footgun.

   Every template that RENDERS THIS HEADER must DECLARE which side of it the
   page is on, in {% block body_class %} — or on its literal <body> tag, for a
   shell that owns one (issue #1549). The scope is "renders the header", not
   "extends layouts/base.html", because home/loader.html — the reader, and the
   most-visited page in the app — extends nothing and includes the header
   partial itself.

     pad-for-header         — clear the header via the shared rule below.
     owns-header-clearance  — the page reserves the space itself (a full-bleed
                              hero, the reader/logic surfaces, or its own
                              calc(var(--header-height) …) rule) and must NOT
                              be padded again.

   Saying nothing is no longer a third option: it is indistinguishable from
   having forgotten, which is how /aia/a5, /admin/settings, the 404 and the 500
   all shipped with their first row unclickable under the nav. The declaration
   is enforced statically (scripts/check_design_drift.py, `header-clearance` —
   the one BLOCKING rule in that scanner) and at render time
   (tests/smoke/test_route_render_smoke.py).

   Do not re-declare the padding in a page's own <style> — a per-page copy of
   `body.<class> main { padding-top: … }` is exactly the fork this class
   exists to prevent, and the scanner flags it as `clearance-fork`. */
body.pad-for-header main {
    padding-top: var(--header-height);
}

/* Header wrapper - spans full width of header */
.header-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Header content - provides consistent 20px padding for all pages */
.header-content {
    width: 100%;
    max-width: 100%;
    padding: 0 20px;  /* Standard horizontal padding */
    box-sizing: border-box;
}

/* Legislation pages: tighter padding to align with TOC buttons */
body.show-lexray-text .header-content {
    padding-left: 0.5rem;  /* 8px - aligns with TOC button left edge */
}

/* On legislation pages: Padding handled by .legislation-layout flex container */
/* Old padding removed - TOC is now inside flex layout, not fixed outside */
/* body.show-lexray-text #loading-skeleton,
body.show-lexray-text #app-container {
    padding-left: calc(var(--viewport-margin) + var(--toc-width));
} */

/* ====== HEADER LAYOUT ======
   Header uses S&S design system's natural container/content structure:
   - .header > .container--large (1200px max-width, centered)
   - .content gets 20px padding from ss-main.css .container .content rule
   - Padding removed at 1240px+ per ss-main.css media query

   No page-specific overrides needed - all pages share same clean alignment */

/* Hide middle navigation on legislation pages */
body.show-lexray-text .header .header_navigation {
    display: none;
}

/* Page title in the header's middle band (`header_page_title`).

   It lives HERE, not above the page's own content, because the middle of the
   bar is dead space: at a 1400px viewport there is ~1000px of clear width
   between the wordmark and the account menu. A title there costs the page NO
   height, which a band above the content cannot do — it would push the whole
   grid down by its own height.

   ABSOLUTE against .header, which is itself positioned and spans the viewport.
   That is what lets `left` be given in PAGE coordinates: a page can line the
   title up with its own first column (--header-page-title-left) instead of
   inheriting whatever width the logo and env badges happen to take. In flow it
   would also grow the bar past its fixed 80px; out of flow it contributes no
   height at all, which is the whole point of putting it here.

   White, like every other thing in this bar: .header is coral on every page
   (transparent over the same coral gradient on a `homepage` body), and
   .header-text / .header-greeting are already #fff.

   `right` stops it clear of the account menu (.header_icons is 170px inside the
   header's 20px padding). It truncates rather than wraps: the bar is a fixed
   80px and a second line would burst it, so ellipsis is the honest failure for
   a title too long for the space it was given. */
.header-page-title {
    position: absolute;
    top: 50%;
    left: var(--header-page-title-left, 20px);  /* 20px = .header-content's own padding */
    right: 200px;
    transform: translateY(-50%);
    margin: 0;
    padding: 0;  /* the site's h1 rule pads 20px top and bottom; here the box IS the text */
    font-family: var(--ss-font-primary);
    /* 42px is the card symbol's size (.browse-page .grid-item .symbol), so the
       page's name reads at the same weight as the names in the grid under it.
       It fits the 80px bar at line-height 1 with 19px of air either side. */
    font-size: 42px;
    font-weight: 700;
    line-height: 1;
    color: var(--lx-on-brand);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Below the S&S breakpoint the bar has no clear middle left — the logo and the
   account menu meet. Drop the title there; the document <title> and the page's
   own content still say where you are. */
@media screen and (max-width: 1199px) {
    .header-page-title {
        display: none;
    }
}

/* Lexray landing page only: transparent floating header over the hero, fixed
   so scroll-snap can't clip it (#753c). The STRIDE homepage has no hero, so it
   keeps the solid coral header (see below). */
body.homepage:not(.stride-page):not(.proposal-page) .header {
    background-color: transparent !important;
    position: fixed;
}

/* STRIDE homepage: keep the header pinned at the top but with the solid coral
   background, matching the other STRIDE pages (it has no hero to float over). */
body.homepage.stride-page .header {
    background-color: var(--color-coral-base) !important;
    position: fixed;
}

/* Remove all navbar backgrounds */
.navbar-main,
.navbar-theme-primary,
.navbar-dark,
.navbar {
    background-color: transparent !important;
    background-image: none !important;
    border: none !important;
    box-shadow: none !important;
}

.navbar-main {
    padding: 30px 0;
    height: 110px;
    display: flex;
    align-items: center;
}

.navbar-brand {
    display: block;
    margin: 0;
    padding: 0;
}

.navbar-brand img {
    height: 50px;
    width: auto;
    display: block;
    filter: brightness(0) invert(1); /* Make logo white */
}

/* ====== BUTTON STYLES ====== */

/* Canonical button skins (.btn-primary, .btn-secondary, the filter .button
   system) live in components.css (issue #1211). */

/* ====== LINK STYLES ====== */

a {
    color: var(--color-coral-base);
    text-decoration: none;
    transition: color var(--ss-transition-fast);
}

a:hover {
    color: var(--ss-brand-red);
    text-decoration: underline;
}

/* ====== DECORATIVE ELEMENTS ====== */

.ss-dot-accent::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    background-color: var(--color-coral-base);
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Coral dot divider - default */
.ss-dot-divider {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' viewBox='0 0 3 3' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='.375' cy='.375' r='.375' fill='%23FD515B' fill-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    height: 3px;
    width: 70px;
    margin: 1rem 0;
}

/* White dot divider - for use on colored backgrounds */
.ss-dot-divider-white {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='12' height='12' viewBox='0 0 3 3' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='.375' cy='.375' r='.375' fill='%23fff' fill-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    height: 3px;
    width: 70px;
    margin: 1.5rem auto;
}

/* Content centering utility */
.content--center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ====== FOOTER BRANDING ====== */

.footer-slide {
    position: fixed;
    bottom: -100px; /* Start hidden below viewport */
    left: 0;
    right: 0;
    background-color: var(--ss-dark);
    border-top: 3px solid var(--color-coral-base);
    transition: bottom 0.3s ease-in-out;
    z-index: 1030;
}

.footer-slide.visible {
    bottom: 0;
}

/* The footer stays position:fixed at all times. It never switches to an inline
 * (position:static) mode, because changing the document height caused the
 * bottom-scroll thrash in issue #1344. Window-scrolled pages reserve a constant
 * strip of padding (set in footer.js) so the fixed footer never overlays
 * content at the bottom. */

.footer-slide a {
    color: var(--color-neutral-white);
    font-family: var(--ss-font-primary);
    font-size: 0.9rem;
    transition: color var(--ss-transition-fast);
}

.footer-slide a:hover {
    color: var(--color-coral-base);
    text-decoration: none;
}

/* Cookie notice styling */
.cookie-notice {
    display: inline-block;
    color: var(--color-neutral-white);
    font-size: 1.1rem;
    transition: transform var(--ss-transition-fast);
    vertical-align: middle;
}

.cookie-notice:hover {
    transform: scale(1.2);
}

/* ====== MODAL BRANDING ====== */

/* Modal branding moved to components.css §8 (issue #1211). */

/* ====== NAVBAR TEXT ====== */

.navbar-text {
    color: var(--color-neutral-white) !important;
    font-family: var(--ss-font-primary);
}

/* User authentication section styling */
.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-section .navbar-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ====== TOAST NOTIFICATIONS ====== */

/* Toast skin moved to components.css §9 (issue #1211). */

/* ====== UTILITY CLASSES ====== */

/* Accent color utilities */
.text-brand-primary {
    color: var(--color-coral-base);
}

.text-brand-red {
    color: var(--ss-brand-red);
}

.bg-brand-primary {
    background-color: var(--color-coral-base);
}

.border-brand-primary {
    border-color: var(--color-coral-base);
}

/* Professional spacing */
.ss-section-spacing {
    padding-top: var(--ss-space-lg);
    padding-bottom: var(--ss-space-lg);
}

/* Hover effects with brand colors */
.grid-item-content:hover {
    border-color: var(--color-coral-base);
    box-shadow: 0 2px 8px rgba(var(--color-coral-base-rgb), 0.15);
}

/* Bootstrap utility classes */
.text-center {
    text-align: center !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-5 {
    margin-bottom: 3rem !important;
}

/* ====== NAVBAR THEME OVERRIDES ====== */

.navbar-theme-primary,
.navbar-theme-secondary {
    background-color: var(--ss-dark) !important;
}

/* Ensure white text in dark navbar */
.navbar-dark .navbar-text,
.navbar-dark .navbar-nav .nav-link {
    color: var(--color-neutral-white);
}

/* Clean, professional transitions */
* {
    transition-timing-function: ease;
}

/* ====== HEADER TEXT STYLING ====== */

/* Shared header text styling - used by both LexRay text and Sign In/Logout */
.header-text {
    text-decoration: none !important;
    border-bottom: none !important;  /* S&S uses border-bottom for underlines, not text-decoration */
    color: #ffffff !important;
    white-space: nowrap;
    gap: 8px;
    display: inline-flex;
    align-items: center;
}

.header-text:hover {
    text-decoration: none !important;
    border-bottom: none !important;
    color: #ffffff !important;
}

.header-text svg {
    fill: #ffffff;
}

.header-text-label {
    color: #ffffff !important;
}

/* #2093's header pricing link had a phone guard here — hidden below 576px,
   because the bar is a fixed 80px with no overflow rule and the S&S logo alone
   takes 112px of a 360px viewport, so the end of that flex row is what gives
   way. #2282 removed the link itself (the row's padding and border are
   Vue-scoped and never reached it, so it sat jammed against the viewport edge
   at EVERY width, not only a phone's), which took the guard with it. The
   persistent route is the footer link, on every page in both shells. */

/* Logo container - flex to put logo and LexRay text adjacent */
.header-logo-container {
    display: flex;
    align-items: center;
    gap: 0; /* No gap, let padding control spacing */
}

/* LexRay text container - hidden by default, shown on specific pages */
.header-lexray-text {
    display: none;
    padding-left: 12px; /* Control spacing between logo and text */
    flex-shrink: 0; /* Don't allow shrinking which would squash logo */
}

/* Show header text on legislation pages.
   Content-sized (not a fixed px width): a hard width clipped/crowded the "Lex-Ray"
   wordmark and the adjacent env (TEST) badge whenever the rendered text ran wider
   than the assumed metric — a different font, fallback face, zoom or density (#1348). */
body.show-lexray-text .header-lexray-text {
    display: block;
    width: auto;
}

/* Show header text on admin and STRIDE pages, and on any page that declared
   its own (`header_text`, which header.html marks `--declared`). A declared
   wordmark is the page's link home; hiding it leaves no way back to `/` (#2630).
   The landing page's scroll-in reveal is the one exception, and it collapses
   the text itself (homepage-coral.css, `brand-morph`). */
body.admin-page .header-lexray-text,
body.stride-page .header-lexray-text,
.header-lexray-text.header-lexray-text--declared {
    display: block;
    width: auto; /* Allow flexible width for different text variants */
}

/* ====== COMMON LAYOUT ====== */

/* Old .main-content - replaced by .content-area in flex layout */
/* .main-content {
    position: relative;
    width: 100%;
} */

/* ====== DOCUMENTATION STYLES ====== */

/* Style for URL bar examples in documentation */
.url-bar-example {
    display: block;
    width: 100%;
    background-color: #f0f0f0;
    border: 2px solid #0d6efd;
    padding: 0.5em 0.75em;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9em;
    word-break: break-all;
    text-align: left;
    color: #000000;
    margin-top: 0.25em;
    margin-bottom: 0.25em;
}

.url-bar-example .url-protocol {
    color: #6c757d;
}

.url-bar-example .url-highlight {
    background-color: yellow;
    padding: 0.1em 0;
    margin: 0 0.05em;
    border-radius: 2px;
}

/* Style for inline code snippets */
.code-inline {
    font-family: monospace;
    font-size: 0.9em;
    background-color: #f8f9fa;
    padding: 0.1em 0.3em;
    border: 1px solid #dee2e6;
    border-radius: 3px;
}

/* ========================================
   LEGISLATION PAGE LAYOUT CENTERING
   ======================================== */

/* Old layout system - TOC sidebar positioning */
/* DISABLED - conflicts with new flexbox layout in .legislation-layout */
/* body.show-lexray-text #toc-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--toc-width);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #f8f9fa;
    z-index: 1046;
    padding: 0.5rem;
} */

/* Old layout - adjust main-content to account for fixed TOC */
/* Only apply to old layout (without .legislation-layout parent) */
body.show-lexray-text #app-container > .container-fluid > #main-content {
    margin-left: var(--toc-width);  /* 66px - space for fixed TOC */
    width: calc(100vw - var(--toc-width));  /* Fill remaining width */
}

/* Center main content at XL breakpoint (≥1200px) - TOC stays left-pinned */
@media (min-width: 1200px) {
    /* Old layout (app-container with Bootstrap grid) */
    /* Center the body-content in the remaining space after TOC */
    body.show-lexray-text #body-content {
        max-width: 1320px;  /* Match Bootstrap container max-width */
        /* Calculate centering: (100vw - toc - max-width) / 2 + toc */
        margin-left: calc((100vw - var(--toc-width) - 1320px) / 2 + var(--toc-width));
        margin-right: calc((100vw - var(--toc-width) - 1320px) / 2);
        /* Equal padding on both sides for visual balance */
        padding-left: var(--viewport-margin);  /* 20px left */
        padding-right: var(--viewport-margin);  /* 20px right */
        /* Ensure proper box-sizing */
        box-sizing: border-box;
    }

    /* New flexbox layout - center content-area in remaining space */
    body.show-lexray-text .legislation-layout .content-area {
        margin-left: auto;
        margin-right: auto;
    }
}

/* ========================================
   HEADER USER MENU
   Role-based visibility using body classes set by auth-manager.js
   Unified hamburger menu with greeting for logged-in users
   ======================================== */

/* User menu container - contains greeting and hamburger dropdown */
.header-user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Greeting text - "Hi, {name}" - matches .header-text-label styling */
.header-greeting {
    color: #ffffff !important;
    font-family: var(--ss-font-primary);
    font-size: 1.25rem;
    font-weight: 300;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-user-name {
    font-weight: 500;
}

/* Hamburger button styling */
.header-hamburger-btn {
    color: #ffffff;
    cursor: pointer;
    padding: 0;
    transition: color var(--ss-transition-fast);
}

.header-hamburger-btn:hover,
.header-hamburger-btn:focus {
    color: rgba(255, 255, 255, 0.8);
}

/* Hide the default dropdown caret on hamburger */
.header-hamburger-btn::after {
    display: none;
}

/* User menu dropdown styling */
.header-user-menu .dropdown {
    position: relative;
    z-index: 9999;
}

.header-user-menu .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--ss-dark);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 0.5rem;
    z-index: 9999;
}

.header-user-menu .dropdown-item {
    color: rgba(255, 255, 255, 0.9);
    font-family: var(--ss-font-primary);
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    transition: all var(--ss-transition-fast);
}

.header-user-menu .dropdown-item:hover,
.header-user-menu .dropdown-item:focus {
    background-color: var(--color-coral-base);
    color: #ffffff;
}

.header-user-menu .dropdown-item i {
    width: 1rem;
    text-align: center;
}

.header-user-menu .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.15);
    margin: 0.25rem 0;
}

/* Role-based menu item visibility - hidden by default */
.nav-admin-only,
.nav-stride-viewer,
.nav-stride-editor,
.nav-stride-approver,
.nav-stride-task-admin,
.nav-stride-owner,
.nav-stride-stewardship-admin,
.nav-lexray-owner,
.nav-product-owner,
.nav-simmons {
    display: none;
}

/* Firm staff (#2596): staff-only items such as /share. */
body.user-is-simmons .nav-simmons {
    display: list-item !important;
}

/* Show admin items for admin users */
body.user-is-admin .nav-admin-only {
    display: list-item !important;
}

/* Show product-owner items for global admins and product admins */
body.user-is-product-owner .nav-product-owner {
    display: list-item !important;
}

body.user-is-stride-owner .nav-stride-owner {
    display: list-item !important;
}

body.user-is-admin .nav-stride-stewardship-admin,
body.user-is-stride-owner .nav-stride-stewardship-admin,
body.user-can-manage-stride-tasks .nav-stride-stewardship-admin {
    display: list-item !important;
}

body.user-is-admin .nav-stride-task-admin,
body.user-can-manage-stride-tasks .nav-stride-task-admin {
    display: list-item !important;
}

body.user-is-lexray-owner .nav-lexray-owner {
    display: list-item !important;
}

/* Show STRIDE items based on access level */
body.user-is-stride-viewer .nav-stride-viewer {
    display: list-item !important;
}

body.user-is-stride-editor .nav-stride-editor {
    display: list-item !important;
}

body.user-is-stride-approver .nav-stride-approver {
    display: list-item !important;
}

/* A link the service worker's shell ships hidden until the live session opens it
   (#4650, `viewer_gate` in header.html). `hidden` wins over the role rules above,
   which show their items with !important; specificity keeps it ahead of them. */
html body [data-viewer-gate][hidden] {
    display: none !important;
}

/* The account holder's footer links on the service worker's shell (#4650):
   rendered for no viewer, shown for a signed-in non-staff viewer from the role
   classes. A server-rendered page leaves them out for anyone else instead. */
.account-holder-only {
    display: none;
}

body.user-is-authenticated:not(.user-is-simmons) .account-holder-only {
    display: inline;
}

/* ---- Menu groups (#2594) ------------------------------------------------
   The admin tools sit under group headings (`nav_group` in header.html). A
   heading has no role of its own: it shows while at least one of its items
   does. So every item rule above has a twin here, naming the same body class,
   for `.nav-group` and for `.nav-groups` — the block holding them all, whose
   top border is the admin divider. A new role class needs its twin too;
   tests/test_header_nav_groups.py fails until it has one.

   The hiding default is behind @supports. A browser without :has() cannot run
   the rules that show a group, so there every group stays shown: an empty
   heading for some roles, rather than no admin menu at all. */
@supports selector(:has(*)) {
    .nav-groups,
    .nav-group {
        display: none;
    }
}

body.user-is-admin :is(.nav-groups, .nav-group):has(.nav-admin-only),
body.user-is-product-owner :is(.nav-groups, .nav-group):has(.nav-product-owner),
body.user-is-stride-owner :is(.nav-groups, .nav-group):has(.nav-stride-owner),
body.user-is-admin :is(.nav-groups, .nav-group):has(.nav-stride-stewardship-admin),
body.user-is-stride-owner :is(.nav-groups, .nav-group):has(.nav-stride-stewardship-admin),
body.user-can-manage-stride-tasks :is(.nav-groups, .nav-group):has(.nav-stride-stewardship-admin),
body.user-is-admin :is(.nav-groups, .nav-group):has(.nav-stride-task-admin),
body.user-can-manage-stride-tasks :is(.nav-groups, .nav-group):has(.nav-stride-task-admin),
body.user-is-lexray-owner :is(.nav-groups, .nav-group):has(.nav-lexray-owner),
body.user-is-stride-viewer :is(.nav-groups, .nav-group):has(.nav-stride-viewer),
body.user-is-stride-editor :is(.nav-groups, .nav-group):has(.nav-stride-editor),
body.user-is-stride-approver :is(.nav-groups, .nav-group):has(.nav-stride-approver),
body.user-is-simmons :is(.nav-groups, .nav-group):has(.nav-simmons) {
    display: block;
}

.header-user-menu .nav-groups {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 0.25rem;
}

.header-user-menu .nav-groups__list,
.header-user-menu .nav-group__items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-user-menu .nav-group {
    break-inside: avoid;
}

.header-user-menu .dropdown-header {
    color: rgba(255, 255, 255, 0.55);
    font-family: var(--ss-font-primary);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.75rem 1rem 0.25rem;
}

/* Never taller than the screen, whoever is looking. */
.header-user-menu .header-user-dropdown {
    max-height: calc(100vh - 5rem);
    max-height: calc(100dvh - 5rem);
    overflow-y: auto;
}

/* The global admin is the one viewer who sees every group, so for them the
   groups sit side by side: as many 14rem columns as the menu is wide (three on
   a laptop, one on a phone), and any tool is still one click away. Every other
   role keeps the single column it had. */
body.user-is-admin .header-user-menu .header-user-dropdown {
    width: min(46rem, calc(100vw - 2rem));
}

body.user-is-admin .header-user-menu .nav-groups__list {
    columns: 14rem;
    column-gap: 0;
}

body.user-is-admin .header-user-menu .header-user-dropdown .dropdown-item {
    padding-block: 0.375rem;
}

/* Secondary Menu Layout - S&S uses Vue scoped selectors, so we need to override */
.secondaryMenu__innerWrapper {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
}
