/* Rälssi-Moukari: carbon-copy paper, blue-black ink, stamp-blue links, highlighter excerpts.
   Uncertainty is always ochre AND dashed/dotted, never colour alone.
   The one loud element is the wordmark, set as a rubber stamp; everything else stays quiet. */

/* Charis SIL (SIL Open Font License, fonts/OFL.txt): Charter's design, served locally so the
   text face is the same on every system. No external CDNs. */
@font-face { font-family: "Charis SIL"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/charis-sil-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Charis SIL"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/charis-sil-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Charis SIL"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/charis-sil-latin-700-normal.woff2") format("woff2"); }

:root {
  --paper: #e9ece7;
  --ink: #1c2430;
  --ink-soft: #4a5562;
  --stamp: #2f4b7c;
  --ochre: #a8650a;
  --marker: #f1e58f;
  --rule: #a9b1ae;
  --rule-soft: color-mix(in srgb, var(--rule) 55%, transparent);
  --card: #f4f6f2;
  --project: #5f7334;

  --serif: "Charis SIL", Charter, "Bitstream Charter", "Iowan Old Style", "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --sans: system-ui, "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --narrow: "Arial Narrow", "Roboto Condensed", "Nimbus Sans Narrow", "Helvetica Neue Condensed", var(--sans);

  --step--1: 0.833rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 2.441rem;
  --measure: 72ch;
}

* { box-sizing: border-box; }

html { font-size: 112.5%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.6 var(--serif);
  font-variant-numeric: lining-nums;
}

a { color: var(--stamp); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; }

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

/* Header: one row on wide screens. The wordmark is a rubber stamp. */
header.site {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem 1.75rem;
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  border-bottom: 3px solid var(--ink);
  font-family: var(--sans);
}
.brand { text-decoration: none; display: inline-block; padding: 0.15rem 0; }
.brand span {
  display: inline-block;
  font-family: var(--narrow); font-stretch: condensed; font-weight: 800;
  font-size: var(--step-2); line-height: 1; letter-spacing: 0.01em; white-space: nowrap;
  color: var(--stamp);
  padding: 0.3rem 0.55rem 0.25rem;
  border: 3px double var(--stamp); border-radius: 3px;
  transform: rotate(-2deg);
  /* Uneven ink, as from a rubber stamp. */
  -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 55%, rgba(0, 0, 0, 0.78) 100%);
          mask-image: radial-gradient(circle at 30% 40%, #000 55%, rgba(0, 0, 0, 0.78) 100%);
}
.brand:hover span, .brand:focus-visible span { color: var(--ink); border-color: var(--ink); }
header.site nav { display: flex; gap: 0.25rem 1.25rem; font-size: var(--step--1); white-space: nowrap; }
header.site nav a { color: var(--ink); text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
header.site nav a:hover { border-bottom-color: var(--ink); }
header.site nav a[aria-current="page"] { border-bottom-color: var(--stamp); color: var(--stamp); }

input[type="search"] {
  font: inherit; font-family: var(--sans); font-size: var(--step--1);
  padding: 0.4rem 0.6rem; width: 13rem;
  border: 1px solid var(--ink-soft); border-radius: 2px; background: #fff; color: var(--ink);
}
button {
  font: 600 var(--step--1) var(--sans);
  padding: 0.55rem 1.1rem; border: 0; border-radius: 2px;
  background: var(--ink); color: var(--paper); cursor: pointer;
}
button:hover { background: var(--stamp); }

main {
  padding: 2rem clamp(1rem, 4vw, 3rem) 4rem;
  max-width: 68rem;
}

footer.site {
  padding: 1.5rem clamp(1rem, 4vw, 3rem) 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft); font-size: var(--step--1);
}
footer.site p { max-width: 60ch; }

h1, h2 { font-weight: 700; line-height: 1.15; }
h1 { font-size: var(--step-3); margin: 0 0 0.5rem; max-width: 32ch; text-wrap: balance; }
h2 { font-size: var(--step-1); margin: 2.75rem 0 0.75rem; font-family: var(--sans); }
h2 .count { font-weight: 400; color: var(--ink-soft); font-size: var(--step-0); margin-left: 0.2rem; font-variant-numeric: tabular-nums; }

p { max-width: var(--measure); }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li { padding: 0.45rem 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 50%, transparent); }

.kind { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin: 0; }
.entity-head .kind { display: flex; align-items: center; margin-bottom: 0.35rem; }
.entity-head .kind .dot { margin-left: 0; }

