/* /laws/ — the act register, direction «Досье».
 *
 * Loaded by templates/core/laws_list.html on top of law-shared.css, whose
 * tokens (--law-ink, --law-paper, --law-void, --law-force-ink …) this file
 * consumes and never redefines. Two rules the predecessor broke:
 *
 *  1. NOTHING here declares a `:root` block. The old page declared a private
 *     shadcn palette at `:root` inside {% block extra_css %}, which renders
 *     AFTER style.css and therefore won document-wide — including `--radius`,
 *     which style.css consumes in 19 places. It also made every filled control
 *     on this page near-black navy while the header above it was #730C0B.
 *
 *  2. Every class is namespaced `.ll-*` and scoped under `.law-page`.
 *     law-reader.css is linked alongside this file and its `.lr-*`,
 *     `.section-*`, `.toc-*` and `.revision-*` selectors are unscoped
 *     top-level names — reusing one here would restyle the act reader.
 *
 * Colour discipline is law-shared's, unchanged: dark red says NO LEGAL FORCE,
 * gold says force but not today's text, green says in force. None of the three
 * is ever spent on decoration, which is why the sort control, the facet
 * checkboxes and the pagination in here are ink and paper, not brand red.
 */

.law-page .ll-page {
  --ll-rail-w: 276px;
  --ll-gap: 28px;
  color: var(--law-ink);
  font-family: var(--law-font);
}

/* ------------------------------------------------------------------ header */

.law-page .ll-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin: 0 0 18px;
}

.law-page .ll-head h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.2rem + 1.4vw, 2.05rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--law-ink);
  text-wrap: balance;
}

.law-page .ll-head-meta {
  font-size: 0.8125rem;
  color: var(--law-ink-muted);
  padding-left: 16px;
  border-left: 1px solid var(--law-line-strong);
  line-height: 1.4;
}

.law-page .ll-head-meta strong {
  color: var(--law-ink-soft);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Status facets. Collapsed onto law-shared's `.law-chip` vocabulary — the page
 * used to carry a second, near-identical `.law-status-chip` set with a
 * different radius and a different selected colour. */
.law-page .ll-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.law-page .ll-superseded {
  margin: 0 0 18px;
}

/* ------------------------------------------------------------------ layout */

.law-page .ll-body {
  display: grid;
  grid-template-columns: var(--ll-rail-w) minmax(0, 1fr);
  gap: var(--ll-gap);
  align-items: start;
}

/* -------------------------------------------------------------- facet rail */

.law-page .ll-rail {
  position: sticky;
  /* navbar.js measures the real bar into --app-header-h and writes 0px on the
   * pages that drop the header. Never a constant: the predecessor's hard-coded
   * offset had been wrong since the header gained a nav item. */
  top: calc(var(--app-header-h, 0px) + 12px);
  /* The rail is taller than a viewport once every act form is listed, so it
   * scrolls inside itself rather than stranding the reset button off-screen. */
  max-height: calc(100vh - var(--app-header-h, 0px) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--law-paper);
  border: 1px solid var(--law-line);
  border-radius: var(--law-radius);
  box-shadow: var(--law-shadow-sm);
}

.law-page .ll-rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--law-line);
}

.law-page .ll-rail-head h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

/* Mobile-only disclosure. The button carries `hidden` in the markup and the
 * page script removes it below 992px, so the rail is open and the control is
 * absent when JavaScript is off. */
.law-page .ll-rail-toggle {
  margin-left: auto;
  padding: 4px 12px;
  border: 1px solid var(--law-line-strong);
  border-radius: var(--law-radius-pill);
  background: var(--law-paper);
  color: var(--law-ink-soft);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.law-page .ll-rail-toggle:hover {
  background: var(--law-sunken);
  color: var(--law-ink);
}

.law-page .ll-rail.is-collapsed .ll-groups {
  display: none;
}

.law-page .ll-reset {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--law-ink-muted);
  text-decoration: none;
}

