/* ============================================================
   RitPlay · App Polish Layer
   Camada puramente visual carregada DEPOIS de styles.css.
   Não altera layout funcional: apenas cores, sombras, raios,
   transições, animações e micro-interações.
   ============================================================ */

/* ---------- Fundação ---------- */

:root {
  --bb-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --bb-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --bb-shadow-soft: 0 6px 24px rgba(76, 37, 31, 0.1);
  --bb-shadow-pop: 0 18px 48px rgba(76, 37, 31, 0.18);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  -webkit-tap-highlight-color: transparent;
}

/* Fundo do app com profundidade sutil, dentro da paleta */
body {
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(255, 121, 102, 0.35), transparent 60%),
    radial-gradient(120% 100% at 100% 100%, rgba(42, 32, 29, 0.5), transparent 55%);
  background-attachment: fixed;
}

/* Foco visível bonito (teclado) sem anel feio no toque */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-primary, #ff523d);
  outline-offset: 2px;
  border-radius: 10px;
}
button:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- Botões: resposta tátil universal ---------- */

button,
.bb-button,
.navbar-button {
  transition:
    transform 0.16s var(--bb-ease-out),
    box-shadow 0.22s var(--bb-ease-out),
    background-color 0.18s ease,
    filter 0.18s ease;
  will-change: transform;
}

button:active:not(:disabled) {
  transform: scale(0.96);
}

/* Botões primários ganham brilho ao pressionar */
.bb-button:active,
.auth-content button:active {
  filter: brightness(1.05);
}

/* Botão "Início" e botões da navbar viram pills com vidro */
.navbar-button {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--bb-shadow-soft);
}
.navbar-button:active {
  transform: scale(0.93);
}

/* ---------- Modais: entrada animada ---------- */

@keyframes bbPopIn {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal:not(.hidden) {
  animation: bbFadeIn 0.25s ease both;
}

.modal:not(.hidden) .modal-content {
  animation: bbPopIn 0.42s var(--bb-ease-spring) both;
}

.modal-content {
  box-shadow: var(--bb-shadow-pop) !important;
}

/* ---------- Login / Auth ---------- */

.auth-content {
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
}

.auth-content input {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.auth-content input:focus {
  box-shadow: 0 0 0 4px rgba(255, 82, 61, 0.14);
}

#auth-login-submit-btn,
#auth-register-submit-btn {
  background-image: linear-gradient(135deg, #ff6a52, #ff523d 55%, #f03f2a) !important;
  box-shadow: 0 10px 24px rgba(255, 82, 61, 0.38) !important;
  border: none !important;
  letter-spacing: 0.04em;
}
#auth-login-submit-btn:active,
#auth-register-submit-btn:active {
  box-shadow: 0 4px 12px rgba(255, 82, 61, 0.3) !important;
}

/* ---------- Menu Principal ---------- */

@keyframes bbRiseIn {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

#app-root-menu:not(.hidden) .app-root-menu-header {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.05s both;
}
#app-root-menu:not(.hidden) .app-root-menu-featured {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.12s both;
}
#app-root-menu:not(.hidden) .app-root-menu-grid > :nth-child(1) {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.2s both;
}
#app-root-menu:not(.hidden) .app-root-menu-grid > :nth-child(2) {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.26s both;
}
#app-root-menu:not(.hidden) .app-root-menu-grid > :nth-child(3) {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.32s both;
}
#app-root-menu:not(.hidden) .app-root-menu-grid > :nth-child(4) {
  animation: bbRiseIn 0.45s var(--bb-ease-out) 0.38s both;
}

/* Card destaque: gradiente da marca + brilho varrendo */
@keyframes bbShine {
  0%, 60% { transform: translateX(-130%) skewX(-18deg); }
  100% { transform: translateX(230%) skewX(-18deg); }
}

.app-root-menu-featured {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(135deg, #ff6a52, #ff523d 50%, #e8462f) !important;
  background-color: #ff523d !important;
  border: none !important;
  color: #fff !important;
  box-shadow: 0 16px 36px rgba(255, 82, 61, 0.4) !important;
  border-radius: 20px !important;
}
.app-root-menu-featured * {
  color: #fff !important;
}
.app-root-menu-featured::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 38%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: bbShine 3.6s ease-in-out infinite;
  pointer-events: none;
}
.app-root-menu-featured:active {
  transform: scale(0.97);
}

/* Cards do menu: ícones + relevo + hover */
.app-root-menu-card {
  position: relative;
  border-radius: 18px !important;
  border: 1px solid rgba(76, 37, 31, 0.1) !important;
  background-color: #fffdfc !important;
  box-shadow: var(--bb-shadow-soft) !important;
  overflow: hidden;
}
.app-root-menu-card:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(76, 37, 31, 0.12) !important;
}
.app-root-menu-card strong {
  display: grid;
  gap: 6px;
  justify-items: start;
}
.app-root-menu-card strong::before {
  font-size: 1.5em;
  line-height: 1;
}
.app-root-menu-grid > :nth-child(1) strong::before { content: "👻"; }
.app-root-menu-grid > :nth-child(2) strong::before { content: "🥁"; }
.app-root-menu-grid > :nth-child(3) strong::before { content: "🏆"; }
.app-root-menu-grid > :nth-child(4) strong::before { content: "🎖️"; }

/* Barrinha colorida no topo de cada card */
.app-root-menu-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ff523d, #ff9f91);
  opacity: 0.85;
}

