/**
 * practice.css
 * Estilos para el modo práctica (overlay completo).
 */

/* ── Overlay de pantalla completa ────────────────────────────────────────── */

#practice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0d0d0d;
  flex-direction: column;
  overflow: hidden;
}

#practice-overlay.practice-overlay--open {
  display: flex;
}

/* En modo juego el overlay es transparente para que el piano sea visible */
#practice-overlay.practice-overlay--game {
  background: transparent;
  overflow: visible;
  pointer-events: none;
}

/* Bloquear controles normales durante la práctica */
#app.practice-active #chord-overlay,
#app.practice-active #transform-overlay,
#app.practice-active #settings-panel,
#app.practice-active #piano-edit-hint {
  pointer-events: none;
  opacity: 0;
}

/* ── Vistas (setup / game / results) ─────────────────────────────────────── */

.practice-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.practice-view--active {
  display: flex;
}

/* ── Vista de setup ──────────────────────────────────────────────────────── */

#practice-setup {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  gap: 0;
}

.practice-setup__header {
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.practice-setup__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #e8e8e8;
}

.practice-setup__body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── Acordeones del formulario de setup ─────────────────────────────────── */

.practice-accordion {
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  overflow: hidden;
}

.practice-accordion__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: #141414;
  gap: 0.5rem;
}

.practice-accordion__header::-webkit-details-marker { display: none; }

.practice-accordion__header::after {
  content: '▶';
  font-size: 0.6rem;
  color: #555;
  transition: transform 0.15s;
  flex-shrink: 0;
}

details[open] > .practice-accordion__header::after {
  transform: rotate(90deg);
}

