/* Notável — estilos. Tokens do docs/SPEC.md §3. */

@font-face { font-family: "Hanken Grotesk"; font-weight: 400; font-display: swap;
  src: url("/fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 500; font-display: swap;
  src: url("/fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 600; font-display: swap;
  src: url("/fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }

:root {
  --color-paper: #F7F8FA;
  --color-sheet: #FFFFFF;
  --color-ink: #1C2238;
  --color-ink-muted: #5A6074;
  --color-staff: #D3D8E2;
  --color-cobalt: #2B44D4;
  --color-cobalt-hover: #2338B3;
  --color-cobalt-active: #1D2F96;
  --color-cobalt-wash: #EEF0FC;
  --color-error: #B42318;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

  --radius-control: 6px;
  --radius-sheet: 12px;
  --shadow-sheet: 0 1px 0 var(--color-staff), 0 8px 24px -12px rgba(28, 34, 56, .12);

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font: 400 16px/26px var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01";
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--space-4); top: -48px; z-index: 10;
  background: var(--color-ink); color: #fff; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-control); text-decoration: none; }
.skip-link:focus { top: var(--space-4); }

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

/* ── Página ─────────────────────────────────────────────────────────────── */

.page { max-width: 720px; margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-8); }

.masthead { margin-bottom: var(--space-7); }
.wordmark {
  margin: 0;
  font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -0.02em;
}
.lede { margin: var(--space-3) 0 0; max-width: 34em; color: var(--color-ink-muted); font-size: 18px; line-height: 28px; }

/* ── Etapas ─────────────────────────────────────────────────────────────── */

.step { border-top: 1px solid var(--color-staff); padding: var(--space-5) 0; }
.step:last-of-type { border-bottom: 1px solid var(--color-staff); }

.step-head {
  display: grid;
  grid-template-columns: 28px auto 1fr auto;
  align-items: center;
  column-gap: var(--space-3);
  min-height: 32px;
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 600; line-height: 1;
  border: 1.5px solid var(--color-staff); color: var(--color-ink-muted);
  transition: background-color .24s var(--ease-out), border-color .24s var(--ease-out), color .24s var(--ease-out);
}
.step-title { margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
.step-title:focus { outline: none; }
.step-summary {
  margin: 0; min-width: 0;
  color: var(--color-ink-muted); font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-edit { justify-self: end; }

.step[data-state="active"] .step-num { background: var(--color-cobalt); border-color: var(--color-cobalt); color: #fff; }
.step[data-state="done"] .step-num { border-color: var(--color-ink); color: var(--color-ink); }
.step[data-state="locked"] .step-title,
.step[data-state="locked"] .step-num { color: #9AA0B2; }
.step:not([data-state="done"]) .step-summary { display: none; }

/* recolher / abrir: grid 0fr → 1fr anima a altura sem medir em JS */
.step-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .24s var(--ease-out);
}
.step-body > .step-inner { overflow: hidden; min-height: 0; opacity: 0; visibility: hidden;
  transition: opacity .24s var(--ease-out), visibility 0s linear .24s; }
.step[data-state="active"] .step-inner,
.step[data-state="open"] .step-inner { visibility: visible; transition: opacity .24s var(--ease-out), visibility 0s; }
.step[data-state="active"] .step-body,
.step[data-state="open"] .step-body { grid-template-rows: 1fr; }
.step[data-state="active"] .step-inner,
.step[data-state="open"] .step-inner { opacity: 1; overflow: visible; padding-top: var(--space-5); }

/* ── Textos de apoio e erros ────────────────────────────────────────────── */

.help { margin: var(--space-2) 0 0; color: var(--color-ink-muted); font-size: 13px; line-height: 18px; max-width: 60ch; }
.inline-error {
  margin: var(--space-2) 0 0; color: var(--color-error); font-size: 14px; line-height: 20px;
  display: flex; gap: var(--space-2); align-items: flex-start;
}
.inline-error::before {
  content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5zm0 6h1.5V12h-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5zm0 6h1.5V12h-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ── Zona de upload: uma pauta em branco ────────────────────────────────── */

.dropzone {
  position: relative; display: grid; place-items: center;
  min-height: 184px; padding: var(--space-6) var(--space-5);
  background: var(--color-sheet);
  border: 1px solid var(--color-staff); border-radius: var(--radius-sheet);
  cursor: pointer; text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone .staff {
  position: absolute; left: var(--space-6); right: var(--space-6); top: 50%;
  height: 64px; transform: translateY(-50%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.dropzone .staff i { display: block; height: 1px; background: var(--color-staff); transition: background-color .15s ease; }
.dropzone-text {
  position: relative; padding: var(--space-2) var(--space-4);
  background: var(--color-sheet); border-radius: var(--radius-control);
  font-size: 16px; font-weight: 500;
}
.dropzone-text u { text-decoration-color: var(--color-cobalt); text-underline-offset: 3px; color: var(--color-cobalt); }
.dropzone-touch { display: none; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--color-cobalt); }
.dropzone:hover .staff i, .dropzone.is-dragover .staff i { background: rgba(43, 68, 212, .4); }
.dropzone:focus-within { outline: 2px solid var(--color-cobalt); outline-offset: 2px; }
.dropzone.is-dragover { background: var(--color-cobalt-wash); }
.dropzone.is-dragover .dropzone-text { background: var(--color-cobalt-wash); }
@media (hover: none) and (pointer: coarse) {
  .dropzone-desktop { display: none; }
  .dropzone-touch { display: inline; color: var(--color-cobalt); }
}

/* ── Arquivo escolhido ──────────────────────────────────────────────────── */

.file-preview {
  background: var(--color-sheet);
  border: 1px solid var(--color-staff); border-radius: var(--radius-sheet);
  padding: var(--space-4) var(--space-4) var(--space-3);
}
.file-row { display: flex; align-items: center; gap: var(--space-3); }
.file-meta { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: var(--space-3); }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-duration { color: var(--color-ink-muted); font-size: 14px; font-variant-numeric: tabular-nums; flex: none; }
.waveform { display: block; width: 100%; height: 56px; margin-top: var(--space-3); cursor: pointer; }

/* ── Botões ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-5);
  border-radius: var(--radius-control); border: 1px solid transparent;
  font-size: 15px; font-weight: 600; line-height: 20px; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: background-color .12s ease, border-color .12s ease, transform .06s ease;
}
.btn-primary { background: var(--color-cobalt); color: #fff; }
.btn-primary:hover { background: var(--color-cobalt-hover); }
.btn-primary:active { background: var(--color-cobalt-active); transform: translateY(1px); }
.btn-secondary { background: var(--color-sheet); color: var(--color-ink); border-color: var(--color-staff); }
.btn-secondary:hover { border-color: var(--color-ink-muted); }
.btn-secondary:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { cursor: default; pointer-events: none; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading { background: var(--color-cobalt-hover); }

.text-btn {
  background: none; border: 0; padding: var(--space-2) var(--space-1); margin: calc(var(--space-2) * -1) 0;
  color: var(--color-cobalt); font-size: 15px; font-weight: 500; cursor: pointer;
  border-radius: var(--radius-control);
}
.text-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.round-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-sheet); border: 1px solid var(--color-staff); cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease;
}
.round-btn:hover { border-color: var(--color-ink-muted); }
.round-btn svg { width: 18px; height: 18px; fill: var(--color-ink); }
.round-btn-primary { width: 44px; height: 44px; background: var(--color-cobalt); border-color: var(--color-cobalt); }
.round-btn-primary:hover { background: var(--color-cobalt-hover); border-color: var(--color-cobalt-hover); }
.round-btn-primary svg { fill: #fff; }
.round-btn .icon-pause, .round-btn.is-playing .icon-play { display: none; }
.round-btn.is-playing .icon-pause { display: block; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Ajustes ────────────────────────────────────────────────────────────── */

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5) var(--space-5); }
.field-wide { grid-column: 1 / -1; }
.field label, .disclosure summary { display: block; margin-bottom: var(--space-2); font-size: 14px; line-height: 20px; font-weight: 500; }
.field input, .field select {
  display: block; width: 100%; height: 44px; padding: 0 var(--space-3);
  background: var(--color-sheet); border: 1px solid var(--color-staff); border-radius: var(--radius-control);
  font-size: 16px; font-variant-numeric: tabular-nums;
  transition: border-color .12s ease;
}
.field select {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%235A6074' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
.field input:hover, .field select:hover { border-color: #B5BCCB; }
.field input:focus, .field select:focus { outline: none; border-color: var(--color-cobalt); box-shadow: 0 0 0 1px var(--color-cobalt); }
.field input[aria-invalid="true"] { border-color: var(--color-error); }
.field-wide .help { max-width: none; }
#instrument { max-width: calc(50% - var(--space-5) / 2); }

.disclosure summary { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; color: var(--color-cobalt); list-style: none; margin: 0; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before {
  content: ""; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--ease-out);
}
.disclosure[open] summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.disclosure .field { margin-top: var(--space-4); max-width: calc(50% - var(--space-5) / 2); }

.submit-row { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); margin-top: var(--space-2); }
.server-note { margin: 0; display: flex; gap: var(--space-3); align-items: flex-start; color: var(--color-ink-muted); font-size: 14px; line-height: 20px; max-width: 60ch; }
.server-note .spinner { flex: none; margin-top: 2px; color: var(--color-cobalt); }

/* ── Progresso ──────────────────────────────────────────────────────────── */

.progress {
  background: var(--color-sheet); border: 1px solid var(--color-staff); border-radius: var(--radius-sheet);
  padding: var(--space-5);
}
.progress-label { margin: 0 0 var(--space-3); font-weight: 500; }
.progress-track { height: 4px; border-radius: 2px; background: var(--color-staff); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--color-cobalt); border-radius: 2px; transition: width .3s ease-in-out; }
.milestones { display: flex; gap: var(--space-5); margin: var(--space-3) 0 0; padding: 0; list-style: none; font-size: 13px; line-height: 18px; color: #9AA0B2; }
.milestones li { display: flex; align-items: center; gap: 6px; }
.milestones li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.milestones li.is-current { color: var(--color-ink); }
.milestones li.is-current::before { background: var(--color-cobalt); }
.milestones li.is-done { color: var(--color-ink-muted); }
.milestones li.is-done::before {
  width: 10px; height: 10px; border-radius: 0; background: var(--color-cobalt);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2l2.3 2.3L8.6 2.6' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2l2.3 2.3L8.6 2.6' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ── Resultado ──────────────────────────────────────────────────────────── */

.result { transition: opacity .24s var(--ease-out); }
.result.is-stale .sheet, .result.is-stale .after-score { opacity: .4; pointer-events: none; }
.stale-note { margin: 0 0 var(--space-3); color: var(--color-ink-muted); font-size: 14px; }

/* a folha pode passar da coluna de texto para caber mais compassos */
.sheet {
  margin: 0;
  margin-inline: min(0px, calc((100% - min(960px, 100vw - 80px)) / 2));
  background: var(--color-sheet); border-radius: var(--radius-sheet); box-shadow: var(--shadow-sheet);
  padding: var(--space-5) var(--space-5) var(--space-4);
  transition: opacity .24s var(--ease-out);
}
.score { min-height: 120px; overflow-x: auto; color: var(--color-ink); }
.score svg { display: block; width: 100%; height: auto; overflow: visible; }
.score svg g, .score svg path, .score svg use, .score svg text { transition: fill 0s, color 0s; }
.score .note.is-playing, .score .note.is-playing * { fill: var(--color-cobalt); stroke: var(--color-cobalt); color: var(--color-cobalt); }
.score .label, .score .labelAbbr { display: none; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); margin-top: var(--space-3);
  font-size: 14px; color: var(--color-ink-muted); font-variant-numeric: tabular-nums; }
.pager-btn { width: 36px; height: 36px; border-radius: var(--radius-control); border: 1px solid var(--color-staff);
  background: var(--color-sheet); font-size: 20px; line-height: 1; cursor: pointer; }
.pager-btn:disabled { opacity: .4; cursor: default; }
.score-fallback { margin: 0; color: var(--color-ink-muted); }

.after-score { transition: opacity .24s var(--ease-out); }

.player { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-5); }
.player-track { flex: 1; height: 24px; display: flex; align-items: center; cursor: pointer; position: relative; }
.player-track::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--color-staff); }
.player-fill { position: relative; height: 4px; width: 0; border-radius: 2px; background: var(--color-cobalt); }
.player-fill::after { content: ""; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--color-cobalt); box-shadow: 0 0 0 3px var(--color-sheet); }
.player-time { font-size: 14px; color: var(--color-ink-muted); font-variant-numeric: tabular-nums; min-width: 88px; text-align: right; }

.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: var(--space-4) var(--space-7);
  margin: var(--space-6) 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: 13px; line-height: 18px; color: var(--color-ink-muted); }
.stats dd { margin: 0; font-size: 28px; line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

.downloads { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.restart { display: inline-block; margin-top: var(--space-5); }

/* ── Revelação da partitura (spec §7) ───────────────────────────────────── */

.score.is-revealing .staff > path {
  stroke-dasharray: var(--len) var(--len); stroke-dashoffset: var(--len);
  animation: draw-line .5s ease-out forwards;
}
.score.is-revealing .note, .score.is-revealing .rest, .score.is-revealing .beam, .score.is-revealing .tie {
  opacity: 0; animation: note-in .2s ease-out forwards; animation-delay: var(--d, .5s);
}
.score.is-revealing .clef, .score.is-revealing .keySig, .score.is-revealing .meterSig,
.score.is-revealing .barLine, .score.is-revealing .tempo, .score.is-revealing .mNum {
  opacity: 0; animation: fade-in .3s ease-out .35s forwards;
}
@keyframes draw-line { to { stroke-dashoffset: 0; } }
@keyframes note-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { to { opacity: 1; } }
.score.is-revealing .note, .score.is-revealing .rest { transform-box: fill-box; }

.after-score.is-hidden { opacity: 0; }

/* ── Rodapé ─────────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: var(--space-7);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: var(--space-3) var(--space-6);
  font-size: 13px; line-height: 18px; color: var(--color-ink-muted);
}
.footer-privacy { margin: 0; max-width: 46ch; }
.lang-switch { display: flex; gap: var(--space-4); }
.lang-switch a {
  color: var(--color-ink-muted); text-decoration: none;
  padding: var(--space-2) 0; border-radius: var(--radius-control);
}
.lang-switch a:hover { color: var(--color-ink); }
.lang-switch a[aria-current="true"] {
  color: var(--color-ink); font-weight: 500;
  text-decoration: underline; text-decoration-color: var(--color-cobalt); text-underline-offset: 4px;
}

/* ── Responsivo ─────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .page { padding: var(--space-6) var(--space-4) var(--space-7); }
  .masthead { margin-bottom: var(--space-6); }
  .wordmark { font-size: 28px; line-height: 32px; }
  .lede { font-size: 16px; line-height: 26px; }
  .settings { grid-template-columns: 1fr; }
  #instrument, .disclosure .field { max-width: none; }
  .sheet { margin: 0 calc(var(--space-4) * -1); border-radius: 0; padding: var(--space-4); }
  .stats { grid-template-columns: 1fr 1fr; gap: var(--space-5) var(--space-5); }
  .downloads .btn { flex: 1 1 100%; }
  .milestones { flex-direction: column; gap: var(--space-1); }
  .round-btn { width: 44px; height: 44px; }
  .dropzone .staff { left: var(--space-4); right: var(--space-4); }
  .player-time { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}

.wordmark-link { color: inherit; text-decoration: none; }
.wordmark-link:hover { color: var(--color-cobalt); }
