/* Swapsies: screen and print. Square corners everywhere, hairline rules, no fills but the button hover. */

:root {
  --stamp: var(--c-earth);
  --rule: var(--c-brick);
}
[data-theme="dark"] { --stamp: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --stamp: var(--accent); }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: 16px;
  line-height: 1.45;
}

.col {
  width: min(calc(var(--cell-w) * 24), 62rem);
  margin: 0 auto;
  padding: 48px 0 64px;
}
@media screen and (max-width: 760px) {
  .col { width: auto; margin: 0 16px; padding-top: 28px; }
}

h1, h2, h3 { color: var(--stamp); margin: 0; }
h1 { font-weight: var(--fw-bold); font-size: 2.25rem; letter-spacing: -.01em; }
h2 {
  font-weight: var(--fw-bold); font-size: 1.15rem;
  border-top: 1px solid var(--ink); padding-top: 10px; margin: 40px 0 14px;
}
h3 { font-weight: var(--fw-bold); font-size: 1rem; margin: 18px 0 8px; }
p { margin: 0 0 8px; }

.lede { margin: 6px 0 14px; }
.steps { margin: 0; padding-left: 1.4em; font-size: .875rem; }
.hint, .plain, .note, .colophon, label, .legs { color: var(--ink-soft); }
.hint, label, .legs { font-weight: var(--fw-thin); }
.hint { font-size: .8rem; }
.err { color: var(--error); }
.warn { color: var(--warn); }
.note { font-size: .875rem; }
.status { min-height: 1.45em; white-space: pre-line; }
.row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* controls: ruled-line inputs, square buttons */
input[type="text"], textarea {
  font: inherit; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0;
  padding: 4px 2px; width: 100%; min-width: 0;
}
textarea { border: 1px solid var(--ink); font-size: .9rem; resize: vertical; margin: 6px 0; }
input[type="text"]:focus, textarea:focus, button:focus-visible, summary:focus-visible, .filebtn:focus-within {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
button, .filebtn {
  font: inherit; color: var(--ink); background: transparent;
  border: 1px solid var(--ink); border-radius: 0;
  padding: 6px 14px; cursor: pointer; display: inline-block;
}
button:hover:not(:disabled), .filebtn:hover { background: var(--accent); color: var(--accent-fg); border-color: var(--accent-fg); }
button:disabled { color: var(--ink-soft); border-color: var(--ink-soft); border-style: dashed; cursor: default; }
.filebtn { font-weight: var(--fw-medium); }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
summary { cursor: pointer; margin: 12px 0 6px; color: var(--ink); }
#bulk-msg { white-space: pre-line; }

.addform { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; margin-bottom: 4px; }
.addform label { display: flex; flex-direction: column; flex: 1 1 12rem; font-size: .8rem; }
.addform input { color: var(--ink); font-weight: var(--fw-medium); font-size: 1rem; }

/* tables: hairline rules, labelled heads */
table { border-collapse: collapse; width: 100%; margin: 10px 0 14px; }
th { text-align: left; vertical-align: bottom; font-weight: var(--fw-thin); font-size: .8rem; color: var(--ink-soft); border-bottom: 1px solid var(--ink); padding: 4px 8px 4px 0; }
td { vertical-align: top; border-bottom: 1px solid var(--ink); padding: 6px 8px 6px 0; }
.roster td { border-bottom: 0; padding-bottom: 2px; }
.roster tr:not(.msgrow) td { padding-top: 10px; }
.roster .lotno { width: 3.5em; font-variant-numeric: tabular-nums; }
.roster tr:not(.msgrow) td.lotno { padding-top: 15px; }
.roster .act { width: 1%; white-space: nowrap; text-align: right; padding-right: 0; }
.roster th:nth-child(4) { width: 30%; }
.roster .hint { display: block; }
.msgrow td { font-size: .875rem; padding-top: 0; }
.msgrow .err + .note { margin-left: .4em; }
#withdrawn ul { list-style: none; padding: 0; margin: 0; }
#withdrawn li { margin: 0 0 6px; color: var(--ink-soft); }
#withdrawn button { margin-left: 8px; padding: 2px 10px; font-size: .875rem; }

.rings { list-style: none; padding: 0; margin: 8px 0; }
.rings li { margin: 0 0 4px; }
.legs { margin-left: .6em; font-size: .875rem; }
.edline { font-weight: var(--fw-bold); }

/* the stamp: a rubber-stamp rectangle, never rotated */
.stamp {
  display: inline-block; border: 1.5px solid var(--stamp); color: var(--stamp);
  padding: 2px 8px; letter-spacing: .04em; font-size: .78rem; font-weight: var(--fw-bold);
  line-height: 1.35; margin: 0;
}
.stamp-super { color: var(--error); border-color: var(--error); display: table; margin: 0 0 3mm auto; text-align: center; }

/* the slip */
#slips h2 + .slip { margin-top: 0; }
.slip {
  position: relative; border: 3px double var(--ink);
  padding: 8mm 8mm 6mm 18mm; margin: 0 0 6mm;
  break-inside: avoid; page-break-inside: avoid;
}
.slip::before { content: ""; position: absolute; top: 0; bottom: 0; left: 14mm; border-left: 1px solid var(--rule); }
.slip .formcode {
  float: left; margin: 0; padding: 3.5px 0;
  font-size: .78rem; font-weight: var(--fw-bold); letter-spacing: .04em; line-height: 1.35;
  color: var(--ink);
}
.slip .stamp-closed { float: right; }
.slip h3 { clear: both; padding-top: 4mm; margin: 0 0 1mm; font-size: 1.15rem; }
.slip .dated { margin-bottom: 2mm; }
.terms { margin: 0 0 3mm; padding-left: 1.1em; font-size: .8rem; }
.terms li { margin: 0; }
.deed { margin: 0 0 3mm; font-size: .875rem; }
.deed th { color: var(--ink); font-weight: var(--fw-thin); }
.deed td { padding-top: 3mm; padding-bottom: 3mm; }
.deed td.sign { width: 12%; }
.nb { white-space: nowrap; }
.slip .footer { margin: 0; font-size: .75rem; color: var(--ink-soft); }
.cut { border-top: 1px dashed var(--ink); margin: 0 0 6mm; }
#earlier details { margin-bottom: 8px; }
#earlier .slip { margin-top: 8px; }

.colophon { margin-top: 56px; border-top: 1px solid var(--ink); padding-top: 12px; font-size: .8rem; font-weight: var(--fw-thin); }
.colophon p { margin: 0 0 4px; max-width: 46rem; }
.colophon img { display: block; margin-top: 18px; }
/* the wordmark is plum on transparent; on the dark ground it sits on a cream label */
[data-theme="dark"] .colophon img { background: var(--c-cream); padding: 4px 6px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .colophon img { background: var(--c-cream); padding: 4px 6px; }
}

/* the sheet only exists on paper */
#sheet { display: none; }

/* narrow screens: every stack table becomes one labelled block per row */
@media screen and (max-width: 760px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: auto; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stack tr { border-top: 1px solid var(--ink); padding: 6px 0; }
  table.stack td { border: 0; padding: 3px 0; text-align: left; position: relative; }
  table.stack td[data-label] { padding-left: calc(7.2em + 8px); }
  table.stack td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 3px; width: 7.2em; color: var(--ink-soft); font-weight: var(--fw-thin); font-size: .8rem; padding-top: .15em; }
  table.stack td.sign { width: auto; }
  table.stack td.sign::after { content: ""; display: block; height: 1.9em; border-bottom: 1px solid var(--ink); }
  .roster tr.msgrow { border-top: 0; padding-top: 0; }
  .roster .msgrow td, .roster .act { display: block; width: auto; }
  .roster .act { padding-top: 6px; }
  .roster tr:not(.msgrow) td.lotno { width: auto; padding-top: 3px; }
  .roster tr:not(.msgrow) td { padding-top: 3px; }
  .roster .hint { display: none; }
  .roster tbody::before {
    content: "Would take: lot numbers, best first. Write mine to end the list.";
    display: block; color: var(--ink-soft); font-weight: var(--fw-thin); font-size: .8rem; padding-bottom: 6px;
  }
  .slip { padding: 6mm 4mm 5mm 11mm; }
  .slip::before { left: 8mm; }
  .slip .stamp-closed { float: none; display: table; margin: 0 0 0 auto; }
  .slip .formcode { float: none; }
}

