/* ==========================================================================
   law-reader.css — the document reader shell.

   Loaded by law_detail, law_as_of, law_article_detail and law_section_detail,
   always together with law-shared.css (which owns the token layer, the
   legal-force badge, the notice bands and the footnote apparatus).

   The three structural decisions this file encodes, and why
   ---------------------------------------------------------
   1. NATIVE PAGE SCROLL. The old reader put the text in an inner
      `overflow-y: auto` pane sized `calc(100vh - 200px)`. That constant was
      wrong (the site header changed and nobody re-measured), and an inner
      scroller breaks Ctrl+F reveal, browser scroll restoration, mobile URL-bar
      collapse and `window.print()` all at once. Sticky bars do the same job
      without owning the scroll.

   2. THE RAIL IS VISIBLE. `law_detail.html` shipped
      `.document-sidebar { display: none !important }` behind `hide_footer`,
      which the view sets to True unconditionally — so the table of contents
      has never rendered for a single reader. It is a docked sticky column here.

   3. STICKY OFFSETS ARE MEASURED, NEVER CONSTANTS. `--lr-sticky-h` is written
      by law-reader-shell.js from the docbar's real height and consumed by every
      `scroll-margin-top` in this file. See the cautionary tale in point 1.

   Frozen names — bound by JS, by bookmarked URLs, or by both. Do not rename:
     ids       documentContent  documentSidebar  tocTree  sidebarContent
               tocFilter  collapseSidebar  revisionsPane  revisionsContent
               revisionDateSearch  fontSizePlus  fontSizeMinus  shareBtn
               section-<id>  st-<number>  footnote-<n>
     classes   section-block  section-title  section-content
               toc-item  toc-link  toc-toggle  toc-children  toc-text
               revision-item  revision-checkbox  revision-year-group
               revision-year-header  revision-date  revision-link
     data-*    data-section-id  data-level  data-version-id
               data-version-date  data-effective-date
   ========================================================================== */

.law-reader {
    /* Reader-local tokens. The two runtime ones are written by
       law-reader-shell.js; the fallbacks here keep a no-JS page usable. */
    --lr-sticky-h: 104px;
    --lr-rail-w: 300px;
    --lr-read-size: 17px;
    --lr-read-lh: 1.7;
    --lr-measure: 68ch;
    --lr-gutter: 40px;
    --lr-max: 1360px;

    background: var(--law-app-bg, #f6f4f2);
    font-family: var(--law-font);
}

@media (prefers-reduced-motion: no-preference) {
    .law-reader {
        scroll-behavior: smooth;
    }
}

/* The reader overrides {% block main %}, so base.html's
   `.container.mt-4.mb-5` never wraps it — which is what let every
   `!important` in the old template go away. */
.lr-main {
    display: block;
    min-height: 60vh;
}

.lr-main .alert {
    max-width: var(--lr-max);
    margin: 16px auto 0;
}

/* --------------------------------------------------------------------------
   1. Docbar — sticky identity + redaction strip
   Replaces .document-top-bar and .document-version-bar, whose four tabs were
   two dead TODOs and one "not the others".
   -------------------------------------------------------------------------- */
.lr-docbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 253, 251, .93);
    backdrop-filter: saturate(1.6) blur(10px);
    -webkit-backdrop-filter: saturate(1.6) blur(10px);
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

/* Gold = "not today's text". The whole bar carries it so the signal cannot be
   scrolled past or missed. Dark red is reserved for "no legal force" and lives
   on the ribbon; the two are never combined into one colour. */
