/* ================================================================
   CELEX.CSS - Legislation Page Styles

   Comprehensive styles for legislation pages including layout,
   TOC sidebar, content cards, floodlight panel, and responsive behavior.

   Dependencies (loaded via <link> tags in template <head>):
   - ss-main.css (Simmons & Simmons design system)
   - base.css (LexRay branding layer)
   - Bootstrap CSS (framework styles)
   - celex_ui.css (UI overlays: search, filter, navigate)
   - Bootstrap Icons (icon font)

   Note: CSS @import is not used - all stylesheets loaded directly
   via <link> tags for better performance and caching.
   ================================================================ */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
    /* Layout dimensions - --header-height inherited from base.css (80px) */
    --sticky-offset: 2vh;           /* Vertical offset for sticky elements when scrolled */

    /* Where a scroll jump parks its target: clear of the sticky omni bar, plus
       4px so the anchored element is not flush against it. Declared once and
       used by BOTH things a jump can anchor -- the card and the run of
       structural headings above it (celex_scroll_target.js walks back over
       those, so a heading is a scroll target in its own right). Two copies of
       the calc would drift, and the drift is invisible: the heading would land
       a few pixels under the bar while the card still cleared it. */
    --scroll-anchor-offset: calc(var(--sticky-offset, 2vh) + 4px);
    --sidebar-hover-delay: 1s;      /* Delay before sidebar expands */
    --toc-button-width: 50px;       /* Width of TOC buttons */

    /* Omni search bar dimensions */
    --omni-bar-height: 51px;          /* Inner height of the search input bar */
    --omni-panel-chrome: 10px;        /* Panel padding (4+4) + border (1+1) around the bar */
    --omni-panel-gap: 6px;            /* Breathing room between panel bottom and content */
    --omni-results-max-height: 300px; /* Max height of the preview results panel */

    /* Breadcrumb color system */
    --breadcrumb-chapter: #1e3a8a;      /* Deep blue */
    --breadcrumb-title: #1e40af;        /* Royal blue */
    --breadcrumb-part: #2563eb;         /* Bright blue */
    --breadcrumb-section: #3b82f6;      /* Sky blue */
    --breadcrumb-article: #60a5fa;      /* Light blue */
    --breadcrumb-recital: #93c5fd;      /* Very light blue */
    --breadcrumb-annex: #7c3aed;        /* Purple */
    --breadcrumb-paragraph: #a5b4fc;    /* Light purple */
    --breadcrumb-default: #6b7280;      /* Gray */

    /* Obligation badge palette (#980). Defined as variables so the chips are
       theme-aware: the dark-mode block below remaps them rather than the
       per-class rules hardcoding light-mode hex. */
    --ob-duty-bg: #e7f1ff;       --ob-duty-fg: #0a58ca;       --ob-duty-border: #b6d4fe;
    --ob-bearer-bg: #e2e3e5;     --ob-bearer-fg: #41464b;     --ob-bearer-border: #c4c8cb;
    --ob-deadline-bg: #fff3cd;   --ob-deadline-fg: #664d03;   --ob-deadline-border: #ffe69c;
    --ob-trigger-bg: #cff4fc;    --ob-trigger-fg: #055160;    --ob-trigger-border: #9eeaf9;
    --ob-exception-bg: #f8d7da;  --ob-exception-fg: #842029;  --ob-exception-border: #f1aeb5;
    --ob-ref-bg: #d1e7dd;        --ob-ref-fg: #0f5132;        --ob-ref-border: #a3cfbb;
    --ob-penalty-bg: #e2d9f3;    --ob-penalty-fg: #432874;    --ob-penalty-border: #c5b3e6;
    --ob-unknown-bg: #fde2c8;    --ob-unknown-fg: #7a3d00;    --ob-unknown-border: #f7c08a;
}

/* Dark-mode remap of the obligation badge palette. Supports both the OS
   preference and Bootstrap 5.3's explicit ``[data-bs-theme="dark"]`` toggle,
   matching the only theming mechanism this project ships (vendored Bootstrap). */
@media (prefers-color-scheme: dark) {
    :root {
        --ob-duty-bg: #0a2540;       --ob-duty-fg: #9ec5fe;       --ob-duty-border: #1c4587;
        --ob-bearer-bg: #2b2f33;     --ob-bearer-fg: #ced4da;     --ob-bearer-border: #495057;
        --ob-deadline-bg: #3a2f05;   --ob-deadline-fg: #ffe187;   --ob-deadline-border: #665200;
        --ob-trigger-bg: #052c33;    --ob-trigger-fg: #6edff6;    --ob-trigger-border: #07505d;
        --ob-exception-bg: #3a1418;  --ob-exception-fg: #ea868f;  --ob-exception-border: #6c2730;
        --ob-ref-bg: #0a2d22;        --ob-ref-fg: #75b798;        --ob-ref-border: #14543c;
        --ob-penalty-bg: #261a40;    --ob-penalty-fg: #c5a8ff;    --ob-penalty-border: #44307a;
        --ob-unknown-bg: #3a2405;    --ob-unknown-fg: #f7c08a;    --ob-unknown-border: #694200;
    }
}

[data-bs-theme='dark'] {
    --ob-duty-bg: #0a2540;       --ob-duty-fg: #9ec5fe;       --ob-duty-border: #1c4587;
    --ob-bearer-bg: #2b2f33;     --ob-bearer-fg: #ced4da;     --ob-bearer-border: #495057;
    --ob-deadline-bg: #3a2f05;   --ob-deadline-fg: #ffe187;   --ob-deadline-border: #665200;
    --ob-trigger-bg: #052c33;    --ob-trigger-fg: #6edff6;    --ob-trigger-border: #07505d;
    --ob-exception-bg: #3a1418;  --ob-exception-fg: #ea868f;  --ob-exception-border: #6c2730;
    --ob-ref-bg: #0a2d22;        --ob-ref-fg: #75b798;        --ob-ref-border: #14543c;
    --ob-penalty-bg: #261a40;    --ob-penalty-fg: #c5a8ff;    --ob-penalty-border: #44307a;
    --ob-unknown-bg: #3a2405;    --ob-unknown-fg: #f7c08a;    --ob-unknown-border: #694200;
}

/* ========================================
   GLOBAL STYLES
   ======================================== */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* ========================================
   LAYOUT - FLEXBOX TOC + CONTENT
   ======================================== */

/* Main layout container - flexbox positions TOC and content side-by-side */
body.show-lexray-text .legislation-layout {
    display: flex;
    gap: var(--viewport-margin);           /* 20px gap between TOC and content */
    padding-left: 0;                       /* TOC touches left edge */
    padding-right: var(--viewport-margin); /* 20px right margin */
    padding-top: var(--header-height);     /* 80px space for fixed header */
    align-items: flex-start;               /* Align items to top */
}

