/* Ombak: a tuning chart on cream. Tokens come unmodified from tokens.css. */

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  padding: 32px 0 48px;
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

/* The sheet stays paper in either scheme, so its ink is scoped back to the light values. */
.sheet {
  --ink: #1A1A1A;
  --ink-soft: #5B5B5B;
  color: var(--ink);
  color-scheme: light;
  background: var(--c-cream);
  border: 1px solid var(--ink);
  border-radius: 0;
  width: max(640px, calc(var(--cell-w) * 18));
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 36px 44px 28px;
}

h1 {
  margin: 0;
  font-size: 44px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.sub { margin: 6px 0 24px; color: var(--ink-soft); }

.lab, th, legend, .boardhead .small {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: var(--fw-medium);
}

.small { font-size: 13px; color: var(--ink-soft); }

.printhead, #counted { display: none; }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 28px;
  padding: 14px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; }
.ctl-rate { grid-column: 1 / -1; }
.ctl-rate .lab { font-size: 16px; }
#rate-out { font-variant-numeric: tabular-nums; min-width: 5.5em; font-size: 17px; font-weight: var(--fw-medium); }

fieldset { border: 0; padding: 0; min-width: 0; }
legend { float: left; margin-right: 4px; padding: 0; }
.ctl-part label, .ctl-hold label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.caption-part { flex-basis: 100%; margin: 0; }

/* square boxes, as on a printed form; a filled square marks the choice */
input[type=radio], input[type=checkbox] {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  margin: 0;
  width: 15px;
  height: 15px;
  padding: 2px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  background-clip: content-box;
  cursor: pointer;
}
input[type=radio]:checked, input[type=checkbox]:checked { background-color: var(--ink); }

button {
  font: inherit;
  color: var(--ink);
  background: var(--c-cream);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 5px 12px;
  cursor: pointer;
}
button:active { background: var(--ink); color: var(--c-cream); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 260px;
  height: 22px;
  margin: 0;
  background: transparent;
  border-radius: 0;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--c-cream);
  border: 1px solid var(--ink);
  border-radius: 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 22px;
  margin-top: -8px;
  background: var(--ink);
  border: 0;
  border-radius: 0;
}
input[type=range]::-moz-range-track {
  height: 6px;
  background: var(--c-cream);
  border: 1px solid var(--ink);
  border-radius: 0;
}
input[type=range]::-moz-range-thumb {
  width: 12px;
  height: 22px;
  background: var(--ink);
  border: 0;
  border-radius: 0;
}

/* Status */
#status {
  margin: 14px 0 18px;
  padding-left: 10px;
  border-left: 2px solid transparent;
  min-height: 1.45em;
}
#status.refusal { border-left-color: var(--c-brick); }

/* Keyboard */
.boardhead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 0 0 8px;
  font-variant-numeric: tabular-nums;
}

#keys {
  position: relative;
  height: 156px;
  border-left: 1px solid var(--ink);
  margin-bottom: 28px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.key {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
  padding: 0 0 8px;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
.key > span { pointer-events: none; }
.key .kc { font-size: 15px; font-weight: var(--fw-medium); line-height: 1.1; }
.key .kn { font-size: 11px; line-height: 1.1; }

.key.w {
  left: calc(var(--x) * 10%);
  width: 10%;
  height: 100%;
  background: var(--c-cream);
  border: 1px solid var(--ink);
  border-left-width: 0;
}
.key.w .kn { color: var(--ink-soft); }

.key.b {
  left: calc((var(--x) + 1) * 10% - 3%);
  width: 6%;
  height: 58%;
  z-index: 1;
  padding-bottom: 6px;
  background: var(--ink);
  color: var(--c-cream);
  border: 1px solid var(--ink);
}

.key.w[aria-pressed=true] { background: var(--c-mustard); }
.key.b[aria-pressed=true] { background: var(--c-moss); border-color: var(--c-moss); }

.key[aria-disabled=true] { cursor: default; }
.key[aria-disabled=true] .kc, .key[aria-disabled=true] .kn { color: var(--ink-soft); }
.key.b[aria-disabled=true] { background: var(--c-cream); border-color: var(--ink-soft); }
/* the strike: a 1 px band from the lower left corner to the upper right */
.key[aria-disabled=true]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink-soft);
  clip-path: polygon(0 100%, calc(100% - 1.1px) 0, 100% 0, 1.1px 100%);
  pointer-events: none;
}