/* Kicker do menu como pill */
.app-root-menu-kicker {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft, #ffe3dc);
  color: var(--brand-primary, #ff523d) !important;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ---------- Criar Cadências (somente estética!) ---------- */

/* Pads/dados: relevo, transição suave de cor e pressão */
.die-wrapper > div,
[data-index][data-value] {
  border-radius: 16px;
  transition:
    background-color 0.12s ease,
    transform 0.1s var(--bb-ease-out),
    box-shadow 0.18s ease;
  box-shadow:
    0 4px 10px rgba(76, 37, 31, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.die-wrapper > div:active,
[data-index][data-value]:active {
  transform: scale(0.94);
  box-shadow: 0 2px 5px rgba(76, 37, 31, 0.16);
}

/* Botões da barra de ferramentas da cadência */
.bb-button.sec-btn {
  border-radius: 16px;
  box-shadow: var(--bb-shadow-soft);
  border: 1px solid rgba(76, 37, 31, 0.08);
}
.bb-button.sec-btn:active {
  transform: scale(0.92);
}

/* Painel inferior com vidro suave */
#tap-assessment-panel {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Botão de loop/avaliar com pulso quando ativo */
@keyframes bbPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 61, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(255, 82, 61, 0); }
}
#cadence-loop-toggle.active,
#play.active,
#listen.active {
  animation: bbPulse 1.4s ease-out infinite;
}

/* ---------- Exercício 1 · Metrônomo Fantasma ---------- */

/* Modal de introdução com entrada elástica */
.ghost-ex1-intro-card {
  animation: bbPopIn 0.5s var(--bb-ease-spring) both;
  box-shadow: var(--bb-shadow-pop);
}
.ghost-ex1-intro-cta {
  background-image: linear-gradient(135deg, #ff6a52, #ff523d 55%, #f03f2a);
  box-shadow: 0 10px 26px rgba(255, 82, 61, 0.4);
  transition: transform 0.16s var(--bb-ease-out), box-shadow 0.2s ease;
}
.ghost-ex1-intro-cta:active {
  transform: scale(0.95);
}

/* Pads do exercício: feedback de toque rápido e suave */
.ghost-ex1-pad {
  transition:
    background-color 0.1s ease,
    transform 0.09s var(--bb-ease-out),
    box-shadow 0.16s ease;
}
.ghost-ex1-pad-face {
  transition: background-color 0.12s ease, box-shadow 0.16s ease;
}

/* Pad principal de toque: anel respirando convidando o toque */
@keyframes bbBreath {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 61, 0.34); }
  50% { box-shadow: 0 0 0 14px rgba(255, 82, 61, 0); }
}
#tap-pad {
  animation: bbBreath 2.2s ease-in-out infinite;
  transition: transform 0.08s var(--bb-ease-out);
}
#tap-pad:active {
  transform: scale(0.95);
  animation: none;
}

/* Elogio "MUITO BEM!" com pop */
@keyframes bbPraise {
  0% { transform: scale(0.6) rotate(-4deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.ghost-ex1-hub-praise {
  animation: bbPraise 0.5s var(--bb-ease-spring) both;
}

/* Badge de pontos com transição de cor */
.ghost-ex1-points-badge,
.ghost-ex1-points-value {
  transition: transform 0.18s var(--bb-ease-spring), color 0.2s ease;
}

/* Medidor de precisão: trilho com gradiente adiantado→perfeito→atrasado */
.ghost-ex1-precision-meter {
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(76, 37, 31, 0.14);
}

/* Toggle de modo: pill deslizante suave */
.ghost-ex1-mode-toggle-pill {
  transition: transform 0.3s var(--bb-ease-spring), background-color 0.2s ease;
}
.ghost-ex1-mode-toggle-option {
  transition: color 0.2s ease, opacity 0.2s ease;
}

/* Cabeçalho/painéis do exercício com sombras suaves */
.ghost-ex1-bottom-panel,
.ghost-ex1-hub-shell {
  box-shadow: var(--bb-shadow-soft);
}

/* Modal de BPM */
.ghost-ex1-bpm-card {
  animation: bbPopIn 0.4s var(--bb-ease-spring) both;
}
.ghost-ex1-bpm-preset {
  transition: transform 0.14s var(--bb-ease-out), background-color 0.16s ease;
}
.ghost-ex1-bpm-preset:active {
  transform: scale(0.92);
}

/* ---------- Ranking & listas ---------- */

.ranking-screen-root .modal-content > * {
  animation: bbRiseIn 0.4s var(--bb-ease-out) both;
}

/* ---------- Tela de resultados ---------- */

#results-screen:not(.hidden) .modal-content,
#results-screen:not(.hidden) > div {
  animation: bbPopIn 0.5s var(--bb-ease-spring) both;
}
@keyframes bbRankReveal {
  0% { transform: scale(2.2) rotate(-8deg); opacity: 0; filter: blur(6px); }
  100% { transform: scale(1) rotate(0); opacity: 1; filter: blur(0); }
}
#rank-letter {
  animation: bbRankReveal 0.65s var(--bb-ease-spring) 0.15s both;
  display: inline-block;
}

/* ---------- Ripple (criado por js/app-polish.js) ---------- */

.bb-ripple-host {
  position: relative;
  overflow: hidden;
}
.bb-ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%);
  transform: scale(0);
  animation: bbRipple 0.55s ease-out forwards;
  pointer-events: none;
  mix-blend-mode: soft-light;
}
@keyframes bbRipple {
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

/* ---------- Modo escuro: manter contraste da camada de polimento ---------- */

[data-theme="dark"] .app-root-menu-card {
  background-color: #322825 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4) !important;
}
[data-theme="dark"] .app-root-menu-kicker {
  background: rgba(255, 82, 61, 0.18);
}
[data-theme="dark"] .die-wrapper > div,
[data-theme="dark"] [data-index][data-value] {
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .bb-button.sec-btn {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- Scrollbars discretas ---------- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 82, 61, 0.35);
  border-radius: 999px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Acessibilidade: respeitar redução de movimento ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