/* TOC Sidebar - positioned by flex, uses sticky for scroll behavior */
body.show-lexray-text .legislation-layout .toc-sidebar {
    /* Sticky positioning - background extends to viewport top */
    position: sticky;
    top: 0;  /* Background goes to viewport top when sticky */

    /* Size */
    width: var(--toc-width);  /* 66px */
    height: 100vh;  /* Full viewport height */
    max-height: 100vh;

    /* Flex behavior */
    flex-shrink: 0;  /* Don't shrink when content is wide */

    /* Visual */
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;

    /* Overflow - allow scrolling but never show a scrollbar (looks awful in a 66px rail) */
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* legacy Edge/IE */

    /* Layering */
    z-index: 1046;  /* Above veil (1045), below header (1050) */

    /* Spacing */
    padding-top: 2vh;  /* Buttons float at 2vh from top (hardcoded; immune to --sticky-offset changes) */
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Never show a scrollbar on the TOC rail — scrolling still works (unscoped so it
   applies in the SPA loader path too, where nesting under .legislation-layout differs) */
.toc-sidebar {
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* legacy Edge/IE */
}
.toc-sidebar::-webkit-scrollbar {  /* Chrome/Safari (WebKit/Blink) */
    display: none;
    width: 0;
    height: 0;
}

/* Content Area - takes remaining space after TOC */
body.show-lexray-text .legislation-layout .content-area {
    /* Flexbox sizing */
    flex: 1 1 auto;  /* Grow, shrink, auto basis */
    min-width: 0;  /* Prevent flex overflow */
    max-width: 100%;  /* Don't exceed container */

    /* Position context for veil */
    position: relative;
}

/* Center content at wide widths using padding instead of margins */
/* This allows flex gap to work naturally while still centering the visible content */
@media (min-width: 1500px) {
    body.show-lexray-text .legislation-layout .content-area {
        /* Calculate equal left/right padding to center content */
        /* Formula: (viewport - toc - gap - content-max - right-margin) / 2 */
        /* viewport = 100vw, toc = 66px, gap = 20px, content-max = 1320px, right-margin = 20px */
        /* Simplified: (100vw - 66px - 20px - 1320px - 20px) / 2 = (100vw - 1426px) / 2 */
        padding-left: max(0px, calc((100vw - var(--toc-width) - var(--viewport-margin) - var(--content-max-width) - var(--viewport-margin)) / 2));
        padding-right: max(0px, calc((100vw - var(--toc-width) - var(--viewport-margin) - var(--content-max-width) - var(--viewport-margin)) / 2));
    }
}

/* Veil - prevents content from showing above float point when scrolling */
body.show-lexray-text .legislation-layout .content-area::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--sticky-offset);
    background-color: var(--background-color);
    z-index: 1045;  /* Above content, below sidebar (1046) */
    pointer-events: none;
}

/* Header alignment - handled in base.css via .header-content override */

/* ========================================
   TOC SIDEBAR - BUTTONS & NAVIGATION
   ======================================== */

/* Grid layout for TOC buttons */
.toc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin: 0;
    padding-top: 0;
}

