/* sol · web: the demo piano (sitio/js/demo/piano.js). Owner: demo (docs/ESPEC.md 5.2, 11.3).
   The app's practice screen: black lacquer, falling light, ivory keys, controls as a quiet brass rail.
   Works on its own (admin, test page): every token has the app's value as a fallback. */

.sp {
  --sp-bg: var(--bg, #050506);
  --sp-text: var(--text, #f4f1ea);
  --sp-text-2: var(--text-2, rgba(244, 241, 234, .64));
  --sp-text-3: var(--text-3, rgba(244, 241, 234, .5));
  --sp-line: var(--line, rgba(244, 241, 234, .08));
  --sp-line-2: var(--line-2, rgba(244, 241, 234, .14));
  --sp-gold: var(--gold, #c9a961);
  --sp-gold-hi: var(--gold-hi, #ead39a);
  --sp-gold-lo: var(--gold-lo, #8c7239);
  --sp-blue: var(--blue, #86a9de);
  --sp-blue-hi: var(--blue-hi, #bcd2f2);
  --sp-ok: var(--ok, #9fd2b0);
  --sp-wrong: var(--wrong, #e0727f);
  --sp-on-gold: #1d1608;
  --sp-ease: var(--ease, cubic-bezier(.2, .8, .2, 1));
  --sp-display: var(--font-display, "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  --sp-body: var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  position: relative; isolation: isolate;
  display: flex; flex-direction: column;
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  background: var(--sp-bg); color: var(--sp-text);
  font: 400 15px/1.4 var(--sp-body);
  container: sp / inline-size;
  -webkit-tap-highlight-color: transparent;
}
.sp *, .sp *::before, .sp *::after { box-sizing: border-box; }
.sp button, .sp select, .sp input { font: inherit; color: inherit; margin: 0; }
.sp button { cursor: pointer; }
.sp [hidden] { display: none !important; }

/* ---------- the stage: one canvas, and a touch surface over the keys only ---------- */
.sp-stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; outline: none; border-radius: inherit; }
.sp-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; touch-action: pan-y; }
.sp--ambient .sp-stage, .sp--ambient .sp-canvas { pointer-events: none; }
.sp-keys {
  position: absolute; left: 0; right: 0; top: 0; height: 0;
  touch-action: none; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* the focus ring is drawn above the canvas (the stage's own box-shadow would be painted under it); a dark inner
   line keeps it clear where it crosses the ivory keys */
.sp-stage:focus-visible::after {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--sp-gold), inset 0 0 0 5px rgba(5, 5, 6, .85);
}

/* no height given by the page: the piano picks its own shape */
.sp--auto { height: auto; }
.sp--auto .sp-stage { flex: none; aspect-ratio: 16 / 9; }
.sp--auto.sp--mini .sp-stage { aspect-ratio: 4 / 3; }
.sp--auto.sp--preview .sp-stage { aspect-ratio: 2 / 1; }
@container sp (max-width: 640px) {
  .sp--auto.sp--interactive .sp-stage { aspect-ratio: 4 / 5; }
  .sp--auto.sp--preview .sp-stage { aspect-ratio: 4 / 3; }
}

/* ---------- message over the notes (the app's stage hint) ---------- */
.sp-hint {
  position: absolute; z-index: 2; top: 14px; left: 50%; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px)); width: max-content;
  padding: 9px 16px; border-radius: 980px;
  background: rgba(18, 18, 20, .84); border: 1px solid var(--sp-line-2);
  color: var(--sp-text-2); font: 500 14px/1.35 var(--sp-body); text-align: center; text-wrap: balance;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  pointer-events: none; transition: opacity .3s var(--sp-ease);
}
.sp-hint:empty { opacity: 0; padding: 0; border-width: 0; }
.sp-hint--waiting { color: var(--sp-gold-hi); border-color: rgba(201, 169, 97, .5); font-weight: 600; }
.sp-hint--note { color: var(--sp-text); }
@media (prefers-reduced-motion: no-preference) {
  .sp-hint--waiting { animation: sp-breathe 1.6s var(--sp-ease) infinite; }
}
@keyframes sp-breathe { 50% { box-shadow: 0 0 22px -4px rgba(201, 169, 97, .55); } }

/* ---------- live accuracy ---------- */
.sp-acc {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  display: inline-flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px 0 14px;
  border-radius: 980px; background: rgba(18, 18, 20, .84); border: 1px solid var(--sp-line-2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font: 600 14px/1 var(--sp-body); color: var(--sp-text-2); font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.sp-acc-k { font-weight: 500; }
.sp-acc-pct { font: 600 16px/1 var(--sp-display); letter-spacing: -.01em; color: var(--sp-gold-hi); }
.sp-acc-n { display: inline-flex; align-items: center; gap: 4px; }
.sp-acc-n .sp-ic { width: 14px; height: 14px; }
/* the app's three counts: right, wrong and missed notes (told apart by their icons, not only by colour) */
.sp-acc-hit .sp-ic { color: var(--sp-ok); }
.sp-acc-wrong .sp-ic { color: var(--sp-wrong); }
.sp-acc-missed .sp-ic { color: var(--sp-text-2); }
.sp--interactive:has(.sp-acc:not([hidden])) .sp-hint { max-width: min(560px, calc(100% - 340px)); }

/* ---------- the control rail ---------- */
.sp-bar {
  flex: none; position: relative; z-index: 3;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--sp-line);
  background: linear-gradient(180deg, #0b0b0d, #060607);
}
.sp-transport { display: flex; align-items: center; gap: 8px; flex: none; }
.sp-timeline { flex: 1 1 220px; min-width: 150px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.sp-tl-labels { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; padding: 0 2px; }
.sp-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 14px/1.2 var(--sp-body); color: var(--sp-text-2); }
.sp-time { flex: none; white-space: nowrap; font: 500 14px/1.2 var(--sp-body); color: var(--sp-text-3); font-variant-numeric: tabular-nums; }
.sp-modes { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.sp-ic { width: 18px; height: 18px; flex: none; display: block; }

.sp-play {
  width: 52px; height: 52px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; flex: none;
  background: radial-gradient(120% 120% at 30% 20%, var(--sp-gold-hi), var(--sp-gold) 55%, var(--sp-gold-lo));
  color: #1b1407; box-shadow: 0 8px 26px -10px rgba(201, 169, 97, .95), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .2s var(--sp-ease), filter .2s var(--sp-ease);
}
.sp-play:hover { transform: scale(1.04); filter: brightness(1.04); }
.sp-play:active { transform: scale(.97); }
.sp-play .sp-ic { width: 22px; height: 22px; }

.sp-icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid transparent; padding: 0; flex: none;
  display: grid; place-items: center; background: transparent; color: var(--sp-text-2);
  transition: background .2s var(--sp-ease), color .2s var(--sp-ease), border-color .2s var(--sp-ease);
}
.sp-icon-btn:hover { background: rgba(244, 241, 234, .06); color: var(--sp-text); }
.sp-icon-btn .sp-ic { width: 20px; height: 20px; }

.sp-pill {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 980px;
  border: 1px solid var(--sp-line-2); background: rgba(244, 241, 234, .035); color: var(--sp-text-2);
  font: 500 14px/1 var(--sp-body); white-space: nowrap;
  transition: background .2s var(--sp-ease), color .2s var(--sp-ease), border-color .2s var(--sp-ease), box-shadow .2s var(--sp-ease);
}
.sp-pill:hover { color: var(--sp-text); border-color: rgba(244, 241, 234, .26); }
.sp-toggle[aria-pressed="true"] {
  color: var(--sp-on-gold); border-color: transparent;
  background: linear-gradient(180deg, var(--sp-gold-hi), var(--sp-gold));
  box-shadow: 0 0 0 1px rgba(234, 211, 154, .25), 0 6px 18px -8px rgba(201, 169, 97, .7);
}

/* speed: a real select dressed as a pill */
.sp-speed { padding: 0; }
.sp-speed:focus-within { outline: 2px solid var(--sp-gold); outline-offset: 2px; }
.sp-select {
  -webkit-appearance: none; appearance: none; border: 0; outline: none; background: transparent;
  height: 44px; padding: 0 32px 0 15px; border-radius: 980px; cursor: pointer; field-sizing: content;
  font: 500 14px/1 var(--sp-body); color: inherit; font-variant-numeric: tabular-nums;
}
.sp-speed > .sp-select { margin: -1px; } /* the whole pill, its 1 px border included: a 44 px tall target */
.sp-select option { background: #121214; color: var(--sp-text); }
.sp-chev { position: absolute; right: 12px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; opacity: .75; pointer-events: none; }

/* hands: the app's control (fuente/src/style.css .hands-pick): one pill with both hands always drawn, side by side,
   the left one mirrored; the hands you play are lit in their colour with a soft glow, the others muted. Beside it,
   Listen (the headphones): gold while sol plays the whole piece, like the other toggles. The two keep the app's 8 px
   apart at every width; the app's pill sizes, 44 px tall here (touch targets): 72 and 50 px wide, 70 and 44 on a
   narrow or sideways rail (the app's narrow 11 px padding) */
.sp-hands-pick { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.sp-pill.sp-hands { gap: 2px; padding: 0 12px; } /* 72 px wide: two 22 px hands, 2 px apart */
.sp-hands .sp-ic { width: 22px; height: 22px; color: var(--sp-text-3); opacity: .5; transition: color .2s, opacity .2s, filter .2s; }
.sp-hand-l { transform: scaleX(-1); }
.sp-hands.sp-l-on .sp-hand-l { color: var(--sp-blue); opacity: 1; filter: drop-shadow(0 0 6px rgba(134, 169, 222, .75)); }
.sp-hands.sp-r-on .sp-hand-r { color: var(--sp-gold); opacity: 1; filter: drop-shadow(0 0 6px rgba(201, 169, 97, .75)); }
.sp-pill.sp-listen { min-width: 44px; padding: 0 14px; } /* 50 px wide: the app's pill padding around 20 px headphones */
.sp-listen .sp-ic { width: 20px; height: 20px; }

/* the piano by cable */
.sp-midi .sp-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--sp-ok); box-shadow: 0 0 10px var(--sp-ok); }
.sp-midi[data-midi="on"] { color: var(--sp-text); border-color: rgba(159, 210, 176, .45); background: rgba(159, 210, 176, .08); }
.sp-midi[data-midi="on"] .sp-dot { display: inline-block; }
.sp-midi[data-midi="on"] .sp-ic { display: none; }
.sp-midi[data-midi="empty"], .sp-midi[data-midi="denied"], .sp-midi[data-midi="blocked"], .sp-midi[data-midi="error"] { color: var(--sp-text-2); border-style: dashed; }

/* timeline: the app's thin rail, gold up to where the music is */
.sp-seek {
  --sp-p: 0%;
  -webkit-appearance: none; appearance: none; display: block; width: 100%;
  height: 44px; margin: -9px 0; /* a 44 px tall touch target that takes 26 px of the layout */
  background: transparent; cursor: pointer; touch-action: pan-y;
}
.sp-seek:focus { outline: none; }
.sp-seek:focus-visible { outline: 2px solid var(--sp-gold); outline-offset: 2px; border-radius: 6px; }
.sp-seek::-webkit-slider-runnable-track {
  height: 6px; border-radius: 980px;
  background: linear-gradient(90deg, var(--sp-gold-lo), var(--sp-gold)) 0 0 / var(--sp-p) 100% no-repeat, rgba(244, 241, 234, .09);
}
.sp-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -5px; border: 0; border-radius: 50%;
  background: var(--sp-text); box-shadow: 0 0 0 3px rgba(5, 5, 6, .9), 0 0 12px rgba(234, 211, 154, .6);
}
.sp-seek::-moz-range-track { height: 6px; border-radius: 980px; background: rgba(244, 241, 234, .09); }
.sp-seek::-moz-range-progress { height: 6px; border-radius: 980px; background: linear-gradient(90deg, var(--sp-gold-lo), var(--sp-gold)); }
.sp-seek::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--sp-text); box-shadow: 0 0 0 3px rgba(5, 5, 6, .9), 0 0 12px rgba(234, 211, 154, .6); }

.sp-bar :focus-visible { outline: 2px solid var(--sp-gold); outline-offset: 2px; }

/* preview: compact, one line */
.sp-bar--preview { flex-wrap: nowrap; gap: 14px; padding: 10px 14px 12px; }
.sp-bar--preview .sp-play { width: 48px; height: 48px; }
.sp-bar--preview .sp-modes { margin-left: 0; flex-wrap: nowrap; }

/* full screen: the whole screen is the piano */
.sp--fs, .sp:fullscreen { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.sp--fs .sp-stage, .sp:fullscreen .sp-stage { flex: 1 1 auto; aspect-ratio: auto; }
.sp--fs .sp-bar, .sp:fullscreen .sp-bar { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.sp:fullscreen::backdrop { background: #050506; }

/* ---------- narrow: the rail goes on two lines, transport first ---------- */
@container sp (max-width: 860px) {
  .sp-bar--interactive { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 14px; padding: 10px 12px 12px; }
  .sp-bar--interactive .sp-timeline { min-width: 0; } /* the grid column decides (320 px: the time stays whole) */
  .sp-bar--interactive .sp-modes { grid-column: 1 / -1; justify-content: center; margin-left: 0; }
}
@container sp (max-width: 560px) {
  .sp-bar--interactive .sp-sound .sp-lbl, .sp-bar--interactive .sp-midi .sp-lbl {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .sp-bar--interactive .sp-sound, .sp-bar--interactive .sp-midi { min-width: 44px; padding: 0 13px; }
  .sp-bar .sp-modes { gap: 6px; }
  .sp-pill { padding: 0 13px; }
  .sp-acc { top: 10px; right: 10px; height: 32px; gap: 8px; padding: 0 10px; }
  .sp-acc-k { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sp-hint { top: 52px; font-size: 14px; padding: 8px 14px; }
  .sp--interactive:has(.sp-acc:not([hidden])) .sp-hint { max-width: calc(100% - 24px); }
  .sp-bar--preview { gap: 10px; }
  .sp-bar--preview .sp-sound .sp-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sp-bar--preview .sp-sound { min-width: 44px; padding: 0 13px; }
}
@container sp (max-width: 380px) {
  .sp-bar--interactive { gap: 8px 10px; padding: 10px 8px 12px; }
  .sp-bar .sp-modes { gap: 5px; }
  .sp-pill, .sp-pill.sp-hands, .sp-pill.sp-listen { padding: 0 11px; } /* the hands 70 px wide, Listen 44 */
  .sp-wait .sp-lbl { font-size: 14px; }
}
/* (a narrow rail makes two short rows of modes by wrapping them in their page order, controls.js: Wait for me, speed
   and sound; then the hands, Listen, the piano and full screen. No CSS order, so the focus follows what is seen) */
@container sp (min-width: 861px) {
  .sp-bar--interactive { flex-wrap: nowrap; }
}
/* a phone on its side (little height): a compact rail, icons with their names for the screen reader; one quiet
   row where it fits (a piano 700 px wide or more), else the two rows of a phone held upright, tighter */
@media (max-height: 520px) and (min-width: 560px) {
  .sp-bar--interactive { gap: 6px 8px; padding: 6px 10px 8px; }
  .sp-bar--interactive .sp-wait .sp-lbl, .sp-bar--interactive .sp-sound .sp-lbl, .sp-bar--interactive .sp-midi .sp-lbl {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .sp-bar--interactive .sp-wait, .sp-bar--interactive .sp-sound, .sp-bar--interactive .sp-midi { min-width: 44px; padding: 0 13px; }
  .sp-bar--interactive .sp-title { display: none; }
  .sp-bar--interactive .sp-tl-labels { justify-content: flex-end; }
  .sp-bar--interactive .sp-play { width: 46px; height: 46px; }
  .sp-bar--interactive .sp-seek { margin: -9px 0; } /* its 44 px target takes 26 px of the height */
  .sp-bar--interactive .sp-hands { padding: 0 11px; }
  .sp-bar--interactive .sp-listen { padding: 0 11px; }
  .sp-hint { top: 10px; }
  .sp-acc { top: 8px; }
  @container sp (min-width: 700px) {
    .sp-bar--interactive { display: flex; flex-wrap: nowrap; gap: 8px; }
    .sp-bar--interactive .sp-modes { grid-column: auto; flex-wrap: nowrap; justify-content: flex-end; margin-left: 0; gap: 6px; }
    .sp-bar--interactive .sp-timeline { min-width: 110px; }
  }
}

/* a very wide piano (full screen on a big monitor): the rail and the messages grow with it, so they keep
   their place in the picture (zoom changes the layout too; where a browser lacks it, they stay as they are) */
@container sp (min-width: 1800px) { .sp-bar, .sp-hint, .sp-acc { zoom: 1.18; } }
@container sp (min-width: 2400px) { .sp-bar, .sp-hint, .sp-acc { zoom: 1.36; } }
@container sp (min-width: 3200px) { .sp-bar, .sp-hint, .sp-acc { zoom: 1.6; } }

@media (prefers-reduced-motion: reduce) {
  .sp *, .sp *::before, .sp *::after { transition-duration: 0s !important; animation: none !important; }
}
@media (forced-colors: active) {
  .sp-pill, .sp-play, .sp-icon-btn { border: 1px solid ButtonText; }
  .sp-toggle[aria-pressed="true"] { outline: 2px solid Highlight; }
  /* the hands you play: in the system's highlight colour; the others faint (the glow is dropped here) */
  .sp-hands .sp-ic { color: ButtonText; opacity: .4; filter: none; }
  .sp-hands.sp-l-on .sp-hand-l, .sp-hands.sp-r-on .sp-hand-r { color: Highlight; opacity: 1; filter: none; }
  .sp-stage:focus-visible::after { outline: 3px solid Highlight; outline-offset: -3px; } /* shadows are dropped here */
}
