/* =========================================================================
   Teclado Interativo — identidade visual do livro de Soraya Aboim
   Papel creme, tinta verde-petróleo, notas em arco-íris.
   ========================================================================= */

:root {
  --paper: #FDF7EC;
  --paper-2: #FFFFFF;
  --ink: #22333B;
  --ink-soft: #6B7A80;
  --brand: #0E5C63;
  --brand-2: #17868C;
  --accent: #FF8A3D;
  --rec: #E5484D;
  --line: #E7DCC9;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(34, 51, 59, 0.09);
  --shadow-lg: 0 20px 50px rgba(34, 51, 59, 0.16);
  --font-display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
}

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

/* várias caixas usam display:flex/grid, que venceria o [hidden] do navegador */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 12% -8%, #E4F3F1 0%, transparent 62%),
    radial-gradient(900px 420px at 92% 4%, #FFEEDD 0%, transparent 58%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; }

kbd {
  font: inherit;
  font-size: 0.78em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}

/* ------------------------------------------------------------------ topo -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(253, 247, 236, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.topbar__mark {
  font-size: 1.9rem;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(14, 92, 99, 0.25));
}

.topbar__brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--brand);
}

.topbar__brand small {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.topbar__nav { display: flex; gap: 6px; }

.topbar__nav a {
  padding: 7px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--brand);
  transition: background 0.18s ease;
}

.topbar__nav a:hover { background: rgba(23, 134, 140, 0.12); }

/* ---------------------------------------------------------------- página -- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 32px) 72px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero { text-align: center; padding: 20px 0 4px; }

.hero h1 {
  font-size: clamp(1.9rem, 5.2vw, 3rem);
  color: var(--brand);
  margin-bottom: 10px;
}

.hero p {
  max-width: 58ch;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 1.03rem;
}

.hero__note {
  margin-top: 14px !important;
  display: inline-block;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--brand);
}

/* --------------------------------------------------------------- legenda -- */

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 4px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
}

.legend__dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--tint);
  color: var(--dot-ink, #fff);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.legend__name {
  font-weight: 800;
  font-size: 0.85rem;
  margin-right: 12px;
  color: var(--ink);
}

/* ---------------------------------------------------------------- cards --- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 18px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.2s ease;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--card-tint, var(--brand));
}

.card:hover,
.card:focus-visible {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  outline: none;
}

.card__emoji { font-size: 2.1rem; line-height: 1.2; }

.card__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
}

.card__credit { font-size: 0.82rem; color: var(--ink-soft); }

.card__meta { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.chip {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: #EEF3F2;
  color: var(--ink-soft);
}

.chip--rec { background: #FDE8E9; color: var(--rec); }

/* --------------------------------------------------------------- painéis -- */

.panel {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 26px);
}

.panel__title {
  font-size: 1.2rem;
  color: var(--brand);
  margin-bottom: 6px;
}

.panel__hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.steps { padding-left: 22px; display: grid; gap: 8px; color: var(--ink-soft); }
.steps strong { color: var(--ink); }

.back {
  align-self: flex-start;
  text-decoration: none;
  font-weight: 800;
  color: var(--brand);
  font-size: 0.92rem;
}

.songhead {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.songhead__emoji { font-size: 2.8rem; line-height: 1; }
.songhead h1 { font-size: clamp(1.6rem, 4.4vw, 2.3rem); color: var(--brand); }
.songhead p { color: var(--ink-soft); font-size: 0.92rem; }

.badge {
  margin-left: auto;
  background: #EEF3F2;
  color: var(--brand);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge--rec { background: #FDE8E9; color: var(--rec); }

/* ------------------------------------------------------------- controles -- */

.transport { display: grid; gap: 16px; }

.transport__buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  border-color: transparent;
  color: #fff;
}

.btn--rec { background: var(--rec); border-color: transparent; color: #fff; }

.btn--ghost { background: transparent; color: var(--brand); }

.transport__seek {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ink-soft);
  min-width: 44px;
  text-align: center;
}

.seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(var(--brand-2), var(--brand)) 0 / var(--progress, 0%) 100% no-repeat,
    #E9EFEE;
  cursor: pointer;
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.seek::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
}

.transport__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.field { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; }
.field > span { color: var(--ink-soft); }

.field select,
.check input,
.field input[type="range"] { accent-color: var(--brand); }

.field select {
  font: inherit;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
}

.field output { font-variant-numeric: tabular-nums; color: var(--brand); }

.check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; cursor: pointer; }

