/*
 * The portal's stylesheet.
 *
 * The idiom is vicaristudio.com's, not Binder's: one measure, the system type
 * stack, white and near-black grounds with a real dark palette, one focus blue,
 * hairline rules between sections, small uppercase section labels, and status that
 * is a word first and a colour second. No cards, no shadows, no radii to speak of.
 *
 * The class names are the ones the views already use (.card, .pill, .notice, .btn,
 * .field ...), so the markup did not have to change to change the look. A .card is
 * a section under a hairline; a .pill is a word.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --text: #101010;
  --muted: #5c5c5c;
  --rule: #e4e4e4;
  --soft: #f4f4f4;
  --focus: #1a56db;
  --ok: #1f6b3a;
  --bad: #b42318;
}

/* Dark is a palette, not an inversion. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0e;
    --text: #ededed;
    --muted: #9a9a9a;
    --rule: #262626;
    --soft: #171717;
    --focus: #7aa2f7;
    --ok: #7fc28d;
    --bad: #f28b82;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; padding: 2.25rem 0 3rem; }

/* One measure for the whole document. Tables scroll inside it rather than widen it. */
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.5rem; }
.wrap-narrow { max-width: 28rem; }

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 1px;
}

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { font-size: 0.875em; }
pre { font: inherit; }

/* ---------- skip link ---------- */
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--bg); padding: 0.5rem 0.75rem; outline: 2px solid var(--focus); }

/* ---------- header and footer ---------- */
header.site { border-bottom: 1px solid var(--rule); }
.bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  padding: 1.1rem 0;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: underline; }
nav.main { display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap; font-size: 0.9375rem; }
nav.main a { color: var(--muted); text-decoration: none; }
nav.main a:hover { color: var(--text); text-decoration: underline; }
nav.main a[aria-current="page"] { color: var(--text); text-decoration: underline; text-underline-offset: 0.3em; }
nav.main form { display: inline; margin: 0; }

footer.site {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0 2rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
footer.site p { margin: 0; }

/* ---------- page head ---------- */
.crumb { margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--muted); }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
  flex-wrap: wrap;
  margin: 0 0 1.75rem;
}
h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.page-head .sub { margin: 0.35rem 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ---------- sections ----------
 * Every .card is a section that opens with a hairline, like the landing page's <hr>
 * before each group. Section titles are small uppercase labels.
 */
.card, .card-table {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  margin: 0 0 1.75rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 0.85rem;
}
.card-head h2, .card > h2, h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-head h2 a { text-decoration: none; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1rem; }
.card-head h2 a:hover { text-decoration: underline; }
h3 { margin: 1rem 0 0.25rem; font-size: 0.9375rem; font-weight: 600; }
h3:first-child { margin-top: 0; }
.card p { margin: 0 0 0.75rem; }
.card p:last-child { margin-bottom: 0; }
.card pre { margin: 0 0 0.75rem; white-space: pre-wrap; }

details.card > summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "+"; display: inline-block; width: 1.1em; }
details.card[open] > summary::before { content: "\2212"; }
details.card[open] > summary { margin-bottom: 0.85rem; }
details > summary + * { margin-top: 0.5rem; }

/* ---------- description lists ---------- */
dl { margin: 0; }
dt { font-weight: 600; margin-top: 1rem; }
dt:first-of-type { margin-top: 0; }
dd { margin: 0.2rem 0 0; color: var(--muted); }

/* ---------- status: a word, then a colour ---------- */
.pill {
  display: inline;
  font-size: 0.875rem;
  white-space: nowrap;
  color: var(--muted);
}
.pill::before { content: "\00b7\00a0"; }
.pill-ok { color: var(--ok); font-weight: 600; }
.pill-warn { color: var(--focus); font-weight: 600; }
.pill-bad { color: var(--bad); font-weight: 600; }
.pill-none { color: var(--muted); }
.page-head .actions .pill { font-size: 0.9375rem; }

/* ---------- notices ---------- */
.notice {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--muted);
  padding: 0.7rem 0.95rem;
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}
.notice p { margin: 0 0 0.5rem; }
.notice p:last-child { margin-bottom: 0; }
.notice-ok { border-left-color: var(--ok); }
.notice-warn { border-left-color: var(--focus); }
.notice-bad { border-left-color: var(--bad); }
.notice-info { border-left-color: var(--muted); }
.notice form { margin: 0; }