/* Base button styles */
.toc-sidebar .toc-btn {
    display: block;
    width: var(--toc-button-width);
    text-align: center;
    padding: 0.25rem 0.1rem;
    margin: 0.2rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 3px;
    font-weight: bold;
    background-color: #ffd4d6; /* Subtle salmon base color */
    border: 1px solid #ffb8bb;
    color: #333;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* All button types use the same subtle salmon base */
.recital-btn,
.definition-btn,
.home-btn,
.chapter-color-1,
.chapter-color-2,
.chapter-color-3,
.chapter-color-4,
.chapter-color-5 {
    background-color: #ffd4d6;
    border: 1px solid #ffb8bb;
}

/* Hover state - brighter salmon */
.toc-btn:hover {
    background-color: #ffb8bb;
    border-color: #ff9ca0;
}

/* Active state - currently focused card */
.toc-btn.active {
    background-color: #ff9ca0 !important;
    border-color: #ff7f85 !important;
    font-weight: bold;
}

/* Ratio toggle in the toc-grid — the slot that used to be the '⚡' home link.
   Deliberately the SAME salmon family as its sibling toc buttons (it inherits
   the .toc-btn base styles; the drawn ∴ mark is the differentiator). Legacy
   stored toc_html still carries .home-btn (kept styled above) until
   celex_logic_view.js upgrades it in place / the artifact is re-materialised.
   Pressed state mirrors .toc-btn.active — mostly moot while the overlay
   covers the sidebar, but keeps the state visible during the armed window. */
.toc-btn.toc-logic-btn[aria-pressed='true'] {
    background-color: #ff9ca0;
    border-color: #ff7f85;
}

/* Ratio is QUIET until it is sold (docs/formal-logic/states.md, "Going
   quiet"): hidden by default, shown only once celex_logic_view.js has read
   the viewer's normative-display capability and marked it .is-offered. The
   default has to be hidden rather than JS-removed because the button is baked
   into every STORED toc_html and the loader skeleton — a JS removal would
   flash it on every act for every visitor. !important beats the
   .toc-sidebar .toc-btn display:block. */
.toc-btn.toc-logic-btn:not(.is-offered) {
    display: none !important;
}

/* Chapter border colors (unified with salmon) */
.chapter-border-1,
.chapter-border-2,
.chapter-border-3,
.chapter-border-4,
.chapter-border-5 {
    border: 1px solid #ffb8bb;
}

/* TOC links */
.toc-link {
    text-decoration: none;
    color: inherit;
}

.toc-link:hover {
    text-decoration: none;
}

/* ========================================
   CONTENT STYLES - CARDS & ARTICLES
   ======================================== */

.icon-box {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.icon-box > * {
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

.gutter {
    background-color: #eee;
    background-repeat: no-repeat;
    background-position: 50%;
}

.gutter.gutter-horizontal {
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
    cursor: col-resize;
}

@media (min-width: 1200px) {
  h2, .h2 {
    font-size: 2rem;
  }
}

.popover-header, .popover-body {
    font-size: 0.8rem;
    color: #333;
}

.popover {
    max-width: min(32rem, calc(100vw - 1.5rem));
}

/* .celex-definition-popover skin moved to components.css (app-wide, shared
   with the FCA glossary). See docs/design_system.md §Popovers. */

@media (max-width: 768px) {
    .popover {
        max-width: calc(100vw - 1rem);
    }
}

.celex-card-sub-header {
    padding: .75rem 1.25rem;
    background-color: #f8f9fa;
}

.celex-card-sub-header-container > .celex-card-sub-header:not(:last-child) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.internal-link {
    color: var(--lx-brand);
    text-decoration: none;
}

.internal-link.toc-link {
    color: #000000;
    text-decoration: none;
}

/* A citation of a provision an unapplied effect inserts (#3726): neither the
   publisher's text nor ours holds it, so it is no link. Dotted and muted, never
   the brand colour a live reference wears; the note is its tooltip, and the icon
   beside it opens the inserting provision on legislation.gov.uk. */
.xref-unapplied {
    color: var(--lx-text-muted);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.15em;
}

.xref-unapplied-source {
    color: var(--lx-text-muted);
    margin-left: 0.15em;
    font-size: 0.8em;
    text-decoration: none;
}

.xref-unapplied-source:hover,
.xref-unapplied-source:focus-visible {
    color: var(--lx-brand);
}

/* Defined-term provenance on FCA content (#1770).

   `data-term-source="fca"` is the regulator's own identification, carried
   through from its `autodeftext` markup, and renders exactly like every other
   defined term — the FCA saying a word is a defined term is the ordinary case.
   `lexray` is OUR inference on a document that also carries the regulator's,
   and it has to look different, because presenting our own identification as
   the FCA's attaches a statutory meaning the regulator did not attach and
   misattributes it under the OGL's attribution obligation (#1663).

   Dotted rather than merely paler, and labelled in the popover as well —
   colour alone cannot carry a distinction (greyscale print and colour blindness
   both erase it), which is the rule #1796's provision-type badge already
   follows. Neither value appears on EU or UK content, where there is no
   official markup for ours to be mistaken for. */
.internal-link.definition[data-term-source='lexray'] {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.15em;
}

.celex-definition-popover .lx-term-provenance {
    display: block;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--lx-border, rgba(0, 0, 0, 0.125));
    font-size: 0.8125rem;
    font-style: italic;
    opacity: 0.85;
}

/* A qualified UK declaration's qualifier (#2168), stated ahead of the
   meaning wherever it renders — popover, Definitions panel, card. */
.lx-term-qualifier {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-style: italic;
    opacity: 0.85;
}

/* A pointer definition shows the provision it points to (#3092): "Meaning
   given in section 103(1)" linked to it, the provision quoted in full with the
   term marked, then the declaration as written. Popover, Definitions panel and
   floodlight card share the markup (pointer_quotes.py / celex_floodlight.js). */
.lx-pointer-heading {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.lx-pointer-quote {
    border-left: 3px solid var(--lx-border-strong, rgba(0, 0, 0, 0.25));
    padding-left: 0.625rem;
    margin-bottom: 0.375rem;
}

.lx-pointer-limb + .lx-pointer-limb {
    margin-top: 0.25rem;
}

.lx-pointer-depth-1 { padding-left: 1rem; }
.lx-pointer-depth-2 { padding-left: 2rem; }
.lx-pointer-depth-3 { padding-left: 3rem; }
.lx-pointer-depth-4 { padding-left: 4rem; }

.lx-pointer-term {
    background: var(--lx-warning-bg);
    border-radius: var(--lx-radius-xs);
    padding: 0 0.125rem;
}

.lx-pointer-note,
.lx-pointer-declared {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-style: italic;
    opacity: 0.85;
}

/* Seam between two defined terms that touch (issue #1905).

   Definition links carry colour and nothing else, so two defined terms with
   only a space between them read as one term — GDPR Art 18(1)'s "obtain from
   the controller restriction of processing" is two. At 1.09% of definition
   links the problem does not justify restyling the other 77,302, so ordinary
   definitions are untouched and only the seam is marked.

   The interpunct is the original mark for exactly this job (Latin inscriptions
   separated words with it before the space existed), so it carries no modern
   punctuation reading that could be confused with the statute's own — unlike
   `/`, which in legislation means and/or.

   It is GENERATED CONTENT, deliberately: with no element it is absent from
   `marked_up_text`, from the clipboard and from the selection, and it needs no
   popover of its own. What the mark means is disclosed by the definition
   popover instead (celex_popover_delegate.js), because a hoverable glyph a
   couple of pixels wide is worse than no explanation at all.

   It is NOT hidden from assistive tech, though — browsers do expose a `content`
   string to the accessibility tree. Suppressing it wants the alt-text syntax
   (`content: '·' / ''`), and a browser that does not support that drops the
   WHOLE declaration and renders no mark at all, which is the worse failure of
   the two. So the glyph is announced, and the seam note the popover carries is
   what explains it.

   The mark renders INSIDE the second anchor, so the word space separating the
   two terms falls entirely on its left; the right-hand gap has to be supplied
   here or the glyph clamps onto the term it precedes.

   Known limitation: at a line break the mark travels to the next line and
   opens it. CSS cannot express "drop this at a break", and by then the
   ambiguity has already gone — two terms on two lines cannot be misread as
   one. */
.internal-link.definition.def-seam-joined::before {
    content: '·';
    color: var(--lx-brand);
    font-weight: 700;
    margin-right: 0.26em;
}

.resources-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.resources-label {
    min-width: 120px;
    white-space: nowrap;
    margin: 0;
}

.resources-content {
    flex: 1;
    margin: 0;
}

.related-link-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.related-link-label {
    min-width: 120px;
    white-space: nowrap;
    font-style: italic;
}

.related-link-content {
    flex: 1;
}

.related_link {
    display: inline-block;
    margin: 0 2px;
}

.fixed-link-item {
    display: block;
    padding: 0.15rem 0;
}

/* Card Header Button Styles */
.card-header-btn {
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    color: #6c757d;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
    line-height: 1;
    text-decoration: none;
}

.card-header-btn:hover,
.card-header-btn:focus {
    background-color: rgba(0, 0, 0, 0.05);
    color: #343a40;
    text-decoration: none;
    outline: 0;
}

.card-header-btn:active {
    background-color: rgba(0, 0, 0, 0.075);
    color: #000;
}

.card-header-btn i {
    font-size: 1rem;
    vertical-align: middle;
}

/* An FCA provision whose wording never changed (#3850): its History clock still
   opens the dates, it just does not ask to be opened. */
.card-header-btn.fhr-trigger-unchanged {
    opacity: 0.4;
}

.card-header-btn.fhr-trigger-unchanged:hover,
.card-header-btn.fhr-trigger-unchanged:focus-visible,
.card-header-btn.fhr-trigger-unchanged[aria-expanded="true"] {
    opacity: 1;
}

.card-header-btn.btn-success,
.card-header-btn.btn-success:hover,
.card-header-btn.btn-success:focus {
    background-color: transparent;
    color: #198754 !important;
    border-color: transparent;
}

.celex-card {
    scroll-margin-top: var(--scroll-anchor-offset);
    margin-bottom: var(--card-gap, 1rem);
    border-top: none;
    contain: layout; /* Create a containing block for sticky positioning */
    /* Off-screen cards skip style/layout/paint entirely (#1460, same trick as
       the logic view's .lp-unit): a whole-document invalidation — the omni
       expand's content-area padding shove (measured ~900ms of its ~1s open on
       GDPR), the 96-article background append, filter class flips — costs a
       screenful instead of the whole act. `auto` intrinsic size remembers each
       card's real height once rendered, keeping the scrollbar stable.

       A card not yet rendered is estimated from its own content (#3531): its
       text length and the blocks it is set in, stamped on the card by the
       server (apps/utils/body_shape.py) or, for a card stored before that, by
       celex_card_estimate.js before it is inserted. Only --px-per-char depends
       on the column width; the reader fits it from the preview cards and
       writes it on #legislation. The fallbacks here are the measured values at
       a desktop column, so a card outside the reader, or a page before its
       scripts run (SSR), still gets a reasonable size. scrollToLink re-anchors
       once after each jump in case estimates are corrected under it. */
    content-visibility: auto;
    contain-intrinsic-size: auto calc(
        var(--card-overhead, 23px)
        + var(--card-chars, 1200) * var(--px-per-char, 0.23px)
        + var(--card-blocks, 8) * var(--px-per-block, 34px)
    );
}

/* The estimate's width-dependent terms until the reader fits them from the
   cards on screen (#3531, celex_card_estimate.js writes them inline): a
   desktop column, a narrower one, a phone's. Mostly for the server-rendered
   page, whose cards are laid out before any script runs. */
#legislation {
    --px-per-char: 0.23px;
    --heading-est: 44px;
}

@media (max-width: 1199px) {
    #legislation {
        --px-per-char: 0.32px;
        --heading-est: 48px;
    }
}

@media (max-width: 991px) {
    #legislation {
        --px-per-char: 0.49px;
        --heading-est: 56px;
    }
}

