/* qavanin_live viewer (lawyer.cargo.ir). Tokens copied verbatim from docs/design/tokens.css
   (palette v2 فیروزه و مس, light + dark); component names follow docs/design/mockups/_shared.css. */

@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #F5F7F7; --surface: #FFFFFF; --surface-2: #ECF1F1;
  --line: #DBE2E2; --line-strong: #C3CECE;
  --text: #16323A; --text-2: #44595F; --text-3: #84979B;
  --brand: #0F6E7A; --brand-strong: #0A5560; --brand-soft: #E2F0F1;
  --on-brand: #FFFFFF; --brand-text: #0E6874;
  --accent: #A85B28; --accent-text: #79411B; --accent-soft: #F4E8DC;
  --ok: #2E7D4F; --ok-soft: #E3F0E8;
  --err: #B23A32; --err-soft: #F8E8E6;
  --warn: #96700F; --warn-soft: #F5EEDA;
  --tier-statute-bg: #E2F0F1; --tier-statute-fg: #0F6E7A;
  --tier-unify-bg: #F4E8DC;   --tier-unify-fg: #79411B;
  --tier-ruling-bg: #E8EBF0;  --tier-ruling-fg: #44506B;
  --tier-opinion-bg: #E3F0E8; --tier-opinion-fg: #2F6B4F;
  --font: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --fs-h1: 28px; --lh-h1: 1.5;
  --fs-h2: 21px; --lh-h2: 1.6;
  --fs-h3: 17px; --lh-h3: 1.7;
  --fs-body: 15px; --lh-body: 1.9;
  --fs-sm: 13.5px; --lh-sm: 1.8;
  --fs-xs: 12px; --lh-xs: 1.7;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-s: 6px; --r-m: 10px; --r-l: 16px;
  --shadow-card: 0 1px 2px rgba(13, 36, 42, .05), 0 4px 16px rgba(13, 36, 42, .06);
  --focus: #0E6874;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C181B; --surface: #132327; --surface-2: #182D32;
    --line: #24393E; --line-strong: #345055;
    --text: #E2EBEC; --text-2: #A3B6B9; --text-3: #6B8184;
    --brand: #238795; --brand-strong: #2E97A5; --brand-soft: #123238;
    --on-brand: #FFFFFF; --brand-text: #6FC4CF;
    --accent: #C97F45; --accent-text: #D89A62; --accent-soft: #2E1F10;
    --ok: #55A56F; --ok-soft: #142619;
    --err: #D66A5C; --err-soft: #2E1512;
    --warn: #CFA044; --warn-soft: #2B2210;
    --tier-statute-bg: #123238; --tier-statute-fg: #6FC4CF;
    --tier-unify-bg: #2E1F10;   --tier-unify-fg: #D89A62;
    --tier-ruling-bg: #1E2E33;  --tier-ruling-fg: #A3B6B9;
    --tier-opinion-bg: #14301F; --tier-opinion-fg: #7CC49A;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .35);
    --focus: #6FC4CF;
  }
}

