/* ============================================================================
   IDB Branch Wiki — prototype stylesheet
   Arabic-first, whole-page RTL, editorial reference-library aesthetic.
   Inherits brand primitives from tokens.css (linked before this file).
   Vanilla CSS only. Motion is CSS-driven; scroll-linked effects are
   progressive enhancements behind @supports and prefers-reduced-motion.
   ============================================================================ */

/* ---------------------------------------------------------------- reset-ish */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ar);
  font-size: 16px;
  line-height: 1.9;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }

/* Latin codes & English labels never break the RTL flow */
.code, .latin {
  font-family: var(--font-ui);
  direction: ltr;
  unicode-bidi: isolate;
}

::selection { background: var(--idb-red-tint); color: var(--idb-red-dark); }

:focus-visible {
  outline: 2px solid var(--idb-red);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------- layout */
.shell {
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 36px);
}

/* ------------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .shell {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.brand img { height: 34px; width: auto; }
.brand .brand-sep {
  width: 1px; height: 26px;
  background: var(--line);
}
.brand .brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--charcoal);
  white-space: nowrap;
}
.topnav {
  display: flex;
  gap: 4px;
  margin-inline-start: auto;
  font-size: 14.5px;
}
.topnav a {
  position: relative;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 500;
  border-radius: 7px;
  transition: color .18s ease, background-color .18s ease;
}
.topnav a::after {
  content: "";
  position: absolute;
  inset-inline: 12px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--idb-red);
  transform: scaleX(0);
  transform-origin: 100% 50%; /* draws from the right — RTL reading direction */
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}
.topnav a:hover { color: var(--ink); }
.topnav a:hover::after,
.topnav a[aria-current="page"]::after { transform: scaleX(1); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* mobile nav — <details> disclosure, no JS needed */
.mobnav { display: none; position: relative; margin-inline-start: auto; }
.mobnav summary {
  list-style: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--charcoal);
  transition: background-color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.mobnav summary::-webkit-details-marker { display: none; }
.mobnav summary:active { background: var(--bg); }
.mobnav .bars, .mobnav .bars::before, .mobnav .bars::after {
  content: "";
  display: block;
  width: 18px; height: 2px;
  border-radius: 2px;
  background: currentColor;
  position: relative;
  transition: translate .2s ease, rotate .2s ease, opacity .2s ease;
}
.mobnav .bars::before { position: absolute; top: -6px; }
.mobnav .bars::after  { position: absolute; top: 6px; }
.mobnav[open] .bars { background: transparent; }
.mobnav[open] .bars::before { top: 0; rotate: 45deg; }
.mobnav[open] .bars::after  { top: 0; rotate: -45deg; }
.mobnav-panel {
  position: fixed;
  top: 64px;
  inset-inline: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 24px 40px -24px rgb(20 20 20 / .25);
  padding: 8px 16px 14px;
  display: grid;
  animation: rise-in .28s cubic-bezier(.22, .8, .3, 1) both;
}
.mobnav-panel a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 10px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}
.mobnav-panel a:last-child { border-bottom: 0; }
.mobnav-panel a:active { background: var(--bg); }
.mobnav-panel a[aria-current="page"] { color: var(--idb-red-dark); font-weight: 700; }
.mobnav-panel a::after { content: "←"; color: var(--muted); font-size: 14px; }
.mobnav-panel a[aria-current="page"]::after { color: var(--idb-red); }

/* ------------------------------------------------- chevron brand ornament */
/* Double-chevron motif echoing the IDB logo mark; pure CSS. */
.chev {
  position: relative;
  display: inline-block;
  width: 22px; height: 22px;
  flex-shrink: 0;
}
.chev::before, .chev::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0 100%, 45% 0, 100% 0, 55% 100%);
}
.chev::before { background: var(--idb-red); translate: 5px 0; }
.chev::after  { background: var(--charcoal); translate: -5px 0; }