/* Front page */
.intro h1 { max-width: 20ch; }
.intro > p { font-size: var(--step-1); color: var(--ink-soft); }
.search.big { margin: 2rem 0 1rem; font-family: var(--sans); }
.search.big label { display: block; font-size: var(--step--1); margin-bottom: 0.35rem; }
.search.big .row { display: flex; gap: 0.5rem; max-width: 40rem; }
.search.big input { flex: 1; font-size: var(--step-0); padding: 0.6rem 0.75rem; border-width: 2px; border-color: var(--ink); }
.intro > p.totals { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }

/* Entity header */
.entity-head { border-bottom: 1px solid var(--rule); padding-bottom: 1.25rem; }
/* Facts read like the fields of a typed form: label above, value on a dotted line. */
dl.facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2.5rem; margin: 1rem 0 0; font-family: var(--sans); }
dl.facts div { display: grid; gap: 0.1rem; min-width: 7rem; }
dl.facts div.wide { flex-basis: 100%; }
dl.facts dt { color: var(--ink-soft); font-size: 0.75rem; }
dl.facts dd { margin: 0; font-size: var(--step-0); font-variant-numeric: tabular-nums; border-bottom: 1px dotted var(--ink-soft); padding-bottom: 0.1rem; }
dd.hash { word-break: break-all; }
.description { color: var(--ink-soft); margin-top: 0.75rem; }

/* Tags: small, sentence case, never decorative */
.tag {
  display: inline-block; font: 600 0.72rem/1.4 var(--sans);
  padding: 0 0.4rem; border: 1px solid var(--ink-soft); border-radius: 2px; color: var(--ink-soft);
  vertical-align: 0.1em; white-space: nowrap;
}
.tag.uncertain { color: var(--ochre); border: 1px dashed var(--ochre); }
.tag.via { border-style: dotted; }
.why { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin: 0.2rem 0 0; }
.hint { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }

.identity li.link-suggested { border-left: 3px dashed var(--ochre); padding-left: 0.75rem; }
.identity li.link-confirmed { border-left: 3px dotted var(--ink); padding-left: 0.75rem; }

/* Connection graph: line style = certainty */
.graph figure { margin: 0; overflow-x: auto; }
.graph svg { width: 100%; min-width: 40rem; max-width: 60rem; height: auto; display: block; }
.edge { stroke: var(--ink); stroke-width: 1.5; }
.edge.inferred { stroke: var(--ochre); stroke-dasharray: 7 5; }
.edge.identity-confirmed { stroke: var(--ink); stroke-dasharray: 1.5 4; stroke-linecap: round; stroke-width: 2.5; }
.edge.identity-suggested { stroke: var(--ochre); stroke-dasharray: 1.5 4; stroke-linecap: round; stroke-width: 2.5; }
.node { stroke: var(--paper); stroke-width: 2; }
.node.kind-person, .dot.kind-person { fill: var(--ink); background: var(--ink); }
.node.kind-organization, .dot.kind-organization { fill: var(--stamp); background: var(--stamp); }
.node.kind-project, .dot.kind-project { fill: var(--project); background: var(--project); }
.node.center { stroke: var(--ink); stroke-width: 3; fill: var(--paper); }
.node-label { font: 600 12px var(--sans); fill: var(--ink); }
.node-role { font: 400 11px var(--sans); fill: var(--ink-soft); }
.graph a:hover .node-label, .graph a:focus .node-label { fill: var(--stamp); text-decoration: underline; }

figcaption { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.5rem; }
.key::before { content: ""; display: inline-block; width: 2rem; margin-right: 0.4rem; vertical-align: middle; border-top: 2px solid var(--ink); }
.key.inferred::before { border-top: 2px dashed var(--ochre); }
.key.identity-confirmed::before { border-top: 3px dotted var(--ink); }
.key.identity-suggested::before { border-top: 3px dotted var(--ochre); }
.key.shape::before { display: none; }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin: 0 0.3rem 0 0.6rem; vertical-align: -0.05em; }