/* paper: A4, white, black ink, no colour fills */
@page { size: A4; margin: 15mm; }
@media print {
  :root, :root:not([data-theme="light"]), [data-theme="dark"] {
    --bg: #fff; --ink: #000; --ink-soft: #000; --stamp: #000; --rule: #000; --error: #000; --warn: #000;
    color-scheme: light;
  }
  html, body { background: #fff; color: #000; }
  body { font-size: 10.5pt; line-height: 1.35; }
  body > :not(#sheet) { display: none !important; }
  #sheet { display: block; }
  .stamp { font-size: 7.5pt; }
  .slip { margin: 0 0 5mm; padding-left: 17mm; }
  .cut { margin: 0 0 5mm; }
  .slip .formcode { font-size: 7.5pt; padding: 2.5px 0; }
  .slip h3 { font-size: 12pt; padding-top: 2mm; }
  .deed td { padding-top: 2.2mm; padding-bottom: 2.2mm; }
  .deed td.sign { width: 15%; }
  .deed td.sign:last-child { width: 10%; }
  .terms { font-size: 8.5pt; }
  .deed { font-size: 8.5pt; }
  .deed th { font-size: 8pt; }
  .slip .footer { font-size: 7.5pt; }

  .catalogue h2 { border-top: 0; margin: 4mm 0 3mm; font-size: 14pt; padding-top: 0; color: #000; }
  .catalogue > .stamp { float: right; }
  .cat th { color: #000; font-size: 8pt; }
  .cat td:first-child { width: 12mm; }

  .cardpage {
    break-before: page; page-break-before: always;
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 88mm);
  }
  .card:nth-child(odd) { border-left: 1px dashed #000; }
  .card:nth-child(-n+2) { border-top: 1px dashed #000; }
  .card {
    border-right: 1px dashed #000; border-bottom: 1px dashed #000;
    padding: 3.5mm 6mm; break-inside: avoid; font-size: 9.5pt;
  }
  .card p { margin: 0 0 1mm; }
  .card .card-head { font-weight: var(--fw-bold); font-size: 11pt; }
  .card .small { font-size: 8pt; }
  .ranks { list-style: none; padding: 0; margin: 1.5mm 0 2mm; }
  .ranks li { display: flex; align-items: flex-end; height: 5.5mm; border-bottom: 1px solid #000; }
  .ranks span { width: 9mm; font-size: 8pt; }
}