.law-page .ll-reset:hover {
  color: var(--law-ink);
  text-decoration: underline;
}

.law-page .ll-group {
  padding: 14px 16px;
  border-bottom: 1px solid var(--law-line);
}

.law-page .ll-group:last-of-type {
  border-bottom: 0;
}

.law-page .ll-group-title {
  margin: 0 0 10px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--law-ink-muted);
}

.law-page .ll-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* The whole option is a <label>, so the native click target covers the text
 * and the count. Do NOT add a JS click handler that toggles the input: with a
 * real label it fires after the native toggle and flips it straight back —
 * the exact bug the catalogue chips shipped. */
.law-page .ll-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 9px;
  padding: 5px 6px;
  margin: 0 -6px;
  border-radius: var(--law-radius-sm);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--law-ink-soft);
  cursor: pointer;
}

.law-page .ll-option:hover {
  background: var(--law-sunken);
  color: var(--law-ink);
}

/* Visible, not `display: none`. A hidden input is unreachable from a keyboard,
 * which is what made the catalogue's filter chips untabbable. */
.law-page .ll-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--law-ink-soft);
  transform: translateY(2px);
}

.law-page .ll-option-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--law-ink-faint);
}

.law-page .ll-option-note {
  grid-column: 2 / -1;
  font-size: 0.75rem;
  color: var(--law-ink-faint);
  line-height: 1.35;
}

.law-page .ll-field {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--law-line-strong);
  border-radius: var(--law-radius-sm);
  background: var(--law-paper);
  color: var(--law-ink);
  font: inherit;
  font-size: 0.875rem;
}

.law-page .ll-field:focus {
  border-color: var(--law-ink-soft);
  outline: none;
}

.law-page .ll-rail-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--law-line);
  background: var(--law-paper);
}

.law-page .ll-fulltext {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--law-link);
  text-decoration: none;
  text-align: center;
}

.law-page .ll-fulltext:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ results */

.law-page .ll-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin: 0 0 12px;
}

.law-page .ll-count {
  font-size: 0.875rem;
  color: var(--law-ink-muted);
}

.law-page .ll-count strong {
  color: var(--law-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.law-page .ll-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--law-ink-muted);
}

/* A short, quiet band that names what the ° marks mean and what «редакция не
 * отслеживается» means. It is the page telling the reader where its knowledge
 * stops, which on a legal database is content, not chrome. */
.law-page .ll-legend {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--law-line);
  border-radius: var(--law-radius-sm);
  background: var(--law-sunken);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--law-ink-muted);
}

.law-page .ll-legend b {
  color: var(--law-ink-soft);
  font-weight: 600;
}

.law-page .ll-rows {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--law-line);
  border-radius: var(--law-radius);
  background: var(--law-paper);
  overflow: hidden;
}

/* -------------------------------------------------------------------- a row */

.law-page .ll-row {
  position: relative;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 0 22px;
  padding: 18px 22px;
  border-top: 1px solid var(--law-line);
  /* The legal-force stripe. Width is deliberate: at 3px it reads as a state,
   * at 1px it reads as a table rule. */
  border-left: 3px solid transparent;
}

.law-page .ll-row:first-child {
  border-top: 0;
}

.law-page .ll-row:hover {
  background: var(--law-sunken);
}

/* Deliberately NOT `.is-in-force` / `.is-repealed`: those exact words follow
 * `law-status-badge` in the badge partial, and a test asserts that the string
 * `law-status-badge is-in-force` appears nowhere on a repealed listing. Two
 * vocabularies that differ by a space are a trap; these have their own names. */
.law-page .ll-row.ll-force {
  border-left-color: var(--law-force-ink);
}

.law-page .ll-row.ll-void {
  border-left-color: var(--law-void);
}

.law-page .ll-row.ll-pending {
  border-left-color: var(--law-anchor);
}

.law-page .ll-row.ll-unknown {
  border-left-color: var(--law-line-strong);
}