/* Relation tables */
table { width: 100%; border-collapse: collapse; font: var(--step--1)/1.5 var(--sans); }
td a.entity { font-family: var(--serif); font-size: var(--step-0); }
th { font: 600 var(--step--1) var(--sans); text-align: left; color: var(--ink-soft); border-bottom: 2px solid var(--ink); padding: 0.35rem 0.6rem 0.35rem 0; }
td { padding: 0.6rem 0.6rem 0.6rem 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); vertical-align: top; }
.num { text-align: right; font-family: var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
.period { font-family: var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.basis { width: 40%; font-family: var(--sans); }
td .sub { display: block; font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft); }
tr.inferred td:first-child { border-left: 3px dashed var(--ochre); padding-left: 0.6rem; }
table.list { max-width: 40rem; font-size: var(--step-0); }

/* Excerpts: highlighter on photocopy */
/* Highlighter stroke: a little wider than the text and uneven at the ends. */
mark {
  color: var(--ink); padding: 0.05em 0.25em; margin: 0 -0.1em;
  background: linear-gradient(100deg, transparent 0.15em, var(--marker) 0.3em, var(--marker) calc(100% - 0.3em), transparent calc(100% - 0.1em));
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.excerpt { margin: 0.3rem 0 0; font-family: var(--serif); font-size: var(--step--1); line-height: 1.55; }
details.excerpt summary { cursor: pointer; list-style: none; }
details.excerpt summary::-webkit-details-marker { display: none; }
details.excerpt[open] summary { display: none; }

sup.note { font-family: var(--sans); font-size: 0.7em; line-height: 0; }
sup.note a { text-decoration: none; padding: 0 0.1em; }

.attr { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft); margin-left: 0.5rem; }
.as-written { font-style: italic; }

.finding { border-left: 3px dashed var(--ochre); padding: 0.6rem 1rem; margin: 1rem 0; background: color-mix(in srgb, var(--ochre) 6%, transparent); max-width: var(--measure); }
.finding h3 { font: 700 var(--step-0) var(--sans); margin: 0 0 0.25rem; }
.finding p { margin: 0.25rem 0; }
ul.evidence { font-family: var(--sans); font-size: var(--step--1); padding-left: 1.2rem; margin: 0.4rem 0 0; }
ul.evidence li { margin: 0.2rem 0; }
.second-hop dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 0 2rem; }
.second-hop dl > div { padding: 0.6rem 0; border-bottom: 1px solid var(--rule-soft); }
.second-hop dt { font-weight: 700; }
.second-hop dd { margin: 0.2rem 0 0; }

.sources ol { padding-left: 1.5rem; font-size: var(--step--1); }
.sources li { padding: 0.25rem 0; }
.sources li:target { background: var(--marker); }
.meta { display: block; font-family: var(--sans); color: var(--ink-soft); font-size: 0.8rem; }

