/* Video 720p Aesthetic Style */
:root {
  --gradient-muro: linear-gradient(35deg, #ff6400, #D50D32, #BD0D63, #6A287C, #2D3A89);
  --color-orange: #ff6400;
  --color-red: #D50D32;
  --color-magenta: #BD0D63;
  --color-purple: #6A287C;
  --color-blue: #2D3A89;
  --glass-bg: rgba(20, 10, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-script: 'Caveat', cursive;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0714;
  font-family: var(--font-sans);
  color: #ffffff;
}

/* Stage wrapper centers the 16:9 720p frame */
.stage-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1b0c26 0%, #06020c 100%);
  position: relative;
}

/* Native 16:9 720p aspect ratio container */
.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  background: var(--gradient-muro);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
}

/* Canvas is strictly 1280x720 internally and stretches to fill the container */
#videoCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Ambient glow & vignette overlay */
.ambient-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(10, 4, 18, 0.65) 100%);
  mix-blend-mode: multiply;
  z-index: 10;
}

/* Header watermark */
.video-header {
  position: absolute;
  top: 24px;
  left: 28px;
  z-index: 50;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.badge-capsule {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: rgba(15, 8, 25, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4757;
  box-shadow: 0 0 12px #ff4757;
  animation: pulse-dot 2s infinite ease-in-out;
}

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

.brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.res-tag {
  font-size: 0.7rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ff6400, #D50D32);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

/* Lower third polaroid-style information capsule */
.lower-third {
  position: absolute;
  bottom: 84px;
  left: 28px;
  z-index: 40;
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 680px;
}

.lower-third.hidden {
  opacity: 0;
  transform: translateY(20px);
}

.info-glass {
  background: rgba(16, 8, 26, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 5px solid #ff6400;
  border-radius: 14px;
  padding: 16px 24px;
  box-shadow: var(--glass-shadow);
}

.info-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.badge-tag {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ff9800;
}

.counter-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.school-title {
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.35;
  color: #ffffff;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.locality-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: #e0e0e0;
  font-weight: 500;
}

.pin-icon {
  color: #ff4757;
  font-size: 1rem;
}

/* Start Overlay */
.start-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 5, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.6s ease, visibility 0.6s;
}

.start-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  max-width: 540px;
  text-align: center;
  padding: 40px;
  background: rgba(30, 14, 46, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(213, 13, 50, 0.2);
  animation: float-card 4s ease-in-out infinite alternate;
}

@keyframes float-card {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.disc-icon {
  font-size: 3.2rem;
  margin-bottom: 14px;
  display: inline-block;
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  100% { transform: rotate(360deg); }
}

.start-card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(120deg, #ffffff, #ffa751);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.song-info {
  font-size: 1.05rem;
  color: #ff9966;
  margin-bottom: 10px;
}

.desc-info {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #cccccc;
  margin-bottom: 20px;
}

/* Locality Selector Group */
.locality-selector-group {
  margin-bottom: 26px;
  text-align: left;
  background: rgba(18, 9, 30, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.locality-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #ff9966;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.locality-dropdown {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(30, 15, 48, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  padding: 12px 42px 12px 16px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.locality-dropdown option {
  background: #1e0f30;
  color: #ffffff;
  padding: 10px;
}

.locality-dropdown:hover {
  border-color: #ff6400;
}

.locality-dropdown:focus {
  border-color: #D50D32;
  box-shadow: 0 0 0 3px rgba(213, 13, 50, 0.35);
}

.select-wrapper::after {
  content: '▼';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #ff9966;
  font-size: 0.75rem;
  pointer-events: none;
}

.locality-count-badge {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #e0d0c0;
  font-weight: 500;
}

.start-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 22px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  background: linear-gradient(135deg, #ff6400, #D50D32);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(213, 13, 50, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(213, 13, 50, 0.7);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 13px 22px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.back-link {
  display: inline-block;
  color: #a0a0b0;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Bottom Hover Zone for Playback Controls */
.controls-hover-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 95px;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  padding: 0 28px 18px 28px;
}

/* Floating Controls Bar - Oculta por defecto, solo visible al pasar el mouse por encima */
.controls-panel {
  width: 100%;
  background: rgba(16, 8, 26, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 8px 18px 12px 18px;
  box-shadow: var(--glass-shadow);
  opacity: 0;
  transform: translateY(22px);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Solo aparece cuando se pasa el mouse por encima */
.controls-hover-zone:hover .controls-panel,
.controls-panel:hover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Timeline */
.timeline-container {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  margin-bottom: 10px;
  cursor: pointer;
}

#timeSlider {
  position: absolute;
  top: -6px;
  left: 0;
  width: 100%;
  height: 18px;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6400, #D50D32, #BD0D63);
  border-radius: 3px;
  position: relative;
  transition: width 0.1s linear;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 100, 0, 0.8);
}

/* Controls Bar Buttons */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ctrl-left, .ctrl-center, .ctrl-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
  text-decoration: none;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.ctrl-btn:active {
  transform: translateY(1px);
}

.export-btn {
  background: linear-gradient(135deg, rgba(255, 100, 0, 0.3), rgba(213, 13, 50, 0.3));
  border-color: rgba(255, 100, 0, 0.5);
  color: #ffd080;
}

.export-btn:hover {
  background: linear-gradient(135deg, #ff6400, #D50D32);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(213, 13, 50, 0.5);
}

.time-display {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: #e0e0e0;
  margin-left: 6px;
}

.song-label {
  font-size: 0.88rem;
  color: #ffa07a;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Recording Overlay Modal */
.record-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 3, 14, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.record-overlay.active {
  opacity: 1;
  visibility: visible;
}

.record-card {
  max-width: 480px;
  width: 90%;
  text-align: center;
  padding: 36px 30px;
  background: rgba(28, 12, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.record-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 18px auto;
  border: 4px solid rgba(255, 100, 0, 0.2);
  border-top: 4px solid #ff6400;
  border-right: 4px solid #D50D32;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

.record-card h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: #ffffff;
}

.record-card p {
  font-size: 0.92rem;
  color: #c0c0c0;
  margin-bottom: 20px;
}

.record-progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}

.record-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff6400, #D50D32, #BD0D63);
  transition: width 0.2s linear;
}

.record-percentage {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ff9966;
  margin-bottom: 20px;
}

.btn-cancel-rec {
  margin: 0 auto;
}

/* Responsiveness for smaller screens */
@media (max-width: 900px) {
  .ctrl-center {
    display: none;
  }
  .school-title {
    font-size: 1.1rem;
  }
  .lower-third {
    bottom: 80px;
    left: 16px;
    right: 16px;
    max-width: none;
  }
}
