/* Shared course stylesheet: Tufte-inspired, print-friendly. */

:root {
  --ink: #1b1b1b;
  --muted: #6b6b6b;
  --paper: #fffff8;
  --rule: #d9d6c8;
  --accent: #8a2b2b;      /* deep red: headings, links */
  --good: #2f6b3a;
  --bad: #a33a2a;
  --hint: #f3efdc;
  --measure: 38rem;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.55;
  counter-reset: sidenote;
}

main {
  max-width: calc(var(--measure) + 16rem);
  padding: 3rem 2rem 6rem;
  margin: 0 auto;
}

main > *:not(.wide) { max-width: var(--measure); }

h1 { font-weight: 400; font-size: 2.2rem; line-height: 1.15; margin: 0 0 .3rem; }
h2 { font-weight: 400; font-style: italic; font-size: 1.5rem; margin: 2.6rem 0 .6rem; color: var(--accent); }
h3 { font-weight: 600; font-size: 1.05rem; margin: 1.8rem 0 .4rem; }
p, li { font-size: 1rem; }
.subtitle { font-style: italic; color: var(--muted); font-size: 1.15rem; margin: 0 0 2rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

nav.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 2rem; font-variant: small-caps; letter-spacing: .04em; }
nav.crumbs a { color: var(--muted); }

/* Sidenotes (citations, asides) */
.sidenote, .marginnote {
  float: right; clear: right;
  margin-right: -16rem; width: 14rem;
  font-size: .8rem; line-height: 1.4; color: var(--muted);
  position: relative;
}
.sidenote-ref { counter-increment: sidenote; }
.sidenote-ref::after { content: counter(sidenote); font-size: .7rem; vertical-align: super; color: var(--accent); }
.sidenote::before { content: counter(sidenote) " "; color: var(--accent); }
@media (max-width: 62rem) {
  .sidenote, .marginnote { float: none; display: block; margin: .4rem 0 .8rem 1rem; width: auto; }
}

/* Boxes */
.win {
  border-left: 3px solid var(--accent);
  padding: .6rem 1rem; margin: 1.5rem 0;
  background: var(--hint);
}
.win strong { font-variant: small-caps; letter-spacing: .05em; }
.callout { border: 1px solid var(--rule); padding: .8rem 1rem; margin: 1.2rem 0; border-radius: 3px; }
.ask {
  margin-top: 3rem; padding: 1rem 1.2rem; border: 1px dashed var(--accent);
  font-style: italic;
}
.source {
  margin-top: 2rem; padding: 1rem 1.2rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule);
}
.source .label { font-variant: small-caps; letter-spacing: .06em; color: var(--muted); display: block; }

kbd, .note {
  font-family: "SF Mono", Menlo, monospace; font-size: .85em;
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px;
  padding: 0 .3em; background: #fff;
}

ol.steps li { margin: .35rem 0; }

