/* Key of the Room. Every radius is 0. Brick is line work only, moss is the keyboard and the trace, peach is a pressed key. */

* { box-sizing: border-box; }

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

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

main {
  /* the central 16 of 32 columns, never narrower than a slip, never wider than the screen */
  width: min(100% - 32px, max(560px, calc(100vw / 32 * 16)));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] { display: none !important; }

.desk-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
}

/* Paper keeps its own ink, so it does not flip with the scheme. */
.paper {
  background: var(--c-cream);
  --ink: #1A1A1A;
  --ink-soft: #5B5B5B;
  color: var(--ink);
  color-scheme: light;
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: none;
}

button, input { font: inherit; color: inherit; border-radius: 0; }

.paper button {
  background: var(--c-cream);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 7px 14px;
  cursor: pointer;
  line-height: 1.3;
}
.paper button:hover, .paper button[aria-pressed="true"] { background: var(--ink); color: var(--c-cream); }
:focus-visible, #file:focus-visible + .file-label { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The slip */

.slip { padding: 0 28px 22px; }

.stub {
  height: 16px;
  margin: 0 -28px 16px;
  border-bottom: 1px dashed var(--ink-soft);
}

.title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.16em;
}

.controls { margin: 0 0 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.file-label { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.status { margin: 0; min-height: 0; font-variant-numeric: tabular-nums; }
.status:not(:empty) { margin-top: 2px; }

.f {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 12px;
  min-height: 31px;
  padding: 6px 0 3px;
  border-bottom: 1px solid var(--c-brick);
}
.l {
  flex: 0 0 11.4em;
  white-space: nowrap;
  color: var(--ink-soft);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.05em;
}
.fv {
  flex: 1 1 14em;
  min-width: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.f.wide .fv { flex-basis: 22em; }

.trio { display: grid; grid-template-columns: 1.7fr 1fr 0.75fr; column-gap: 18px; }
.trio .l { flex-basis: auto; }
.num {
  display: inline-block;
  min-width: 10.5em;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--c-brick);
  font-size: 20px;
  line-height: 28px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

#room {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline-offset: 1px;
}

.cands { display: grid; grid-template-columns: auto auto auto auto 1fr; column-gap: 10px; }
.cand { display: contents; }
.cand .mark { color: var(--ink); }

.keytable { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5em, 1fr)); column-gap: 18px; }
.kt { display: grid; grid-template-columns: 2.2em 4.6em 1fr; column-gap: 6px; }
.kt .iv { color: var(--ink-soft); }

.fig { padding: 14px 0 0; min-height: 186px; }
.fig svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig text { fill: currentColor; color: var(--ink-soft); font: 10px var(--font-body); font-variant-numeric: tabular-nums; }
.fig text.n { color: var(--ink); font-weight: 700; }
.fig .g1 { stroke: var(--ink-soft); stroke-width: 0.5; stroke-opacity: 0.55; }
.fig .g2 { stroke: var(--ink-soft); stroke-width: 0.5; stroke-opacity: 0.25; }
.fig .axis { fill: none; stroke: var(--ink); stroke-width: 1; }
.fig .trace { fill: none; stroke: var(--c-moss); stroke-width: 1.1; stroke-linejoin: round; }
.fig .floor { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 1 2.5; }
.fig .threshold { fill: none; stroke: var(--ink); stroke-width: 0.8; stroke-dasharray: 5 3; }
.fig .mark { stroke: var(--ink); stroke-width: 1; }

.colophon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.colophon img { display: block; width: 105px; height: auto; }

/* The fill: line by line, as typed. The values are in the page from the first frame. */
.typing > * { animation: appear 0s calc(var(--i, 0) * 45ms) both; }
@keyframes appear { from { visibility: hidden; } to { visibility: visible; } }
@media (prefers-reduced-motion: reduce) { .typing > * { animation: none; } }

/* Show the measurement */

