/* ======================================================
   ESPACIO BPM — reproductor.css
   Video ejercicio:  720×900  (4/5)
   Video partitura: 1280×800  (8/5)
====================================================== */

.rp-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "left  video"
    "controls video";
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

.rp-left {
  grid-area: left;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.rp-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-top: 1px solid var(--border);
  z-index: 2;
}

.rp-video-wrap {
  grid-area: video;
  height: 100%;
  aspect-ratio: 4 / 5;
  background: #000;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Partitura ───────────────────────────────────── */
.rp-partitura-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #0a0a0a;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#rp-vid-partitura {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.rp-partitura-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.55rem;
  letter-spacing: 0.3em;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 0.3s;
}

#rp-vid-partitura:not([src=""]) ~ .rp-partitura-placeholder {
  opacity: 0;
}

/* ── Video ejercicio ─────────────────────────────── */
#rp-vid-ejercicio {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Beat grande (precuenta) ─────────────────────── */
#rp-beat-large {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

#rp-beat-large .beat-ring {
  position: relative;
  width: clamp(120px, 22vw, 280px);
  height: clamp(120px, 22vw, 280px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(20,16,8,0.95) 55%, rgba(10,8,4,0.98) 100%);
  box-shadow:
    0 0 0 1px rgba(212,175,55,0.15),
    inset 0 0 40px rgba(0,0,0,0.8);
}

/* anillo exterior SVG-like con border */
#rp-beat-large .beat-ring::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(212,175,55,0.25);
}

#rp-beat-large .beat-ring::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1.5px solid rgba(212,175,55,0.08);
}

#rp-beat-large .beat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3.5rem, 11vw, 9rem);
  color: #fff;
  letter-spacing: 0.05em;
  line-height: 1;
  text-shadow: 0 0 30px rgba(212,175,55,0.4);
  position: relative;
  z-index: 1;
}

#rp-beat-large.visible {
  animation: beat-fade-in 0.08s ease forwards;
}
#rp-beat-large.visible .beat-ring {
  animation: beat-ring-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
#rp-beat-large.visible .beat-num {
  animation: beat-num-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

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

@keyframes beat-ring-pop {
  0%   { box-shadow: 0 0 0 1px rgba(212,175,55,0.15), inset 0 0 40px rgba(0,0,0,0.8), 0 0 0 0 rgba(212,175,55,0.6); }
  30%  { box-shadow: 0 0 0 1px rgba(212,175,55,0.4),  inset 0 0 40px rgba(0,0,0,0.8), 0 0 0 18px rgba(212,175,55,0.15); }
  100% { box-shadow: 0 0 0 1px rgba(212,175,55,0.15), inset 0 0 40px rgba(0,0,0,0.8), 0 0 0 28px rgba(212,175,55,0); }
}

@keyframes beat-num-pop {
  0%   { transform: scale(1.5); opacity: 0; filter: blur(4px); }
  50%  { opacity: 1; filter: blur(0); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

/* ── Beat row (4 círculos) ───────────────────────── */
#rp-beat-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
}

.rp-beat-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.rp-beat-circle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  transition: background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
}

.rp-beat-dot span {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  transition: color 0.08s ease;
}

.rp-beat-dot.active .rp-beat-circle {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(212,175,55,0.5);
}

.rp-beat-dot.active span {
  color: var(--gold);
}

/* ── Overlay ─────────────────────────────────────── */
.rp-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: scale(1);
  transform-origin: center center;
  transition: opacity 0.4s cubic-bezier(0.2, 0, 0, 1),
              transform 0.4s cubic-bezier(0.2, 0, 0, 1);
  z-index: 10;
}

.rp-overlay.visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

.rp-overlay.closing {
  opacity: 0;
  pointer-events: none;
  transform: scale(0);
}

.rp-overlay-header {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.52rem;
  letter-spacing: 0.35em;
  color: var(--muted);
  padding: 16px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#rp-lista {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  overscroll-behavior: contain;
}

#rp-lista::-webkit-scrollbar       { width: 3px; }
#rp-lista::-webkit-scrollbar-track { background: transparent; }
#rp-lista::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Items ───────────────────────────────────────── */

#rp-idle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 2;
}