.nextnote { margin-left: auto; font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.nextnote strong { color: var(--accent); font-family: var(--font-display); font-size: 1.05rem; }

/* ------------------------------------------------------------- partitura -- */

.score { display: grid; gap: 10px; }

.score__line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #FBF6EC;
}

.ball {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.ball:hover { transform: translateY(-2px) scale(1.06); }

.ball--on {
  transform: scale(1.22);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.65), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.ball--next { box-shadow: 0 0 0 3px rgba(14, 92, 99, 0.32), inset 0 -3px 0 rgba(0, 0, 0, 0.18); }

/* -------------------------------------------------------------- gravação -- */

.record__buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.record__buttons--files { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }

.record__buttons label.btn { cursor: pointer; }

.record__hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-weight: 800;
  color: var(--rec);
}

.record__pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rec);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.4; }
}

.record__result {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #F3F8F7;
  display: grid;
  gap: 10px;
}

body.is-recording .keyboard-frame {
  box-shadow: 0 0 0 3px var(--rec), var(--shadow-lg);
}

/* --------------------------------------------------------------- teclado -- */

.keyboard-frame {
  background: linear-gradient(160deg, #1B3B40, #0C2529);
  border-radius: var(--radius);
  padding: 20px 16px 26px;
  box-shadow: var(--shadow-lg);
  overflow-x: auto;
  overflow-y: hidden;
  transition: box-shadow 0.2s ease;
}

.keyboard { display: flex; justify-content: center; min-width: max-content; }

.keyboard__whites { display: flex; gap: 3px; }

.key {
  position: relative;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.key--white {
  width: 44px;
  height: 156px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #FFFDF8 0%, #EFE9DD 100%);
  box-shadow: 0 4px 0 #C9C0AE, 0 8px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-bottom: 12px;
}

.key__badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.key__name { font-size: 0.6rem; font-weight: 800; color: #8A8375; letter-spacing: 0.03em; }

.key--black {
  position: absolute;
  top: 0;
  right: -14px;
  width: 28px;
  height: 96px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(180deg, #2E3B3E 0%, #131C1F 100%);
  box-shadow: 0 4px 0 #05090A, 0 8px 14px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

.key--held,
.key:active { transform: translateY(3px); filter: brightness(1.06); }
.key--held.key--white { box-shadow: 0 1px 0 #C9C0AE, 0 4px 8px rgba(0, 0, 0, 0.3); }
.key--held.key--black { box-shadow: 0 1px 0 #05090A, 0 4px 8px rgba(0, 0, 0, 0.4); }

.key--playing.key--white { background: linear-gradient(180deg, #FFF3D9 0%, #FFD79B 100%); }
.key--playing.key--black { background: linear-gradient(180deg, #5A4630 0%, #2A1D10 100%); }

.key--next.key--white { background: linear-gradient(180deg, #EAF7F5 0%, #C3E6E1 100%); }
.key--next.key--black { background: linear-gradient(180deg, #274A4C 0%, #10282A 100%); }

.key--pulse { animation: keyPulse 0.32s ease-out; }

@keyframes keyPulse {
  0% { transform: translateY(4px); filter: brightness(1.3); }
  100% { transform: translateY(0); filter: brightness(1); }
}

/* ----------------------------------------------------------------- letra -- */

.lyrics p { color: var(--ink-soft); }
.lyrics p:empty { height: 8px; }

/* ---------------------------------------------------------------- rodapé -- */

.footer {
  border-top: 1px solid var(--line);
  padding: 26px 20px 40px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.5);
}

.footer strong { color: var(--brand); }

/* ----------------------------------------------------------------- aviso -- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

/* ------------------------------------------------------------ responsivo -- */

@media (max-width: 640px) {
  .key--white { width: 36px; height: 132px; }
  .key--black { width: 23px; height: 80px; right: -11px; }
  .key__badge { width: 24px; height: 24px; font-size: 0.75rem; }
  .ball { width: 34px; height: 34px; font-size: 0.92rem; }
  .nextnote { margin-left: 0; }
  .badge { margin-left: 0; }
  .topbar__nav a { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