/* ---------------------------------------------------------------- hero (home) */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(720px 340px at 85% -60px, color-mix(in srgb, var(--idb-red-tint) 68%, transparent), transparent 70%),
    linear-gradient(180deg, var(--paper), var(--bg));
  border-bottom: 1px solid var(--line);
}
.hero-watermark {
  position: absolute;
  inset-inline-start: -90px;
  bottom: -120px;
  width: 420px; height: 420px;
  opacity: .05;
  pointer-events: none;
}
.hero-watermark::before, .hero-watermark::after {
  content: "";
  position: absolute; inset: 0;
  clip-path: polygon(0 100%, 45% 0, 100% 0, 55% 100%);
}
.hero-watermark::before { background: var(--idb-red); translate: 90px 0; }
.hero-watermark::after  { background: var(--charcoal); translate: -90px 0; }
.hero-inner {
  position: relative;
  padding-block: clamp(56px, 9vw, 104px) clamp(44px, 7vw, 84px);
  max-width: 780px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--idb-red-dark);
  letter-spacing: .01em;
}
.eyebrow::before {
  content: "";
  width: 26px; height: 2px;
  background: var(--idb-red);
  border-radius: 2px;
}
.hero h1 {
  margin-top: 14px;
  font-size: clamp(34px, 5.4vw, 52px);
  font-weight: 700;
  line-height: 1.35;
  color: var(--charcoal);
}
.hero .hero-sub {
  margin-top: 12px;
  font-size: clamp(16px, 2vw, 18.5px);
  color: var(--muted);
  max-width: 56ch;
}
.hero .hero-sub strong { color: var(--ink); font-weight: 700; }

/* big search */
.search-box {
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 8px 20px;
  max-width: 640px;
  box-shadow: 0 1px 2px rgb(20 20 20 / .04), 0 10px 34px -18px rgb(20 20 20 / .14);
  transition: border-color .2s ease, box-shadow .25s ease, translate .2s ease;
}
.search-box:focus-within {
  border-color: var(--idb-red);
  box-shadow: 0 0 0 4px var(--idb-red-tint), 0 14px 40px -18px rgb(224 0 40 / .22);
  translate: 0 -1px;
}
.search-box svg { flex-shrink: 0; color: var(--muted); transition: color .2s ease; }
.search-box:focus-within svg { color: var(--idb-red); }
.search-box input {
  flex: 1;
  border: 0;
  background: none;
  font: inherit;
  font-size: 17px;
  padding-block: 10px;
  color: var(--ink);
  outline: none;
}
.search-box input::placeholder { color: var(--muted); opacity: .8; }
.search-box .kbd {
  font-family: var(--font-ui);
  direction: ltr;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  background: var(--bg);
  flex-shrink: 0;
}
.search-hint {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--muted);
}
.search-hint a {
  color: var(--idb-red-dark);
  font-weight: 500;
  border-bottom: 1px dashed color-mix(in srgb, var(--idb-red) 40%, transparent);
  transition: border-color .18s ease;
}
.search-hint a:hover { border-bottom-style: solid; border-color: var(--idb-red); }

/* stats strip */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 34px;
  margin-top: 40px;
  font-size: 14px;
  color: var(--muted);
}
.stats .stat { display: flex; align-items: baseline; gap: 8px; }
.stats .stat b {
  font-size: 21px;
  font-weight: 700;
  color: var(--charcoal);
}
.stats .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  align-self: center;
  flex-shrink: 0;
}
.dot.full { background: var(--cov-full); }
.dot.stub { background: var(--cov-stub); }
.dot.none { background: var(--cov-none); }

/* ------------------------------------------------------------ section titles */
.section { padding-block: clamp(40px, 6vw, 64px) 0; }
.section:last-of-type { padding-bottom: clamp(48px, 7vw, 80px); }
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.section-head .chev { width: 16px; height: 16px; }
.section-head h2 {
  font-size: clamp(20px, 2.6vw, 24px);
  font-weight: 700;
  color: var(--charcoal);
}
.section-head .section-note {
  margin-inline-start: auto;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- unit cards */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.unit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 24px 20px;
  overflow: hidden;
  transition: translate .22s cubic-bezier(.4, 0, .2, 1), box-shadow .25s ease, border-color .2s ease;
}
.unit-card::before {
  /* thin brand rule that slides in on hover */
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--idb-red), var(--idb-red-dark));
  transform: scaleX(0);
  transform-origin: 100% 50%;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
