@import "tokens.css";

@page { size: A4; margin: 15mm; }

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

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

.col { max-width: calc(44rem + 32px); margin: 0 auto; padding: 28px 16px 72px; }

.wordmark { display: block; height: 22px; width: auto; }
/* the wordmark is plum on its own stock: on the dark ground it keeps a cream label */
:root[data-theme="dark"] .wordmark { background: var(--c-cream); padding: 5px 7px; box-sizing: content-box; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark { background: var(--c-cream); padding: 5px 7px; box-sizing: content-box; }
}
h1 { font-family: var(--font-display); font-weight: var(--fw-bold); font-size: 2rem; line-height: 1.1; margin: 28px 0 8px; letter-spacing: -0.01em; }
.lede { margin: 0 0 24px; max-width: 36rem; }

.field { margin: 0 0 16px; }
.field > label, .field > .label { display: block; font-size: 0.875rem; color: var(--ink-soft); margin: 0 0 6px; }

select, input[type="text"], input[type="number"], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--ink);
  min-height: 44px;
  padding: 8px 10px;
}
select { padding-right: 28px; max-width: 100%; }
#tune { min-width: 18rem; }
textarea { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9375rem; line-height: 1.5; resize: vertical; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--ink);
  min-height: 44px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--accent); color: var(--accent-fg); }
button:disabled { color: var(--ink-soft); border-color: var(--ink-soft); cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* the strip of twelve keys */
#strip { display: grid; grid-template-columns: repeat(12, 1fr); padding: 1px 0 0 1px; }
#strip button {
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: -1px 0 0 -1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
}
#strip button:focus-visible { z-index: 1; }
#strip .sharp { font-size: 1.0625rem; font-weight: var(--fw-medium); line-height: 1; }
#strip .flatname { font-size: 0.6875rem; color: var(--ink-soft); line-height: 1; }
#strip button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
#strip button[aria-checked="true"] .sharp { font-weight: var(--fw-bold); }
#strip button[aria-checked="true"] .flatname { color: var(--bg); }
#strip button[aria-checked="true"]:hover { background: var(--ink); color: var(--bg); }