/* The server-rendered page (#3531): the browser lays the body out as it parses
   it, so the column states its whole shape up front and is held at that height
   until the page has parsed (celex_card_estimate.js then adds .body-settled). */
#legislation.has-body-shape:not(.body-settled) {
    min-height: calc(
        var(--reserve-cards, 0) * (var(--card-overhead, 23px) + 1px + var(--card-gap, 1rem))
        + var(--reserve-chars, 0) * var(--px-per-char, 0.23px)
        + var(--reserve-blocks, 0) * var(--px-per-block, 34px)
        + var(--reserve-headings, 0) * var(--heading-est, 44px)
    );
}

/* The rest of the act's height before the rest of the act (#3531). The preview
   ends with one reserve element sized by the cards' own formula over the totals
   of everything after it; the body is inserted above it and it shrinks by what
   was inserted, so the page is its full height from the first frame and stays
   that height. Never a scroll anchor: a reader scrolled into it must not be
   pushed as it shrinks. Static bars at its top in the card rhythm, never an
   animation on an element a million pixels tall. */
.legislation-reserve {
    display: block;
    overflow-anchor: none;
    contain: strict;
    height: calc(
        var(--reserve-cards, 0) * (var(--card-overhead, 23px) + 1px + var(--card-gap, 1rem))
        + var(--reserve-chars, 0) * var(--px-per-char, 0.23px)
        + var(--reserve-blocks, 0) * var(--px-per-block, 34px)
        + var(--reserve-headings, 0) * var(--heading-est, 44px)
    );
    background-image:
        linear-gradient(var(--lx-surface-inset, #e9ecef) 0 0),
        linear-gradient(var(--lx-surface-inset, #e9ecef) 0 0),
        linear-gradient(var(--lx-surface-inset, #e9ecef) 0 0),
        linear-gradient(var(--lx-surface-inset, #e9ecef) 0 0);
    background-size: 40% 24px, 92% 14px, 88% 14px, 64% 14px;
    background-position: 1rem 1rem, 1rem 3.5rem, 1rem 5rem, 1rem 6.5rem;
    background-repeat: no-repeat;
}

.celex-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: var(--sticky-offset);
    z-index: 999;
    background-color: #fff;
    border-top: 1px solid #dee2e6;
}

.celex-card .card-header h4,
.celex-card .card-header .h4 {
    margin-right: 1rem;
    margin-bottom: 0;
}

/* An act that names one meaning twice -- "'disabled person' OR 'person with
   reduced mobility' means ..." -- puts both names on the card, because the card
   is the surface a reader looking a term up reaches (#149). The alias is a name,
   not a second heading: it sits in the h3 so find-in-page and the definitions
   panel both see it, at body weight and size so the term the act puts first is
   still what the eye reads. */
.definition-alias {
    font-size: 0.85rem;
    font-weight: 400;
    white-space: nowrap;
}

.first-structural-container:empty {
    margin-bottom: 0;
    display: none;
}

/* A structural heading is a scroll TARGET, not just a label: `scrollToLink`
   walks back from a card over the run of headings introducing it and anchors on
   the outermost one it takes (celex_scroll_target.js), so that the reader
   arrives knowing which Chapter/Section/Subsection they landed in rather than
   with all of them scrolled off the top -- 46% of COBS cards carry at least one.
   Without this the heading lands flush under the sticky omni bar, i.e. half
   hidden by the very thing `.celex-card` above declares the same clearance for.
   Both read the one custom property; see its declaration for why. */
.structural-element {
    scroll-margin-top: var(--scroll-anchor-offset);
}

/* Structural headings (Part, Title, Chapter, Section, Subsection, Crossheading,
   Schedule) render as <h1>-<h5>. The Part/Schedule level is an <h1>, which
   would otherwise take the application h1 tier — `--lx-h1` via components.css's
   bare `h1` rule — and a UK SI with many Parts then renders page-title-sized
   headings that dwarf the content. Size them by structural level instead
   (#1059-followup). (That tier is 3rem today. This comment used to say 5rem and
   name base.css, which is where `.heading-title` reads the same token; both
   numbers and the file were stale, and the demotion is the point rather than
   any particular figure — so it is stated as a token, not a size.)

   Every level `render_html.STRUCTURAL_LEVEL_STYLES` can emit needs its own rung
   here. Section and Subsection had none, so both fell through to the base rule
   below and drew at chapter size — invisible on an EU regulation, and most of
   the page on an FCA sourcebook, where Subsection is the innermost and most
   numerous level (#1824). `tests/test_structural_heading_ladder.py` reads that
   map and fails if a level the renderer emits is unsized here, so the next
   corpus cannot fall off the end the same way. The base rule below is the
   fallback for an unrecognised type, never a level's size.

   Only the top two levels need a size the type scale does not already hold:
   Part/Schedule is an <h1> and Title an <h2>, and both are page-title sizes in
   body copy, so they carry literals that DEMOTE them. Chapter, Section,
   Subsection and Crossheading are at their own tag's designed size and say so
   with the token — `--lx-h3`/`--lx-h4`/`--lx-h5` — rather than restating the
   number. (Crossheading is a title-only grouping emitted at the same HTML rank
   as Subsection, so it is sized alongside that level rather than below it.)
   They still need the rule: the base `.structural-heading` selector below beats
   the bare `h4`/`h5` element rules in components.css on specificity, so a level
   with no rung does not fall back to its tag's size, it falls back to 1.5rem.
   That is the whole mechanism of #1824.

   The granular band (Section, Subsection, Crossheading) carries weight the
   larger levels do not need: at 1.25rem and below, `--lx-heading-weight` (300)
   no longer reads as a heading against the body copy beneath it. */
.structural-heading {
    font-size: 1.5rem;
    line-height: 1.2;
    margin: 0;
}

.structural-part .structural-heading,
.structural-schedule .structural-heading {
    font-size: 2rem;
    font-weight: 700;
}

.structural-title .structural-heading {
    font-size: 1.75rem;
}

.structural-chapter .structural-heading {
    font-size: var(--lx-h3);
}

.structural-section .structural-heading {
    font-size: var(--lx-h4);
    font-weight: 600;
}

.structural-subsection .structural-heading {
    font-size: var(--lx-h5);
    font-weight: 600;
}

.structural-crossheading .structural-heading {
    font-size: var(--lx-h5);
    font-weight: 600;
}

/* The document-opening structural element takes its own rung, like every heading
   after it: it sits in the text column now, and the Lens above the grid is the act's
   lead-in. (It used to be drawn larger, above the grid, as the page's lead-in.) */

.legislation-column-wrapper {
    padding-right: 1rem;
}

/* Transitions only during omni bar open/close/preview toggle — not during scroll */
body.omni-animating .content-area { transition: padding-top 0.25s ease; }
body.omni-animating .content-area::before { transition: height 0.25s ease; }
body.omni-animating .celex-card .card-header { transition: top 0.25s ease; }
body.omni-animating .floodlight-stack { transition: top 0.25s ease; }

/* ========================================
   FLOODLIGHT PANEL
   ======================================== */

/* Sticky stack wrapping the version panel + the floodlight box so the two
   separate boxes scroll together. The stack owns the sticky/height; the panel
   sits above the floodlight box in flow and pushes it down when opened. */
.floodlight-stack {
    position: sticky;
    top: var(--sticky-offset);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.floodlight-box {
    position: relative;       /* positioning context for .floodlight-loading */
    flex: 1 1 auto;           /* fill the height left below the panel */
    min-height: 0;            /* allow the flex child to shrink and scroll */
    background-color: #FFEEEF;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 1;
    font-family: var(--ss-font-primary);
    font-size: 0.875rem;

    /* WebKit browsers (Chrome, Safari, Edge) */
    &::-webkit-scrollbar {
        width: 6px;
    }

    &::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.floodlight-box.content-ready {
    opacity: 1;
}

.floodlight-loading {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    text-align: center;
}

.floodlight-section {
    padding: 0.25rem;
    border-radius: 0.25rem;
}

/* The loader shell's preview renders Article 1's definitions for every full
   viewer, and a plan without definitions saw them until page-data emptied the
   section, closing the panel up under text on screen (#3532). The shell seeds
   the capability, content-root.js copies it onto the shadow host, and this
   holds them back from the first frame. Inert, they are the gated names. */
:host([data-capability-definitions='false']:not([data-content-variant='inert'])) #floodlight-definitions {
    display: none;
}

.floodlight-drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem;
    margin-top: 0.25rem;
    border: 1.5px dashed #ccc;
    border-radius: 0.25rem;
    color: #999;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.floodlight-drop-zone:hover {
    border-color: #0d6efd;
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.03);
}

.floodlight-drop-zone.drag-over {
    border-color: #0d6efd;
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.06);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.definition-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.definition-item:last-child {
    border-bottom: none;
}

.definition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.definition-term {
    font-weight: bold;
    color: #333;
}

.definition-term::after {
    content: ":";
}

.definition-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.5rem;
}

.definition-copy-icon,
.definition-filter-icon,
.definition-filter-descendants-icon {
    cursor: pointer;
    color: #6c757d;
    font-size: 0.8rem;
    padding: 0.2rem 0.3rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
}

.definition-copy-icon:hover {
    color: #ff5555;
    background-color: rgba(13, 110, 253, 0.1);
}

.definition-filter-icon:hover {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.1);
}

.definition-filter-descendants-icon:hover {
    color: #198754;
    background-color: rgba(25, 135, 84, 0.1);
}

.definition-copy-icon.copied-success {
    color: #198754 !important;
    background-color: rgba(25, 135, 84, 0.15) !important;
}

.definition-filter-descendants-icon .fa-plus {
    font-size: 0.6rem;
    position: relative;
    top: -0.2rem;
    right: -0.1rem;
}

.definition-meaning {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
    margin-left: 0.5rem;
}

.definition-close-icon {
    cursor: pointer;
    color: #6c757d;
    font-size: 1rem;
    line-height: 1;
    padding: 0.2rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
}

.definition-close-icon:hover {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.highlight-flash {
    transition: background-color 0.5s;
    background-color: #ffffd0 !important;
}

.definitions-section,
.marginalia-section {
    position: relative;
}

.section-close-icon {
    position: absolute;
    top: 0rem;
    right: 0rem;
    cursor: pointer;
    font-size: 1rem;
    color: #000000;
    opacity: 0.5;
}

.section-close-icon:hover {
    color: #777;
    opacity: 1;
}

.legislation-age-details {
    text-decoration: underline dotted;
    cursor: pointer;
}

/* Commentary & Marginalia in Floodlight — unified marg-entry style */

.marg-entry .marg-icon.icon-commentary {
    background: #e8eaf6;
    color: #5c6bc0;
}

/* Unified marginalia entry — icon square + blockquote border */
.marg-entry {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.4rem 0.4rem 0.4rem 0.5rem;
    margin-bottom: 0.5rem;
    border-left: 2px solid #ccc;
    margin-left: 0.25rem;
}
.marg-entry.has-attach {
    border-left: 3px solid #d32f2f;
}
.marg-entry .marg-icon {
    flex-shrink: 0;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    font-size: 0.85rem;
}
.marg-entry .marg-icon.icon-note {
    background: #fff3e0;
    color: #e6a817;
}
.marg-entry .marg-icon.icon-pdf {
    background: #fce4ec;
    color: #d32f2f;
}
.marg-entry .marg-body {
    flex: 1;
    min-width: 0;
}
.marg-entry .marg-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: #333;
}
.marg-entry .marg-title a {
    color: #333;
    text-decoration: none;
}
.marg-entry .marg-title a:hover {
    color: #0d6efd;
    text-decoration: underline;
}
.marg-entry .marg-summary {
    font-size: 0.82rem;
    line-height: 1.4;
    color: #555;
    margin-top: 0.2rem;
}

/* ========================================
   BREADCRUMB NAVIGATION
   ======================================== */

#floodlight-breadcrumbs {
    display: block;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
}

.breadcrumb-trail {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 0.25rem;
    font-weight: 600;
    transition: background-color 150ms ease, transform 100ms ease;
    user-select: none;
}

.breadcrumb-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.breadcrumb-item:active {
    transform: translateY(0);
}

.breadcrumb-item-chapter { color: var(--breadcrumb-chapter); }
.breadcrumb-item-title { color: var(--breadcrumb-title); }
.breadcrumb-item-part { color: var(--breadcrumb-part); }
.breadcrumb-item-section { color: var(--breadcrumb-section); }
.breadcrumb-item-article { color: var(--breadcrumb-article); }
.breadcrumb-item-recital { color: var(--breadcrumb-recital); }
.breadcrumb-item-annex { color: var(--breadcrumb-annex); }
.breadcrumb-item-paragraph { color: var(--breadcrumb-paragraph); }

/* Transitional / commencement breadcrumb indicators (#136, tokens only) */
.breadcrumb-cal-icon {
    margin-left: 0.25rem;
    font-size: 0.78em;
    vertical-align: -0.05em;
}
.breadcrumb-commencement--not_in_force {
    background-color: var(--lx-warning-bg);
    color: var(--lx-warning-fg);
    border: 1px solid var(--lx-warning-border);
}
.breadcrumb-commencement--partially_in_force {
    background-color: var(--lx-info-bg);
    color: var(--lx-info-fg);
    border: 1px solid var(--lx-info-border);
}
.breadcrumb-commencement--recently_in_force {
    background-color: var(--lx-success-bg);
    color: var(--lx-success-fg);
    border: 1px solid var(--lx-success-border);
}
.breadcrumb-commencement--expired {
    background-color: var(--lx-danger-bg);
    color: var(--lx-danger-fg);
    border: 1px solid var(--lx-danger-border);
}

/* Act Regulatory Stack panel (#4064 Stage 1, tokens only) */
.regulatory-stack-panel {
    background: var(--lx-surface);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius-md);
    padding: 0.75rem 1rem;
    text-align: left;
}
.regulatory-stack-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}
.regulatory-stack-counts {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.regulatory-stack-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--lx-radius-pill);
    background: var(--lx-surface-muted);
    color: var(--lx-text-muted);
    border: 1px solid var(--lx-border);
}
.regulatory-stack-pill--l2 {
    background: var(--lx-info-bg);
    color: var(--lx-info-fg);
    border-color: var(--lx-info-border);
}
.regulatory-stack-body {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--lx-border);
}
.regulatory-stack-layer + .regulatory-stack-layer {
    margin-top: 1rem;
}
.regulatory-stack-layer-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}
.regulatory-stack-authority-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
    color: var(--lx-text-muted);
}
.regulatory-stack-group {
    margin-bottom: 0.35rem;
}
.regulatory-stack-group-summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}
.regulatory-stack-list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
}
.regulatory-stack-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--lx-border);
}
.regulatory-stack-item:last-child {
    border-bottom: none;
}
.regulatory-stack-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.regulatory-stack-link {
    font-size: 0.875rem;
    font-weight: 500;
}
.regulatory-stack-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: var(--lx-radius-sm);
    background: var(--lx-surface-muted);
    color: var(--lx-text-muted);
    border: 1px solid var(--lx-border);
}
.regulatory-stack-badge--adopted {
    background: var(--lx-success-bg);
    color: var(--lx-success-fg);
    border-color: var(--lx-success-border);
}
.regulatory-stack-badge--draft {
    background: var(--lx-warning-bg);
    color: var(--lx-warning-fg);
    border-color: var(--lx-warning-border);
}
.regulatory-stack-meta {
    font-size: 0.78rem;
    color: var(--lx-text-muted);
    margin-top: 0.15rem;
}