/* Identity column: what kind of act this is and whose it is. */
.law-page .ll-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.law-page .ll-identity .law-type-label {
  /* law-shared already styles this; only the block placement is ours. */
  align-self: flex-start;
}

.law-page .ll-level {
  color: var(--law-ink-muted);
}

.law-page .ll-territory {
  color: var(--law-ink-faint);
  font-size: 0.75rem;
}

/* Main column. */
.law-page .ll-main {
  min-width: 0;
}

.law-page .ll-title {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.42;
  /* Real ЭКБ titles run 200-370 characters and the distinguishing part lives
   * at the END («…в приказ … от 30 апреля 2021 года № 156/НҚ «Об утверждении
   * Правил…»»), so this clamps generously rather than to one line. */
  text-wrap: pretty;
}

.law-page .ll-title a {
  color: var(--law-ink);
  text-decoration: none;
}

/* Stretched link: the whole row is clickable, but the row is NOT one big <a>,
 * so the secondary links inside it (the amended act, «редакции») stay real
 * links. The predecessor wrapped the card in an anchor and had to kill
 * pointer events on everything inside. */
.law-page .ll-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
}

.law-page .ll-row:hover .ll-title a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.law-page .ll-title-caps {
  /* Part of the corpus is stored ALL CAPS. Never `text-transform` it back —
   * that would destroy «Республики Казахстан» and «НҚ» — just stop it
   * shouting louder than its neighbours. */
  font-size: 0.875rem;
  letter-spacing: 0.005em;
}

.law-page .ll-facts {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.law-page .ll-facts dt {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--law-ink-faint);
  padding-top: 2px;
}

.law-page .ll-facts dd {
  margin: 0;
  min-width: 0;
  color: var(--law-ink-soft);
}

.law-page .ll-requisites {
  color: var(--law-ink-soft);
}

.law-page .ll-num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Relation to another act. The label is a chip because it is a category
 * («вносит изменения»), the target is running text because it is a citation. */
.law-page .ll-relation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.law-page .ll-relation-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--law-radius-pill);
  border: 1px solid var(--law-anchor-line);
  background: var(--law-anchor-bg);
  color: var(--law-anchor-ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Redaction. `.is-untracked` is not a warning, it is an absence: we have no
 * ingested redaction for this act, which is different from "never amended". */
.law-page .ll-redaction {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.law-page .ll-redaction-date {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.law-page .ll-untracked {
  color: var(--law-ink-faint);
  font-style: italic;
}

/* The registry marker: this fact is missing from our copy of the row, not
 * from the act. Rendered as a superscript ring, explained once in .ll-legend. */
.law-page .ll-gap {
  color: var(--law-ink-faint);
  font-size: 0.6875rem;
  vertical-align: super;
  line-height: 0;
}

.law-page .ll-kk {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--law-ink-faint);
}

.law-page .ll-kk-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: var(--law-radius-sm);
  border: 1px solid var(--law-line-strong);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Secondary links must sit above the stretched-link pseudo-element or they
 * are unclickable. */
.law-page .ll-row a:not(.ll-title a) {
  position: relative;
  z-index: 1;
  color: var(--law-link);
  text-decoration: none;
}

.law-page .ll-row a:not(.ll-title a):hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------- empty & foot */

.law-page .ll-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--law-ink-muted);
}

.law-page .ll-empty h2 {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--law-ink);
}

.law-page .ll-empty p {
  margin: 0;
  font-size: 0.875rem;
}

.law-page .laws-pagination-section {
  margin: 22px 0 8px;
}

.law-page .ll-pagefoot {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--law-ink-faint);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 991.98px) {
  .law-page .ll-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .law-page .ll-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 575.98px) {
  .law-page .ll-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 16px 14px;
  }

  /* The identity column becomes a wrapping strip above the title rather than
   * a 178px column squeezed into a 390px screen. */
  .law-page .ll-identity {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }

  .law-page .ll-facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .law-page .ll-facts dt {
    padding-top: 6px;
  }

  .law-page .ll-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