.unit-card:hover {
  translate: 0 -4px;
  border-color: color-mix(in srgb, var(--idb-red) 22%, var(--line));
  box-shadow: 0 18px 44px -22px rgb(20 20 20 / .22);
}
.unit-card:hover::before { transform: scaleX(1); }
.unit-card .chev {
  width: 19px; height: 19px;
  transition: translate .25s cubic-bezier(.4, 0, .2, 1);
}
.unit-card:hover .chev { translate: -3px 0; } /* nudges "forward" in RTL */
.unit-card h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.5;
}
.unit-card .unit-en {
  font-family: var(--font-ui);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: end;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.unit-card .unit-count {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--muted);
}
.unit-card .unit-count b { color: var(--ink); font-weight: 700; }
.unit-card .go {
  color: var(--idb-red);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  translate: 4px 0;
  transition: opacity .2s ease, translate .25s cubic-bezier(.4, 0, .2, 1);
}
.unit-card:hover .go { opacity: 1; translate: 0 0; }

/* stacked coverage micro-bar */
.covbar {
  display: flex;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--cov-none-bg);
}
.covbar i { display: block; height: 100%; }
.covbar .full { background: var(--cov-full); }
.covbar .stub { background: var(--cov-stub); }
.covbar .none { background: var(--cov-none-bg); }

/* ------------------------------------------------------------- browse panels */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.panel h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 6px;
}
.panel .panel-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 16px;
}
.chip-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--charcoal);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 14px;
  transition: border-color .18s ease, background-color .18s ease, color .18s ease, translate .18s ease;
}
.chip .n {
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--muted);
}
.chip:hover {
  border-color: var(--idb-red);
  background: var(--idb-red-tint);
  color: var(--idb-red-dark);
  translate: 0 -1px;
}
.chip:hover .n { color: var(--idb-red-dark); }
.chip.sys { font-family: var(--font-ui); direction: ltr; unicode-bidi: isolate; }

/* ------------------------------------------------------------------- footer */
.footer {
  margin-top: clamp(48px, 7vw, 80px);
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.footer .shell {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 36px;
  align-items: center;
  padding-block: 26px;
  font-size: 13px;
  color: var(--muted);
}
.footer .legend { display: flex; gap: 18px; flex-wrap: wrap; }
.footer .legend span { display: inline-flex; align-items: center; gap: 7px; }
.footer .foot-note { margin-inline-start: auto; }

/* ----------------------------------------------------------------- breadcrumb */
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding-block: 22px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.crumbs a { color: var(--muted); transition: color .15s ease; padding: 2px 4px; border-radius: 5px; }
.crumbs a:hover { color: var(--idb-red-dark); }
.crumbs .sep { color: var(--line); margin-inline: 2px; user-select: none; }
.crumbs .here { color: var(--ink); font-weight: 500; padding-inline: 4px; }

/* --------------------------------------------------------------- page header */
.page-head { padding-block: 26px 30px; }
.page-head .head-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 700;
  line-height: 1.4;
  color: var(--charcoal);
}
.page-head .head-en {
  font-family: var(--font-ui);
  direction: ltr;
  unicode-bidi: isolate;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .03em;
  color: var(--muted);
  margin-top: 4px;
  text-align: end;
}
.page-head .page-desc {
  margin-top: 12px;
  max-width: 68ch;
  color: var(--muted);
  font-size: 15.5px;
}
.head-covsummary {
  margin-inline-start: auto;
  min-width: 240px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 13px;
  color: var(--muted);
}
.head-covsummary .covbar { margin-block: 10px 12px; height: 8px; }
.head-covsummary .cov-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.head-covsummary .cov-legend span { display: inline-flex; align-items: center; gap: 6px; }
.head-covsummary .cov-total { font-size: 15px; color: var(--ink); font-weight: 700; }

