/* Leadsheet web. Colors, type, radii and spacing are the design tokens of leadsheet/design.py (css/tokens.css,
   generated by the build): Mist background, white surfaces, navy ink, teal for action; serif for what matters. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-body)/1.5 var(--sans); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .bar:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--text); margin: 0; }
p { margin: 0 0 var(--sp-s); }
.small { font-size: var(--fs-small); color: var(--text2); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--accent); padding: var(--sp-s) var(--sp-m); z-index: 20; }
.skip:focus { left: var(--sp-s); top: var(--sp-s); }
[hidden] { display: none !important; }

/* header and footer */
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-m); padding: var(--sp-s) var(--sp-l);
       background: var(--raised); border-bottom: 1px solid var(--hairline); }
.brand { display: inline-flex; align-items: center; gap: var(--sp-s); text-decoration: none; color: var(--text);
         font: 400 var(--fs-app-name)/1 var(--serif); min-height: var(--target); }
.top nav a { display: inline-flex; align-items: center; min-height: var(--target); padding: 0 var(--sp-s); font-weight: 600; text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
main { flex: 1; width: 100%; }
.foot { padding: var(--sp-l); color: var(--text2); text-align: center; border-top: 1px solid var(--hairline); background: var(--raised); }
.foot p { margin: 0; }
.foot a { display: inline-block; padding: var(--sp-xs) var(--sp-s); min-height: 32px; }

/* buttons */
button, select, input { font: inherit; color: inherit; }
button { font-weight: 600; color: var(--accent); background: var(--surface); border: 1px solid var(--accent); touch-action: manipulation;
         border-radius: var(--r-button); min-height: var(--target); min-width: var(--target); padding: 0 var(--sp-m); cursor: pointer; }
button:hover { background: var(--hover); }
button:disabled { color: var(--text2); border-color: var(--hairline); cursor: default; background: var(--surface); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); padding: 0 var(--sp-l);
                 display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { background: var(--surface); color: var(--text2); border-color: var(--hairline); filter: none; }  /* QA WQA-21 */
button.text { border-color: transparent; background: transparent; }
button.text:hover { background: var(--hover); }
button.text:disabled:hover { background: transparent; }  /* a tap leaves no hover mark on a disabled text button */
button.on { background: var(--highlight); color: var(--text); }
button .ico svg { width: 22px; height: 22px; display: block; fill: currentColor; }

/* the start page */
#start { max-width: 760px; margin: 0 auto; padding: var(--sp-xl) var(--sp-m) var(--sp-l); }
#start h1 { font-size: 32px; line-height: 1.2; margin-bottom: var(--sp-s); }
.lede { color: var(--text2); font-size: 16px; margin-bottom: var(--sp-l); }
.drop { background: var(--surface); border: 2px dashed var(--hairline); border-radius: var(--r-card); padding: var(--sp-xl) var(--sp-l);
        text-align: center; transition: background .15s, border-color .15s; }
.drop.over { background: var(--highlight); border-color: var(--accent); }
.drop.over .drop-kinds { color: var(--text); }
.drop-title { font: 400 var(--fs-drop)/1.3 var(--serif); margin-bottom: var(--sp-xs); }
.drop-kinds { color: var(--text2); margin-bottom: var(--sp-m); }
.drop-actions { display: flex; flex-wrap: wrap; gap: var(--sp-s); justify-content: center; }
.option { margin: var(--sp-m) 0 0; }
.check { display: inline-flex; align-items: center; gap: var(--sp-s); min-height: var(--target); cursor: pointer; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.help { color: var(--text2); margin: 0 0 0 30px; }
.status { margin-top: var(--sp-l); background: var(--surface); border-radius: var(--r-box); padding: var(--sp-m); display: grid;
          grid-template-columns: 1fr auto; gap: var(--sp-s) var(--sp-m); align-items: center; box-shadow: 0 1px 3px var(--shadow); }
.status p { margin: 0; }
.progress { grid-column: 1 / -1; height: var(--progress-line, 3px); background: var(--tint); border-radius: 2px; overflow: hidden; order: 3; }
#status-bar { height: 100%; width: 0; background: var(--accent2); transition: width .2s; }
.notice { margin-top: var(--sp-m); background: var(--tint); border-radius: var(--r-box); padding: var(--sp-m); }
.notice.error { background: var(--surface); border: 1px solid var(--error); color: var(--error); }
.expect { margin-top: var(--sp-l); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-box); padding: var(--sp-m) var(--sp-l); }
.expect h2 { font: 600 var(--fs-section)/1.4 var(--sans); color: var(--accent); margin-bottom: var(--sp-xs); }
.expect p { margin: 0; }

/* about */
.about { max-width: 760px; margin: 0 auto; padding: var(--sp-l) var(--sp-m) var(--sp-xl); }
.about h2 { font-size: var(--fs-title); margin-bottom: var(--sp-m); }
.about h3 { font: 600 var(--fs-section)/1.4 var(--sans); color: var(--accent); margin: var(--sp-m) 0 var(--sp-xs); }
.credits { padding-left: 1.2em; margin: 0 0 var(--sp-s); }
.credits li { margin-bottom: var(--sp-xs); }

/* results */
#results { display: flex; flex-direction: column; }
.res-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--sp-s) var(--sp-m);
            padding: var(--sp-m) var(--sp-l) var(--sp-xs); background: var(--surface); }