#rp-idle.oculto {
  display: none;
}

.rp-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 20px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.rp-item:hover  { background: rgba(212,175,55,0.05); }
.rp-item.active { border-left-color: var(--gold); background: rgba(212,175,55,0.08); }

.rp-item-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text);
  flex-shrink: 0;
  width: 28px;
  padding-top: 2px;
}
.rp-item.active .rp-item-num { color: var(--gold); }

.rp-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.rp-item-titulo {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text);
  line-height: 1.3;
}
.rp-item.active .rp-item-titulo { color: var(--gold); }

.rp-item-desc {
  font-size: 0.62rem;
  color: var(--text);
  font-weight: 300;
  line-height: 1.4;
  opacity: 0.45;
}
.rp-item.active .rp-item-desc { color: var(--gold-dim); opacity: 1; }

.rp-item-bpm {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  flex-shrink: 0;
  padding-top: 3px;
}

/* ── Botones ─────────────────────────────────────── */
.rp-btn-play {
  background: var(--gold);
  border: none;
  color: #000;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 6px 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.rp-btn-play:hover   { opacity: 0.85; }
.rp-btn-play.playing { opacity: 0.6; }

.rp-bpm-display {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-shrink: 0;
}

.rp-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.46rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.rp-bpm-val {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  min-width: 30px;
}

.rp-btn-loop {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.rp-btn-loop:hover  { border-color: var(--gold-dim); color: var(--gold); }
.rp-btn-loop.active { border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.08); }

.rp-btn-toggle {
  background: var(--gold);
  border: none;
  color: #000;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 6px 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
  animation: rp-toggle-pulse 2.5s ease-in-out infinite;
  white-space: nowrap;
}
.rp-btn-toggle:hover  { opacity: 0.85; animation: none; }
.rp-btn-toggle.active { opacity: 0.7;  animation: none; }

@keyframes rp-toggle-pulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(212,175,55,0);   }
  50%       { box-shadow: 0 0 0 6px rgba(212,175,55,0.2); }
}

/* ══════════════════════════════════════════════════════
   PORTRAIT  (max-width: 900px)
══════════════════════════════════════════════════════ */
@media (max-width: 900px) and (orientation: portrait) {

  .rp-layout {
    display: block;
    position: absolute;
    inset: 0;
  }

  .rp-video-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    z-index: 1;
  }

  #rp-vid-ejercicio {
    object-fit: contain;
    object-position: center bottom;
  }

  .rp-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-right: none;
    z-index: 2;
  }

  .rp-partitura-wrap {
    flex: none;
    width: 100%;
    aspect-ratio: 128 / 65;
    background: #0a0a0a;
    border-bottom: none;
    display: none;
  }

  .rp-partitura-wrap.con-video { display: flex; }

  .rp-controls { display: none; }

  .rp-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
  }
}
/* ══════════════════════════════════════════════════════
   CONTROLS WRAP — contenedor unificado beat + botones
   Se posiciona como bloque en la esquina inferior derecha
   y escala junto con clamp()
══════════════════════════════════════════════════════ */

.rp-controls-wrap {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.rp-controls-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (min-width: 570px) {
  .rp-controls-wrap {
    font-size: clamp(0.5rem, 0.8vw, 0.85rem);
  }

  .rp-btn-play,
  .rp-btn-toggle {
    font-size: clamp(0.5rem, 0.8vw, 0.82rem);
    padding: clamp(4px, 0.5vw, 8px) clamp(10px, 1.3vw, 20px);
  }

  .rp-btn-loop {
    font-size: clamp(0.4rem, 0.65vw, 0.65rem);
    padding: clamp(3px, 0.4vw, 6px) clamp(8px, 1vw, 15px);
  }

  .rp-beat-circle {
    width:  clamp(11px, 1.3vw, 19px);
    height: clamp(11px, 1.3vw, 19px);
  }

  .rp-beat-dot span {
    font-size: clamp(0.6rem, 0.8vw, 1rem);
  }

  #rp-beat-row {
    gap: clamp(12px, 1.6vw, 26px);
  }
}

@media (max-width: 380px) {
  .rp-controls-wrap {
    transform: scale(0.7);
    transform-origin: bottom right;
  }
}