/* -------------------------------------------------------------- filter chips */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.filters .chip[aria-pressed="true"] {
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: var(--paper);
}
.filters .chip[aria-pressed="true"] .n { color: rgb(255 255 255 / .7); }

/* ---------------------------------------------------------------- task list */
.tasklist {
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.task-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background-color .18s ease;
}
.tasklist li:last-child .task-row { border-bottom: 0; }
.task-row::before {
  /* accent bar that grows on hover */
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--idb-red);
  transform: scaleY(0);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}
a.task-row:hover { background: color-mix(in srgb, var(--bg) 62%, var(--paper)); }
a.task-row:hover::before { transform: scaleY(1); }
.task-row .code {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--charcoal);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  flex-shrink: 0;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
a.task-row:hover .code {
  background: var(--idb-red-tint);
  border-color: color-mix(in srgb, var(--idb-red) 30%, var(--line));
  color: var(--idb-red-dark);
}
.task-row .t {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.6;
}
.task-row .t small {
  display: block;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
}
.task-row .arr {
  color: var(--muted);
  opacity: 0;
  translate: 4px 0;
  transition: opacity .18s ease, translate .22s ease, color .18s ease;
}
a.task-row:hover .arr { opacity: 1; translate: 0 0; color: var(--idb-red); }

/* gap rows: dignified, quieter, not broken */
.task-row.is-stub .t, .task-row.is-none .t { font-weight: 400; }
.task-row.is-none { background: color-mix(in srgb, var(--bg) 45%, var(--paper)); }
.task-row.is-none .t { color: var(--muted); }
.task-row.is-none .code { opacity: .65; }

/* --------------------------------------------------------------- cov badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 20px;
  padding: 3px 12px;
  flex-shrink: 0;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.badge.full { color: var(--cov-full); background: var(--cov-full-bg); }
.badge.full::before { background: var(--cov-full); }
.badge.stub { color: var(--cov-stub); background: var(--cov-stub-bg); }
.badge.stub::before { background: var(--cov-stub); }
.badge.none { color: var(--cov-none); background: var(--cov-none-bg); }
.badge.none::before { background: var(--cov-none); }

/* ------------------------------------------------------------ task page ---- */
/* reading progress — scroll-driven, Chromium+ only; harmless elsewhere */
.progress {
  position: fixed;
  top: 0; inset-inline: 0;
  height: 3px;
  background: var(--idb-red);
  transform: scaleX(0);
  transform-origin: 100% 50%; /* fills from the right, matching RTL reading */
  z-index: 60;
  pointer-events: none;
}
@supports (animation-timeline: scroll()) {
  .progress {
    animation: progress-grow linear both;
    animation-timeline: scroll(root);
  }
}
@keyframes progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  padding-block: 8px 40px;
}
@media (max-width: 900px) {
  .task-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (min-width: 901px) {
  .toc-mobile { display: none; }
}

/* mobile TOC — sticky horizontal pill bar under the topbar (≤900px only) */
.toc-mobile {
  display: flex;
  position: sticky;
  top: 64px;
  z-index: 40;
  gap: 8px;
  overflow-x: auto;
  padding-block: 10px;
  margin-inline: calc(-1 * clamp(18px, 4vw, 36px));
  padding-inline: clamp(18px, 4vw, 36px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.toc-mobile::-webkit-scrollbar { display: none; }
.toc-mobile a {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
  transition: color .18s ease, border-color .18s ease, background-color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.toc-mobile a.active {
  color: var(--idb-red-dark);
  background: var(--idb-red-tint);
  border-color: color-mix(in srgb, var(--idb-red) 30%, var(--line));
  font-weight: 700;
}

/* article header */
.task-head {
  padding-block: 20px 26px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}
.task-head .task-meta-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.task-head .code {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--idb-red-dark);
  background: var(--idb-red-tint);
  border-radius: 7px;
  padding: 4px 12px;
}
.task-head h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  line-height: 1.5;
  color: var(--charcoal);
}
.task-head .task-en {
  font-family: var(--font-ui);
  direction: ltr;
  unicode-bidi: isolate;
  text-align: end;
  display: block;
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 6px;
}
.task-head .task-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.task-head .chip { font-size: 12.5px; padding: 3px 12px; }
.task-head .chip b { font-weight: 500; color: var(--muted); }

/* sticky TOC (inline-end column = left in RTL) */
.toc {
  position: sticky;
  top: 88px;
  font-size: 13.5px;
}
.toc .toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc ul { list-style: none; border-inline-start: 2px solid var(--line); }
.toc a {
  display: block;
  padding: 5px 14px;
  color: var(--muted);
  border-inline-start: 2px solid transparent;
  margin-inline-start: -2px;
  transition: color .16s ease, border-color .16s ease;
}
.toc a:hover { color: var(--ink); }
.toc a.active {
  color: var(--idb-red-dark);
  font-weight: 700;
  border-inline-start-color: var(--idb-red);
}

/* prose sections */
.prose section { margin-bottom: clamp(34px, 5vw, 48px); scroll-margin-top: 90px; }
.prose h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 16px;
}
.prose h2 .chev { width: 13px; height: 13px; }
.prose p { max-width: 70ch; }
.prose .lead {
  font-size: 17.5px;
  line-height: 2;
  color: var(--ink);
}

/* info card pair (executor / system) */
.info-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.info-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
}
.info-card .info-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}
.info-card .info-value { font-size: 15px; font-weight: 500; color: var(--ink); }