.res-titles { min-width: 0; flex: 1 1 320px; }
#song-title { font-size: var(--fs-title); line-height: 1.25; overflow-wrap: anywhere; }
#keyline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-xs) var(--sp-s); margin-top: var(--sp-xs); }
#keyline .key { font: 400 var(--fs-key)/1.2 var(--serif); margin-right: var(--sp-xs); }
#keyline .meta { color: var(--text2); font-size: 13px; }
.pill { font-size: var(--fs-small); color: var(--text); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-pill);
        padding: 2px 10px; white-space: nowrap; }
.pill.low { border-style: dashed; }
/* "Bars: half / double" next to the tempo (web v1.1 item 3): quiet text buttons */
.barscale { display: inline-flex; align-items: center; gap: 2px; color: var(--text2); font-size: 13px; }
.barscale .lbl { margin-right: 2px; }
.barscale button { min-height: 32px; min-width: 0; padding: 0 8px; font-size: 13px; }
.midi-track { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-s); padding: var(--sp-xs) var(--sp-l) var(--sp-s); background: var(--surface); }
.midi-track label { color: var(--text2); font-size: 13px; }
select { min-height: 40px; border: 1px solid var(--hairline); border-radius: var(--r-field); background: var(--surface); color: var(--text);
         padding: 0 var(--sp-s); max-width: 100%; }
.controls { display: flex; flex-direction: column; gap: var(--sp-s); padding: var(--sp-s) var(--sp-l) var(--sp-m); background: var(--surface);
            border-bottom: 1px solid var(--hairline); box-shadow: 0 1px 3px var(--shadow); position: sticky; top: 0; z-index: 5; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-s) var(--sp-m); }
.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: var(--r-button); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; }
.seg button + button { border-left: 1px solid var(--hairline); }
.grp { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-s); }
.grp label, .grp .lbl, .exports .lbl { color: var(--text2); font-size: 13px; }
.exports { gap: var(--sp-xs) var(--sp-s); }
.save-help { margin: 0; flex: 1 1 20em; }  /* what the formats open in (web v1.1 item 2); wraps under the buttons when narrow */
input[type=number] { width: 4.2em; min-height: 40px; padding: 0 var(--sp-s); border: 1px solid var(--hairline); border-radius: var(--r-field);
                     background: var(--surface); color: var(--text); }
input[type=range] { accent-color: var(--accent); width: 110px; }
#time { font-variant-numeric: tabular-nums; min-width: 9.5em; }
#progress { flex: 1 1 160px; min-width: 120px; }
#tr-v { font: 400 20px/1 var(--serif); min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; }
#tr button { font-size: 24px; line-height: 1; padding: 0; }
.touch-only { display: none; }
.controls.compact > .row:not(:first-child) { display: none !important; }
/* the notes on the result (the experimental melody, no sound in this browser) stay visible with the controls folded */
.res-note { margin: 0; padding: 0 var(--sp-l) var(--sp-s); background: var(--surface); color: var(--text2); }
.stage { position: relative; padding: var(--sp-m); }
#msg { text-align: center; padding: var(--sp-l); }
/* the engraved music: black on white, or the dark theme's paper and ink */
#sheet { position: relative; z-index: 0; margin: 0 auto 40vh; padding: var(--sp-l) 0 var(--sp-s); border-radius: var(--r-card); color: var(--paper-ink); }
#sheet.drawn { background: var(--paper); box-shadow: 0 1px 3px var(--shadow); }
#sheet svg { display: block; margin: 0 auto; position: relative; z-index: 2; color: var(--paper-ink); fill: var(--paper-ink); }
#sheet g.measure { cursor: pointer; }
#sheet .low-conf, #sheet .low-conf * { fill: var(--text2) !important; color: var(--text2) !important; }
#sheet g.note.playing, #sheet g.note.playing * { fill: var(--accent) !important; color: var(--accent) !important; }
#cursor { position: absolute; z-index: 1; pointer-events: none; background: var(--highlight); border-radius: var(--r-small);
          transition: top .12s, left .12s, width .12s, height .12s; display: none; }
.loopbox { position: absolute; z-index: 0; pointer-events: none; background: var(--tint); border-bottom: 3px solid var(--accent2); border-radius: var(--r-small); }
#chart { display: none; max-width: 1100px; margin: 0 auto; padding-bottom: 40vh; }
#chart .crow { display: grid; grid-template-columns: 2.4em repeat(4, minmax(0, 1fr)); gap: var(--sp-s); margin-bottom: var(--sp-s); }
#chart .sec { font: 400 22px/1 var(--serif); color: var(--accent); padding-top: 14px; text-align: center; }
#chart .bar { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-pill); padding: var(--sp-s) 12px; text-align: left;
              cursor: pointer; min-height: 76px; touch-action: manipulation; font-weight: 400; color: var(--text); display: block; width: 100%; }