/* ---- base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: var(--fs-body); line-height: var(--lh-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:is(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-s);
}
mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; padding: 0 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sarlouheh { border: 0; border-top: 3px double var(--accent); width: 72px; margin: var(--sp-3) 0; }

/* ---- top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar__in {
  max-width: 1180px; margin: 0 auto; padding: var(--sp-2) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
}
.logo { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-h3); font-weight: 700; color: var(--text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo__mark {
  width: 30px; height: 30px; border-radius: var(--r-s); background: var(--brand); color: var(--on-brand);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.topbar__nav { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.topbar__nav a { color: var(--text-2); font-size: var(--fs-sm); padding: 4px 10px; border-radius: var(--r-s); white-space: nowrap; }
.topbar__nav a.active { color: var(--brand-text); background: var(--brand-soft); font-weight: 500; }
.topbar__nav a:hover { text-decoration: none; background: var(--surface-2); }

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-7); }
.foot { max-width: 1180px; margin: 0 auto; padding: var(--sp-4); color: var(--text-3); font-size: var(--fs-xs); border-top: 1px solid var(--line); }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 8px 18px; border: 1px solid transparent; border-radius: var(--r-s);
  background: var(--brand); color: var(--on-brand); font: inherit; font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--brand-text); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--brand-soft); }
.input, select.input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm);
}
.input::placeholder { color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field > label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1); padding: 0 9px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.9; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); vertical-align: 1px;
}
.chip--statute { background: var(--tier-statute-bg); color: var(--tier-statute-fg); }
.chip--unify   { background: var(--tier-unify-bg);   color: var(--tier-unify-fg); }
.chip--ruling  { background: var(--tier-ruling-bg);  color: var(--tier-ruling-fg); }
.chip--opinion { background: var(--tier-opinion-bg); color: var(--tier-opinion-fg); }
.chip--ok   { background: var(--ok-soft);   color: var(--ok); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--accent { background: var(--accent-soft); color: var(--accent-text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4); }
.notice { background: var(--warn-soft); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--sp-3) var(--sp-4); margin: 0 0 var(--sp-4); font-size: var(--fs-sm); }
.crumbs { font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--sp-3); }

/* ---- page head ---- */
.pagehead { margin-bottom: var(--sp-4); }
.pagehead h1 { margin-bottom: var(--sp-1); }
.pagehead .lede { color: var(--text-2); font-size: var(--fs-sm); margin: 0; }

/* ---- filters ---- */
.filterbox { margin-top: var(--sp-3); }
.filterbox > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); margin-bottom: var(--sp-2); width: max-content; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-3); align-items: end; }
.filters .field--wide { grid-column: span 2; }
.filterbox .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.searchrow { display: flex; gap: var(--sp-2); }
.searchrow .input { font-size: var(--fs-body); padding: 10px 14px; }
.countline { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 2px var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); }
.countline b { color: var(--text); }
.sorts { display: flex; gap: var(--sp-1); flex-wrap: wrap; align-items: center; }
.sorts a { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-xs); background: var(--surface); }
.sorts a.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.sorts a:hover { text-decoration: none; border-color: var(--brand); }

/* ---- list rows (whole row is a link) ---- */
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-1) var(--sp-4); padding: var(--sp-3) var(--sp-4); color: var(--text); }
.row:hover { background: var(--brand-soft); text-decoration: none; }
.row__title { font-weight: 500; line-height: 1.8; }
.row__meta { color: var(--text-2); font-size: var(--fs-xs); display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); align-items: center; }
.row__side { text-align: end; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; display: flex; flex-direction: column; gap: 2px; justify-content: center; }
.row__side b { color: var(--text-2); font-weight: 500; }
.row__snip { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.9; }

/* ---- pager ---- */
.pager { display: flex; gap: var(--sp-1); justify-content: center; flex-wrap: wrap; margin: var(--sp-5) 0 0; }
.pager a, .pager span { min-width: 38px; text-align: center; padding: 4px 10px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pager span.cur { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pager span.gap { border-color: transparent; background: none; }
.pager a:hover { text-decoration: none; border-color: var(--brand); }

/* ---- law page ---- */
.lawhead h1 { font-size: 26px; }
.lawhead .chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-2) 0 0; }
.attrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-2) var(--sp-5); margin: var(--sp-3) 0 0; }
.attrs div { border-bottom: 1px dashed var(--line); padding-bottom: 4px; min-width: 0; }
.attrs dt { font-size: var(--fs-xs); color: var(--text-3); }
.attrs dd { margin: 0; font-size: var(--fs-sm); font-weight: 500; overflow-wrap: anywhere; }
.srcline { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); }
.srcline a { color: var(--accent-text); }

.lawgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
@media (min-width: 1024px) {
  .lawgrid { grid-template-columns: 290px minmax(0, 1fr); align-items: start; }
  .toc { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
}
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.toc > summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 2px 0; }
.toc .d { display: block; color: var(--text); line-height: 1.7; padding: 2px 0; }
.toc .d small { color: var(--text-3); }
.toc .lv2 { padding-inline-start: 10px; } .toc .lv3 { padding-inline-start: 20px; }
.toc .lv4 { padding-inline-start: 30px; } .toc .lv5 { padding-inline-start: 40px; } .toc .lv6 { padding-inline-start: 50px; }
.toc .arts { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 6px; }
.toc .arts a { font-size: 11.5px; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); line-height: 1.8; }
.toc .arts a:hover { background: var(--brand-soft); color: var(--brand-text); text-decoration: none; }