/* the plate keeps paper and ink in both themes */
.plate {
  --ink: #1A1A1A;
  --ink-soft: #5B5B5B;
  --error: #BE3B27;
  background: #FCF0DD;
  color: #1A1A1A;
  border: 1px solid #1A1A1A;
  padding: 24px;
  margin: 28px 0 20px;
}
.plateno { margin: 0 0 14px; font-family: Georgia, "Times New Roman", serif; font-size: 12px; color: var(--ink-soft); }
.score-wrap { position: relative; }
.score-wrap svg, .print-only svg { display: block; }
.playhead { position: absolute; width: 1px; background: var(--ink); pointer-events: none; }
#caption {
  margin: 18px 0 0;
  text-align: center;
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}
.platenum {
  margin: 12px 0 0;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.print-only { display: none; }

/* engraving */
.staff, .ledger, .barline { stroke: var(--ink); }
.barline.thick { fill: var(--ink); stroke: none; }
.glyph, .head, .flag, .acc, .dot, .rest { fill: var(--ink); }
.stem { stroke: var(--ink); }
.acc.stroke, .rest.stroke { fill: none; stroke: var(--ink); }
.head.hollow { fill: none; stroke: var(--ink); }
.struck { fill: var(--ink-soft); }
.struck.stroke, .struck.hollow { fill: none; stroke: var(--ink-soft); }
.strike { stroke: var(--error); }
.numeral { fill: var(--ink); font-family: Georgia, "Times New Roman", serif; }
.numeral.barno { fill: var(--ink-soft); }

/* playing */
.play { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 0 0 20px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.tempo { display: inline-flex; align-items: center; gap: 8px; }
.tempo input { width: 5.5rem; }
#print { margin-left: auto; }

#count, #largest { margin: 0 0 6px; font-variant-numeric: tabular-nums; }
#largest { margin-bottom: 24px; }

/* the table */
#table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 0 0 32px; }
#table caption { text-align: left; caption-side: top; font-size: 0.875rem; color: var(--ink-soft); padding: 0 0 8px; }
#table th, #table td { text-align: left; padding: 6px 10px 6px 8px; border-bottom: 1px solid var(--ink-soft); vertical-align: middle; }
#table th { font-weight: var(--fw-medium); font-size: 0.875rem; border-bottom-color: var(--ink); }
#table td:first-child, #table th:first-child { border-left: 2px solid transparent; }
#table tr[aria-current="true"] td { font-weight: var(--fw-bold); }
#table tr[aria-current="true"] td:first-child { border-left-color: var(--ink); }
#table .num { text-align: right; }
#table th.num { text-align: right; }
.share { display: flex; align-items: center; gap: 10px; }
.share .fig { min-width: 3.4em; text-align: right; }
.track { display: inline-block; width: 120px; height: 8px; border-bottom: 1px solid var(--ink-soft); position: relative; flex: none; }
.bar { position: absolute; left: 0; bottom: 0; height: 8px; background: var(--ink-soft); }

/* your own tune */
details { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); margin: 0 0 24px; }
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: var(--fw-medium); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; display: inline-block; width: 1.25em; }
details[open] summary::before { content: "\2212"; }
.own { padding: 4px 0 20px; }
.own label { display: block; font-size: 0.875rem; color: var(--ink-soft); }
.own label > input, .own label > select, .own label > textarea { display: block; margin-top: 4px; color: var(--ink); font-size: 1rem; }
.own label > input[type="checkbox"] { display: inline-block; margin: 0; }
.row3 { display: grid; grid-template-columns: 1fr 7rem 11rem; gap: 12px; margin: 0 0 12px; }
.row3 input, .row3 select { width: 100%; }
.help { font-size: 0.875rem; color: var(--ink-soft); margin: 8px 0 16px; }
.entry { border: 1px solid var(--ink-soft); margin: 0 0 12px; padding: 8px 12px 12px; }
.entry legend { font-size: 0.875rem; color: var(--ink-soft); padding: 0 6px; }
.entry-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; margin: 0 0 10px; }
.entry-opts .check { color: var(--ink); font-size: 1rem; }
.entry-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-keys button { min-width: 44px; padding: 8px 10px; }
#errors { margin: 0; white-space: pre-line; color: var(--ink); min-height: 1.45em; }

.colophon { font-size: 0.8125rem; color: var(--ink-soft); margin: 0 0 6px; max-width: 40rem; }

@media (max-width: 560px) {
  #strip { grid-template-columns: repeat(6, 1fr); }
  #tune { min-width: 0; width: 100%; }
  #print { margin-left: 0; }
  .share { display: block; }
  .share .fig { display: block; text-align: left; }
  .track { display: block; width: min(120px, 100%); margin-top: 4px; }
  #table th, #table td { padding: 6px 6px 6px 6px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 label:first-child { grid-column: 1 / -1; }
  h1 { font-size: 1.75rem; }
}

@media print {
  html, body { background: #fff; color: #1A1A1A; }
  :root { --ink: #1A1A1A; --ink-soft: #5B5B5B; --bg: #fff; }
  .col { max-width: none; padding: 0; }
  .lede, .pick, .play, details, #print, .score-wrap { display: none; }
  .print-only { display: block; }
  .head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; }
  .wordmark { height: 16px; background: none; padding: 0; }
  h1 { font-size: 12pt; margin: 0; }
  .plate { background: #fff; margin: 0 0 10px; padding: 10px 0 10px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
  .plateno { padding: 0 14px; margin-bottom: 4px; }
  #score-print svg { display: block; width: 100%; height: auto; break-inside: avoid; }
  #score-print svg + svg { margin-top: 6px; }
  #caption { margin-top: 10px; font-size: 13pt; break-before: avoid; }
  .platenum { margin-top: 8px; }
  #count, #largest { font-size: 9.5pt; margin: 0 0 2px; break-after: avoid; }
  #largest { margin-bottom: 8px; }
  #table { font-size: 9pt; line-height: 1.2; break-inside: avoid; margin-bottom: 8px; }
  #table caption { font-size: 9pt; padding-bottom: 4px; }
  #table tr { break-inside: avoid; }
  #table th, #table td { padding: 0 8px; }
  #table th { font-size: 9pt; }
  .track, .bar { height: 6px; }
  .colophon { font-size: 7.5pt; max-width: none; margin-bottom: 2px; }
}
