/* Twang: a practical sheet on a desk. Square corners, hairlines, no shadow. */

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

html { background: var(--bg); color: var(--ink); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
}

.sheet {
  background: #FFFFFF;
  border: 1px solid var(--ink);
  padding: 40px 44px 36px;
}

h1 { font-size: 32px; line-height: 1.1; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

.lbl {
  color: var(--ink-soft);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-size: 16px;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* header fields */
.fields { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 22px 0 0; padding: 10px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink-soft); }
.field { display: flex; align-items: center; gap: 6px; margin: 0; }
.field.ruler { flex: 1 1 260px; }
.field.ruler input { flex: 1; min-width: 0; }

input, select {
  font: inherit;
  color: var(--ink);
  background: #FFFFFF;
  border: 1px solid var(--ink-soft);
  height: 32px;
  padding: 0 6px;
}
input:focus, select:focus { border-color: var(--ink); }
select:disabled { color: var(--ink-soft); }
option { color: var(--ink); background: #FFFFFF; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.btn:focus-within { outline: 2px solid var(--ink); outline-offset: 1px; }
::selection { background: var(--ink); color: #FFFFFF; }

button, .btn {
  font: inherit;
  font-size: 13px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  background: #FFFFFF;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  position: relative;
}
button:hover:not(:disabled), .btn:hover { background: var(--bg); }
button:disabled, .btn.off { color: var(--ink-soft); border-color: var(--ink-soft); background: #FFFFFF; cursor: default; }
button.on { background: var(--ink); color: #FFFFFF; }
.btn.small { font-size: 12px; height: 28px; padding: 0 8px; border-color: var(--ink-soft); color: var(--ink-soft); }

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

.pv { display: none; }

/* aim, apparatus, method */
.blocks { margin: 22px 0 30px; }
.blocks p { margin: 0 0 8px; max-width: 70ch; }
#micline { font-size: 13px; color: var(--ink-soft); }
.method ol { margin: 4px 0 0; padding-left: 22px; max-width: 70ch; }
.method li { margin: 0 0 4px; }

/* observations */
.listening { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; font-size: 14px; }
.listening[hidden] { display: none; }
.meter { width: 140px; height: 10px; border: 1px solid var(--ink-soft); background: #FFFFFF; }
#meterfill { height: 100%; width: 0; background: var(--ink); }

/* positioned so the absolute .vh labels inside the table are clipped by the overflow */
.tablewrap { position: relative; overflow-x: auto; border-top: 1px solid var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
#obs-table { min-width: 820px; }
th {
  text-align: left;
  vertical-align: bottom;
  color: var(--ink-soft);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.25;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--ink);
}
th.num { text-align: right; }
td { padding: 7px 8px; border-bottom: 1px solid var(--ink-soft); vertical-align: middle; }
td.num { white-space: nowrap; }
tfoot td { border-bottom: 0; padding-top: 10px; }
#obs-table th:nth-child(1) { width: 2.6em; }
#obs-table th:nth-child(3), #obs-table th:nth-child(4), #obs-table th:nth-child(5), #obs-table th:nth-child(6) { width: 5.4em; }
#obs-table th:nth-child(7) { min-width: 12em; }

.oh { white-space: nowrap; }
td .wrap { display: flex; align-items: center; gap: 6px; }
td.ctl .wrap { justify-content: flex-end; }
.oh input { width: 5.2em; text-align: right; font-variant-numeric: tabular-nums; }
td.note { font-size: 13px; line-height: 1.35; }
td.note span { display: block; }
.rej, .err { color: var(--error); }
tr.struck td.num, tr.struck td.note, tr.struck .oh input, tr.struck .oh .pv { text-decoration: line-through; }
td.ctl { text-align: right; }

.smallprint { margin-top: 8px; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
.smallprint p { margin: 0 0 3px; }

/* working and graph */
.working { margin-top: 30px; }
#working p { margin: 0 0 5px; font-variant-numeric: tabular-nums; max-width: 78ch; }
.graph { margin-top: 30px; }
#graph svg { display: block; width: 100%; max-width: 620px; height: auto; }
#graph p { margin: 0; color: var(--ink-soft); }
svg text { fill: var(--ink); font-family: var(--font-body); font-size: 11px; }
svg .tick { fill: var(--ink-soft); font-size: 10px; font-variant-numeric: tabular-nums; }
svg .grid { stroke: var(--ink-soft); stroke-width: 0.5; stroke-opacity: 0.3; }
svg .grid.major { stroke-opacity: 0.75; }
svg .frame { fill: none; stroke: var(--ink); stroke-width: 0.75; }
svg .fit { stroke: var(--ink); stroke-width: 1.4; }
svg .book { stroke: var(--ink-soft); stroke-width: 1.4; stroke-dasharray: 6 4; }
svg .pt { fill: var(--ink); }

.sheetctl { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--ink-soft); }
#status, #keep { margin: 10px 0 0; font-size: 13px; }
#status:empty { display: none; }

/* the card */
.card { width: 100%; max-width: 470px; padding: 26px 28px 24px; }
.cardctl { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 12px; }
.cardctl label { display: flex; align-items: center; gap: 8px; }
#cardbody p { margin: 0 0 3px; }
#cardbody .cap { margin: 0 0 8px; font-size: 14px; }
#cardbody table { font-size: 13px; margin: 0 0 10px; border-top: 1px solid var(--ink); }
#cardbody th { font-size: 12px; padding: 6px 5px 5px; }
#cardbody td { padding: 5px; }
#cardbody .foot-lines { font-size: 12px; color: var(--ink-soft); }
.card > .ctl:last-child { margin: 14px 0 0; }

/* the tune */
.cells { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 6px; margin: 6px 0 14px; }
.cell { min-width: 0; }
.cell .sq {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.cell.cur .sq { background: var(--ink); color: #FFFFFF; }
.cell .c { font-size: 11px; text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.4em; padding-top: 2px; }
#tunebody p { margin: 0 0 5px; font-variant-numeric: tabular-nums; }
.log { margin: 8px 0 0; padding-left: 2.2em; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; columns: 2 16em; column-gap: 24px; }
.log li { margin: 0 0 2px; break-inside: avoid; }
.tunectl { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.foot { display: flex; justify-content: center; padding: 4px 0 0; }
.foot img { display: block; height: 20px; width: auto; }

@media (max-width: 640px) {
  main { padding: 16px 12px 24px; gap: 18px; }
  .sheet { padding: 22px 16px 20px; }
  h1 { font-size: 28px; }
  input, select { height: 44px; }
  button, .btn { height: 44px; }
  .btn.small { height: 44px; }
  #obs-table { min-width: 640px; }
  .oh .wrap { display: grid; grid-template-columns: auto auto; gap: 6px; }
  .oh input { width: 100%; grid-column: 1 / 3; }
  .cells { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  svg text { font-size: 13px; }
  svg .tick { font-size: 12px; }
  .card { padding: 20px 16px; }
}

@media print {
  @page { margin: 12mm; }
  html, body { background: #FFFFFF; font-size: 10pt; }
  main { display: block; max-width: none; padding: 0; }
  .ctl, .listening, button, .btn, input, select { display: none !important; }
  .pv { display: inline; }
  .sheet { border: 0; padding: 0; }
  .blocks { margin: 12px 0 16px; }
  .tablewrap { overflow: visible; }
  #obs-table { min-width: 0; font-size: 9.5pt; }
  .obs-block { break-inside: avoid; }
  .working, .graph { margin-top: 16px; break-inside: avoid; }
  #graph svg { max-width: 125mm; }
  .foot { justify-content: flex-start; padding-top: 10mm; }
  .foot img { height: 14px; }

  html:not([data-print="card"]) #card,
  html:not([data-print="card"]) #tune { display: none; }

  html[data-print="card"] #sheet,
  html[data-print="card"] #tune,
  html[data-print="card"] .foot { display: none; }
  html[data-print="card"] #card {
    width: 100mm; max-width: none; margin: 0;
    border: 0.2mm solid var(--ink); padding: 5mm;
    font-size: 8pt; break-inside: avoid;
  }
  html[data-print="card"] #card h2 { font-size: 11pt; margin-bottom: 2mm; }
  html[data-print="card"] #cardbody .cap { font-size: 8.5pt; }
  html[data-print="card"] #cardbody table { font-size: 8pt; }
  html[data-print="card"] #cardbody th { font-size: 7pt; padding: 1.2mm 1mm; }
  html[data-print="card"] #cardbody td { padding: 1mm; }
  html[data-print="card"] #cardbody .foot-lines { font-size: 7pt; }
}
