/* One type scale (--step-*), one accent colour (--accent, for what can be clicked), greys for
   everything else. Errors and warnings differ by shape, not by colour. No JavaScript. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-subtle: #f4f4f5;
  --fg: #18181b;
  --fg-muted: #52525b;
  --border: #d4d4d8;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --bg-subtle: #1c1c1f;
    --fg: #ececee;
    --fg-muted: #a1a1aa;
    --border: #3f3f46;
    --accent: #7aa2f7;
    --accent-fg: #111113;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--step-0) / 1.5 var(--sans);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 1.5rem 0 0.5rem;
}

h1 {
  font-size: var(--step-2);
}

h2 {
  font-size: var(--step-1);
}

h3 {
  font-size: var(--step-0);
}

p {
  margin: 0.5rem 0;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
pre:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

code,
pre {
  font-family: var(--mono);
  font-size: inherit;
}

pre {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--step--1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre.scroll {
  max-height: 22rem;
  overflow: auto;
  margin: 0;
}

/* --- Frame ------------------------------------------------------------------------------ */

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}

.header-inner nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  font-size: var(--step--1);
}

.header-inner nav a {
  color: var(--fg-muted);
  text-decoration: none;
}

.header-inner nav a:hover {
  color: var(--fg);
  text-decoration: underline;
}

main.page {
  padding-top: 0.5rem;
  padding-bottom: 2rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--step--1);
  padding: 0.75rem 0;
}

/* --- Text blocks ------------------------------------------------------------------------ */

.hero h1 {
  margin-top: 1rem;
}

.lead {
  color: var(--fg-muted);
  margin: 0 0 1rem;
}

.note,
.muted,
.breadcrumb {
  color: var(--fg-muted);
  font-size: var(--step--1);
}

.breadcrumb {
  margin: 1rem 0 0;
}

.prose {
  max-width: 46rem;
}

