/* ─── Animación del sorteo — cabecera expandible ───────────────────────────
   Se usa tanto en jugador.html como en admin (base.html).
   La cabecera se expande al hacer click, muestra la animación p5.js,
   y se contrae al terminar o al hacer click fuera.
   ──────────────────────────────────────────────────────────────────────────── */

/* Cabecera: transición suave de altura */
.cabecera.cabecera-animable {
  display: block;
  overflow: hidden;
  transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
}
.cabecera.cabecera-animable .cabecera-titulo {
  position: relative;
  z-index: 10;
}
.cabecera.cabecera-animable .cabecera-nav {
  position: absolute;
  right: 2rem;
  top: 0.75rem;
  z-index: 10;
}
.cabecera.cabecera-animable.expandida {
  cursor: default;
}

/* Contenedor del canvas p5.js */
#animacion-contenedor {
  width: 100%;
  position: relative;
  overflow: hidden;
}
#animacion-contenedor canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Pipeline estático (aparece tras la animación) */
#pipeline-estatico {
  display: none;
  width: 100%;
  height: 90px;
  position: relative;
  padding: 0 20px;
}

.pipeline-contenido {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}

/* Línea dorada de fondo */
.pipeline-linea {
  position: absolute;
  top: 50%;
  left: 40px;
  right: 40px;
  height: 3px;
  background: var(--accent);
  transform: translateY(-50%);
  z-index: 0;
}

.pipeline-seccion {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  flex: 1;
}

.pipeline-seccion .titulo {
  font-family: 'Georgia', serif;
  font-size: 10px;
  font-weight: bold;
  color: var(--bg);
  opacity: 0.9;
}
.pipeline-seccion .subtitulo {
  font-size: 8px;
  color: #B0A0C0;
  margin-bottom: 4px;
}

/* Mini iconos del pipeline estático */
.pipeline-icono {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: bold;
  margin: 2px 0;
}
.icono-bloque {
  background: var(--primary);
  border: 2px solid var(--secondary);
  color: var(--accent);
  font-size: 18px;
}
.icono-mezcla { color: var(--secondary); font-size: 16px; }
.icono-corte { color: var(--accent); font-family: monospace; font-size: 11px; }
.icono-tabla { color: #B0A0C0; font-family: monospace; font-size: 9px; }
.icono-modulo { color: var(--accent); font-size: 14px; }
.icono-resultado {
  background: #FFFCF0;
  border: 2px solid var(--accent);
  border-radius: 6px;
  width: 50px;
  height: 40px;
}
.icono-resultado .etiqueta-nostrolotto {
  font-family: 'Georgia', serif;
  font-size: 6px;
  color: var(--secondary);
  font-weight: bold;
}
.icono-resultado .numero-misterio {
  font-size: 22px;
  font-weight: bold;
  color: #FF8800;
  text-shadow: 0 0 12px rgba(255, 136, 0, 0.6), 0 0 24px rgba(255, 136, 0, 0.3);
  line-height: 1;
}

/* Flechas entre secciones */
.pipeline-flecha {
  color: var(--accent);
  font-size: 14px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin: 0 -4px;
}

/* Overlay para detectar click fuera de la animación */
#animacion-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
}
#animacion-overlay.activo {
  display: block;
}

/* La cabecera expandida queda por encima del overlay */
.cabecera.cabecera-animable.expandida {
  z-index: 100;
  position: relative;
}

/* Hint visual de que la cabecera es clickable */
.cabecera.cabecera-animable:not(.expandida):hover {
  box-shadow: 0 2px 16px rgba(200, 150, 62, 0.4);
}
.cabecera.cabecera-animable:not(.expandida)::after {
  content: '▶ Ver cómo funciona el sorteo';
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Lato', sans-serif;
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.cabecera.cabecera-animable:not(.expandida):hover::after {
  opacity: 0.8;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .pipeline-seccion .titulo { font-size: 8px; }
  .pipeline-seccion .subtitulo { font-size: 7px; }
  .pipeline-icono { width: 30px; height: 30px; }
  .cabecera.cabecera-animable:not(.expandida)::after { display: none; }
}