.practice-accordion__title {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 600;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.practice-accordion__summary {
  font-size: 0.78rem;
  color: #576cbc;
  text-align: right;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-accordion__content {
  padding: 0.6rem 0.75rem 0.75rem;
  border-top: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.practice-form-subsection {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.4rem;
  padding-top: 0.6rem;
  border-top: 1px solid #222;
}

.practice-form-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.practice-form__label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.practice-form__hint {
  margin: 0;
  font-size: 0.78rem;
  color: #606060;
  font-style: italic;
}

/* ── Grupos de radio ─────────────────────────────────────────────────────── */

.practice-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.practice-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.practice-radio-label:hover {
  background: #1a1a1a;
}

.practice-radio-label:has(.practice-radio:checked) {
  background: rgba(87, 108, 188, 0.15);
  border-color: rgba(87, 108, 188, 0.4);
}

.practice-radio {
  margin-top: 3px;
  accent-color: #576cbc;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.practice-radio-label__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.practice-radio-label__name {
  font-size: 0.88rem;
  color: #d8d8d8;
}

.practice-radio-label__desc {
  font-size: 0.75rem;
  color: #707070;
}

/* ── Checkboxes de tipos ─────────────────────────────────────────────────── */

.practice-chordtypes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.practice-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  color: #d0d0d0;
  transition: background 0.15s, border-color 0.15s;
}

.practice-checkbox-label:hover {
  background: #1a1a1a;
}

.practice-checkbox-label:has(.practice-checkbox:checked) {
  background: rgba(87, 108, 188, 0.15);
  border-color: rgba(87, 108, 188, 0.4);
}

.practice-checkbox-label--disabled {
  opacity: 0.35;
  pointer-events: none;
}

.practice-checkbox {
  accent-color: #576cbc;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ── Extras de duración ──────────────────────────────────────────────────── */

.practice-duration-extra {
  padding-left: 0.25rem;
}

.practice-select {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 0.4rem 0.6rem;
  font-size: 0.88rem;
}

.practice-select:focus {
  outline: 2px solid #576cbc;
  outline-offset: 1px;
}

.practice-range {
  width: 100%;
  accent-color: #576cbc;
}

.practice-range-label {
  font-size: 0.85rem;
  color: #a0a0a0;
  margin-top: 0.3rem;
  display: block;
}

/* ── Footer de setup ─────────────────────────────────────────────────────── */

.practice-setup__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid #2a2a2a;
}

/* ── Vista de juego — diseño sándwich ────────────────────────────────────── */
/*
 * El overlay en modo juego es transparente. El piano queda expuesto entre los
 * dos paneles (superior e inferior) que tienen fondo sólido.
 *
 * ┌─ .practice-game__top ──────────────────┐  ← panel sólido (estado + acorde)
 * ├─ .practice-game__spacer ───────────────┤  ← transparente (piano visible)
 * └─ .practice-game__bottom ───────────────┘  ← panel sólido (botón de pista)
 */

#practice-game {
  pointer-events: none;
  overflow: visible; /* evitar que el panel superior quede recortado */
}

/* Panel superior */
.practice-game__top {
  background: rgba(13, 13, 13, 0.97);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
  flex-shrink: 0;
  padding: 0.5rem 1rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* Espaciador transparente: el piano queda visible e interactivo aquí */
.practice-game__spacer {
  flex: 1;
  pointer-events: none;
  min-height: 80px;
}

/* Panel inferior */
.practice-game__bottom {
  background: rgba(13, 13, 13, 0.97);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
  flex-shrink: 0;
  padding: 0.4rem 1rem;
  border-top: 1px solid #2a2a2a;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* Fila de estado (contador + progreso + stats + botón terminar) */
.practice-game__status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.practice-counter {
  font-size: 0.8rem;
  color: #808080;
  white-space: nowrap;
}

.practice-progress-bar {
  flex: 1;
  min-width: 60px;
  height: 4px;
  background: #2a2a2a;
  border-radius: 2px;
  overflow: hidden;
}

.practice-progress-bar__fill {
  height: 100%;
  background: #576cbc;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Temporizador de sesión (modo tiempo) */
.practice-session-timer {
  font-size: 0.85rem;
  font-weight: 700;
  color: #576cbc;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin: 0 0.15rem;
}

/* Barra de tiempo por acorde */
.practice-card-timer {
  width: 100%;
  height: 5px;
  background: #1a1a1a;
  border-radius: 3px;
  overflow: hidden;
  margin: 0.3rem 0 0.1rem;
}

.practice-card-timer__bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.85s linear;
}

.practice-game__stats {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.82rem;
}

.practice-stat--hits    { color: #4ade80; }
.practice-stat--misses  { color: #f87171; }
.practice-stat--streak  { color: #a0a0a0; }

.practice-finish-btn {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-left: auto;
}
.practice-finish-btn:hover { opacity: 1; }

/* Nombre del acorde (elemento central de la vista de juego) */
.practice-chord-name {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  color: #f0f0f0;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.1;
  padding: 0.1rem 0;
  transition: color 0.2s;
}

.practice-chord-name--correct {
  color: #4ade80;
  animation: practice-flash-correct 0.35s ease;
}

.practice-chord-name--wrong {
  color: #f87171;
  animation: practice-flash-wrong 0.35s ease;
}

@keyframes practice-flash-correct {
  0%   { text-shadow: 0 0 0 rgba(74,222,128,0.8); }
  50%  { text-shadow: 0 0 20px rgba(74,222,128,0.4); }
  100% { text-shadow: none; }
}

@keyframes practice-flash-wrong {
  0%   { text-shadow: 0 0 0 rgba(248,113,113,0.8); }
  50%  { text-shadow: 0 0 20px rgba(248,113,113,0.4); }
  100% { text-shadow: none; }
}

.practice-feedback {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

.practice-feedback--correct { color: #4ade80; }
.practice-feedback--wrong   { color: #f87171; }

/* Fila de respuesta incorrecta */
.practice-wrong-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.practice-expected {
  font-size: 0.82rem;
  color: #808080;
}

.practice-expected__name {
  font-size: 1rem;
  font-weight: 600;
  color: #d0d0d0;
}

.practice-continue-btn {
  min-width: 100px;
}

.practice-hint-btn {
  font-size: 0.82rem;
  opacity: 0.7;
}
.practice-hint-btn:hover:not(:disabled) { opacity: 1; }
.practice-hint-btn--used { opacity: 0.3; }

.practice-eval-btn {
  min-width: 100px;
  font-size: 0.9rem;
}

.practice-retry-btn {
  font-size: 0.85rem;
}

.practice-solution-btn {
  font-size: 0.82rem;
  opacity: 0.6;
}
.practice-solution-btn:hover { opacity: 1; }

/* ── Vista de resultados ─────────────────────────────────────────────────── */

#practice-results {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.practice-results__title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e0e0e0;
  margin: 0;
  text-align: center;
}

.practice-results__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 400px;
}

.practice-results__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 1rem;
}

.practice-results__stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #e8e8e8;
  line-height: 1;
}

.practice-results__stat-value--hits   { color: #4ade80; }
.practice-results__stat-value--misses { color: #f87171; }

.practice-results__stat-label {
  font-size: 0.75rem;
  color: #707070;
  text-align: center;
}

.practice-results__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

/* ── Botón de práctica en toolbar ────────────────────────────────────────── */

#btn-practice {
  position: relative;
}

#btn-practice.practice-running {
  color: #576cbc;
}

/* ── Error de no-tarjetas ────────────────────────────────────────────────── */

.practice-error-msg {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 6px;
  color: #f87171;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .practice-chordtypes-grid {
    grid-template-columns: 1fr;
  }
  .practice-results__grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .practice-card {
    padding: 1.25rem 1rem;
  }
}