#chart .bar:hover { background: var(--hover); }
#chart .bar .n { font-size: 11px; color: var(--text2); display: block; }
#chart .bar .c { font: 400 22px/1.3 var(--serif); overflow-wrap: anywhere; display: block; }  /* a second choice wraps, never cut (QA WQA-14) */
#chart .bar .r { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#chart .bar.cur { background: var(--highlight); border-color: var(--highlight); }
#chart .bar.cur .n, #chart .bar.cur .r { color: var(--text); }
#chart .bar.inloop { box-shadow: inset 0 -3px 0 var(--accent2); }
#chart .sections { margin-top: var(--sp-l); color: var(--text2); }
#chart .legend, #chart .chart-note { margin: var(--sp-s) 0 0; color: var(--text2); }
#chart .sections p { margin: 0 0 var(--sp-xs); }
#keepawake { position: fixed; right: 0; bottom: 0; width: 4px; height: 4px; opacity: 0.01; pointer-events: none; }
#audio { display: none; }

@media (max-width: 640px) {
  .top { padding: var(--sp-xs) var(--sp-m); }
  #start { padding-top: var(--sp-l); }
  #start h1 { font-size: 26px; }
  .drop { padding: var(--sp-l) var(--sp-m); }
  .res-head { padding: 12px var(--sp-m) var(--sp-xs); }
  #song-title { font-size: 20px; }
  #keyline .key { font-size: 20px; }
  .midi-track { padding: var(--sp-xs) var(--sp-m) var(--sp-s); }
  .res-note { padding: 0 var(--sp-m) var(--sp-s); }
  .controls { padding: var(--sp-s) 12px 12px; }
  .row { gap: var(--sp-s) 12px; }
  .seg button { padding: 0 12px; }
  .stage { padding: var(--sp-s); }
  #chart .crow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #chart .sec { grid-column: 1 / -1; text-align: left; padding: var(--sp-s) var(--sp-xs) 0; }
  #chart .sec:empty { display: none; }
  #chart .bar .c { font-size: 19px; }
  input[type=range] { width: 80px; }
  .hide-narrow { display: none; }
  #less { display: inline-flex; align-items: center; justify-content: center; }
}
/* touch screens (a tablet at the piano): every control at least 48 px */
@media (pointer: coarse) {
  .touch-only { display: inline-flex; align-items: center; justify-content: center; }
  input[type=number], select { min-height: var(--target); }
  input[type=range] { height: var(--target); }
  #chart .bar { min-height: 96px; }
  .barscale button { min-height: 44px; padding: 0 10px; }
}
/* a tablet in landscape: one compact header line, a large chord chart */
@media (pointer: coarse) and (orientation: landscape) and (min-width: 900px) {
  .res-head { padding: var(--sp-s) var(--sp-l) 0; }
  #song-title { font-size: 22px; }
  .controls { padding: var(--sp-xs) var(--sp-l) var(--sp-s); gap: var(--sp-xs); }
  .stage { padding: var(--sp-s) var(--sp-l); }
  #chart { max-width: none; }
  #chart .crow { grid-template-columns: 2.2em repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
  #chart .sec { font-size: clamp(24px, 4.2vh, 40px); padding-top: 2.5vh; }
  #chart .bar { min-height: clamp(88px, 17vh, 150px); padding: 10px 16px; border-radius: var(--r-card); }
  #chart .bar .n { font-size: 14px; }
  #chart .bar .c { font-size: clamp(30px, 6.2vh, 60px); line-height: 1.2; }
  #chart .bar .r { font-size: clamp(14px, 2.4vh, 20px); }
}
@media (pointer: coarse) and (orientation: portrait) and (min-width: 600px) {
  #chart .crow { grid-template-columns: 2.2em repeat(4, minmax(0, 1fr)); }
  #chart .sec { grid-column: auto; text-align: center; padding-top: 14px; }
  #chart .bar .c { font-size: clamp(24px, 4.2vw, 40px); }
  #chart .bar .r { font-size: 15px; }
}

/* print: the chord chart first, then the sheet; nothing else */
@media print {
  :root { color-scheme: light; }
  html, body { background: #fff; color: #000; }
  .top, .foot, #start, .about, .controls, .midi-track, .res-note, #again, .barscale, #msg, #cursor, .loopbox, #keepawake { display: none !important; }
  #results { display: block !important; }
  .res-head { background: #fff; padding: 0 0 8px; }
  .stage { padding: 0; display: flex; flex-direction: column; }
  #chart { order: -1; display: block !important; max-width: none; padding: 0; break-after: page; }
  #chart .bar { min-height: 0; border-color: #ccc; background: #fff; break-inside: avoid; }
  #chart .bar.cur { background: #fff; }
  #chart .crow { break-inside: avoid; }
  #sheet { display: block !important; box-shadow: none; margin: 0; padding: 0; background: #fff; }
  #sheet svg { color: #000; fill: #000; }
  #sheet .low-conf, #sheet .low-conf * { fill: #777 !important; }
}
