/* Pitch Cluster. Colours, sizes and weights are taken from the design pack's
   "Pitch Cluster Window" component; the macOS window chrome is dropped and the
   toolbar spans the browser window instead. */

@font-face {
  font-family: 'Noto Music';
  font-style: normal;
  font-weight: 400;
  font-display: block;                  /* the clefs must not flash unstyled */
  src: url('../fonts/noto-music-symbols.woff2') format('woff2');
  unicode-range: U+25CC, U+2669-266F, U+1D000-1D0F5, U+1D100-1D126, U+1D129-1D1EA, U+1D200-1D245;
}

:root {
  --bg: #ffffff;
  --toolbar-bg: #f1efee;
  --hairline: rgba(0, 0, 0, 0.13);
  --ink: #1b1a19;
  --ink-2: #6d6866;
  --btn-bg: #ffffff;
  --btn-border: rgba(0, 0, 0, 0.17);
  --btn-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  --meter-track: #e7e4e2;
  --meter-fill: #4c4846;
  --sheet-bg: #faf9f8;
  --accent: #ec3013;
  --toolbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1d;
    --toolbar-bg: #2a2a2c;
    --hairline: rgba(255, 255, 255, 0.13);
    --ink: #f1efee;
    --ink-2: #9d9997;
    --btn-bg: #3a3a3c;
    --btn-border: rgba(255, 255, 255, 0.14);
    --btn-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
    --meter-track: #3a3736;
    --meter-fill: #dcd8d6;
    --sheet-bg: #2c2c2e;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;                     /* the staff fits; the page never scrolls */
}
body {
  /* dvh tracks Safari's collapsing toolbars; height:100% above is the fallback. */
  height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- toolbar ---------- */

.toolbar {
  flex: 0 0 auto;
  min-height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--hairline);
}

.transport {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  min-width: 104px;
  padding: 0 14px 0 11px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  box-shadow: var(--btn-shadow);
  color: var(--ink);
  font: inherit;
  font-weight: 590;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.transport-glyph {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
}
.transport[data-state="listening"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.transport[data-state="listening"] .transport-glyph {
  width: 11px; height: 11px;
  border-radius: 0;
  background: #ffffff;
}
.transport:disabled { opacity: 0.45; cursor: default; }

.app-title {
  flex: 1;
  text-align: center;
  font-size: 13.5px;
  font-weight: 590;
  color: var(--ink-2);
  white-space: nowrap;
}

.picker {
  position: relative;
  display: flex;
  align-items: center;
  width: 236px;
  height: 28px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  box-shadow: var(--btn-shadow);
  color: var(--ink-2);
}
.picker select {
  appearance: none;
  width: 100%;
  height: 100%;
  padding: 0 30px 0 11px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-overflow: ellipsis;
}
.picker select:disabled { color: var(--ink-2); cursor: default; }
.picker:has(select:disabled) { opacity: 0.45; }
.picker-chevron {
  position: absolute;
  right: 8px;
  width: 13px; height: 13px;
  pointer-events: none;
}

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 124px;
  color: var(--ink-2);
  transition: opacity 150ms linear;
}
.meter[hidden] { display: none; }
.meter-icon { flex: 0 0 auto; width: 14px; height: 14px; }
.meter-track {
  flex: 1;
  height: 6px;
  background: var(--meter-track);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.meter-fill {
  width: 0;
  height: 100%;
  background: var(--meter-fill);
}

/* ---------- stage ---------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 34px 56px 0;
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}

.staff-holder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  transition: opacity 200ms linear;
}
.staff {
  width: 100%;
  height: 100%;
  color: var(--ink);                    /* staff lines, brace, clefs, ledgers */
  overflow: visible;
}
.clef { font-family: 'Noto Music'; }

.legend {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 14px 0 22px;
  transition: opacity 200ms linear;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.legend-item svg { width: 24px; height: 16px; }

.stage[data-blocked="true"] .staff-holder,
.stage[data-blocked="true"] .legend { opacity: 0.28; }

/* ---------- notes ---------- */

.note-ink { transition: fill 150ms linear; }
.note { animation: note-in 150ms ease-out; }
.staff-notes.is-clearing { opacity: 0; transition: opacity 120ms ease-in; }

@keyframes note-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .note { animation: none; }
  .note-ink, .staff-notes.is-clearing, .staff-holder, .legend, .meter { transition: none; }
}

/* ---------- blocked-state sheet ---------- */

.sheet-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
}
.sheet-layer[hidden] { display: none; }
.sheet {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 430px;
  padding: 26px 28px;
  background: var(--sheet-bg);
  border: 1px solid var(--hairline);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  color: var(--ink);
}
.sheet-icon { width: 26px; height: 26px; }
.sheet-title { font-size: 19px; font-weight: 640; letter-spacing: -0.015em; }
.sheet-body { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }
.sheet-action {
  margin-top: 6px;
  height: 32px;
  padding: 0 15px;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  font: inherit;
  font-weight: 590;
  cursor: pointer;
}
.sheet-action[hidden] { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- iPad and narrower ---------- */

@media (pointer: coarse) {
  .transport { height: 36px; min-width: 112px; }
  .picker, .picker select { height: 34px; }
}

@media (max-width: 900px) {
  .stage { padding: 24px 28px 0; }
  .picker { width: 168px; }
  .toolbar { gap: 12px; }
}

@media (max-width: 700px) {
  .app-title { display: none; }
  .toolbar { gap: 10px; padding: 6px 10px; }
  .stage { padding: 14px 12px 0; }
  .picker { width: auto; flex: 1; min-width: 0; }
  .meter { width: 72px; }
  .legend { gap: 16px; padding: 8px 0 12px; }
}
