/* Hairline. A structural inspection sheet that happens to be live.
 *
 * section 5: warm paper ground, a cold drafting blue rather
 * than the terracotta that ground would normally attract, a crisp text serif for
 * the report's own voice and a grotesque for everything instrumental. The page is
 * ruled like a drawing sheet, not set like a magazine column. There is no dark
 * theme: this is a document that gets printed and filed, so the effort went into
 * the print stylesheet at the bottom of this file instead.
 *
 * Contrast ratios in the comments are computed from these hex values with the
 * WCAG 2.1 relative luminance formula. */

@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600&family=Barlow+Condensed:wght@500;600&family=Spectral:wght@400;600&display=swap");

:root {
  color-scheme: light;

  --ground: #faf8f3;
  --surface: #ffffff;
  --raised: #f1eee6;
  --rule: #e2dccc;
  --rule-strong: #c9c1ac;

  --ink: #12181d;          /* 17.89:1 on surface */
  --ink-dim: #5e6670;      /*  5.82:1 on surface */
  --ink-faint: #8b8578;

  --accent: #15618f;       /*  6.69:1 on surface */
  --accent-wash: #eaf2f8;
  --caution: #8a5a06;      /*  5.92:1 on surface */
  --caution-wash: #f9f1e0;
  --signal: #a8321f;       /*  6.69:1 on surface */
  --signal-wash: #fbeeea;
  --ok: #2c6247;

  --font-ui: "Barlow", system-ui, -apple-system, sans-serif;
  --font-note: "Barlow Condensed", "Barlow", sans-serif;
  --font-doc: "Spectral", Georgia, serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --sidebar: 268px;
  --radius: 3px;           /* a drawing sheet has square corners */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- layout -- */

.sheet { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: var(--s5) var(--s4) var(--s4);

  /* The rail is pinned to the viewport and is exactly one viewport tall, so its
   * own content has to scroll inside it. Without this, everything below the fold
   * in the rail is unreachable at any page scroll position: on a 1080p laptop
   * that was the primary action itself, 98px below the bottom of the screen. */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.rail__mark { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: var(--s2); }
.rail__name { font-family: var(--font-doc); font-size: 25px; font-weight: 600; }
.rail__version { font-family: var(--font-note); font-size: 13px; color: var(--ink-faint); }
.rail__tagline { font-size: 13px; color: var(--ink-dim); margin: 0 0 var(--s5); line-height: 1.4; }

.rail__section { margin-bottom: var(--s5); }
.rail__legend {
  font-size: 13px; font-weight: 600; color: var(--ink-dim);
  margin-bottom: var(--s2); display: block;
}

.rail__status { margin-top: auto; border-top: 1px solid var(--rule); padding-top: var(--s3); }
.rail__row {
  display: flex; justify-content: space-between; gap: var(--s2);
  font-size: 13px; padding: 3px 0; color: var(--ink-dim);
}
.rail__row b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }

.page { padding: var(--s6) var(--s7) var(--s8); max-width: 1180px; }

.page__title { font-family: var(--font-doc); font-size: 33px; line-height: 1.15; }
.page__standfirst {
  font-family: var(--font-doc); font-size: 17px; color: var(--ink-dim);
  margin: var(--s2) 0 var(--s6); max-width: 62ch;
}

/* --------------------------------------------------------------- controls -- */

.dropzone {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--raised); border: 1px dashed var(--rule-strong);
  border-radius: var(--radius); padding: var(--s3); color: var(--ink);
  font: inherit; font-size: 13px;
}
.dropzone:hover, .dropzone[data-dragging="true"] { border-color: var(--accent); background: var(--accent-wash); }
.dropzone__file { display: block; font-weight: 500; }
.dropzone__hint { display: block; color: var(--ink-dim); margin-top: 2px; }

.rail__details > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: var(--s2);
}
.rail__details > summary::-webkit-details-marker { display: none; }
.rail__details > summary::after {
  content: "+"; margin-left: auto; color: var(--ink-faint); font-size: 15px; line-height: 1;
}
.rail__details[open] > summary::after { content: "\2212"; }
.rail__details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail__details > div { padding-top: var(--s2); }

