@import url('fonts/fonts.css');

/* ─────────────────────────────────────────────────────────────
   Tokens — a proof-test form: drafting linen, ink, safety orange
   ───────────────────────────────────────────────────────────── */
:root {
  --ink:        #171a1c;
  --ink-2:      #4a5257;
  --ink-3:      #6f777b;
  --paper:      #dfe2da;
  --paper-2:    #ebede6;
  --paper-3:    #f3f4ef;
  --rule:       #a9aea3;
  --rule-soft:  #c4c8bd;
  --orange:     #d6480f;
  --webbing:    #262c33;
  --webbing-2:  #171b20;
  --pass:       #2c6b4c;
  --marginal:   #a9720a;
  --fail:       #a4201a;

  --display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --body:    'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono:    'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

  --gut: 22px;
  --hair: 1px solid var(--rule);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  /* faint horizontal fibre, like linen drafting stock */
  background-image: repeating-linear-gradient(
    0deg, rgba(23,26,28,.022) 0 1px, transparent 1px 4px
  );
}

/* ── Masthead ─────────────────────────────────────────────── */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 18px var(--gut) 12px;
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 700;
  font-size: clamp(20px, 4.2vw, 31px);
  letter-spacing: -.01em;
  line-height: 1;
  margin: 0;
  text-transform: uppercase;
}
.wordmark em {
  font-style: normal;
  color: var(--orange);
}
.masthead .sub {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-left: auto;
  text-align: right;
}

/* ── View switch ──────────────────────────────────────────── */
.views {
  display: flex;
  gap: 0;
  border-bottom: var(--hair);
  padding: 0 var(--gut);
  background: var(--paper-2);
  position: sticky;
  top: 0;
  z-index: 20;
}
.views button {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 13px 16px 10px;
  cursor: pointer;
}
.views button:hover { color: var(--ink); }
.views button[aria-selected='true'] {
  color: var(--ink);
  border-bottom-color: var(--orange);
}

/* ── Shell ────────────────────────────────────────────────── */
.sheet {
  max-width: 1160px;
  margin: 0 auto;
  padding: var(--gut) var(--gut) 64px;
}
[hidden] { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: var(--gut);
  align-items: start;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Field block: an engineering drawing's titled frame ───── */
.block {
  border: var(--hair);
  border-top: 2px solid var(--ink);
  background: var(--paper-2);
  padding: 26px 16px 16px;
  position: relative;
  margin-bottom: var(--gut);
}
.block > .tag {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--ink);
  color: var(--paper-3);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  padding: 3px 9px 3px 10px;
}
.block > .tag .n { color: var(--orange); }
.block:last-child { margin-bottom: 0; }

/* ── Inputs ───────────────────────────────────────────────── */
.field {
  display: grid;
  grid-template-columns: 1fr 104px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dotted var(--rule-soft);
}
.field:last-of-type { border-bottom: 0; }
.field > label {
  font-size: 13.5px;
  color: var(--ink);
}
.field .hint {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
}
.field input,
.field select {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 6px 7px;
  width: 100%;
  text-align: right;
}
.field select { text-align: left; font-size: 12.5px; }
.field input:focus-visible,
.field select:focus-visible,
.views button:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}
.field.wide { grid-template-columns: 1fr; }
.field.wide select, .field.wide input { text-align: left; }

.subhead {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 18px 0 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule-soft);
}
.subhead:first-of-type { margin-top: 2px; }

/* ── The plate: to-scale webbing with live stitch path ────── */
.plate {
  border: var(--hair);
  border-top: 2px solid var(--ink);
  background: var(--webbing-2);
  padding: 26px 0 0;
  position: relative;
  margin-bottom: var(--gut);
}
.plate > .tag {
  position: absolute; top: 0; left: 0;
  background: var(--ink); color: var(--paper-3);
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase;
  padding: 3px 9px;
}
.plate .scale-note {
  position: absolute; top: 4px; right: 10px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .06em; color: #7d858c;
}
/* Below this the note would run under the tag, and the drawing is
   already dimensioned — so drop it rather than crowd the plate. */
@media (max-width: 760px) { .plate .scale-note { display: none; } }
.plate svg { display: block; width: 100%; height: auto; }

/* ── Verdict ──────────────────────────────────────────────── */
.verdict {
  border: 2px solid var(--ink);
  background: var(--paper-2);
  margin-bottom: var(--gut);
}
.verdict .top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px 12px;
}
.verdict .stamp {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 700;
  font-size: clamp(24px, 5vw, 38px);
  line-height: .95;
  text-transform: uppercase;
  letter-spacing: -.005em;
}
.verdict .stamp .mark {
  font-family: var(--mono);
  font-size: .42em;
  font-weight: 500;
  letter-spacing: .1em;
  display: block;
  color: var(--ink-2);
  margin-bottom: 3px;
}
.verdict .tally {
  margin-left: auto;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .02em;
}
.verdict .tally b {
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  display: block;
  letter-spacing: -.01em;
}
.verdict[data-state='pass']     { border-color: var(--pass); }
.verdict[data-state='pass']     .stamp { color: var(--pass); }
.verdict[data-state='marginal'] { border-color: var(--marginal); }
.verdict[data-state='marginal'] .stamp { color: var(--marginal); }
.verdict[data-state='fail']     { border-color: var(--fail); }
.verdict[data-state='fail']     .stamp { color: var(--fail); }

.verdict .advice {
  border-top: var(--hair);
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--paper-3);
}
.verdict .advice b { font-family: var(--mono); font-weight: 500; }