/* approvals ladder */
.ladder { list-style: none; position: relative; max-width: 72ch; }
.ladder::before {
  content: "";
  position: absolute;
  inset-block: 14px;
  inset-inline-start: 11px;
  width: 2px;
  background: linear-gradient(180deg, var(--line), color-mix(in srgb, var(--idb-red) 45%, var(--line)));
}
.ladder li {
  position: relative;
  padding-inline-start: 44px;
  padding-block: 10px;
}
.ladder li::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 22px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--cov-none);
  transition: border-color .2s ease;
}
.ladder li:nth-child(2)::before { border-color: var(--cov-stub); }
.ladder li:nth-child(3)::before { border-color: color-mix(in srgb, var(--idb-red) 60%, var(--cov-stub)); }
.ladder li:nth-child(n+4)::before { border-color: var(--idb-red); }
.ladder .rung-amount {
  display: inline-block;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--charcoal);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1px 12px;
  margin-bottom: 4px;
}
.ladder .rung-body { font-size: 15px; color: var(--ink); }

/* numbered steps */
.steps { list-style: none; counter-reset: step; position: relative; max-width: 74ch; }
.steps::before {
  content: "";
  position: absolute;
  inset-inline-start: 19px;
  top: 26px; bottom: 26px;
  width: 2px;
  background: var(--line);
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-inline-start: 60px;
  padding-block: 12px;
}
.steps li::before {
  content: counter(step, arabic-indic);
  position: absolute;
  inset-inline-start: 0;
  top: 10px;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--charcoal);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 50%;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.steps li:hover::before {
  border-color: var(--idb-red);
  color: var(--idb-red-dark);
  background: var(--idb-red-tint);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--idb-red-tint) 55%, transparent);
}
.steps li .step-body { font-size: 15.5px; }
.steps li .step-body .latin { font-size: .92em; }

/* checklist (documents) */
.checklist { list-style: none; max-width: 70ch; }
.checklist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-block: 8px;
  font-size: 15.5px;
}
.checklist li::before {
  content: "";
  flex-shrink: 0;
  width: 20px; height: 20px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1.5px solid var(--cov-full);
  background:
    center / 12px no-repeat
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%231b8a4c" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>'),
    var(--cov-full-bg);
}

/* limits tiers */
.limits { list-style: none; max-width: 72ch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.limits li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 12px 20px;
  font-size: 15px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.limits li:last-child { border-bottom: 0; }
.limits li:nth-child(even) { background: color-mix(in srgb, var(--bg) 55%, var(--paper)); }
.limits .lim-mark {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 2px;
  rotate: 45deg;
  background: var(--idb-red);
  opacity: .75;
  align-self: center;
}

/* notes / callouts */
.callout {
  display: flex;
  gap: 14px;
  max-width: 72ch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--cov-stub);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  font-size: 15px;
}
.callout.warn { border-inline-start-color: var(--idb-red); background: color-mix(in srgb, var(--idb-red-tint) 30%, var(--paper)); }
.callout .co-label {
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  color: var(--muted);
  padding-top: 2px;
}
.callout.warn .co-label { color: var(--idb-red-dark); }