table { border-collapse: collapse; margin: 1rem 0; font-size: .95rem; }
th, td { padding: .3rem .8rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th { font-weight: 600; border-bottom: 1px solid var(--ink); }

/* Interactive widgets (piano-kit.js, quiz.js) */
.pk-diagram { margin: 1.5rem 0; padding: 1.2rem 1rem 1rem; border: 1px solid var(--rule); border-radius: 4px; background: #fff; max-width: var(--measure); }
.pk-widget { margin: 1.5rem 0; padding: 1rem; border: 1px solid var(--rule); border-radius: 4px; background: #fff; max-width: var(--measure); }
.pk-status { font-size: .8rem; color: var(--muted); margin-bottom: .6rem; }
.pk-status.ok { color: var(--good); }
.pk-prompt { font-size: 1.6rem; text-align: center; margin: .4rem 0 .8rem; min-height: 2.2rem; }
.pk-feedback { text-align: center; min-height: 1.4rem; font-size: .95rem; }
.pk-feedback.good { color: var(--good); }
.pk-feedback.bad { color: var(--bad); }
.pk-controls { display: flex; gap: .5rem; justify-content: center; margin-top: .8rem; flex-wrap: wrap; }
.pk-controls button, .quiz button.opt {
  font: inherit; font-size: .9rem; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 3px; padding: .35rem .9rem;
}
.pk-controls button:hover, .quiz button.opt:hover:not(:disabled) { background: var(--hint); }
.pk-steps { display: flex; gap: .35rem; justify-content: center; flex-wrap: wrap; margin: .3rem 0; }
.pk-steps span {
  font-family: "SF Mono", Menlo, monospace; font-size: .8rem;
  min-width: 1.8rem; text-align: center; padding: .15rem .25rem;
  border: 1px solid var(--rule); border-radius: 3px; color: var(--muted);
}
.pk-steps span.done { background: var(--good); color: #fff; border-color: var(--good); }
.pk-steps span.current { border-color: var(--ink); color: var(--ink); font-weight: 700; }

.pk-keys { position: relative; height: 120px; margin: 0 auto; user-select: none; touch-action: manipulation; }
.pk-key { -webkit-print-color-adjust: exact; print-color-adjust: exact; position: absolute; top: 0; cursor: pointer; border: 1px solid #333; border-radius: 0 0 4px 4px; }
.pk-key.white { background: #fff; height: 120px; z-index: 1; }
.pk-key.black { background: #222; height: 74px; z-index: 2; }
.pk-key.down.white { background: #e9dfb8; }
.pk-key.down.black { background: #6b5a2a; }
.pk-key.target.white { background: #f6e3e3; }
.pk-key.right.white { background: #cfe6d3; }
.pk-key.right.black { background: var(--good); }
.pk-key.wrong.white { background: #f0c8c0; }
.pk-key.wrong.black { background: var(--bad); }
.pk-key .lbl { position: absolute; bottom: 4px; width: 100%; text-align: center; font-size: 11px; color: #888; font-family: "SF Mono", Menlo, monospace; pointer-events: none; }
.pk-key.black .lbl { color: #bbb; bottom: 3px; font-size: 9px; }

/* Sheet music (score.js): current step blue, played steps green */
.pk-score { max-width: var(--measure); margin: .4rem auto; }
.pk-score .pk-cur, .pk-score .pk-cur * { fill: #79a9ed; stroke: #79a9ed; }
.pk-score .pk-done, .pk-score .pk-done * { fill: var(--good); stroke: var(--good); }
.pk-score .abcjs-annotation { fill: var(--muted); font-family: "SF Mono", Menlo, monospace; }
.pk-tempo { text-align: center; font-size: .8rem; color: var(--muted); margin: .2rem 0; }
.score-figure { margin: 1.5rem 0; max-width: var(--measure); }

/* Rhythm strip (rhythmTrainer): beat 4 → next 1, targets and hits */
.pk-strip { position: relative; height: 74px; margin: .6rem 1.5rem 1rem; border-bottom: 1px solid var(--rule); }
.pk-strip > div { position: absolute; transform: translateX(-50%); white-space: nowrap; font-size: .75rem; }
.pk-strip .tick { bottom: -1.3rem; color: var(--muted); font-family: "SF Mono", Menlo, monospace; }
.pk-strip .tick::before { content: ""; position: absolute; left: 50%; bottom: 1.3rem; height: 8px; border-left: 1px solid var(--muted); }
.pk-strip .tgt { top: 0; color: var(--ink); }
.pk-strip .tgt::after { content: "◆"; display: block; text-align: center; color: #999; font-size: .9rem; }
.pk-strip .hold { top: 2.55rem; height: 4px; background: #ccc; transform: none; border-radius: 2px; }
.pk-strip .hit { top: 2.2rem; width: 12px; height: 12px; border-radius: 50%; }
.pk-strip .hit.ok { background: var(--good); }
.pk-strip .hit.off { background: var(--bad); }

.quiz { margin: 1.5rem 0; max-width: var(--measure); }
.quiz .q { margin: 1.4rem 0; }
.quiz .q p.stem { font-weight: 600; margin-bottom: .5rem; }
.quiz .opts { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.quiz button.opt { text-align: left; }
.quiz button.opt.right { background: #cfe6d3; border-color: var(--good); }
.quiz button.opt.wrong { background: #f0c8c0; border-color: var(--bad); }
.quiz .why { font-size: .9rem; color: var(--muted); margin-top: .4rem; min-height: 1rem; }
.quiz .score { font-style: italic; }

/* Print */
@media print {
  html { font-size: 11pt; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .pk-widget, .quiz, .ask, nav.crumbs, .no-print { display: none !important; }
  .sidenote, .marginnote { float: none; display: block; margin: .2rem 0 .5rem 1rem; width: auto; }
  a { color: var(--ink); }
  h2 { break-after: avoid; }
  table, .card, .pk-diagram { break-inside: avoid; }
  .pk-diagram { border: none; padding: 0; }
}