.breadcrumb-separator {
    color: #6c757d;
    font-weight: 400;
    padding: 0 0.1rem;
    user-select: none;
}

/* ========================================
   RESPONSIVE - MOBILE/TABLET
   ======================================== */

@media (max-width: 991px) {
    /* Keep flex but hide TOC - content fills full width */
    body.show-lexray-text .legislation-layout {
        /* Keep flexbox for proper layout */
        padding-left: var(--viewport-margin);
        padding-right: var(--viewport-margin);
        padding-top: var(--header-height);
        gap: 0;  /* No gap when TOC is hidden */
    }

    /* Hide TOC on mobile */
    body.show-lexray-text .legislation-layout .toc-sidebar {
        display: none;
    }

    /* Content takes full width */
    body.show-lexray-text .legislation-layout .content-area {
        max-width: none;
        margin-left: 0;  /* No offset when TOC hidden */
        width: 100%;
    }

    /* Header aligns with content left edge on mobile */
    body.show-lexray-text .header .content {
        padding-left: var(--viewport-margin);
        padding-right: var(--viewport-margin);
    }

    /* Smaller breadcrumb font on mobile */
    .breadcrumb-trail {
        font-size: 0.75rem;
    }
}

/* Print - hide breadcrumbs */
@media print {
    #floodlight-breadcrumbs {
        display: none !important;
    }
}