/* source */
.source-line {
  font-size: 13px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 18px;
  max-width: 72ch;
}

/* prev / next */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
  max-width: 74ch;
}
.pager a {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  transition: border-color .18s ease, translate .2s ease, box-shadow .2s ease;
}
.pager a:hover {
  border-color: color-mix(in srgb, var(--idb-red) 25%, var(--line));
  translate: 0 -2px;
  box-shadow: 0 10px 28px -18px rgb(20 20 20 / .2);
}
.pager .pager-label { font-size: 12px; color: var(--muted); display: block; }
.pager .pager-title { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.pager .next { text-align: start; }
.pager .prev { text-align: end; }

/* ----------------------------------------------------------------- stub page */
.stub-hero { text-align: center; padding-block: clamp(40px, 7vw, 72px) 0; }
.stub-hero .code { font-size: 13.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 4px 12px; }
.stub-hero h1 {
  margin-top: 16px;
  font-size: clamp(26px, 4.4vw, 38px);
  font-weight: 700;
  line-height: 1.5;
  color: var(--charcoal);
}
.stub-hero .task-en { font-family: var(--font-ui); font-size: 13.5px; color: var(--muted); margin-top: 6px; display: block; }
.stub-hero .badge { margin-top: 18px; font-size: 13.5px; padding: 5px 16px; }
.stub-msg {
  max-width: 52ch;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 16px;
}
.stub-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 9px;
  padding: 9px 22px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  transition: border-color .18s ease, background-color .18s ease, translate .18s ease, box-shadow .2s ease;
}
.btn:hover { border-color: var(--charcoal); translate: 0 -1px; }
.btn.primary {
  background: var(--idb-red);
  border-color: var(--idb-red);
  color: #fff;
}
.btn.primary:hover {
  background: var(--idb-red-dark);
  border-color: var(--idb-red-dark);
  box-shadow: 0 10px 26px -12px rgb(224 0 40 / .45);
}

/* ghost preview of the future article */
.ghost {
  max-width: 640px;
  margin: clamp(40px, 6vw, 60px) auto 0;
  border: 1.5px dashed color-mix(in srgb, var(--muted) 36%, transparent);
  border-radius: 18px;
  padding: 30px 34px;
  position: relative;
  background: color-mix(in srgb, var(--paper) 60%, transparent);
}
.ghost .ghost-tag {
  position: absolute;
  top: -12px;
  inset-inline-start: 26px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg);
  padding: 0 12px;
}
.ghost ul { list-style: none; display: grid; gap: 16px; }
.ghost li { display: flex; align-items: center; gap: 14px; opacity: .75; }
.ghost .g-ico {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--cov-none-bg);
  display: grid;
  place-items: center;
  color: var(--cov-none);
  font-size: 14px;
  font-weight: 700;
}
.ghost .g-label { font-size: 14px; font-weight: 500; color: var(--muted); flex-shrink: 0; }
.ghost .g-bar {
  flex: 1;
  height: 9px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--cov-none-bg) 25%, color-mix(in srgb, var(--cov-none-bg) 40%, var(--paper)) 37%, var(--cov-none-bg) 63%);
  background-size: 300% 100%;
  animation: shimmer 2.2s linear infinite;
}
.ghost li:nth-child(2) .g-bar { max-width: 82%; }
.ghost li:nth-child(3) .g-bar { max-width: 64%; }
.ghost li:nth-child(4) .g-bar { max-width: 74%; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -150% 0; } }