.measure { margin: 10px 0 22px; font-size: 13px; }
.measure summary { cursor: pointer; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.measure .f { border-bottom: 0; min-height: 0; padding: 2px 0; }
.measure .l { flex-basis: 10em; }
.measure[open] summary { margin-bottom: 6px; }

/* The keyboard */

.kb { margin-top: 18px; padding: 20px 28px 22px; }

.keys {
  position: relative;
  display: flex;
  height: 170px;
  margin-bottom: 14px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.paper .key {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding: 0 0 10px;
  border: 1px solid var(--c-moss);
  background: var(--c-cream);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.paper .key.white { flex: 1; margin-left: -1px; }
.paper .key.white:first-child { margin-left: 0; }
.paper .key.black {
  position: absolute;
  top: 0;
  z-index: 1;
  width: calc(100% / 7 * 0.62);
  height: 60%;
  background: var(--c-moss);
  color: var(--c-cream);
}
.paper .key:hover { background: var(--c-cream); color: var(--ink); }
.paper .key.black:hover { background: var(--c-moss); color: var(--c-cream); }
.paper .key.down, .paper .key.down:hover { background: var(--c-peach); color: var(--ink); }
.keys.silent .key { cursor: default; }
.key .iv { font-size: 15px; font-weight: 600; }
.key .sc { font-size: 11px; color: var(--ink-soft); }
.key.black .sc { color: var(--c-cream); }
.key.down .sc { color: var(--ink); }

.caption { margin: 0 0 12px; }
.kb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin: 0 0 12px; }
.group { display: inline-flex; align-items: center; gap: 8px; }
.group .temp + .temp { margin-left: -1px; }
.octave { font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: center; }

.hold { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.hold input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--ink);
  background: var(--c-cream);
}
.hold input:checked { background: var(--c-moss); }
.hold input:disabled { border-color: var(--ink-soft); }

.root { display: inline-flex; align-items: center; gap: 10px; }
.root input {
  width: 7em;
  padding: 6px 8px;
  border: 1px solid var(--ink);
  background: var(--c-cream);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.hint { color: var(--ink-soft); font-size: 13px; }
.sounding { margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.note { margin: 0; color: var(--ink-soft); font-size: 13px; }

.log { width: 100%; margin-top: 20px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.log caption { text-align: left; padding-bottom: 6px; color: var(--ink-soft); font-variant-caps: all-small-caps; letter-spacing: 0.07em; font-size: 15px; }
.log th { text-align: left; font-weight: 500; color: var(--ink-soft); }
.log th, .log td { padding: 5px 10px 4px 0; border-bottom: 1px solid var(--ink-soft); vertical-align: top; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  main { padding-top: 18px; }
  .slip { padding: 0 16px 18px; }
  .stub { margin: 0 -16px 14px; }
  .kb { padding: 16px; }
  .l { flex-basis: 100%; }
  .trio { display: block; }
  .trio .l { flex-basis: 100%; }
  .kb-row button { padding: 7px 10px; white-space: nowrap; }
  .group { gap: 6px; }
  .keys { height: 150px; }
  .cands { grid-template-columns: auto auto auto auto; }
  .cand .mark { grid-column: 2 / -1; margin-bottom: 3px; }
  .keytable { grid-template-columns: 1fr; }
}

@media print {
  @page { margin: 12mm 14mm; }
  html, body { background: #fff; }
  body { font-size: 9.5pt; line-height: 1.32; }
  main { width: auto; margin: 0; padding: 0; }
  .desk-title, .controls, .measure, .kb { display: none !important; }
  .paper.slip { border: 0; padding: 0; background: none; }
  .stub { margin: 0 0 8px; height: 6px; }
  .title { margin-bottom: 4px; }
  .f { min-height: 0; padding: 2px 0 1px; break-inside: avoid; }
  .num { font-size: 13pt; line-height: 1.4; min-height: 0; }
  .keytable { grid-template-columns: repeat(3, 1fr); }
  .fig { min-height: 0; padding-top: 4px; break-inside: avoid; }
  .typing > * { animation: none; }
  .colophon { padding-top: 8px; }
}