.field { margin-bottom: var(--s3); }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.field input, .field select {
  width: 100%; font: inherit; font-size: 14px; padding: 6px 8px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.field__help { font-size: 12px; color: var(--ink-dim); margin: 3px 0 0; line-height: 1.35; }
.field__unit { color: var(--ink-faint); font-weight: 400; }

#submit { margin-top: var(--s3); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: inherit; font-weight: 500; font-size: 15px; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 9px 16px; width: 100%;
}
.button:hover:not(:disabled) { background: #114f75; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button--quiet {
  background: var(--surface); color: var(--accent); border-color: var(--rule-strong);
  width: auto; font-size: 14px; padding: 6px 12px;
}
.button--quiet:hover:not(:disabled) { background: var(--accent-wash); }

.samples { display: grid; gap: var(--s1); }
.samples button {
  text-align: left; font: inherit; font-size: 13px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 7px 9px; color: var(--ink);
}
.samples button:hover { border-color: var(--accent); background: var(--accent-wash); }
.samples b { display: block; font-weight: 500; }
.samples span { color: var(--ink-dim); font-size: 12px; }

.advice {
  margin-top: var(--s2); padding: var(--s2) var(--s3);
  border-left: 3px solid var(--rule-strong); background: var(--raised);
  font-size: 13px; line-height: 1.4;
}
.advice b { display: block; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.advice--ready { border-color: var(--ok); background: #e9f2ed; }
.advice--ready b { color: var(--ok); }
.advice--marginal { border-color: var(--caution); background: var(--caution-wash); }
.advice--marginal b { color: var(--caution); }
.advice--not-ready { border-color: var(--signal); background: var(--signal-wash); }
.advice--not-ready b { color: var(--signal); }
.advice dl { display: grid; grid-template-columns: auto 1fr; gap: 1px var(--s2);
             margin: var(--s2) 0 0; font-size: 12px; }
.advice dt { color: var(--ink-dim); }
.advice dd { margin: 0; font-variant-numeric: tabular-nums; }

/* The calibration gate's own banner. It is red and it is at the top, because a build
   that cannot measure a line it drew itself must not be quietly trusted.
   Named `notpublishing`, not `gate`: `.gate` is already the frames-not-used grid, and
   the collision put a red alarm border around an ordinary panel. */
.notpublishing {
  border: 2px solid var(--signal); background: var(--signal-wash);
  padding: var(--s4); margin-bottom: var(--s5);
}
.notpublishing h2 { font-family: var(--font-doc); font-size: 21px; color: var(--signal); }
.notpublishing p { margin: var(--s2) 0 0; font-size: 14px; max-width: 70ch; }

.titleblock { border: 1px solid var(--ink); background: var(--surface); margin-top: var(--s4); }
.titleblock__head {
  background: var(--ink); color: var(--ground); padding: 6px var(--s3);
  font-family: var(--font-doc); font-size: 14px; font-weight: 600;
  display: flex; justify-content: space-between; gap: var(--s3);
}
.titleblock__row {
  display: grid; grid-template-columns: 172px 1fr; gap: var(--s3);
  padding: 7px var(--s3); border-bottom: 1px solid var(--rule); font-size: 13px;
}
.titleblock__row:last-child { border-bottom: 0; }
.titleblock__row dt { font-family: var(--font-note); font-weight: 600; color: var(--ink-dim); }
.titleblock__row dd { margin: 0; font-variant-numeric: tabular-nums; }
.titleblock__sign {
  border-top: 1px solid var(--ink); padding: var(--s2) var(--s3);
  font-size: 12px; color: var(--ink-dim); font-style: italic;
}

/* ----------------------------------------------------------- manual scale -- */

.check {
  display: flex; align-items: flex-start; gap: var(--s2); cursor: pointer;
  font-size: 13px; font-weight: 500; margin-top: var(--s3);
}
.field .check { margin: 0 0 var(--s2); }
.check input { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
#manual-help { margin-bottom: 0; }

.manual .stations .button--quiet { color: var(--accent); }
.manual__stage {
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--raised); display: flex; justify-content: center;
}
.manual__stage canvas { display: block; max-width: 100%; cursor: crosshair; touch-action: none; }
.manual__fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s2) var(--s5); margin-top: var(--s4);
}
.manual__fields input[type="number"] { max-width: 180px; }

.notice ul { margin: var(--s2) 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); }
.notice li { margin-bottom: 2px; }

/* --------------------------------------------------------------- progress -- */

.progress { margin-bottom: var(--s5); }
.progress__track { height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--accent); transition: width 180ms linear; }
.progress__row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); }
.progress__message { font-size: 14px; color: var(--ink-dim); }
.log {
  font-family: var(--font-note); font-size: 13px; color: var(--ink-dim);
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: var(--s2) var(--s3); max-height: 150px; overflow: auto;
  white-space: pre-wrap; margin: var(--s3) 0 0;
}

