/* WhenLeads shared base: structure only. Every color, font, radius and shadow comes from the
   tokens each site defines in /assets/css/site.css (loaded after this file). Light theme only.
   Class conventions are documented in docs/CONTRACTS.md, "CSS classes". Mobile first. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--fs-body, 1.0625rem); line-height: 1.6;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); line-height: 1.15; margin: 0 0 .5em; font-weight: var(--fw-head, 700); letter-spacing: var(--ls-head, -0.01em); }
h1 { font-size: var(--fs-h1, clamp(2rem, 5vw, 3.25rem)); }
h2 { font-size: var(--fs-h2, clamp(1.4rem, 3vw, 2rem)); }
h3 { font-size: var(--fs-h3, 1.2rem); }
p, ul, ol, dl, blockquote, pre, figure { margin: 0 0 1em; }
ul, ol { padding-left: 1.25em; }
li + li { margin-top: .3em; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
pre { overflow-x: auto; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
blockquote { margin-left: 0; padding: .25rem 0 .25rem 1rem; border-left: 3px solid var(--accent); color: var(--ink-2); }
small, .small { font-size: .875rem; }
.muted { color: var(--ink-2); }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 16px; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--maxw, 1280px); margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }
.band { padding: clamp(2.5rem, 6vw, 5rem) 0; }
.band--tint { background: var(--panel); }
.band--tight { padding: 1.5rem 0; }
.band + .band:not(.band--tint) { padding-top: 0; }
.band > .wrap > .split:first-child { padding-top: 0; border-top: 0; }
.stack > * + * { margin-top: var(--stack, 1rem); }
.grid { display: grid; gap: var(--gap, 1.25rem); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* An odd card left alone on the last row of a 2-column grid takes the full row instead of leaving a hole. */
@media (min-width: 640px) { .grid--2 > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
@media (min-width: 640px) and (max-width: 1023px) { .grid--3 > :last-child:nth-child(odd), .grid--4 > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
@media (min-width: 1024px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* heading-left / text-right: the default for every long text section (markdown H2s render into it) */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem 3rem; padding: 2rem 0; border-top: 1px solid var(--line); }
.split:first-child, .split--lead { border-top: 0; }
.split--lead .split__head:empty { display: none; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(220px, 4fr) 8fr; }
  .split--lead .split__head:empty { display: block; }
  .split__head h2 { position: sticky; top: var(--sticky-top, 1.5rem); }
}
.split__head h2 { margin: 0; }
.split__body > :last-child { margin-bottom: 0; }
.split__body { min-width: 0; }

/* ---------- page head ---------- */
.page-head { padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem; border-bottom: 1px solid var(--line); }
.page-head__grid { display: grid; gap: 1rem 3rem; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 900px) { .page-head__grid { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); } }
.eyebrow { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 .75rem; }
.lede { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--ink-2); margin: 0; }
.meta-line { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .875rem; color: var(--ink-2); margin: 1rem 0 0; }
.meta-line strong { color: var(--ink); font-weight: 600; }

/* ---------- breadcrumbs ---------- */
.crumbs { font-size: .85rem; margin: 0 0 1rem; color: var(--ink-2); }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.crumbs li + li { margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: .25rem; color: var(--line-strong, var(--line)); }
.crumbs a { color: var(--ink-2); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .7rem 1.2rem; border-radius: var(--radius-btn, var(--radius)); border: 2px solid transparent; font: 600 1rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; }
.btn--primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover, var(--accent)); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--panel); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- cards, callouts, badges ---------- */
.card { background: var(--card, var(--bg)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-top: 0; }
.card--link { display: block; color: inherit; text-decoration: none; }
.card--link:hover { border-color: var(--ink); }
.callout { border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--panel); padding: 1rem 1.25rem; border-radius: var(--radius); margin: 0 0 1.25rem; }
.callout > :last-child { margin-bottom: 0; }
.callout--warn { border-left-color: var(--warn); }
.callout--source { border-left-color: var(--ink-2); }
.badge { display: inline-block; font: 600 .75rem/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase; padding: .35rem .5rem; border-radius: var(--radius-sm, 4px); border: 1px solid currentColor; }
.badge--high { color: var(--ok); } .badge--medium { color: var(--warn-ink, var(--warn)); } .badge--low { color: var(--bad); }
.cite { font-family: var(--font-mono); font-size: .85em; color: var(--ink-2); overflow-wrap: anywhere; }
table .col-main { min-width: 16rem; }
@media (min-width: 900px) { table .col-main { width: 50%; } }
.kpi { display: flex; flex-direction: column; gap: .25rem; }
.kpi__value { font: 700 clamp(1.75rem, 4vw, 2.5rem)/1 var(--font-head); color: var(--ink); }
.kpi__label { font-size: .9rem; color: var(--ink-2); }