.unknown { font-style: italic; color: var(--ink-soft); font-family: var(--sans); }
.rel { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); }
.fulltext pre { white-space: pre-wrap; font: var(--step--1)/1.5 var(--serif); background: #fff; padding: 1rem; border: 1px solid var(--rule); max-width: var(--measure); }
.fulltext summary { cursor: pointer; font-family: var(--sans); margin-top: 2rem; }

.notice { font-family: var(--sans); font-size: var(--step--1); border-left: 3px solid var(--stamp); padding: 0.4rem 0.75rem; background: #fff; max-width: 40rem; }
.queue-new { font-family: var(--sans); margin: 1rem 0 1.5rem; }
.queue-new label { display: block; font-size: var(--step--1); margin-bottom: 0.35rem; }
.queue-new .row { display: flex; gap: 0.5rem; max-width: 40rem; }
.queue-new input { flex: 1; font: inherit; font-size: var(--step--1); padding: 0.45rem 0.6rem; border: 1px solid var(--ink-soft); border-radius: 2px; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
button:disabled { background: var(--rule); color: var(--ink); cursor: not-allowed; }
.queue-state { font-family: var(--sans); font-size: var(--step--1); margin: 1rem 0; padding: 0.6rem 0.9rem; border-left: 3px solid var(--rule); background: #fff; max-width: 48rem; }
.queue-state.paused { border-left: 3px dashed var(--ochre); }
.queue-state p { margin: 0 0 0.5rem; }
.queue-state .row { display: flex; gap: 0.5rem; }
.queue-state input { flex: 1; font: inherit; padding: 0.35rem 0.5rem; border: 1px solid var(--ink-soft); border-radius: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 1rem; font-family: var(--sans); font-size: var(--step--1); margin: 0.5rem 0 1rem; }
.filters a[aria-current="page"] { font-weight: 700; text-decoration: none; color: var(--ink); }
.pager { display: flex; gap: 1.5rem; margin-top: 1.5rem; font-family: var(--sans); font-size: var(--step--1); }

/* Narrower: wordmark and account on the first row, menu on the second. */
@media (max-width: 80rem) {
  header.site { grid-template-columns: 1fr auto; }
  header.site .account { grid-column: 2; grid-row: 1; justify-self: end; }
  header.site nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; scrollbar-width: none; }
}

@media (max-width: 40rem) {
  html { font-size: 106%; }
  .who { max-width: 10rem; }
  .brand span { font-size: var(--step-1); }
  tr.inferred { border-left: 3px dashed var(--ochre); padding-left: 0.6rem; }
  tr.inferred td:first-child { border-left: 0; padding-left: 0; }
  .graph svg { min-width: 34rem; }
  td.basis { width: auto; }
  table thead { display: none; }
  table tr { display: block; border-bottom: 1px solid var(--rule); padding: 0.5rem 0; }
  table td { display: block; border: 0; padding: 0.15rem 0; }
  .num { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Account and sign-in */
header.site .account { display: flex; align-items: center; gap: 0.9rem; font-size: var(--step--1); }
header.site .account form { display: inline; }
header.site .account button.link, header.site .account > a { white-space: nowrap; }
.who { display: grid; line-height: 1.25; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 0.78rem; }
.who .role { color: var(--ink); font-weight: 600; }
button.link {
  background: none; color: var(--stamp); padding: 0; font: inherit; font-family: var(--sans);
  text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 1px;
}
button.link:hover { background: none; text-decoration-thickness: 2px; }
.public-note {
  margin: 0; max-width: none; padding: 0.5rem clamp(1rem, 4vw, 3rem);
  font: var(--step--1) var(--sans); color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
}
.error { font-family: var(--sans); color: #8a1c1c; font-weight: 600; }
form.inline { display: inline-flex; gap: 0.4rem; align-items: center; }
select { font: var(--step--1) var(--sans); padding: 0.3rem; }

/* Information requests */
a.button {
  display: inline-block; font: 600 var(--step--1) var(--sans); text-decoration: none;
  padding: 0.55rem 1.1rem; border-radius: 2px; background: var(--ink); color: var(--paper);
}
a.button:hover { background: var(--stamp); }
a.button.small { padding: 0.25rem 0.6rem; font-size: 0.75rem; margin-top: 0.3rem; }
a.button.secondary { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
a.button.secondary:hover { background: #fff; }
.request-group h3 { font: 700 var(--step-0) var(--sans); margin: 2rem 0 0.5rem; }
ol.steps { font-family: var(--sans); font-size: var(--step--1); padding-left: 1.25rem; max-width: var(--measure); }
ol.steps li { margin: 0.2rem 0; }
.compose-form { display: grid; gap: 0.3rem; max-width: 46rem; font-family: var(--sans); margin-top: 1.5rem; }
.compose-form label { font-size: var(--step--1); font-weight: 600; margin-top: 0.75rem; }
.compose-form input, .compose-form textarea {
  font: var(--step-0)/1.5 var(--sans); padding: 0.5rem 0.65rem;
  border: 1px solid var(--ink-soft); border-radius: 2px; background: #fff; color: var(--ink);
}
.compose-form textarea { font-family: var(--serif); resize: vertical; }
.compose-form .hint { margin: 0; }
.compose-form .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; align-items: center; }
form.upload { display: grid; gap: 0.25rem; margin-top: 0.6rem; font-size: 0.8rem; max-width: 20rem; }
form.upload label { color: var(--ink-soft); }
form.upload input[type="text"] { font: inherit; padding: 0.25rem 0.4rem; border: 1px solid var(--ink-soft); border-radius: 2px; }
form.upload button { justify-self: start; margin-top: 0.25rem; }
details.sent-text summary { cursor: pointer; font-size: 0.75rem; color: var(--stamp); margin-top: 0.3rem; }
details.sent-text pre { white-space: pre-wrap; font: 0.8rem/1.45 var(--serif); background: #fff; padding: 0.6rem; border: 1px solid var(--rule); max-width: 40rem; }
.request-group td:nth-child(3) { white-space: nowrap; }
details.close-request { margin-top: 0.6rem; font-size: 0.8rem; }
details.close-request summary { cursor: pointer; color: var(--stamp); }
form.upload textarea { font: inherit; padding: 0.25rem 0.4rem; border: 1px solid var(--ink-soft); border-radius: 2px; resize: vertical; }
button.small.secondary { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
button.small.secondary:hover { background: #fff; }
.tag.refused { border-style: double; border-width: 3px; }
a.who { text-decoration: none; } a.who:hover { color: var(--stamp); }
.site .version { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.75rem; font-variant-numeric: tabular-nums; }