/* ========================================
   EDIT LOCATION MODAL (Admin/Legal Admin)
   ======================================== */

/* Admin-only elements - hidden by default */
.admin-only {
    display: none !important;
}

/* Show admin-only elements when user has admin role */
body.user-is-admin .admin-only,
body.user-is-legal-admin .admin-only {
    display: inline-flex !important;
}

/* Logged-in-only elements - hidden by default, shown for authenticated users */
.logged-in-only {
    display: none !important;
}

body.user-is-authenticated .logged-in-only {
    display: inline-flex !important;
}

/* Lexray-editor-only elements - hidden by default */
.lexray-editor-only {
    display: none !important;
}

body.user-is-lexray-editor .lexray-editor-only,
body.user-is-admin .lexray-editor-only {
    display: list-item !important;
}

/* Edit modal tab navigation - override ss-main.css .nav padding */
.edit-modal-tabs {
    padding: 0;
}

/* Edit modal resources tab styling */
.resources-editor .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.resources-editor .list-group-item:hover {
    background-color: #f8f9fa;
}

.resources-editor .list-group-item.active {
    background-color: #0d6efd;
    color: white;
}

.resources-editor .list-group-item.active .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

.resources-editor .list-group-item.active .badge {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Visibility badges */
.marginalia-visibility-badge,
.commentary-visibility-badge,
.resources-visibility-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.8rem;
    border-radius: 1rem;
    font-family: var(--badge-font);
    font-weight: var(--badge-font-weight);
}

.marginalia-visibility-badge {
    background-color: #fff3cd;
    color: #856404;
}

.commentary-visibility-badge,
.resources-visibility-badge {
    background-color: #d1e7dd;
    color: #0f5132;
}

/* Marginalia file dropzone */
.marginalia-dropzone {
    border: 2px dashed #ced4da;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.marginalia-dropzone:hover {
    border-color: #86b7fe;
    background-color: #f8f9ff;
}

.marginalia-dropzone.drag-over {
    border-color: #0d6efd;
    background-color: #e7f1ff;
}

/* FCA onshored content (contentType HTML from the FCA API) wraps sub-points in
   <ol> with their own "(a)/(b)" labels inside <li class="subpara1">. Suppress
   the browser's auto-numbering — which would double-number "1. (a)" — and tame
   the default list indent, matching the FCA's own rendering. Scoped to the
   FCA .section-content wrapper so other legislation lists are unaffected. */
.celex-card .section-content ol {
    list-style: none;
    padding-left: 1.5rem;
    margin-left: 0;
}

