/* Cerno: one stylesheet for every page.
   Paper background, serif body, sans for labels and controls. */

:root {
  color-scheme: light dark;
  --bg: #f6f3ec;
  --ink: #1c1a17;
  --muted: #645e55;
  --rule: #d9d3c6;
  --card: #fffdf8;
  --tint: #ece7db;
  --accent: #8a3b12;
  --alert: #9a1f1f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --ink: #ece7dc;
    --muted: #a39c90;
    --rule: #37322c;
    --card: #1e1b18;
    --tint: #28241f;
    --accent: #e0915f;
    --alert: #f2a59b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.6 var(--serif);
}
.sans { font-family: var(--sans); }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Focus: one visible ring everywhere, only for keyboard use. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
[tabindex="-1"]:focus { outline: none; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  padding: 0.6rem 0.9rem; border-radius: 4px;
  background: var(--ink); color: var(--bg); font-size: 0.9rem; text-decoration: none;
}
.skip:focus { top: 0.75rem; }

/* ---- frame ---- */

.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.25rem; }

header { display: flex; justify-content: space-between; align-items: baseline; gap: 1.5rem; padding: 1.75rem 0; }
.mark { display: inline-flex; align-items: center; gap: 0.45rem; flex: none; font-size: 1.25rem; letter-spacing: 0.02em; color: inherit; text-decoration: none; }
.mark::before { content: ""; width: 1.6rem; height: 1.6rem; background: url(mark.svg) center / contain no-repeat; }
.nav { font-size: 0.8rem; color: var(--muted); display: flex; gap: 1rem; align-items: baseline; min-width: 0; }
.nav .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav form { margin: 0; flex: none; }

footer { border-top: 1px solid var(--rule); padding: 1.75rem 0 3rem; font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; }
footer nav { display: flex; gap: 1.25rem; }
footer a { color: var(--muted); text-underline-offset: 0.15em; }
footer a:hover { color: var(--ink); }

/* ---- shared pieces ---- */

h1 { font-size: clamp(2.1rem, 6vw, 3.25rem); line-height: 1.12; font-weight: 500; margin: 0 0 1.25rem; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.5rem; }
.lede { font-size: 1.2rem; color: var(--muted); margin: 0 0 2rem; max-width: 36rem; }

.cta {
  display: inline-block; padding: 0.8rem 1.3rem; border: 0; border-radius: 4px;
  background: var(--ink); color: var(--bg); font: inherit; font-size: 0.95rem; line-height: 1.3;
  text-decoration: none; cursor: pointer;
}
.cta:hover { opacity: 0.88; }
.cta:active { opacity: 0.75; }
.cta[disabled] { opacity: 0.5; cursor: default; }
.cta.quiet { background: none; color: var(--ink); border: 1px solid var(--muted); padding: 0.6rem 1.1rem; font-size: 0.9rem; }
.cta.quiet:hover { opacity: 1; border-color: var(--ink); }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em; }
.linkbtn:hover { color: var(--ink); }

.note { font-size: 0.85rem; color: var(--muted); }
.error { color: var(--alert); font-size: 0.95rem; }

/* ---- privacy and terms ---- */

.page.legal h1 { margin-bottom: 0.5rem; }
.legal .updated { color: var(--muted); font-size: 0.9rem; margin: 0 0 2rem; }
.legal section { padding: 2rem 0; }
.legal h2 { margin-bottom: 1rem; }
.legal p { margin: 0 0 1rem; }
.legal p:last-child { margin-bottom: 0; }
.legal a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

/* ---- home ---- */

.hero { padding: 3.5rem 0 3rem; }
section { border-top: 1px solid var(--rule); padding: 2.75rem 0; }