.plain {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.card h2 {
  margin-top: 0;
}

.info {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  align-items: start;
}

.card-wide {
  grid-column: 1 / -1;
}

.secret {
  font-family: var(--mono);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* --- Upload form, side by side with the API call when there is room ---------------------- */

.top {
  display: grid;
  gap: 0 2rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 52rem) {
  .top {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }

  .top .side {
    margin-top: 1rem;
  }
}

.side h2 {
  margin-top: 0;
}

.upload {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.upload label {
  font-weight: 600;
}

.upload input[type="file"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px dashed var(--fg-muted);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--step--1);
}

.upload input[type="password"],
.upload input[type="text"],
.upload input[type="email"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--step--1);
}

.upload input[type="password"] {
  font-family: var(--mono);
}

.card .upload {
  padding: 0;
  border: 0;
}

.upload .option {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-weight: 400;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

button,
.plan button,
.card form button {
  justify-self: start;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* --- Validation report ----------------------------------------------------------------- */

.report {
  margin-top: 1rem;
}

/* Verdict: filled when invalid, outlined when valid. */
.verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
}

.verdict h1 {
  margin: 0;
  font-size: var(--step-1);
}

.verdict p {
  margin: 0;
}

.verdict-invalid {
  background: var(--fg);
  color: var(--bg);
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 1rem;
  margin: 0.75rem 0;
  font-size: var(--step--1);
}

.facts dt {
  color: var(--fg-muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.findings {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  border-top: 1px solid var(--border);
}

.finding {
  padding: 0.5rem 0 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid var(--fg);
}

.finding-warning {
  border-left: 1px solid var(--fg-muted);
  padding-left: calc(0.75rem + 3px);
}

.finding p {
  margin: 0;
}

.finding-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.badge {
  padding: 0 0.375rem;
  border: 1px solid var(--fg);
  border-radius: 2px;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.finding-error .badge {
  background: var(--fg);
  color: var(--bg);
}

.finding-warning .badge {
  border-color: var(--fg-muted);
  color: var(--fg-muted);
}

.rule-id {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.explain {
  margin-left: auto;
  font-size: var(--step--1);
}

.finding-message {
  margin-top: 0.25rem;
}

.finding-location {
  color: var(--fg-muted);
  font-size: var(--step--1);
  overflow-wrap: anywhere;
}

.warnings summary {
  cursor: pointer;
}

.warnings summary h2 {
  display: inline;
}

/* --- Tables --------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.rules-table,
.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.rules-table th,
.rules-table td,
.data th,
.data td {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.rules-table tbody tr:last-child td,
.data tbody tr:last-child td {
  border-bottom: 0;
}

.rules-table th,
.data th {
  color: var(--fg-muted);
  font-weight: 600;
}

.rules-table td:first-child {
  width: 34%;
  font-weight: 600;
}

.totals td:first-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* --- Example of /v1/parse: input and output side by side when there is room ------------ */

.example {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  margin: 0.75rem 0;
}

.example figure {
  margin: 0;
  min-width: 0;
}

.example figcaption {
  margin-bottom: 0.25rem;
  color: var(--fg-muted);
  font-size: var(--step--1);
}

/* --- Notices -------------------------------------------------------------------------- */

.notice {
  margin: 1rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--fg-muted);
  border-radius: var(--radius);
}

.notice h1,
.notice h2 {
  margin: 0;
  font-size: var(--step-1);
}

.notice-error {
  border-left-color: var(--fg);
}

/* --- Pricing --------------------------------------------------------------------------- */

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.plan {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.plan .price {
  margin: 0;
  font-size: var(--step-2);
  font-weight: 700;
}

.plan form {
  margin-top: auto;
}

.card blockquote {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--fg-muted);
  background: var(--bg-subtle);
}

.card blockquote p {
  margin: 0;
}

/* --- Client area ---------------------------------------------------------------------- */

.figure {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

progress {
  width: 100%;
  height: 0.5rem;
  accent-color: var(--fg-muted);
}

select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--step--1);
  max-width: 100%;
}

.actions p {
  margin: 0 0 0.25rem;
}

.actions details + details {
  margin-top: 0.25rem;
}

.actions summary {
  color: var(--accent);
  cursor: pointer;
}

.actions form {
  display: grid;
  gap: 0.375rem;
  justify-items: start;
  margin: 0.375rem 0 0.5rem;
}

.keys-table td:first-child {
  font-weight: 600;
}

/* --- Legal documents: identity as a list, gaps left to fill stand out ----------------- */

.identity {
  display: grid;
  grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
  gap: 0.25rem 1rem;
  margin: 0.5rem 0;
}

.identity dt {
  color: var(--fg-muted);
}

.identity dd {
  margin: 0;
}

/* Inverted ink: visible on any page, without a colour of its own. */
mark.to-fill {
  padding: 0 0.25em;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

@media (max-width: 40rem) {
  .identity {
    grid-template-columns: minmax(0, 1fr);
  }

  .identity dd {
    margin-bottom: 0.5rem;
  }
}

/* --- Charts of /admin/stats: SVG drawn on the server, one grey series each ------------ */

.chart-figure {
  margin: 0.75rem 0 1rem;
}

.chart-wrap {
  overflow-x: auto;
}

/* Drawn at most at its own width, where one SVG unit is one pixel; scrolls below 35rem. */
.chart {
  display: block;
  width: 100%;
  min-width: 35rem;
  max-width: 45rem;
  height: auto;
}

.chart text {
  font-family: var(--sans);
  font-size: var(--step--1);
  fill: var(--fg-muted);
}

.chart .value,
.chart .name {
  fill: var(--fg);
}

.chart .code {
  font-family: var(--mono);
  fill: var(--fg);
}

.chart .grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart .bar {
  fill: var(--fg-muted);
}

.chart .hit {
  fill: transparent;
}

.chart .mark:hover .bar {
  fill: var(--fg);
}

.chart-figure figcaption {
  color: var(--fg-muted);
  font-size: var(--step--1);
}

.chart-figure details {
  font-size: var(--step--1);
}

/* --- Narrow screens ------------------------------------------------------------------- */

@media (max-width: 40rem) {
  .rules-table thead {
    display: none;
  }

  .rules-table tr,
  .rules-table td {
    display: block;
  }

  .rules-table td {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .rules-table td:first-child {
    width: auto;
  }

  .rules-table td:last-child {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.375rem;
  }

  /* One block per key, each value after its column name. */
  .keys-table thead {
    display: none;
  }

  .keys-table tr,
  .keys-table td {
    display: block;
  }

  .keys-table tr {
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border);
  }

  .keys-table tbody tr:last-child {
    border-bottom: 0;
  }

  .keys-table td,
  .keys-table tbody tr:last-child td {
    padding: 0.125rem 0.75rem;
    border-bottom: 0;
  }

  .keys-table td[data-label]::before {
    content: attr(data-label) " : ";
    color: var(--fg-muted);
  }
}