.celex-card .section-content ol > li.subpara1 {
    list-style: none;
}

/* In-page EU↔UK jurisdiction switcher (epic #655 / #668) */
.jurisdiction-switcher { display: flex; justify-content: center; }
.jurisdiction-toggle {
    display: inline-flex; align-items: stretch;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 999px; overflow: hidden; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.jurisdiction-toggle__opt {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .85rem; font-size: .85rem; font-weight: 600;
    color: #6c757d; text-decoration: none; cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}
.jurisdiction-toggle__opt + .jurisdiction-toggle__opt {
    border-left: 1px solid var(--bs-border-color, #dee2e6);
}
.jurisdiction-toggle__opt:hover { background: #f1f3f5; color: #212529; }
.jurisdiction-toggle__opt.is-active {
    background: var(--bs-primary, #0d6efd); color: #fff; cursor: default;
}
.jurisdiction-toggle__flag {
    width: 20px; height: 14px; border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12);
}
.jurisdiction-toggle__opt.is-active .jurisdiction-toggle__flag {
    box-shadow: 0 0 0 1px rgba(255,255,255,.5);
}
/* The option a switch is fetching (#4616): set by celex_jurisdiction_switch.js
   at the click, cleared when the swap commits. The active option stays on the
   act on screen meanwhile. The spinner is the version panel's .compare-pending
   one, in the option's own colour. */
.jurisdiction-toggle__opt.is-pending { cursor: progress; }
.jurisdiction-toggle__opt.is-pending::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: jurisdiction-pending-spin 0.8s linear infinite;
}
@keyframes jurisdiction-pending-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .jurisdiction-toggle__opt.is-pending::after { animation: none; }
}

/* Static jurisdiction + document-type pill (single-jurisdiction pages, #693) */
.jurisdiction-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; letter-spacing: .02em;
    color: #495057; background: #f1f3f5;
    border: 1px solid var(--bs-border-color, #dee2e6);
}
.jurisdiction-pill__flag {
    width: 18px; height: 12px; border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12);
}

/* Inline obligation badges (#980) — chips under a provision header that
   surface its typed obligation structure. Each chip's title attribute shows
   the verbatim source span it was grounded in. */
/* Container stacks one row per obligation unit (norm). */
.obligation-badges {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.5rem 1rem 0;
}

/* One obligation unit = one coherent norm, read as a single rule row: the
   operator·actor pill leads, the action reads as text, and conditions /
   exceptions / references trail as small chips. A left border colour-codes the
   row by deontic operator so a multi-norm article scans at a glance. */
.obligation-unit {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem 0.45rem;
    padding: 0.2rem 0.5rem;
    border-left: 3px solid var(--ob-duty-border, #b6d4fe);
}

/* The action — the readable core of the rule — fills the middle and wraps. */
.ob-action {
    flex: 1 1 14rem;
    min-width: 8rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--bs-secondary-color, #555);
}

/* Trailing conditions/exceptions/refs are visually secondary to the duty. */
.ob-secondary {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.3rem;
    flex: 0 1 auto;
}
.ob-secondary .obligation-badge {
    font-size: 0.66rem;
    padding: 0.1rem 0.45rem;
}

/* Colour the row + its duty pill by deontic operator (obligation keeps the
   default blue). The duty pill recolours via the operator class on the row. */
.obligation-unit.ob-op-prohibition { border-left-color: var(--ob-exception-border); }
.obligation-unit.ob-op-permission  { border-left-color: var(--ob-ref-border); }
.obligation-unit.ob-op-right        { border-left-color: var(--ob-penalty-border); }

.ob-op-prohibition .obligation-badge.ob-duty {
    background-color: var(--ob-exception-bg);
    color: var(--ob-exception-fg);
    border-color: var(--ob-exception-border);
}
.ob-op-permission .obligation-badge.ob-duty {
    background-color: var(--ob-ref-bg);
    color: var(--ob-ref-fg);
    border-color: var(--ob-ref-border);
}
.ob-op-right .obligation-badge.ob-duty {
    background-color: var(--ob-penalty-bg);
    color: var(--ob-penalty-fg);
    border-color: var(--ob-penalty-border);
}

/* ---- Obligation structure tree (#980): L1 norm head + L2 facets at card top */
.obligation-tree {
    padding: 0.6rem 1rem 0.5rem;
    border-bottom: 1px solid var(--bs-border-color, #e9ecef);
}
.ob-tree-title {
    font-family: var(--badge-font);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 0.45rem;
}
/* L1 — one norm, left border colour-coded by deontic operator. */
.ob-norm {
    border-left: 3px solid var(--ob-duty-border, #b6d4fe);
    padding-left: 0.6rem;
    margin-bottom: 0.5rem;
}
.ob-norm:last-child { margin-bottom: 0; }
.ob-norm.ob-op-prohibition { border-left-color: var(--ob-exception-border); }
.ob-norm.ob-op-permission  { border-left-color: var(--ob-ref-border); }
.ob-norm.ob-op-right        { border-left-color: var(--ob-penalty-border); }
.ob-norm-head { margin-bottom: 0.15rem; }
/* L2 — the norm's facets, indented under the head. */
.ob-norm-facets {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.75rem;
}
.ob-facet {
    display: flex;
    gap: 0.6rem;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0.05rem 0;
}
.ob-facet-k {
    flex: 0 0 4rem;
    text-align: right;
    color: #8a9099;
    font-family: var(--badge-font);
    font-weight: 500;
    font-size: 0.66rem;
    text-transform: uppercase;
    line-height: 1.85;
}
.ob-facet-v { color: var(--bs-body-color, #333); flex: 1 1 auto; min-width: 0; }
.ob-facet-exception .ob-facet-v { color: var(--ob-exception-fg); }
.ob-facet-cross_ref .ob-facet-v,
.ob-facet-def_ref .ob-facet-v { color: var(--ob-ref-fg); }
/* L3 — e.g. a deadline's qualifier, nested under its facet. */
.ob-l3 {
    list-style: none;
    margin: 0.1rem 0 0;
    padding-left: 0.9rem;
    font-size: 0.74rem;
    color: #6c757d;
}
.ob-l3 li::before { content: '↳ '; color: #adb5bd; }

/* Badges anchored beneath the specific clause they describe (#980): tighter
   top/bottom spacing so they read as belonging to the paragraph above. */
.obligation-anchor-row {
    padding-top: 0.15rem;
    padding-bottom: 0.4rem;
}
.obligation-anchor-row .obligation-badges {
    padding: 0;
}

/* Document-level "obligations by role" summary (#955/#969): one row per role
   bearing a duty, with its count and links to the provisions. Rendered as a
   light document section (a titled list), consistent with the rest of the
   reader rather than a heavy bordered card. */
.obligations-by-role {
    margin: 0 0 1.25rem;
    padding: 0;
}
.obligations-by-role-title {
    font-family: var(--badge-font);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #495057;
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--bs-border-color, #e9ecef);
}
.role-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.2rem 0;
}
.role-row + .role-row {
    border-top: 1px solid var(--bs-border-color, #f1f3f5);
}
/* The unattributed bucket: muted, so it reads as a coverage note rather than an
   actor row. */
.role-row-unattributed {
    margin-top: 0.25rem;
}
.role-name-unattributed {
    color: #868e96;
    font-style: italic;
}
.role-name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 12rem;
    font-family: var(--badge-font);
    font-weight: 500;
    font-size: 0.82rem;
}
.role-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 0 0.4rem;
    font-size: 0.72rem;
    border-radius: 1rem;
    background: var(--ob-duty-bg, #e7f1ff);
    color: var(--ob-duty-fg, #0a58ca);
    border: 1px solid var(--ob-duty-border, #b6d4fe);
}
.role-provisions {
    font-size: 0.78rem;
    line-height: 1.6;
}
.role-provisions a {
    margin-right: 0.15rem;
}

.obligation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.55rem;
    font-family: var(--badge-font);
    font-weight: var(--badge-font-weight);
    font-size: 0.72rem;
    line-height: 1.4;
    border-radius: 1rem;
    border: 1px solid transparent;
    cursor: default;
    white-space: nowrap;
}

/* Duty type — the primary chip (e.g. "Obligation·Controller"). */
.obligation-badge.ob-duty {
    background-color: var(--ob-duty-bg);
    color: var(--ob-duty-fg);
    border-color: var(--ob-duty-border);
}

/* Unsupported (non-enum) duty value — visibly flagged, not dressed as valid. */
.obligation-badge.ob-duty-unknown {
    background-color: var(--ob-unknown-bg);
    color: var(--ob-unknown-fg);
    border-color: var(--ob-unknown-border);
}

.obligation-badge.ob-bearer {
    background-color: var(--ob-bearer-bg);
    color: var(--ob-bearer-fg);
    border-color: var(--ob-bearer-border);
}

/* Time limits and standalone deadline qualifiers. */
.obligation-badge.ob-deadline,
.obligation-badge.ob-deadline-qualifier {
    background-color: var(--ob-deadline-bg);
    color: var(--ob-deadline-fg);
    border-color: var(--ob-deadline-border);
}

.obligation-badge.ob-trigger {
    background-color: var(--ob-trigger-bg);
    color: var(--ob-trigger-fg);
    border-color: var(--ob-trigger-border);
}

/* Carve-outs / derogations. */
.obligation-badge.ob-exception {
    background-color: var(--ob-exception-bg);
    color: var(--ob-exception-fg);
    border-color: var(--ob-exception-border);
}

/* Cross-references and definition references. */
.obligation-badge.ob-cross-ref,
.obligation-badge.ob-def-ref {
    background-color: var(--ob-ref-bg);
    color: var(--ob-ref-fg);
    border-color: var(--ob-ref-border);
}

.obligation-badge.ob-penalty {
    background-color: var(--ob-penalty-bg);
    color: var(--ob-penalty-fg);
    border-color: var(--ob-penalty-border);
}

/* ============================================================================
   FCA provision type — rule vs guidance (#1796)
   ============================================================================
   The Handbook's central distinction is whether a provision binds. Before this,
   the only thing on the page that said so was the trailing letter in the
   citation ('COBS 9B.8.3R' against 'COBS 6.1B.10G') — one unemphasised
   character at the end of a heading.

   THREE REDUNDANT CHANNELS, and the redundancy is the requirement. Colour alone
   cannot carry a load-bearing legal distinction: it is gone in greyscale print
   and unreliable for ~8% of male readers.

     1. THE WORD. Each badge spells its category out. This is the only channel
        that works with no vision of colour or shape at all, so it is the one
        that must never be dropped for a tidier chip.
     2. FILL AND BORDER STYLE. A rule is FILLED; everything non-binding is
        outlined, and the outline's style separates them further (dashed
        guidance, double evidential, dotted onshored legislation). The card's
        left rail repeats the same style, so the category is legible from the
        margin without reading the header.
     3. COLOUR, last and redundant.

   A provision whose category could not be resolved carries no
   `data-provision-type` and gets none of this — see fca_parser's
   `classify_provision_type`. Untyped renders exactly as it did before, which is
   the point: a silent provision is recoverable, a wrongly badged one is not.

   The BADGE is a shared component (components.css §20) since #1874 gave it a
   second surface. What is here is the reader's own structure around it — the
   heading slot and the card's left rail — which is `.celex-card` markup and
   goes nowhere else. */

/* The header's heading slot when a badge is present. Emitted only then, so a
   card with no badge keeps <h4> as the header's own flex child. */
.celex-card-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 0;
}

/* The h4's own 1rem right margin would stack with the gap above. */
.celex-card-heading > h4 {
    margin-right: 0;
}

/* The badge itself now lives in components.css §20 — the FCA search panel
   (#1874) draws the same marker on a result row, and /fca-handbook does not
   load this sheet. What stays here is the READER's half: the heading wrapper
   above and the card's left rail below, both of which are `.celex-card`
   structure and belong to the reader's domain. */

/* The card's left rail — the same distinction, readable from the margin. */
.celex-card[data-provision-type] {
    border-left-width: 4px;
    border-left-style: solid;
    border-left-color: var(--lx-border-strong);
}

.celex-card[data-provision-type='rule'] {
    border-left-color: var(--ss-dark);
}

.celex-card[data-provision-type='guidance'] {
    border-left-style: dashed;
    border-left-color: var(--lx-text-muted);
}

.celex-card[data-provision-type='evidential_provision'] {
    border-left-style: double;
    border-left-color: var(--lx-warning-fg);
}

.celex-card[data-provision-type='uk_provision'],
.celex-card[data-provision-type='eu_provision'] {
    border-left-style: dotted;
    border-left-color: var(--lx-info-fg);
}

/* Evidential relations (#3146): what a provision tends to establish, and on the
   rule it relates to, what is evidence of compliance with it or its
   contravention. Server-rendered by apps/fca/fca_evidential_html.py, and only
   on a card that carries a relation. A target the FCA links nothing for is
   kept as its words, marked by a dotted underline rather than colour alone. */
.fca-evidential {
    margin: 0 1rem 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius-sm);
    background: var(--lx-surface-muted);
    font-size: 0.875rem;
}

.fca-evidential__title {
    margin: 0 0 0.25rem;
    font-weight: 600;
}

.fca-evidential__list {
    margin: 0;
    padding-left: 1.25rem;
}

.fca-evidential__source,
.fca-evidential__condition {
    color: var(--lx-text-muted);
}

.fca-evidential__unlinked {
    text-decoration: underline dotted;
}

/* The roles strip that sat under the title is gone (the Lens carries the act's people). A
   stored preview rendered before that still carries its markup until the stale-preview
   sweep regenerates it, and nothing hydrates or styles it now: hide it. */
#cast-strip { display: none !important; }