.lr-docbar.is-point-in-time {
    background: var(--law-anchor-bg, #fffbef);
    border-bottom-color: var(--law-anchor-line, #f2e3b4);
    box-shadow: inset 5px 0 0 var(--law-anchor, #f2c93e);
}

.lr-docbar__inner {
    max-width: var(--lr-max);
    margin: 0 auto;
    padding: 0 var(--lr-gutter);
}

.lr-docbar__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 9px 0;
    border-bottom: 1px solid var(--law-line, #e7e2de);
    overflow: hidden;
}

.lr-docbar.is-point-in-time .lr-docbar__identity {
    border-bottom-color: var(--law-anchor-line, #f2e3b4);
}

.lr-docbar__title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--law-ink, #1a1614);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-wrap: balance;
}

.lr-docbar__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    font-size: 12.5px;
    color: var(--law-ink-muted, #6b615c);
    white-space: nowrap;
}

.lr-docbar__meta .lr-dot {
    color: var(--law-ink-faint, #9a908a);
}

.lr-docbar__version {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 0;
}

/* Compaction: the identity row folds away once the masthead scrolls out, so a
   long read keeps one 52px bar instead of two. Driven by an
   IntersectionObserver on a sentinel — never a scroll handler. */
.lr-docbar.is-compact .lr-docbar__identity {
    display: none;
}

.lr-docbar.is-compact .lr-docbar__version {
    min-height: 48px;
}

/* Redaction chip — the answer to "which text am I reading". */
.lr-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    max-width: 46%;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    padding: 7px 13px;
    border-radius: var(--law-radius-pill);
    border: 1px solid var(--law-line-strong, #d6cfc9);
    background: var(--law-paper, #fffdfb);
    color: var(--law-ink, #1a1614);
    cursor: pointer;
    text-align: start;
    transition: border-color .15s var(--law-ease), background-color .15s var(--law-ease);
}

.lr-chip:hover {
    border-color: var(--law-ink-faint, #9a908a);
    background: var(--law-sunken, #f0ede9);
}

.lr-chip i {
    font-size: 14px;
    color: var(--law-ink-muted, #6b615c);
}

.lr-chip__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lr-chip__num {
    font-family: var(--law-font-mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--law-ink-muted, #6b615c);
}

.lr-chip.is-stale {
    border-color: var(--law-anchor, #f2c93e);
    background: #fff;
    color: var(--law-anchor-ink, #8a6510);
}

.lr-chip.is-stale i {
    color: var(--law-anchor-ink, #8a6510);
}

/* Scroll-spy breadcrumb: where in the act the reading line currently is.
   Built from the DOM by law-reader-toc.js; empty until the first spy tick, so
   it never renders a placeholder. */
.lr-crumb {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12.5px;
    line-height: 1.3;
    color: var(--law-ink-muted, #6b615c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    padding: 0 8px;
}

.lr-crumb:empty {
    display: none;
}

.lr-crumb b {
    font-weight: 600;
    color: var(--law-ink-soft, #443c38);
}

.lr-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
    margin-inline-start: auto;
}

.lr-tools__sep {
    width: 1px;
    height: 22px;
    margin: 0 6px;
    background: var(--law-line, #e7e2de);
    flex: none;
}

/* Reading-progress hairline along the bar's bottom edge. */
.lr-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--law-anchor, #f2c93e);
    transform: scaleX(0);
    transform-origin: 0 50%;
    will-change: transform;
    pointer-events: none;
}

/* Dropdown menus in the toolbar (print scope, overflow). */
.lr-menu {
    position: relative;
}

.lr-menu__list {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    z-index: 60;
    min-width: 248px;
    padding: 6px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius);
    background: var(--law-paper, #fffdfb);
    box-shadow: var(--law-shadow-lg);
    display: none;
}

.lr-menu.is-open .lr-menu__list {
    display: block;
}

.lr-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-radius: var(--law-radius-sm);
    background: transparent;
    font: inherit;
    font-size: 13.5px;
    color: var(--law-ink-soft, #443c38);
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}

.lr-menu__item:hover {
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink, #1a1614);
}

.lr-menu__item i {
    font-size: 15px;
    color: var(--law-ink-muted, #6b615c);
    flex: none;
}

.lr-menu__sep {
    height: 1px;
    margin: 5px 8px;
    background: var(--law-line, #e7e2de);
}

/* --------------------------------------------------------------------------
   2. Force ribbon — in flow, scrolls away. It is a statement, not a control.
   Absence is the signal: an in-force act on its current redaction shows none.
   -------------------------------------------------------------------------- */
.lr-ribbon {
    max-width: var(--lr-max);
    margin: 0 auto;
    padding: 16px var(--lr-gutter) 0;
    display: grid;
    gap: 10px;
}

.lr-ribbon:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   3. Body grid: rail + reading column
   -------------------------------------------------------------------------- */
.lr-body {
    display: grid;
    grid-template-columns: var(--lr-rail-w) minmax(0, 1fr);
    gap: 0;
    max-width: var(--lr-max);
    margin: 0 auto;
    padding: 0 var(--lr-gutter) 72px;
    align-items: start;
}

.lr-body.is-rail-collapsed {
    grid-template-columns: 44px minmax(0, 1fr);
}

/* Focus mode hides both the rail and the drawer and centres the column. */
.law-reader.lr-focus .lr-body {
    grid-template-columns: minmax(0, 1fr);
}

.law-reader.lr-focus .lr-rail {
    display: none;
}

/* --------------------------------------------------------------------------
   4. Rail — the table of contents
   -------------------------------------------------------------------------- */
.lr-rail {
    position: sticky;
    top: var(--lr-sticky-h);
    height: calc(100vh - var(--lr-sticky-h));
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-inline-end: 24px;
    border-inline-end: 1px solid var(--law-line, #e7e2de);
    overscroll-behavior: contain;
}

.lr-rail__head {
    flex: none;
    padding: 18px 0 10px;
    display: grid;
    gap: 8px;
}

.lr-rail__search {
    position: relative;
    display: flex;
    align-items: center;
}

.lr-rail__search i {
    position: absolute;
    inset-inline-start: 10px;
    font-size: 13px;
    color: var(--law-ink-faint, #9a908a);
    pointer-events: none;
}

#tocFilter {
    width: 100%;
    padding: 8px 12px 8px 30px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius-sm);
    background: var(--law-paper, #fffdfb);
    font: inherit;
    font-size: 13px;
    color: var(--law-ink, #1a1614);
}

#tocFilter::placeholder {
    color: var(--law-ink-faint, #9a908a);
}

#tocFilter:focus {
    border-color: var(--law-ink-faint, #9a908a);
    outline-offset: 1px;
}

.lr-rail__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--law-ink-muted, #6b615c);
}

.lr-rail__count {
    font-variant-numeric: tabular-nums;
}

.lr-rail__minibtn {
    font: inherit;
    font-size: 12px;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--law-radius-sm);
    background: transparent;
    color: var(--law-ink-muted, #6b615c);
    cursor: pointer;
}

.lr-rail__minibtn:hover {
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink, #1a1614);
}

#sidebarContent {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 32px;
    scrollbar-width: thin;
}

#sidebarContent::-webkit-scrollbar {
    width: 8px;
}

#sidebarContent::-webkit-scrollbar-thumb {
    background: var(--law-line-strong, #d6cfc9);
    border-radius: 4px;
}

#sidebarContent::-webkit-scrollbar-thumb:hover {
    background: var(--law-ink-faint, #9a908a);
}

/* Collapsed rail: a 44px re-open gutter, not `width: 0` as before. */
.lr-body.is-rail-collapsed .lr-rail {
    padding-inline-end: 0;
    align-items: center;
}

.lr-body.is-rail-collapsed .lr-rail__head,
.lr-body.is-rail-collapsed #sidebarContent {
    display: none;
}

.lr-rail__reopen {
    display: none;
    margin-top: 18px;
    writing-mode: vertical-rl;
    padding: 14px 6px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius-pill);
    background: var(--law-paper, #fffdfb);
    font: inherit;
    font-size: 12px;
    color: var(--law-ink-muted, #6b615c);
    cursor: pointer;
}

.lr-body.is-rail-collapsed .lr-rail__reopen {
    display: block;
}

/* --- TOC tree -------------------------------------------------------------
   Indentation comes from `--depth` on the <li>, not from a `data-level`
   selector: real `level` values in the corpus reach the 80s, and the old
   CSS only styled 0–4, so everything deeper silently flattened to the root. */
.toc-tree,
.toc-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
    /* The rail can carry thousands of rows even after pruning. */
    content-visibility: auto;
    contain-intrinsic-size: auto 34px;
}

.toc-row {
    display: flex;
    align-items: flex-start;
    gap: 2px;
    border-inline-start: 3px solid transparent;
}

.toc-toggle {
    flex: none;
    width: 22px;
    height: 30px;
    margin-inline-start: calc(2px + min(var(--depth, 0), 5) * 14px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--law-ink-faint, #9a908a);
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
}

.toc-toggle:hover {
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink, #1a1614);
}

.toc-toggle::before {
    content: "\25B6";
    transition: transform .15s var(--law-ease);
}

.toc-item.expanded > .toc-row > .toc-toggle::before {
    transform: rotate(90deg);
}

/* A leaf keeps the toggle's footprint so its text lines up with its siblings. */
.toc-row.is-leaf::before {
    content: "";
    flex: none;
    width: 22px;
    margin-inline-start: calc(2px + min(var(--depth, 0), 5) * 14px);
}

.toc-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 6px 8px;
    border-radius: var(--law-radius-sm);
    color: var(--law-ink-soft, #443c38);
    font-size: 13px;
    line-height: 1.45;
    text-decoration: none;
}

.toc-link:hover {
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink, #1a1614);
}

.toc-num {
    flex: none;
    max-width: 5.5em;
    font-family: var(--law-font-mono);
    font-size: 11.5px;
    color: var(--law-ink-faint, #9a908a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toc-text {
    flex: 1 1 auto;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.toc-item[data-level="0"] > .toc-row > .toc-link {
    font-weight: 600;
    color: var(--law-ink, #1a1614);
}

.toc-row:has(.toc-link.active),
.toc-item > .toc-row > .toc-link.active {
    color: var(--law-void, #8b0000);
    font-weight: 600;
}

.toc-link.active {
    background: var(--law-void-bg, #fdf3f2);
}

.toc-row:has(> .toc-link.active) {
    border-inline-start-color: var(--law-void, #8b0000);
}

.toc-children {
    display: none;
}

.toc-item.expanded > .toc-children {
    display: block;
}

.toc-item.is-filtered-out {
    display: none;
}

/* --------------------------------------------------------------------------
   5. Reading column
   -------------------------------------------------------------------------- */
.lr-column {
    min-width: 0;
    padding: 26px 0 0 44px;
    font-size: var(--lr-read-size);
    line-height: var(--lr-read-lh);
    color: var(--law-ink, #1a1614);
}

.law-reader.lr-focus .lr-column {
    padding-inline-start: 0;
    margin: 0 auto;
}

/* Everything in the column obeys one measure. */
.lr-column > * {
    max-width: min(var(--lr-measure), 100%);
}

.law-reader.lr-wide {
    --lr-measure: 92ch;
}

/* The 3px gold edge repeats the docbar's signal at the text itself, so a
   screenshot of the text alone still says "this is not today's version". */
.lr-column.is-point-in-time {
    border-top: 3px solid var(--law-anchor, #f2c93e);
    padding-top: 23px;
}

/* --- Masthead ------------------------------------------------------------- */
.lr-masthead {
    margin-bottom: 30px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

.lr-h1 {
    margin: 0 0 10px;
    font-size: clamp(23px, 1.35em, 30px);
    font-weight: 680;
    line-height: 1.28;
    letter-spacing: -.012em;
    color: var(--law-ink, #1a1614);
    text-wrap: pretty;
}

.lr-h1-kk {
    margin: 0 0 14px;
    font-size: .84em;
    line-height: 1.5;
    color: var(--law-ink-muted, #6b615c);
}

.lr-h1-kk__lang {
    display: inline-block;
    margin-inline-end: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--law-ink-faint, #9a908a);
}

.lr-identity {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: .8em;
    color: var(--law-ink-muted, #6b615c);
}

.lr-identity .lr-dot {
    color: var(--law-ink-faint, #9a908a);
}

.lr-freshness {
    margin: 0;
    font-size: .76em;
    color: var(--law-ink-faint, #9a908a);
}

/* --- Requisites disclosure («О документе») -------------------------------- */
.lr-about {
    margin-top: 16px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius);
    background: var(--law-paper, #fffdfb);
}

.lr-about > summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 15px;
    font-size: .8em;
    font-weight: 600;
    color: var(--law-ink-soft, #443c38);
    cursor: pointer;
    list-style: none;
    border-radius: var(--law-radius);
}

.lr-about > summary::-webkit-details-marker {
    display: none;
}

.lr-about > summary::after {
    content: "\25BE";
    margin-inline-start: auto;
    font-size: 11px;
    color: var(--law-ink-faint, #9a908a);
    transition: transform .15s var(--law-ease);
}

.lr-about[open] > summary::after {
    transform: rotate(180deg);
}

.lr-about > summary:hover {
    background: var(--law-sunken, #f0ede9);
}

.lr-dl {
    display: grid;
    grid-template-columns: minmax(140px, 34%) minmax(0, 1fr);
    gap: 0;
    margin: 0;
    padding: 4px 15px 14px;
    font-size: .8em;
    line-height: 1.55;
}

.lr-dl dt {
    padding: 7px 12px 7px 0;
    font-weight: 500;
    color: var(--law-ink-muted, #6b615c);
    border-top: 1px solid var(--law-line, #e7e2de);
}

.lr-dl dd {
    margin: 0;
    padding: 7px 0;
    color: var(--law-ink, #1a1614);
    border-top: 1px solid var(--law-line, #e7e2de);
    overflow-wrap: anywhere;
}

.lr-dl dt:first-of-type,
.lr-dl dt:first-of-type + dd {
    border-top: 0;
}

.lr-dl .is-mono {
    font-family: var(--law-font-mono);
    font-size: .93em;
}

.lr-tagchips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lr-tagchip {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: var(--law-radius-pill);
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink-soft, #443c38);
    font-size: .92em;
    text-decoration: none;
}

.lr-tagchip:hover {
    background: var(--law-line, #e7e2de);
    color: var(--law-ink, #1a1614);
}

/* --- Section blocks ------------------------------------------------------- */
.section-block {
    position: relative;
    margin-bottom: 4px;
    scroll-margin-top: calc(var(--lr-sticky-h) + 14px);
}

/* Virtualisation is OPT-IN, applied by the server only to acts with enough
   sections to need it (`.is-virtualized`, see law_detail.html).
   `content-visibility: auto` makes the browser reserve `contain-intrinsic-size`
   for every block it has not laid out yet — on a five-section act that is a
   screen of blank paper between every paragraph, which is exactly what it
   looked like when this was unconditional. Reset in @media print. */
.lr-column.is-virtualized .section-block {
    content-visibility: auto;
    contain-intrinsic-size: auto 320px;
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 26px 0 8px;
    font-size: 1.06em;
    font-weight: 650;
    line-height: 1.4;
    color: var(--law-ink, #1a1614);
    scroll-margin-top: calc(var(--lr-sticky-h) + 14px);
    break-after: avoid;
}

.section-block:first-child .section-title,
.lr-masthead + .section-block .section-title {
    margin-top: 0;
}

.section-title:focus {
    outline: none;
}

.section-num {
    flex: none;
    font-family: var(--law-font-mono);
    font-size: .82em;
    font-weight: 600;
    color: var(--law-void, #8b0000);
    letter-spacing: -.01em;
}

.section-name {
    min-width: 0;
}

.section-content {
    color: var(--law-ink-soft, #443c38);
    overflow-wrap: break-word;
}

/* `|linebreaks` emits <p>; collapse the doubled margins it brings. */
.section-content p {
    margin: 0;
}

.section-content p + p {
    margin-top: .9em;
}

/* Act text arrives with trailing blank lines, and `|linebreaks` turns each one
   into an empty <p> that still claims a line box plus its own top margin. */
.section-content p:empty {
    display: none;
}

.section-content a {
    color: var(--law-link, #1d4ed8);
    text-underline-offset: 2px;
}

/* Arrival by anchor — a 1.2s wash instead of the old inline style mutation. */
.section-block.is-flash > .section-title,
.section-block:target > .section-title {
    animation: lr-flash 1.2s var(--law-ease);
}

@keyframes lr-flash {
    from {
        background: rgba(242, 201, 62, .34);
        box-shadow: 0 0 0 6px rgba(242, 201, 62, .34);
    }
    to {
        background: transparent;
        box-shadow: 0 0 0 6px transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .section-block.is-flash > .section-title,
    .section-block:target > .section-title {
        animation: none;
        background: rgba(242, 201, 62, .22);
    }
}

/* Clamp for the pathological nodes — a single row in the corpus reaches ~7.9 MB. */
.lr-clamp {
    position: relative;
    max-height: 60vh;
    overflow: hidden;
}

.lr-clamp.is-open {
    max-height: none;
}

.lr-clamp::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 90px;
    background: linear-gradient(to bottom, rgba(255, 253, 251, 0), var(--law-paper, #fffdfb));
    pointer-events: none;
}

.lr-clamp.is-open::after {
    display: none;
}

.lr-clamp__more {
    margin-top: 10px;
}

/* --- Per-section apparatus ------------------------------------------------
   Revealed on hover/focus-within in CSS only. One delegated listener handles
   every action for the whole document; there is never a listener per node. */
/* Absolutely positioned, not in flow. Hidden-but-in-flow (`opacity: 0` on a
   static row) reserved ~30px of blank space under EVERY section, which read as
   a paragraph gap the size of a line and a half — the single biggest source of
   the "why is this so airy" look. It floats in the column's own right padding
   now and costs nothing when nobody is hovering. */
.lr-apparatus {
    position: absolute;
    top: -2px;
    inset-inline-end: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius-pill);
    background: var(--law-paper, #fffdfb);
    box-shadow: var(--law-shadow-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s var(--law-ease);
}

.section-block:hover .lr-apparatus,
.section-block:focus-within .lr-apparatus {
    opacity: 1;
    pointer-events: auto;
}

.lr-apparatus button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font: inherit;
    font-size: 12px;
    padding: 4px 9px;
    border: 0;
    border-radius: var(--law-radius-sm);
    background: transparent;
    color: var(--law-ink-faint, #9a908a);
    cursor: pointer;
}

.lr-apparatus button:hover {
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink, #1a1614);
}

.lr-apparatus i {
    font-size: 13px;
}

/* Hover does not exist on touch. There the cluster returns to the flow as a
   quiet row under the section — floating it would sit under the reader's
   thumb and over the text. */
@media (hover: none) {
    .lr-apparatus {
        position: static;
        margin-top: 6px;
        border: 0;
        background: transparent;
        box-shadow: none;
        opacity: 1;
        pointer-events: auto;
    }
}

/* --- Next steps ----------------------------------------------------------- */
.lr-next-steps {
    margin-top: 48px;
    padding-top: 22px;
    border-top: 1px solid var(--law-line, #e7e2de);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .82em;
}

.lr-replacement {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: 100%;
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid var(--law-void-line, #f0d4d1);
    border-inline-start: 4px solid var(--law-void, #8b0000);
    border-radius: var(--law-radius);
    background: var(--law-void-bg, #fdf3f2);
    color: #6d1512;
    text-decoration: none;
    line-height: 1.55;
}

.lr-replacement:hover {
    background: #fbeae8;
    color: #6d1512;
}

.lr-replacement i {
    font-size: 18px;
    flex: none;
}

/* --------------------------------------------------------------------------
   5b. Redaction timeline (law_version_history)
   -------------------------------------------------------------------------- */
.lr-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lr-timeline__item {
    position: relative;
    display: flex;
    gap: 16px;
    padding-bottom: 26px;
}

/* The spine, drawn between markers rather than as a background image so the
   last item does not trail a line into nothing. */
.lr-timeline__item:not(:last-child)::before {
    content: "";
    position: absolute;
    inset-inline-start: 6px;
    top: 20px;
    bottom: 0;
    width: 2px;
    background: var(--law-line, #e7e2de);
}

.lr-timeline__marker {
    flex: none;
    width: 14px;
    height: 14px;
    margin-top: 5px;
    border-radius: 50%;
    border: 2px solid var(--law-line-strong, #d6cfc9);
    background: var(--law-paper, #fffdfb);
    z-index: 1;
}

.lr-timeline__item.is-current .lr-timeline__marker {
    border-color: var(--law-force-ink, #0f7a54);
    background: var(--law-force-ink, #0f7a54);
    box-shadow: 0 0 0 4px var(--law-force-bg, #ecfdf5);
}

.lr-timeline__body {
    flex: 1 1 auto;
    min-width: 0;
}

.lr-timeline__head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.lr-timeline__date {
    font-size: 1.02em;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--law-ink, #1a1614);
    text-decoration: none;
}

.lr-timeline__date:hover {
    color: var(--law-void, #8b0000);
    text-decoration: underline;
}

.lr-timeline__reason {
    margin: 5px 0 0;
    font-size: .84em;
    line-height: 1.6;
    color: var(--law-ink-muted, #6b615c);
}

.lr-timeline__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 11px;
    font-size: .84em;
}

.lr-deltas {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.lr-delta {
    font-size: .76em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 3px 9px;
    border-radius: var(--law-radius-pill);
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink-muted, #6b615c);
}

.lr-delta.is-added {
    background: var(--law-force-bg, #ecfdf5);
    color: var(--law-force-ink, #0f7a54);
}

.lr-delta.is-removed {
    background: var(--law-void-bg, #fdf3f2);
    color: var(--law-void, #8b0000);
}

.lr-delta.is-changed {
    background: var(--law-anchor-bg, #fffbef);
    color: var(--law-anchor-ink, #8a6510);
}

/* --------------------------------------------------------------------------
   6. Revisions drawer
   -------------------------------------------------------------------------- */
/* Above .header-main, which style.css puts at z-index 1000. At the drawer's
   original z-index 60 the site header painted straight over the top of the
   panel — its title row and close button were simply not there. */
.lr-scrim {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(26, 22, 20, .42);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s var(--law-ease), visibility .2s;
}

.lr-scrim.is-open {
    opacity: 1;
    visibility: visible;
}

.lr-drawer {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    z-index: 1060;
    width: min(480px, 100vw);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--law-paper, #fffdfb);
    border-inline-start: 1px solid var(--law-line, #e7e2de);
    box-shadow: var(--law-shadow-lg);
    transform: translateX(100%);
    transition: transform .24s var(--law-ease);
}

/* `[hidden]` is what keeps the closed drawer out of the tab order and out of
   the accessibility tree; the transform alone would not. */
.lr-drawer[hidden] {
    display: none;
}

.lr-drawer.is-open {
    transform: translateX(0);
}

[dir="rtl"] .lr-drawer {
    transform: translateX(-100%);
}

[dir="rtl"] .lr-drawer.is-open {
    transform: translateX(0);
}

.lr-drawer__head {
    flex: none;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

.lr-drawer__titlerow {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lr-drawer__title {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
    color: var(--law-ink, #1a1614);
}

.lr-drawer__count {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    padding: 2px 8px;
    border-radius: var(--law-radius-pill);
    background: var(--law-sunken, #f0ede9);
    color: var(--law-ink-muted, #6b615c);
}

.lr-drawer__close {
    margin-inline-start: auto;
}

.lr-drawer__note {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--law-ink-muted, #6b615c);
}

.lr-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.lr-drawer__section {
    padding: 14px 18px;
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

.lr-drawer__label {
    display: block;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--law-ink-faint, #9a908a);
}

.lr-asof-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lr-asof-form input[type="date"] {
    flex: 1 1 150px;
    min-width: 0;
    padding: 8px 11px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius-sm);
    background: var(--law-paper, #fffdfb);
    font: inherit;
    font-size: 13.5px;
    color: var(--law-ink, #1a1614);
}

#revisionDateSearch {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--law-line, #e7e2de);
    border-radius: var(--law-radius-sm);
    background: var(--law-paper, #fffdfb);
    font: inherit;
    font-size: 13.5px;
    color: var(--law-ink, #1a1614);
}

.lr-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* --- Revision rows -------------------------------------------------------- */
.revision-year-group {
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

.revision-year-group[open] > .revision-year-header {
    border-bottom: 1px solid var(--law-line, #e7e2de);
}

.revision-year-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: var(--law-sunken, #f0ede9);
    font-size: 12.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--law-ink-soft, #443c38);
    cursor: pointer;
    list-style: none;
}

.revision-year-header::-webkit-details-marker {
    display: none;
}

.revision-year-header::after {
    content: "\25BE";
    margin-inline-start: auto;
    font-size: 10px;
    color: var(--law-ink-faint, #9a908a);
    transition: transform .15s var(--law-ease);
}

.revision-year-group[open] > .revision-year-header::after {
    transform: rotate(180deg);
}

.revision-year-count {
    font-weight: 500;
    color: var(--law-ink-faint, #9a908a);
}

.revision-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--law-line, #e7e2de);
    transition: background-color .12s var(--law-ease);
}

.revision-item:last-child {
    border-bottom: 0;
}

.revision-item:hover {
    background: var(--law-sunken, #f0ede9);
}

.revision-item.is-current-view {
    background: var(--law-void-bg, #fdf3f2);
    box-shadow: inset 3px 0 0 var(--law-void, #8b0000);
}

.revision-item.is-hidden {
    display: none;
}

/* Read mode: no checkboxes at all. They appear only in selection mode, so an
   ordinary "open this redaction" click cannot accidentally start a comparison. */
.revision-checkbox {
    flex: none;
    margin-top: 3px;
    accent-color: var(--law-void, #8b0000);
    cursor: pointer;
    display: none;
}

.lr-drawer.is-selecting .revision-checkbox {
    display: inline-block;
}

.revision-content {
    flex: 1 1 auto;
    min-width: 0;
}

.revision-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--law-ink, #1a1614);
}

.revision-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--law-radius-pill);
    background: var(--law-force-bg, #ecfdf5);
    color: var(--law-force-ink, #0f7a54);
}

.revision-changes {
    margin-top: 3px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--law-ink-muted, #6b615c);
}

.revision-link {
    display: inline-block;
    margin-top: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--law-link, #1d4ed8);
    text-decoration: none;
}

.revision-link:hover {
    text-decoration: underline;
}

.lr-drawer.is-selecting .revision-link {
    pointer-events: none;
    opacity: .45;
}

/* --- Compare bar ---------------------------------------------------------- */
.lr-drawer__foot {
    flex: none;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--law-line, #e7e2de);
    background: var(--law-paper, #fffdfb);
    display: grid;
    gap: 9px;
}

.lr-comparebar {
    display: none;
    align-items: center;
    gap: 10px;
}

.lr-drawer.is-selecting .lr-comparebar {
    display: flex;
}

.lr-comparebar__status {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--law-ink-muted, #6b615c);
}

.lr-comparebar.is-refused {
    animation: lr-shake .28s var(--law-ease);
}

@keyframes lr-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* --------------------------------------------------------------------------
   7. Mobile bar and off-canvas sheets
   -------------------------------------------------------------------------- */
.lr-mobilebar {
    display: none;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 1040;
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--law-line, #e7e2de);
    background: rgba(255, 253, 251, .96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lr-mobilebar__inner {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: 56px;
}

.lr-mobilebar button,
.lr-mobilebar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 11px;
    color: var(--law-ink-muted, #6b615c);
    text-decoration: none;
    cursor: pointer;
}

.lr-mobilebar button i,
.lr-mobilebar a i {
    font-size: 17px;
}

.lr-mobilebar button[aria-expanded="true"] {
    color: var(--law-void, #8b0000);
}

/* --------------------------------------------------------------------------
   8. Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1399px) {
    .law-reader {
        --lr-gutter: 32px;
    }
}

@media (max-width: 1199px) {
    .law-reader {
        --lr-rail-w: 260px;
        --lr-gutter: 26px;
    }

    .lr-column {
        padding-inline-start: 30px;
    }

    .lr-drawer {
        width: min(420px, 100vw);
    }
}

@media (max-width: 991px) {
    .law-reader {
        --lr-gutter: 20px;
    }

    .lr-body {
        grid-template-columns: minmax(0, 1fr);
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .lr-column {
        padding: 22px 0 0;
    }

    /* The rail becomes a left sheet. */
    .lr-rail {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        /* Same reason as .lr-drawer: over .header-main's z-index 1000. */
        z-index: 1060;
        width: min(85vw, 360px);
        height: 100dvh;
        padding: 0 16px;
        border-inline-end: 1px solid var(--law-line, #e7e2de);
        background: var(--law-paper, #fffdfb);
        box-shadow: var(--law-shadow-lg);
        transform: translateX(-100%);
        transition: transform .24s var(--law-ease);
    }

    .lr-rail.is-open {
        transform: translateX(0);
    }

    .lr-rail__reopen,
    #collapseSidebar {
        display: none;
    }

    .lr-mobilebar {
        display: block;
    }

    .lr-docbar__identity {
        min-height: 46px;
        padding: 7px 0;
    }

    .lr-docbar__meta {
        display: none;
    }

    .lr-crumb {
        display: none;
    }

    .lr-chip {
        max-width: 60%;
    }
}

@media (max-width: 767px) {
    .law-reader {
        --lr-read-size: 16px;
        --lr-read-lh: 1.65;
        --lr-gutter: 16px;
    }

    .lr-docbar__version {
        min-height: 46px;
        gap: 6px;
    }

    /* Below 768 the drawer is a bottom sheet — a side sheet at this width is a
       full-screen modal wearing the wrong animation. */
    .lr-drawer {
        top: auto;
        bottom: 0;
        inset-inline: 0;
        width: 100%;
        height: auto;
        max-height: 85dvh;
        border-inline-start: 0;
        border-top: 1px solid var(--law-line, #e7e2de);
        border-radius: var(--law-radius-lg) var(--law-radius-lg) 0 0;
        transform: translateY(100%);
    }

    .lr-drawer.is-open,
    [dir="rtl"] .lr-drawer.is-open {
        transform: translateY(0);
    }

    [dir="rtl"] .lr-drawer {
        transform: translateY(100%);
    }

    .lr-dl {
        grid-template-columns: minmax(0, 1fr);
    }

    .lr-dl dt {
        padding-bottom: 0;
        border-top: 0;
        padding-top: 10px;
    }

    .lr-dl dd {
        padding-top: 2px;
        border-top: 0;
    }

    .lr-tools .lr-hide-sm {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   9. Print
   The family had no @media print at all, behind a Print button that dumped a
   clipped scroll pane plus the whole site chrome onto paper.
   -------------------------------------------------------------------------- */
.lr-print-masthead {
    display: none;
}

@media print {
    @page {
        margin: 18mm 16mm;
    }

    .law-reader {
        background: #fff;
        font-size: 11pt;
    }

    header.header-main,
    .footer,
    .lr-docbar,
    .lr-rail,
    .lr-drawer,
    .lr-scrim,
    .lr-mobilebar,
    .lr-apparatus,
    .lr-next-steps,
    .lr-progress,
    .law-toast,
    .law-skip,
    .ai-chat-widget,
    #aiChatWidget {
        display: none !important;
    }

    .lr-print-masthead {
        display: block;
        margin-bottom: 16pt;
        padding-bottom: 10pt;
        border-bottom: 1pt solid #666;
        font-size: 9.5pt;
        line-height: 1.45;
    }

    .lr-print-masthead h1 {
        font-size: 14pt;
        line-height: 1.3;
        margin: 0 0 6pt;
    }

    .lr-print-masthead__url {
        word-break: break-all;
        color: #444;
    }

    .lr-body {
        display: block;
        max-width: none;
        padding: 0;
    }

    .lr-column {
        padding: 0;
        font-size: 11pt;
        line-height: 1.45;
    }

    .lr-column > * {
        max-width: none;
    }

    .lr-masthead {
        display: none;
    }

    /* Non-negotiable: without this, every section still off-screen when the
       print job starts is silently omitted from the paper. */
    .section-block,
    .lr-column.is-virtualized .section-block {
        content-visibility: visible !important;
        contain-intrinsic-size: none !important;
        margin-bottom: 10pt;
    }

    .section-title {
        margin: 14pt 0 5pt;
        font-size: 11.5pt;
        break-after: avoid;
    }

    .section-content {
        orphans: 3;
        widows: 3;
        color: #000;
    }

    /* The requisites are part of the record on paper, always. */
    .lr-about {
        display: block !important;
        border: 0;
        margin-top: 14pt;
    }

    .lr-about > summary {
        padding: 0 0 4pt;
        font-size: 10pt;
    }

    .lr-about > summary::after {
        display: none;
    }

    .lr-about .lr-dl {
        display: block;
        padding: 0;
    }

    .lr-about .lr-dl dt {
        border: 0;
        padding: 4pt 0 0;
        font-weight: 700;
    }

    .lr-about .lr-dl dd {
        border: 0;
        padding: 0;
    }

    /* Scoped to the panel — expanding every href in the act text would be
       unreadable. */
    .lr-about a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: .85em;
        color: #555;
    }

    .lr-clamp,
    .lr-clamp.is-open {
        max-height: none;
        overflow: visible;
    }

    .lr-clamp::after,
    .lr-clamp__more {
        display: none;
    }

    .toc-children {
        display: block;
    }

    /* Print scope — set by law-reader-print.js, cleared on afterprint. */
    .lr-print-scope-article .section-block:not(.is-print-target),
    .lr-print-scope-section .section-block:not(.is-print-target) {
        display: none !important;
    }
}