/* state switcher (prototype-only dev control) */
.proto-switch {
  position: fixed;
  bottom: 18px;
  inset-inline-start: 18px;
  z-index: 70;
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--charcoal);
  color: rgb(255 255 255 / .75);
  font-size: 12px;
  border-radius: 12px;
  padding: 7px 12px;
  box-shadow: 0 12px 34px -12px rgb(0 0 0 / .4);
}
.proto-switch b { color: #fff; font-weight: 500; margin-inline-end: 4px; }
.proto-switch button {
  font: inherit;
  color: inherit;
  background: rgb(255 255 255 / .08);
  border: 1px solid rgb(255 255 255 / .14);
  border-radius: 7px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.proto-switch button:hover { background: rgb(255 255 255 / .18); color: #fff; }
.proto-switch button[aria-pressed="true"] {
  background: var(--idb-red);
  border-color: var(--idb-red);
  color: #fff;
}

/* --------------------------------------------------------------- search page */
.search-head { padding-block: 34px 8px; max-width: 720px; }
.search-head .search-box { margin-top: 0; }
.result-meta {
  padding-block: 18px 4px;
  font-size: 14px;
  color: var(--muted);
}
.result-meta b { color: var(--ink); }
.results { list-style: none; display: grid; gap: 14px; padding-block: 14px 40px; max-width: 780px; }
.result {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 24px;
  transition: border-color .18s ease, translate .2s ease, box-shadow .22s ease;
}
.result:hover {
  border-color: color-mix(in srgb, var(--idb-red) 25%, var(--line));
  translate: 0 -2px;
  box-shadow: 0 14px 36px -20px rgb(20 20 20 / .2);
}
.result .r-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.result .r-title { font-size: 16.5px; font-weight: 700; color: var(--charcoal); }
.result .r-unit { font-size: 12.5px; color: var(--muted); }
.result .r-unit::before { content: "·"; margin-inline-end: 8px; color: var(--line); }
.result .badge { margin-inline-start: auto; }
.result .r-snippet {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.9;
  max-width: 65ch;
}
.result mark {
  background: var(--idb-red-tint);
  color: var(--idb-red-dark);
  font-weight: 700;
  border-radius: 3px;
  padding-inline: 2px;
}
.result .r-where { font-size: 12px; color: var(--cov-none); margin-top: 6px; }

/* empty / no-results states */
.state-block {
  text-align: center;
  padding-block: clamp(40px, 8vw, 90px);
  max-width: 520px;
  margin-inline: auto;
}
.state-block .chev { width: 34px; height: 34px; opacity: .3; margin-bottom: 18px; }
.state-block h2 { font-size: 20px; font-weight: 700; color: var(--charcoal); margin-bottom: 8px; }
.state-block p { color: var(--muted); font-size: 15px; }
.state-block .chip-cloud { justify-content: center; margin-top: 20px; }

/* loading skeleton */
.skeleton { list-style: none; display: grid; gap: 14px; padding-block: 14px 40px; max-width: 780px; }
.skeleton li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 24px;
  display: grid;
  gap: 10px;
}
.skeleton .sk {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg) 25%, color-mix(in srgb, var(--bg) 40%, var(--paper)) 37%, var(--bg) 63%);
  background-size: 300% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skeleton .sk.w40 { width: 40%; } .skeleton .sk.w70 { width: 70%; } .skeleton .sk.w90 { width: 90%; }

/* ------------------------------------------------------------------- motion */
/* Entry rise: staggered on load via --d (set inline per element) */
.rise {
  opacity: 0;
  translate: 0 14px;
  animation: rise-in .6s cubic-bezier(.22, .8, .3, 1) both;
  animation-delay: var(--d, 0s);
}
@keyframes rise-in { to { opacity: 1; translate: 0 0; } }

/* Scroll-linked section reveal — progressive enhancement (Chromium 115+).
   Elsewhere sections simply render visible; nothing is ever hidden. */
@supports (animation-timeline: view()) {
  .reveal {
    animation: rise-in .7s cubic-bezier(.22, .8, .3, 1) both;
    animation-timeline: view();
    animation-range: entry 0% entry 32%;
    opacity: 0;
    translate: 0 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
  .rise, .reveal { opacity: 1; translate: 0 0; animation: none; }
}

/* --------------------------------------------------------------- responsive */
/* touch devices: tactile press feedback instead of hover lifts */
@media (hover: none) {
  a, button, summary { -webkit-tap-highlight-color: transparent; }
  .unit-card:active, .result:active, .pager a:active { translate: 0 0; scale: .985; }
  a.task-row:active { background: color-mix(in srgb, var(--bg) 62%, var(--paper)); }
  .chip:active { background: var(--idb-red-tint); border-color: var(--idb-red); color: var(--idb-red-dark); }
  .btn:active { scale: .97; }
  .search-box .kbd { display: none; } /* keyboard hint is meaningless on touch */
}

@media (max-width: 720px) {
  .topnav { display: none; }
  .mobnav { display: block; }
  .brand .brand-title { font-size: 13.5px; }
  .brand img { height: 28px; }
  .brand { gap: 10px; }

  /* hero */
  .hero-inner { padding-block: 40px 36px; }
  .hero h1 { font-size: clamp(30px, 9vw, 38px); }
  .search-box { padding: 4px 16px; border-radius: 15px; }
  .search-box input { font-size: 16px; } /* ≥16px prevents iOS focus zoom */
  .stats { gap: 8px 22px; margin-top: 30px; }
  .stats .stat b { font-size: 18px; }

  /* lists & cards */
  .units-grid { grid-template-columns: 1fr; gap: 12px; }
  .unit-card { padding: 20px 20px 16px; }
  .panel { padding: 20px; }
  .task-row { flex-wrap: wrap; row-gap: 6px; padding: 14px 16px; }
  .task-row .badge { order: 2; margin-inline-start: auto; }
  .task-row .t { flex-basis: 100%; order: 3; }
  .task-row .arr { display: none; }
  .head-covsummary { min-width: 100%; }
  .filters { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding-bottom: 4px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters .chip { flex-shrink: 0; }

  /* task article */
  .task-head { padding-block: 14px 20px; margin-bottom: 24px; }
  .task-head .task-chips { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin-inline: -18px; padding-inline: 18px; }
  .task-head .task-chips::-webkit-scrollbar { display: none; }
  .task-head .task-chips .chip { flex-shrink: 0; }
  .prose h2 { font-size: 18px; }
  .prose .lead { font-size: 16.5px; }
  .steps::before { inset-inline-start: 15px; }
  .steps li { padding-inline-start: 48px; padding-block: 10px; }
  .steps li::before { width: 32px; height: 32px; font-size: 14px; top: 12px; }
  .ladder li { padding-inline-start: 38px; }
  .limits li { padding: 11px 16px; }
  .callout { padding: 14px 16px; flex-direction: column; gap: 4px; }
  .pager { grid-template-columns: 1fr; }

  /* stub + search */
  .ghost { padding: 24px 20px; }
  .ghost .g-label { font-size: 13px; }
  .result { padding: 16px 18px; }
  .result .badge { margin-inline-start: 0; flex-basis: 100%; max-width: max-content; order: 4; margin-top: 2px; }
  .result .r-top { row-gap: 4px; }

  /* fixed widgets respect the home-indicator area */
  .proto-switch {
    inset-inline: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    justify-content: center;
    flex-wrap: wrap;
  }

  .footer .shell { padding-block: 20px; gap: 10px; }
  .footer .foot-note { margin-inline-start: 0; }
}

@media (max-width: 480px) {
  .search-box { padding-inline: 16px; border-radius: 14px; }
  .search-box input { font-size: 15px; }
  .search-box .kbd { display: none; } /* keyboard hint is meaningless on touch */
  .stats { gap: 10px 22px; }
  .steps li { padding-inline-start: 48px; }
  .steps li::before { width: 34px; height: 34px; font-size: 14.5px; top: 13px; }
  .steps::before { inset-inline-start: 16px; }
  .ladder li { padding-inline-start: 36px; }
  .task-head .task-chips .chip { font-size: 12px; }
  .proto-switch { inset-inline: 12px; justify-content: center; flex-wrap: wrap; }
}