/* -------------------------------------------------------------------- kpi -- */

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); margin-bottom: var(--s6);
}
.kpi { padding: var(--s4); border-right: 1px solid var(--rule); }
.kpi:last-child { border-right: 0; }
.kpi__label { font-size: 13px; color: var(--ink-dim); }
.kpi__value { font-size: 27px; font-weight: 600; line-height: 1.15; margin-top: 2px; }
.kpi__value small { font-size: 14px; font-weight: 500; color: var(--ink-dim); }
.kpi__note { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ------------------------------------------------------------------ block -- */

.block { margin-bottom: var(--s6); }
.block__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  border-bottom: 1px solid var(--rule-strong); padding-bottom: var(--s2); margin-bottom: var(--s3);
}
.block__title { font-family: var(--font-doc); font-size: 21px; }
.block__note { font-size: 13px; color: var(--ink-dim); }

figure { margin: 0; }
.figure img {
  width: 100%; display: block; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--surface);
}
figcaption { font-size: 13px; color: var(--ink-dim); margin-top: var(--s2); line-height: 1.45; }

.stations { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.stations button {
  font: inherit; font-size: 13px; cursor: pointer; padding: 5px 10px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.stations button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ table -- */

table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
thead th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-dim);
  border-bottom: 1px solid var(--rule-strong); padding: var(--s2) var(--s3); white-space: nowrap;
}
tbody td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:hover { background: var(--raised); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.id { font-family: var(--font-note); font-weight: 600; }
.u { color: var(--ink-dim); font-size: 13px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 2px 7px; border-radius: 2px;
  border: 1px solid currentColor; white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.tag--high { color: var(--ok); }
.tag--moderate { color: var(--caution); }
.tag--low { color: var(--caution); }
.tag--low::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tag--none, .tag--bounded { color: var(--signal); }
.tag--none::before, .tag--bounded::before { border-radius: 50%; }

.refused td { background: var(--signal-wash); }
.refused .reason { color: var(--signal); font-size: 13px; }

/* ---------------------------------------------------------------- refusal -- */

.refusal {
  border: 2px solid var(--signal); border-radius: var(--radius);
  background: var(--surface); padding: var(--s5); margin-bottom: var(--s6);
}
.refusal__head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.refusal__title { font-family: var(--font-doc); font-size: 27px; color: var(--signal); }
.refusal__code { font-family: var(--font-note); font-size: 14px; color: var(--ink-dim); }
.refusal__body { font-family: var(--font-doc); font-size: 17px; max-width: 60ch; margin: var(--s3) 0 0; }
.refusal__next { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--rule); }
.refusal__next h3 { font-size: 14px; margin-bottom: var(--s2); }
.refusal__next ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-dim); }
.refusal__next li { margin-bottom: 3px; }
.refusal .figure { margin-top: var(--s4); }

.empty { color: var(--ink-dim); font-family: var(--font-doc); font-size: 17px; }

.notice {
  border-left: 3px solid var(--caution); background: var(--caution-wash);
  padding: var(--s3) var(--s4); font-size: 14px; margin-bottom: var(--s4);
}
.notice--error { border-color: var(--signal); background: var(--signal-wash); }

.exports { display: flex; gap: var(--s2); flex-wrap: wrap; }

.gate {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s2);
  font-size: 13px;
}
.gate div { border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s2) var(--s3); background: var(--surface); }
.gate b { font-weight: 600; }

.footnote { font-size: 13px; color: var(--ink-dim); max-width: 72ch; line-height: 1.5; }

@media (max-width: 900px) {
  .sheet { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .page { padding: var(--s5) var(--s4) var(--s7); }
}

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

/* ------------------------------------------------------------------ print -- */
/* The atlas calls for a print stylesheet instead of a dark theme, because this is
 * a document that gets attached to an inspection record. */

@media print {
  body { background: #fff; font-size: 11pt; }
  .sheet { display: block; }
  .rail__section, .stations, .exports, .log, .progress, .manual { display: none; }
  .rail {
    position: static; height: auto; border: 0; border-bottom: 1pt solid #000;
    padding: 0 0 8pt; display: block; margin-bottom: 12pt;
  }
  .rail__status { border-top: 0; }
  .rail__row { display: inline-flex; margin-right: 18pt; }
  .page { padding: 0; max-width: none; }
  .block, .kpis, .refusal, table, figure { break-inside: avoid; }
  .figure img { border: 0.5pt solid #000; }
  tbody tr:hover { background: none; }
  a[href^="/api"]::after { content: ""; }
}