.notice-row { padding: 0.7rem 0; border-top: 1px solid var(--rule); }
.notice-row:first-of-type { border-top: 0; padding-top: 0; }
.notice-row p { margin: 0 0 0.35rem; }

.empty { color: var(--muted); padding: 0.25rem 0 0; }
.empty h3 { margin: 0; font-size: 0.9375rem; font-weight: 400; }
.empty p { margin: 0.25rem 0 0; font-size: 0.9375rem; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.75rem 0.45rem 0;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th:last-child, td:last-child { padding-right: 0; }
td form { margin: 0; }
td .row { gap: 0.4rem; }
.cell-main { font-weight: 600; }
.cell-main a { text-decoration: none; }
.cell-main a:hover { text-decoration: underline; }

@media (max-width: 40rem) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; padding: 0.7rem 0; border-bottom: 1px solid var(--rule); }
  .table-stack td { display: block; border: 0; padding: 0.1rem 0; }
  .table-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.8125rem; }
  .table-stack td:empty { display: none; }
}

/* ---------- forms ---------- */
.field { margin: 0 0 1rem; }
label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.25rem; }
.hint { margin: 0 0 0.4rem; font-size: 0.8125rem; color: var(--muted); }
input, textarea, select, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.5rem 0.6rem;
}
input:not([type="checkbox"]):not([type="radio"]):focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--focus);
  outline-offset: 0;
}
textarea { resize: vertical; min-height: 4.5rem; }
select { appearance: auto; }
input[type="file"] { font-size: 0.9375rem; }
label:has(> input[type="checkbox"]) { font-weight: 400; }
label > input[type="checkbox"] { margin: 0 0.45rem 0 0; vertical-align: -0.1em; }
.field-row { display: grid; gap: 0 1rem; }
.field-row-2 { grid-template-columns: 1fr 1fr; }
.field-row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 40rem) { .field-row-2, .field-row-3 { grid-template-columns: 1fr; } }
.form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.code-input {
  font-size: 1.5rem !important;
  letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums;
  max-width: 12rem;
}
[data-expired="1"] { color: var(--bad); }
/* Inputs reach 16px on touch so iOS Safari does not zoom the page on focus. */
@media (hover: none), (pointer: coarse) { input, textarea, select { font-size: 16px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--text);
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9375rem;
  line-height: 1.3;
}
.btn:hover { background: var(--soft); text-decoration: none; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--text); opacity: 0.88; }
.btn-quiet { border-color: transparent; color: var(--muted); padding-left: 0.35rem; padding-right: 0.35rem; }
.btn-quiet:hover { background: transparent; color: var(--text); text-decoration: underline; }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: transparent; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8125rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: 0.5; cursor: default; }
@media (hover: none), (pointer: coarse) { .btn { min-height: 44px; } }

/* ---------- small text and layout helpers ---------- */
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--muted); font-size: 0.875rem; }
.fine { color: var(--muted); font-size: 0.8125rem; }
.faint a, .fine a { color: inherit; }
ul, ol { padding-left: 1.25rem; }
li { margin: 0.2rem 0; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

@media (max-width: 30rem) {
  main { padding-top: 1.5rem; }
  .wrap { padding: 0 1.1rem; }
}

/* ---------- rendered documents ----------
 * Agreements read as documents: real headings, paragraph rhythm, a measure. The
 * global h2 rule makes section labels; inside .prose a heading is a heading.
 */
.prose { max-width: 40rem; }
.prose h1 { font-size: 1.25rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -0.01em; }
.prose h2 { font-size: 1rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text); margin: 1.75rem 0 0.5rem; }
.prose h3 { font-size: 0.9375rem; font-weight: 600; margin: 1.25rem 0 0.35rem; }
.prose p { margin: 0 0 0.85rem; }
.prose ul, .prose ol { margin: 0 0 0.85rem; padding-left: 1.35rem; }
.prose li { margin: 0.25rem 0; }
.prose hr { margin: 1.5rem 0; }
.prose table { margin: 0.5rem 0 1rem; font-size: 0.9rem; }
.prose em { font-style: italic; }
.prose code { font-size: 0.85em; }
