/* Superlawyer palette: slate neutrals with the app's sky primary (see
   frontend/src/assets/base.css in the superlawyer repo). */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0069a8;
  --accent-strong: #00598a;
  --accent-soft: #f0f9ff;
  --code-bg: #f1f5f9;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111a2e;
    --border: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #7dd3fc;
    --accent-soft: #0c2a40;
    --code-bg: #0b1120;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
h1, h2, p { margin: 0; }

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: -0.01em; }
.brand:hover { color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 20px; font-size: 14px; }
.nav a { color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { font-weight: 600; }

/* Hero and search */
.hero { padding-top: 64px; padding-bottom: 40px; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
h1 { margin-top: 10px; font-size: clamp(28px, 5vw, 40px); line-height: 1.15; letter-spacing: -0.025em; font-weight: 700; }
.lede { margin-top: 12px; max-width: 34em; color: var(--muted); font-size: 17px; }

.search {
  position: relative;
  display: flex;
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.search-icon { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; fill: var(--muted); pointer-events: none; }
.search input, .search select {
  font: inherit; color: inherit; background: transparent; border: 0; outline: none;
}
.search input { flex: 1; min-width: 0; padding: 14px 14px 14px 42px; font-size: 16px; }
.search input::placeholder { color: var(--muted); opacity: 0.8; }
.search select {
  border-left: 1px solid var(--border);
  padding: 0 36px 0 14px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath d='M5.2 7.2a.75.75 0 0 1 1.06 0L10 10.94l3.74-3.74a.75.75 0 1 1 1.06 1.06l-4.27 4.27a.75.75 0 0 1-1.06 0L5.2 8.26a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
}
.search select option { color: var(--text); background: var(--surface); }

/* Results */
.results-status { margin-top: 16px; color: var(--muted); font-size: 14px; }
.results-list { list-style: none; margin: 8px 0 0; padding: 0; }
.results-list:empty { display: none; }
.result {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-width: 0;
}
.result:first-child { border-top-width: 1px; border-radius: var(--radius) var(--radius) 0 0; }
.result:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.result:only-child { border-radius: var(--radius); }
.result-name { font-weight: 600; }
.result-regno { font: 13px var(--mono); color: var(--muted); text-align: right; }
.result-logo {
  grid-row: span 2;
  align-self: start;
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 650;
}
/* Favicons are drawn for light tab bars, so sit them on white in both themes. */
.result-logo.has-image { background: #fff; color: transparent; }
.result-logo img { position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; object-fit: contain; }
.result-meta { grid-column: 2 / -1; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.result-meta a { margin-left: 8px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-value { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-source { margin-top: 4px; font-size: 13px; color: var(--muted); }
.stat-date { display: block; }

#api { margin-top: 16px; margin-bottom: 64px; }
.api { display: grid; gap: 14px; }
.api h2 { font-size: 17px; font-weight: 650; }
.api .muted { font-size: 14px; }
.api pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 13px/1.5 var(--mono);
}
.method { color: var(--accent); font-weight: 600; }
.api-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; font-size: 14px; }
.api-foot a + a { margin-left: 16px; }

/* Doc pages (/api, /sources) */
.page { padding-top: 56px; padding-bottom: 72px; }
.page > section { margin-top: 48px; }
.page h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.page section > * + *, .source > * + * { margin-top: 14px; }
.page ul { margin: 0; padding-left: 20px; }
.page li + li { margin-top: 6px; }
.page pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 13px/1.55 var(--mono);
}
:not(pre) > code {
  padding: 1px 5px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: 0.86em var(--mono);
  white-space: nowrap;
}
blockquote {
  margin: 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
}

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.toc a {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}
.toc a:hover { color: var(--text); border-color: var(--muted); text-decoration: none; }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-top: 1px solid var(--border); }
thead th { border-top: 0; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--code-bg); }
td:first-child { white-space: nowrap; }

.sources { display: grid; gap: 16px; margin-top: 36px; }
.source-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.source-head h2 { font-size: 18px; }
.source-head .muted { font-size: 14px; margin-top: 2px; }
.source-count { text-align: right; flex-shrink: 0; }
.source-count .stat-value { margin-top: 0; font-size: 24px; }
.source-count .stat-date { font-size: 13px; }
.source-links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 15px; }
.source-links a::after { content: " ↗"; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 20px; }
.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--text); }

@media (max-width: 640px) {
  .nav { gap: 14px; }
  .hero { padding-top: 40px; padding-bottom: 28px; }
  .search { flex-direction: column; }
  .search select { border-left: 0; border-top: 1px solid var(--border); padding: 12px 36px 12px 14px; }
  .search-icon { top: 26px; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
  .stat { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; padding: 16px; }
  .stat-value { order: 2; margin-top: 0; font-size: 22px; }
  .stat-source { order: 3; flex-basis: 100%; }
  .footer-inner { flex-direction: column; }
  .page { padding-top: 36px; }
  .source-head { flex-direction: column; gap: 8px; }
  .source-count { text-align: left; }
}

@media (max-width: 420px) {
  .header-inner { gap: 12px; }
  .brand span { font-size: 15px; }
  .nav { gap: 12px; font-size: 13px; }
}