/* travel bar: delivered stitching against required */
.travel { padding: 0 16px 16px; }
.travel .track {
  position: relative;
  height: 15px;
  background: var(--paper-3);
  border: 1px solid var(--rule);
}
.travel .fill { position: absolute; inset: 0 auto 0 0; }
.verdict[data-state='pass']     .travel .fill { background: var(--pass); }
.verdict[data-state='marginal'] .travel .fill { background: var(--marginal); }
.verdict[data-state='fail']     .travel .fill { background: var(--fail); }
.travel .req {
  position: absolute; top: -4px; bottom: -4px;
  width: 2px; background: var(--ink);
}
.travel .legend {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin-top: 5px;
}

/* ── Data tables ──────────────────────────────────────────── */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
table.data th {
  text-align: right;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 0 5px;
  border-bottom: 1px solid var(--rule);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td {
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule-soft);
  text-align: right;
}
table.data td.qty { color: var(--ink-2); }
table.data tr.sum td {
  border-top: 1px solid var(--ink);
  border-bottom: 0;
  padding-top: 7px;
  font-weight: 500;
}
table.data tr.sum td:first-child {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
}
table.data tr.need td { color: var(--ink-2); border-bottom: 0; }
table.data td .unit { color: var(--ink-3); font-size: 11px; }

/* ── Assembly check rows ──────────────────────────────────── */
.check { border-bottom: 1px dotted var(--rule-soft); padding: 9px 0; }
.check:last-of-type { border-bottom: 0; }
.check .row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.check .name { font-size: 13.5px; }
.check .num {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.check .num .kn { color: var(--ink-3); font-weight: 400; }
.check .flag {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 6px; border: 1px solid currentColor;
}
.check .flag[data-ok='yes'] { color: var(--pass); }
.check .flag[data-ok='no']  { color: var(--fail); }
.check .why {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
  letter-spacing: .02em; margin-top: 3px;
}

/* ── Notes / references ───────────────────────────────────── */
details.notes {
  border: var(--hair);
  background: var(--paper-3);
  padding: 0;
  margin-bottom: var(--gut);
}
details.notes > summary {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 11px 14px;
  cursor: pointer;
  color: var(--ink-2);
}
details.notes[open] > summary { border-bottom: var(--hair); color: var(--ink); }
/* Reference prose. The column count follows the width — one on a phone, two
   or three on a desktop — so the panel fills without lines running to 150
   characters. Headings span the full width and restart the flow, which keeps
   each section reading top to bottom. */
details.notes .body {
  padding: 14px;
  font-size: 13.5px;
  columns: 46ch;
  column-gap: 32px;
  column-rule: 1px solid var(--rule-soft);
  orphans: 2;
  widows: 2;
}
details.notes .body p { margin: 0 0 10px; }
details.notes .body p:last-child { margin-bottom: 0; }
/* A table squeezed into one 40ch column is unreadable — let it have the width. */
details.notes .body table { column-span: all; break-inside: avoid; }
details.notes .body h4 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule-soft);
  column-span: all;
}
details.notes .body h4:first-child { margin-top: 0; }
details.notes code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--paper); padding: 1px 4px; border-radius: 2px;
}
details.notes a { color: var(--orange); text-decoration-thickness: 1px; }
details.notes ol, details.notes ul { margin: 0 0 10px; padding-left: 20px; }
details.notes li { margin-bottom: 5px; break-inside: avoid; }
/* Below the two-column threshold a single column would stretch to ~95
   characters on a tablet, so cap the measure there. No effect on a phone,
   where the container is already narrower than the cap. */
@media (max-width: 849px) {
  details.notes .body > :not(h4) { max-width: 72ch; }
}

/* ── Caution strip ────────────────────────────────────────── */
.caution {
  border: 1px solid var(--ink);
  border-left: 5px solid var(--orange);
  background: var(--paper-3);
  padding: 11px 14px;
  margin-bottom: var(--gut);
  font-size: 13px;
  max-width: 76ch;
}
.caution strong {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .11em; text-transform: uppercase;
  display: block; margin-bottom: 3px;
}

/* ── Cut list ─────────────────────────────────────────────── */
.cut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--gut);
  align-items: start;
}
.readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  background: var(--ink);
  color: var(--paper-3);
  padding: 12px 14px;
  margin: 4px 0 14px;
}
.readout .k {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: #969ea3; display: block;
}
.readout .v {
  font-size: 27px; font-weight: 500; line-height: 1.1;
  letter-spacing: -.01em;
}
.readout .v .unit { font-size: 15px; color: #969ea3; }
.readout .alt { font-size: 11.5px; color: #969ea3; margin-top: 2px; }

.marks { margin-top: 4px; }
.marks svg { display: block; width: 100%; height: auto; }

.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; }
.steps li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dotted var(--rule-soft);
  font-size: 13.5px;
}
.steps li::before {
  content: counter(s, decimal-leading-zero);
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--orange); letter-spacing: .04em; padding-top: 2px;
}
.steps li:last-child { border-bottom: 0; }

/* ── Footer ───────────────────────────────────────────────── */
.colophon {
  border-top: var(--hair);
  margin-top: 34px;
  padding-top: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-3);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.colophon button {
  appearance: none; background: none; border: 0;
  font: inherit; color: var(--orange); cursor: pointer;
  padding: 0; text-decoration: underline;
}

/* ── Print: it becomes a shop ticket ──────────────────────── */
@media print {
  body { background: #fff; background-image: none; font-size: 11pt; }
  .views, .colophon, details.notes:not([open]) { display: none; }
  .block, .verdict, .plate, .caution { break-inside: avoid; }
  .plate { background: #fff; }
}

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