/* Ledger tables */
.ledger {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 2px;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.ledger th, .ledger td { padding: 5px 8px; border-radius: 0; text-align: right; }
.ledger th:nth-child(-n+2), .ledger td:nth-child(-n+2), .ledger [data-col=state], .ledger [data-field=state] { text-align: left; }
.ledger th {
  vertical-align: bottom;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  font-size: 14px;
  line-height: 1.2;
}
.ledger td { white-space: nowrap; border-bottom: 1px solid var(--ink-soft); }
.ledger tbody tr:first-child td { border-top: 1px solid var(--ink); }
.ledger tbody tr:last-child td { border-bottom: 2px solid var(--ink); }
.ledger td.empty { text-align: left; color: var(--ink-soft); }
.ledger tr[data-state=sounding] td { background: var(--c-mustard); }
.ledger tr[data-state=withheld] td { color: var(--ink-soft); }
.ns { white-space: nowrap; }

#tuner { margin-bottom: 30px; }

caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 8px;
  font-size: 14px;
}

#notes { margin: 18px 0 6px; padding-left: 1.6em; font-size: 14px; }
#notes li { padding-left: 2px; }
.foot { margin: 10px 0 0; font-size: 14px; }

.printrow { margin: 22px 0 0; }

#colophon {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  color: var(--ink);
  font-size: 12px;
}
#colophon img { display: block; height: 20px; width: auto; margin-bottom: 6px; }
#colophon p { margin: 0; max-width: 60ch; }

/* Narrow screens: hide Key and State, wrap headings, keep figures on one line. */
@media (max-width: 559px) {
  body { padding: 16px 0 32px; font-size: 14px; }
  .sheet { padding: 22px 12px 20px; }
  h1 { font-size: 36px; }
  .controls { grid-template-columns: 1fr; gap: 12px; }
  .ctl-rate { display: grid; grid-template-columns: 1fr auto; }
  .ctl-rate input { grid-column: 1 / -1; grid-row: 2; }
  #rate-out { text-align: right; }
  #keys { height: 128px; }
  .key .kc { font-size: 13px; }
  .key .kn { font-size: 10px; }
  .key.b .kn { font-size: 9px; }
  .ledger [data-col=key], .ledger [data-field=key], .ledger [data-col=state], .ledger [data-field=state] { display: none; }
  .ledger th, .ledger td { padding: 3px 4px; }
  .ledger td { font-size: 12px; }
  .ledger th { font-size: 12px; }
  .ledger th .ns { display: block; }
}

@media print {
  @page { margin: 14mm; }
  html, body { background: #fff; }
  body { padding: 0; font-size: 10pt; line-height: 1.3; }
  .sheet { width: auto; max-width: none; margin: 0; padding: 0; border: 0; background: #fff; }
  .controls, .board, #tuner, #status, .printrow { display: none; }
  h1 { font-size: 22pt; }
  .sub { margin: 2px 0 8px; }
  .printhead { display: block; margin-bottom: 14px; }
  .printhead p { margin: 0; }
  #printline { font-weight: var(--fw-medium); }
  .ledger th, .ledger td { padding: 2px 6px; }
  .ledger th { font-size: 9.5pt; }
  .ledger tr[data-state=sounding] td { background: none; }
  caption { padding-bottom: 4px; }
  #notes { margin-top: 10px; font-size: 9.5pt; }
  .foot { margin-top: 6px; font-size: 9.5pt; }
  #counted:not([hidden]) { display: block; margin: 12px 0 0; }
  #colophon { margin-top: 12px; padding-top: 6px; font-size: 8.5pt; }
  #colophon img { height: 14px; filter: grayscale(1) brightness(0); }
}
