/* ============================================================
   DisputeDesk — shared design system (owner B1)
   Implements spec §2 exactly: tokens + class vocabulary.
   No external fonts, no CDN, works offline.
   ============================================================ */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, ul, ol, li, figure, blockquote, dl, dd { margin: 0; }
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; }

/* ---------- tokens (spec §2) ---------- */
:root {
  --bg:#0f1216; --surface:#171b21; --surface-2:#1e242c; --line:#2a313a;
  --text:#e8ecf1; --muted:#9aa5b1; --brand:#3d8bfd; --brand-ink:#ffffff;
  --ok:#2fbf71; --warn:#e0a800; --danger:#e5534b;
  --r:10px; --pad:20px; --max:1040px;
  --fs:16px; --lh:1.6;
}

/* ---------- base ---------- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs);
  line-height: var(--lh);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; }

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.3rem; }
strong, b { font-weight: 700; }

/* fluid headings, tight leading, short measure on h1 */
h1, h2, h3 {
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0 0 0.55em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 22ch;
}
h2 { font-size: clamp(1.55rem, 3.4vw, 2.25rem); line-height: 1.15; }
h3 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.01em; }

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }
.input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  /* darken the fill so the white label keeps AA (>=4.5:1) — same rescue as .btn--primary */
  background-color: var(--brand);
  background-image: linear-gradient(rgba(0,0,0,.2), rgba(0,0,0,.2));
  color: var(--brand-ink);
  font-weight: 600;
  text-decoration: none;
  padding: 12px 18px;
  border-radius: var(--r);
  transition: top 150ms ease;
}
.skip-link:focus,
.skip-link:focus-visible { top: 8px; }

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 16px;
}
.section { padding-block: 48px; }
@media (max-width: 639px) {
  .section { padding-block: 32px; }
}

.grid { display: grid; gap: 16px; }
.grid--2, .grid--3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  max-width: var(--max);
  margin-inline: auto;
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.nav__brand {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  margin-right: 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav__brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--brand);
  margin-right: 8px;
}
.nav__brand:hover { color: #fff; }
.nav__links {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  border-radius: var(--r);
}
.nav__links a:hover { color: var(--text); background: var(--surface-2); }
.nav__links a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--brand);
}
.nav__cta { flex: 0 0 auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.btn:hover { border-color: var(--line); background: #242b34; }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background-color: var(--brand);
  /* darken the fill so white label keeps AA (>=4.5:1) contrast */
  background-image: linear-gradient(rgba(0,0,0,.2), rgba(0,0,0,.2));
  border-color: rgba(255,255,255,.16);
  color: var(--brand-ink);
}
.btn--primary:hover {
  background-color: var(--brand);
  background-image: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.3));
  border-color: rgba(255,255,255,.32);
}
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn--block { display: flex; width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
  transition: transform 200ms ease, border-color 200ms ease;
}
.card:hover { transform: translateY(-4px); border-color: #39424e; }

/* ---------- eyebrow / section label ---------- */
.eyebrow {
  display: block;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, "DejaVu Sans Mono", monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* semantic badges: solid fill + dark ink so every badge clears AA (>=4.5:1) */
.badge--ok { color: var(--bg); background: var(--ok); border-color: var(--ok); }
.badge--warn { color: var(--bg); background: var(--warn); border-color: var(--warn); }
.badge--danger { color: var(--bg); background: var(--danger); border-color: var(--danger); }

/* ---------- table ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.table { width: 100%; font-size: 0.95rem; }
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.table thead th {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }

/* ---------- alerts ---------- */
.alert {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 12px;
}
.alert:last-child { margin-bottom: 0; }
.alert a { color: inherit; }
.alert--info { border-left-color: var(--brand); background: rgba(61,139,253,.10); }
.alert--warn { border-left-color: var(--warn); background: rgba(224,168,0,.10); }
.alert--danger { border-left-color: var(--danger); background: rgba(229,83,75,.10); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}
.input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
select { cursor: pointer; }
.input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- stats ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat__num {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat__label { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- steps ---------- */
.steps {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  counter-reset: step;
}
@media (min-width: 640px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
  position: relative;
}
.step__num {
  display: block;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--brand);
  margin-bottom: 12px;
}

/* ---------- checklist ---------- */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.checklist li {
  position: relative;
  padding-left: 28px;
}
.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ok);
  font-weight: 700;
}

/* ---------- footer ---------- */
.footer {
  flex-shrink: 0;
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 28px 0;
}
.footer__inner {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 16px;
}
.disclaimer {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 85ch;
  margin-bottom: 12px;
}
.footer .hint a { color: var(--muted); }
.footer .hint a:hover { color: var(--text); }

/* ---------- toast host (used by site.js DD.toast) ---------- */
#toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
#toast-host .alert {
  margin: 0;
  pointer-events: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,.55);
}
@media (max-width: 639px) {
  #toast-host { left: 16px; right: 16px; width: auto; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .btn:active { transform: none; }
}