.sample { background: var(--card); border: 1px solid var(--rule); border-radius: 6px; padding: 1.5rem 1.5rem 1.25rem; }
.sample h3 { font-size: 1.3rem; font-weight: 500; line-height: 1.3; margin: 0 0 0.9rem; }
.sample p { margin: 0 0 0.9rem; font-size: 1rem; }
.sample .evidence { color: var(--muted); font-size: 0.95rem; }
.sample .reading { border-left: 2px solid var(--accent); padding-left: 0.9rem; }
.sample .reading b { color: var(--accent); font-weight: 600; }
.caption { font-size: 0.8rem; color: var(--muted); margin: 0.75rem 0 0; }

ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.steps li { counter-increment: step; display: grid; grid-template-columns: 2.25rem 1fr; gap: 0 0.5rem; margin-bottom: 1.25rem; }
ol.steps li::before { content: counter(step); color: var(--accent); font-size: 1.3rem; line-height: 1.35; }
ol.steps strong { font-weight: 600; }
ol.steps span { color: var(--muted); }

dl { margin: 0; }
dt { font-weight: 600; margin-top: 1.1rem; }
dt:first-child { margin-top: 0; }
dd { margin: 0.15rem 0 0; color: var(--muted); }

/* ---- setup, building, error: one column, one card at a time ---- */

.page { padding: 1.5rem 0 3rem; }
.page h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); margin-bottom: 0.9rem; }
.page .lede { margin-bottom: 1.75rem; }

.panel { background: var(--card); border: 1px solid var(--rule); border-radius: 6px; padding: 1.4rem 1.5rem 1.5rem; margin: 0 0 1.5rem; }
.panel h2 { margin-bottom: 0.9rem; }
.panel p { margin: 0 0 0.9rem; font-size: 1rem; }
.panel > :last-child { margin-bottom: 0; }
.panel .cta { margin-top: 0.35rem; }
.panel.failed { border-left: 3px solid var(--alert); }
.panel.failed .error { font-size: 1rem; }
.panel.quiet { background: none; border-style: dashed; }