.body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: var(--sp-4) var(--sp-5); }
.sec { padding: var(--sp-2) var(--sp-2); border-radius: var(--r-s); scroll-margin-top: 76px; }
.sec:target { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sec__h { font-weight: 700; margin: 0 0 2px; font-size: var(--fs-body); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; }
.sec__h a.self { color: inherit; }
.sec__t { text-align: justify; white-space: pre-line; overflow-wrap: anywhere; }
.sec--title { text-align: center; padding: var(--sp-3) 0; }
.sec--title .sec__h { justify-content: center; font-size: var(--fs-h3); color: var(--brand-text); }
.sec--division { margin-top: var(--sp-4); text-align: center; border-top: 1px solid var(--line); padding-top: var(--sp-4); }
.sec--division .sec__h { justify-content: center; font-size: var(--fs-h3); color: var(--accent-text); }
.sec--division .sec__t { text-align: center; font-weight: 500; }
.sec--article { margin-top: var(--sp-2); }
.sec--article .sec__h { color: var(--brand-text); }
.sec--note, .sec--clause { margin-inline-start: var(--sp-5); }
.sec--note .sec__h { color: var(--text-2); }
.sec--clause .sec__h { color: var(--text-2); font-weight: 500; }
.sec--plain .sec__t { color: var(--text-2); }
.sec__x { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 2px; font-size: var(--fs-xs); }
.sec__x .links a { color: var(--text-2); }

details.rul { width: 100%; }
details.rul > summary { cursor: pointer; display: inline-flex; list-style: none; }
details.rul > summary::-webkit-details-marker { display: none; }
details.rul > summary .chip { background: var(--tier-ruling-bg); color: var(--tier-ruling-fg); }
details.rul[open] > summary .chip { background: var(--brand); color: var(--on-brand); }
.rulbox { margin: var(--sp-2) 0; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); padding: var(--sp-2) var(--sp-3); }
.rullist { list-style: none; margin: 0; padding: 0; }
.rullist li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); line-height: 1.8; }
.rullist li:last-child { border-bottom: 0; }
.rullist .m { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.more { display: inline-block; margin-top: var(--sp-2); font-size: var(--fs-sm); font-weight: 500; }

.side h2 { font-size: var(--fs-h3); margin: var(--sp-5) 0 var(--sp-2); }
.lawlinks { list-style: none; padding: 0; margin: 0; }
.lawlinks li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); }
.lawlinks li:last-child { border-bottom: 0; }

/* ---- ruling page ---- */
.ruling-text { text-align: justify; line-height: 2.05; overflow-wrap: anywhere; }
.facetchips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.facetchips a { padding: 2px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); }
.facetchips a.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.facetchips a:hover { text-decoration: none; border-color: var(--brand); }
.facetchips .fc { font-size: var(--fs-xs); opacity: .8; }

.prose h2 { font-size: var(--fs-h3); margin: var(--sp-4) 0 var(--sp-2); }
.prose ul { padding-inline-start: var(--sp-5); margin: 0 0 var(--sp-3); }

@media (max-width: 640px) {
  .wrap { padding: var(--sp-4) var(--sp-3) var(--sp-6); }
  h1, .lawhead h1 { font-size: 21px; }
  .card, .body { padding: var(--sp-3); }
  .row { grid-template-columns: 1fr; }
  .row__side { flex-direction: row; gap: var(--sp-3); text-align: start; }
  .filters .field--wide { grid-column: 1 / -1; }
  .sec--note, .sec--clause { margin-inline-start: var(--sp-3); }
  .topbar { position: static; }
  .topbar__in { gap: var(--sp-2); }
  .sec { scroll-margin-top: 8px; }
  .filters { grid-template-columns: 1fr 1fr; }
}