/* ---------- verdicts (checker) ---------- */
.verdict { border: 2px solid var(--ink); border-radius: var(--radius); padding: 1.25rem; background: var(--bg); }
.verdict__label { font: 700 .8rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 .5rem; }
.verdict--required { border-color: var(--bad); } .verdict--required .verdict__label { color: var(--bad); }
.verdict--exempt { border-color: var(--ok); } .verdict--exempt .verdict__label { color: var(--ok); }
.verdict--ahj { border-color: var(--warn); } .verdict--ahj .verdict__label { color: var(--warn-ink, var(--warn)); }

/* ---------- tables (always data-sortable; see shared/static/js/sortable.js) ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--panel); font-family: var(--font-head); font-weight: 600; font-size: .85rem; letter-spacing: .02em; color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.srt { cursor: pointer; user-select: none; white-space: nowrap; }
th.srt::after { content: " \2195"; opacity: .35; font-size: .8em; }
th.srt[aria-sort="ascending"]::after { content: " \2191"; opacity: 1; }
th.srt[aria-sort="descending"]::after { content: " \2193"; opacity: 1; }
[data-tip] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.wl-tip { position: fixed; z-index: 9999; max-width: 340px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 13px/1.45 var(--font-body); box-shadow: 0 10px 30px rgba(10, 20, 40, .15); }
.wl-tip ol, .wl-tip ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------- sources, verified, faq, toc ---------- */
.sources ol { padding-left: 1.25em; }
.sources li { overflow-wrap: anywhere; }
.sources .src-meta { display: block; font-size: .85rem; color: var(--ink-2); }
.faq details { border-top: 1px solid var(--line); padding: .9rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.faq details > div { margin-top: .5rem; }
.toc { font-size: .9rem; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- forms (see shared/static/js/forms.js) ---------- */
.form { display: grid; gap: 1rem; }
.form__row { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form__row--2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .form__row--3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); } }
.field { display: grid; gap: .35rem; min-width: 0; align-content: start; }
.field__label { font-weight: 600; font-size: .95rem; }
.field__hint { font-size: .85rem; color: var(--ink-2); }
.field__error { font-size: .85rem; color: var(--bad); min-height: 0; }
.field__error:empty { display: none; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: .6rem .75rem; font: inherit; color: var(--ink); background: var(--input-bg, #fff);
  border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-sm, 6px);
}
textarea { min-height: 120px; resize: vertical; }
[aria-invalid="true"] { border-color: var(--bad) !important; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 .35rem; }
.choice { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; }
.choice input { width: 20px; height: 20px; margin-top: .15rem; flex: none; accent-color: var(--accent); }
.consent { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; font-size: .92rem; }
.consent > :last-child { margin-bottom: 0; }
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }
.form__status { font-size: .95rem; margin: 0; }
.form__status--error { color: var(--bad); } .form__status--ok { color: var(--ok); } .form__status--busy { color: var(--ink-2); }
.success { border: 2px solid var(--ok); border-radius: var(--radius); padding: 1.25rem; }

/* ---------- form and tool pages ---------- */
.form-layout { display: grid; gap: 2rem 3rem; grid-template-columns: minmax(0, 1fr); padding: 2rem 0; }
@media (min-width: 960px) { .form-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } .form-layout__aside { position: sticky; top: 1.5rem; align-self: start; } }
.form-layout__aside > :last-child { margin-bottom: 0; }
.tool { padding: 2rem 0; }
.tool-layout { display: grid; gap: 2rem 3rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .tool-layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); } }

/* ---------- header / footer skeleton (sites style the look) ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--header-bg, var(--bg)); }
.site-header__bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0; padding: 0; }
.site-nav li + li { margin: 0; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 500; display: inline-block; padding: .5rem 0; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
.nav-toggle { display: none; }
@media (max-width: 859px) {
  .site-nav { width: 100%; display: none; padding-bottom: 1rem; }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .nav-toggle { display: inline-flex; min-height: 44px; min-width: 44px; align-items: center; justify-content: center; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm, 6px); font: 600 .9rem var(--font-body); color: var(--ink); }
}
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0; font-size: .92rem; color: var(--ink-2); background: var(--footer-bg, var(--bg)); }
.site-footer a { color: var(--ink-2); }
.site-footer__grid { display: grid; gap: 1.5rem 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .site-footer__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .site-footer__grid > :first-child { grid-column: 1 / -1; } }
@media (min-width: 1100px) { .site-footer__grid { grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)); } .site-footer__grid > :first-child { grid-column: auto; } }
.site-footer h2 { font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: .75rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer address { font-style: normal; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
@media print { .site-header, .site-footer, .nav-toggle { display: none; } }