/* The three steps of setup. The current one carries the accent; finished ones a tick. */
.progress { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; counter-reset: progress; font-size: 0.8rem; line-height: 1.35; color: var(--muted); }
.progress li { counter-increment: progress; border-top: 2px solid var(--rule); padding-top: 0.55rem; }
.progress li::before { content: counter(progress); display: block; font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.progress li[data-done] { border-top-color: var(--muted); }
.progress li[data-done]::before { content: "\2713"; }
.progress li[aria-current] { border-top-color: var(--accent); color: var(--ink); font-weight: 600; }
.progress li[aria-current]::before { color: var(--accent); font-weight: 400; }

/* What was found, as a sentence first and the sum beneath it. */
.statement { font-size: 1.3rem; line-height: 1.4; margin-bottom: 1.1rem; text-wrap: pretty; }
.panel .statement { font-size: 1.3rem; }
.statement strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.counts { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0; margin: 0 0 1.1rem; padding: 0.8rem 0 0; border-top: 1px solid var(--rule); font-size: 0.9rem; }
.counts dt { font-weight: 400; margin: 0; color: var(--muted); }
.counts dd { margin: 0; padding-left: 1.5rem; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
#nothing:not([hidden]) ~ .counts { margin-bottom: 0; }
#message { margin: 0 0 1.5rem; padding-left: 0.9rem; border-left: 3px solid var(--alert); }

/* The stages of a build. Only the stage is known, so only the stage is shown. */
.stages { list-style: none; margin: 0 0 1.1rem; padding: 0 0 1rem; border-bottom: 1px solid var(--rule); font-size: 1.1rem; }
.stages li { display: grid; grid-template-columns: 1.75rem 1fr; align-items: baseline; padding: 0.3rem 0; color: var(--muted); }
.stages li::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; border: 1.5px solid var(--muted); opacity: 0.6; align-self: center; }
.stages li[data-state="done"]::before { content: "\2713"; width: auto; height: auto; border: 0; border-radius: 0; align-self: baseline; font-size: 0.95rem; opacity: 1; }
.stages li[data-state="current"] { color: var(--ink); }
.stages li[data-state="current"]::before { background: var(--accent); border-color: var(--accent); opacity: 1; animation: breathe 2.4s ease-in-out infinite; }
#checking:has(+ #trouble[hidden]) { margin-bottom: 0; }
@keyframes breathe { 50% { opacity: 0.3; } }

/* ---- the profile reader ---- */

.reader { padding: 0.5rem 0 3rem; }
.contents { display: none; }

.reader ol { list-style: none; margin: 0; padding: 0; }
.reader ol a { display: block; padding: 0.3rem 0.5rem 0.3rem 0.8rem; border-left: 2px solid transparent; color: var(--ink); text-decoration: none; line-height: 1.35; }
.reader ol a:hover { color: var(--accent); }
.reader ol a:focus-visible, .filenav summary:focus-visible { outline-offset: -2px; }
.reader ol a[aria-current] { border-left-color: var(--accent); color: var(--accent); font-weight: 600; }

.filenav { margin: 0 0 2rem; font-size: 0.9rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); }
.filenav summary { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.7rem 0.9rem; cursor: pointer; list-style: none; border-radius: 6px; }
.filenav summary::-webkit-details-marker { display: none; }
.filenav summary::after { content: ""; flex: none; align-self: center; width: 0.45rem; height: 0.45rem; margin-left: auto; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-25%) rotate(45deg); }
.filenav[open] summary::after { transform: translateY(25%) rotate(-135deg); }
.filenav .label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); flex: none; }
.filenav .where { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filenav .of { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.filenav ol { border-top: 1px solid var(--rule); padding: 0.5rem 0 0.6rem; }
.filenav ol a { padding-top: 0.5rem; padding-bottom: 0.5rem; }

.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
/* One page: h1 is the page title, h2 a section (a file of the profile), h3 and
   below the headings inside a document. */
.prose h1 { font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.15; margin: 0 0 0.5rem; text-wrap: balance; }
.prose h2 { font-size: clamp(1.7rem, 4.5vw, 2.1rem); font-weight: 500; line-height: 1.2; letter-spacing: -0.005em; text-transform: none; color: var(--ink); margin: 0 0 0.5rem; text-wrap: balance; }
.prose h3 { font-size: 1.4rem; font-weight: 500; line-height: 1.3; margin: 2.75rem 0 0.8rem; text-wrap: balance; }
.prose h4 { font-size: 1.1rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
.prose h5, .prose h6 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.4rem; }
.prose hr + h3 { margin-top: 0; }
.prose .part { border-top: 1px solid var(--rule); padding: 0; margin: 4.5rem 0 0; padding-top: 3rem; scroll-margin-top: 1rem; }
.prose .part.intro { border-top: 0; margin: 0; padding: 0; }
.part-head { margin: 0 0 1.25rem; }
.part-head .range { margin: 0; font-size: 0.85rem; letter-spacing: 0.02em; color: var(--muted); font-variant-numeric: tabular-nums; }
.part-head + p { font-size: 1.15rem; line-height: 1.55; color: var(--muted); }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose p { text-wrap: pretty; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose ol { list-style: decimal; }
.prose li { margin: 0 0 0.4rem; }
.prose li::marker { color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0 2.25rem; }
.prose blockquote { margin: 0 0 1rem; padding: 0.1rem 0 0.1rem 1rem; border-left: 2px solid var(--rule); color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font: 0.82em var(--mono); background: var(--tint); border-radius: 3px; padding: 0.1em 0.3em; overflow-wrap: anywhere; }
.prose pre { overflow-x: auto; background: var(--tint); border-radius: 4px; padding: 0.8rem 1rem; margin: 0 0 1rem; }
.prose pre code { padding: 0; background: none; }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.prose a code { color: inherit; }
.prose .link { color: var(--ink); }
/* Interpretation is set apart from evidence by a rule in the accent colour. */
.prose .reading { border-left: 2px solid var(--accent); padding-left: 1rem; margin-top: 1.25rem; }
.prose .reading strong:first-child { color: var(--accent); }
/* A wide table scrolls inside itself; the page never does. */
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1.5rem 0 1.75rem; font-size: 0.9rem; line-height: 1.45; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 0.5rem 1.1rem 0.5rem 0; border-bottom: 1px solid var(--rule); }
.prose th:last-child, .prose td:last-child { padding-right: 0; }
.prose th { font: 600 0.72rem/1.45 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; border-bottom-color: var(--muted); }
.prose td:first-child { white-space: nowrap; }
.prose td:last-child:not(:first-child) { min-width: 9rem; }

/* The profile's two views, the full write-up and the portrait, as links above the reading. */
.tabs { display: flex; gap: 1.5rem; margin: 0 0 2rem; border-bottom: 1px solid var(--rule); font-size: 0.9rem; }
.tabs a { margin-bottom: -1px; padding: 0.5rem 0; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }

/* Admin only, at the top: which run is shown, as a dropdown, and its numbers. */
.pick { margin: 0 0 2rem; padding: 0 0 1rem; border-bottom: 1px solid var(--rule); font-size: 0.85rem; line-height: 1.5; }
.page .pick { margin-top: 0; }
.pick form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0 0 0.5rem; }
.pick label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pick select { flex: 1 1 14rem; min-width: 0; max-width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--muted); border-radius: 4px; background: var(--card); color: var(--ink); font: inherit; }
.pick .cta { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
.pick .figures { margin: 0 0 0.4rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pick .figures a { color: var(--accent); }
.pick .misses { margin: 0 0 0.4rem; color: var(--muted); }
.pick .misses summary { cursor: pointer; }
.pick .misses ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }

/* Admin only, after the reading: the runs that are not ready, and the way to make another. */
.admin { margin: 4.5rem 0 0; padding: 1.5rem 0 0; border-top: 1px solid var(--rule); font-size: 0.85rem; line-height: 1.5; }
.page .admin { margin-top: 2rem; }
.admin .label { margin: 0 0 0.75rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.admin p { margin: 0 0 0.75rem; }
.admin .note { max-width: 32rem; }
.admin .cta { margin: 0.25rem 0 0.75rem; }
.admin .error { margin: 0; font-size: 0.85rem; }
.admin .panel { padding: 1rem 1.1rem 1.1rem; font-size: 0.9rem; }
.admin .panel h2 { margin-bottom: 0.6rem; }
.rebuild-form { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; margin: 0 0 0.75rem; }
.rebuild-form .field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.rebuild-form .field:nth-child(2) { flex: 1 1 14rem; }
.rebuild-form label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.rebuild-form select, .rebuild-form input { min-width: 0; max-width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--muted); border-radius: 4px; background: var(--card); color: var(--ink); font: inherit; }
.runs-scroll { overflow-x: auto; margin: 0 0 1rem; }
.runtable { border-collapse: collapse; width: 100%; font-size: 0.8rem; line-height: 1.4; }
.runtable th, .runtable td { text-align: left; vertical-align: top; padding: 0.4rem 0.9rem 0.4rem 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.runtable th { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--muted); }
.runtable tr.why td { white-space: normal; padding-top: 0; }

/* Wide screens: the list of sections stays beside the text. */
@media (min-width: 60rem) {
  .wrap.wide { max-width: 62rem; }
  .reader { display: grid; grid-template-columns: 14rem minmax(0, 40rem); column-gap: 3.5rem; justify-content: space-between; padding-top: 1rem; }
  .filenav { display: none; }
  .contents { display: block; position: sticky; top: 1.5rem; align-self: start; max-height: calc(100vh - 3rem); overflow-y: auto; font-size: 0.85rem; padding: 0.4rem 0 1rem; }
  .contents-title { margin: 0 0 0.9rem; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
  .contents ol { border-left: 1px solid var(--rule); }
  .contents ol a { margin-left: -1px; }
}

@media (max-width: 34rem) {
  .panel { padding: 1.2rem 1.1rem 1.3rem; }
  .prose h3 { font-size: 1.3rem; }
  .prose .part { margin-top: 3.5rem; padding-top: 2.5rem; }
  /* Dates may wrap, so a two-column table fits a phone. */
  .prose td:first-child { white-space: normal; }
  .part-head + p { font-size: 1.1rem; }
}

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

@media print {
  header .nav, .filenav, .contents, .skip, footer, .admin, .pick, .tabs { display: none; }
  .reader { display: block; }
  body { background: none; }
}
