/* =========================================================
   Odisea del Código — Estilos personalizados
   ========================================================= */

/* --- Patrón de meandro griego (borde decorativo) --- */
.meandro {
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 10px,
    rgba(212, 175, 55, 0.15) 10px,
    rgba(212, 175, 55, 0.15) 12px
  );
  height: 3px;
}

/* --- Animación de pulso para misión disponible en el mapa --- */
@keyframes pulso-isla {
  0%, 100% { filter: drop-shadow(0 0 4px #D4AF37); }
  50%       { filter: drop-shadow(0 0 12px #D4AF37) brightness(1.2); }
}

.isla-disponible {
  animation: pulso-isla 2.2s ease-in-out infinite;
  cursor: pointer;
  transition: transform 0.15s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.isla-disponible:hover {
  transform: scale(1.08);
}

.isla-completada {
  filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.5));
}

.isla-bloqueada {
  opacity: 0.35;
  filter: grayscale(1);
}

/* --- Accesibilidad: reducir movimiento --- */
@media (prefers-reduced-motion: reduce) {
  .isla-disponible { animation: none; }
  .isla-disponible:hover { transform: none; }
  #barco-odiseo { transition: none !important; }
  #mapa-egeo { transition: none !important; filter: none !important; }
}

/* --- Layouts mobile-first: columnas dobles que colapsan en pantallas chicas --- */
.layout-2col {
  grid-template-columns: 1fr 1fr;
}

.layout-paleta-area {
  flex-direction: row;
}

@media (max-width: 768px) {
  .layout-2col {
    grid-template-columns: 1fr;
  }
  .layout-paleta-area {
    flex-direction: column;
  }
  .layout-paleta-area > .w-44 {
    width: 100%;
  }
}

/* --- Selector de avatar (registro) --- */
.avatar-opcion {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.2);
  cursor: pointer;
  font-size: 1.4rem;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.avatar-opcion:hover {
  transform: translateY(-1px);
  border-color: rgba(212, 175, 55, 0.4);
}

.avatar-opcion:has(input:checked) {
  border-color: #D4AF37;
  background: rgba(212, 175, 55, 0.15);
}

/* --- Popover de cambio de avatar (navbar) --- */
.avatar-popover {
  position: fixed;
  z-index: 90;
  display: flex;
  gap: 6px;
  background: rgba(11, 36, 71, 0.97);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.avatar-popover-opcion {
  border: none;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  font-size: 1.2rem;
  padding: 6px 8px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.avatar-popover-opcion:hover {
  transform: translateY(-1px);
  background: rgba(212, 175, 55, 0.2);
}

/* --- Toasts no intrusivos --- */
.toast-container {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(11, 36, 71, 0.97);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: #F5F0E8;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.01s linear; transform: none; }
}

/* --- Banner de Tormenta de Poseidón --- */
.tormenta-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(90deg, #0b1a3a, #1a3a6e, #0b1a3a);
  border-bottom: 2px solid rgba(212,175,55,0.4);
  padding: 0.5rem 1rem;
  text-align: center;
  color: #F5F0E8;
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.tormenta-banner.desvaneciendo {
  opacity: 0;
}

/* --- Modal de Pergamino (intervenciones docente) --- */
.modal-pergamino {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6,26,51,0.85);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal-pergamino.visible {
  opacity: 1;
}
.modal-pergamino-contenido {
  max-width: 480px;
  width: 90%;
  background: radial-gradient(ellipse at center, #f5e6c8 0%, #e8d5a0 60%, #d4b87a 100%);
  border: 2px solid rgba(139,90,43,0.6);
  border-radius: 8px;
  padding: 2rem;
  color: #3a2a0a;
  font-family: "Cinzel", serif;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-pergamino.visible .modal-pergamino-contenido {
  transform: translateY(0);
}

/* --- Olas animadas --- */
@keyframes ola {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.olas-container {
  overflow: hidden;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  opacity: 0.15;
}

.olas {
  animation: ola 12s linear infinite;
  width: 200%;
}

/* --- Bloques de programación (Mundo I) --- */
.bloque {
  border-radius: 8px;
  padding: 8px 14px;
  cursor: grab;
  user-select: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  border: 2px solid rgba(255,255,255,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.bloque:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.bloque:active { cursor: grabbing; }

.bloque.dragging {
  opacity: 0.5;
  transform: scale(0.97);
}

/* Colores por categoría de bloque */
.bloque-movimiento { background: #1a5c9a; border-color: #2a7cd4; }
.bloque-control    { background: #9a5c1a; border-color: #d47c2a; }
.bloque-sensor     { background: #1a7c5c; border-color: #2aac7c; }
.bloque-variable   { background: #7c3a1a; border-color: #ac5a2a; }
.bloque-accion     { background: #5c1a7c; border-color: #8c2aac; }

/* Muesca superior (conector de bloques) */
.bloque::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 20px;
  height: 6px;
  border-radius: 3px 3px 0 0;
  background: inherit;
  border: 2px solid rgba(255,255,255,0.15);
  border-bottom: none;
}

/* Muesca inferior */
.bloque::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 16px;
  width: 20px;
  height: 6px;
  border-radius: 0 0 3px 3px;
  background: inherit;
  border: 2px solid rgba(255,255,255,0.15);
  border-top: none;
}

/* Bloques contenedores (REPEAT, IF) */
.bloque-contenedor {
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.2);
  padding: 8px;
  margin: 4px 0;
}

.bloque-contenedor .bloque-header {
  border-radius: 6px 6px 0 0;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.bloque-contenedor .bloque-body {
  min-height: 36px;
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 0 0 4px 4px;
  padding: 4px;
  margin-top: 2px;
  background: rgba(0,0,0,0.2);
}

.bloque-contenedor .bloque-body.drop-activo {
  border-color: rgba(212, 175, 55, 0.6);
  background: rgba(212, 175, 55, 0.05);
}

/* --- Barra de bloques usados vs máximo --- */
.barra-bloques {
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.barra-bloques-relleno {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #D4AF37, #f0d060);
  transition: width 0.25s ease, background 0.25s ease;
}

.barra-bloques-relleno.barra-bloques-excedida {
  background: linear-gradient(90deg, #C1440E, #fca5a5);
}

/* --- Área de programa (zona de drop) --- */
#area-programa {
  min-height: 200px;
  border: 2px dashed rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  transition: border-color 0.2s, background 0.2s;
}

#area-programa.drop-activo {
  border-color: rgba(212, 175, 55, 0.7);
  background: rgba(212, 175, 55, 0.05);
}

/* --- Tablero de grilla --- */
.celda-grilla {
  border: 1px solid rgba(25, 55, 109, 0.6);
  background: rgba(11, 36, 71, 0.4);
  position: relative;
  transition: background 0.15s;
}

.celda-grilla.celda-meta {
  background: rgba(212, 175, 55, 0.15);
}

.celda-grilla.celda-obstaculo {
  background: rgba(193, 68, 14, 0.4);
}

.celda-grilla.celda-coleccionable::after {
  content: '🌿';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
}

/* --- Editor de Python --- */
.editor-python {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  color: #e2e8f0;
  padding: 12px;
  resize: vertical;
  tab-size: 4;
  outline: none;
  width: 100%;
}

.editor-python:focus {
  border-color: rgba(212, 175, 55, 0.5);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

.consola-output {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 8px;
  color: #86efac;
  padding: 12px;
  min-height: 80px;
  white-space: pre-wrap;
  overflow-y: auto;
}

.consola-error {
  color: #fca5a5;
}

/* --- Semáforo de progreso (panel docente) --- */
.semaforo-completada  { background: #166534; color: #bbf7d0; }
.semaforo-disponible  { background: #854d0e; color: #fef08a; }
.semaforo-bloqueada   { background: #1e293b; color: #64748b; }

/* --- Medallas --- */
.medalla {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Cinzel', serif;
}

.medalla-bronce { background: rgba(180, 100, 40, 0.25); border: 1px solid #b46428; color: #f0a05a; }
.medalla-plata  { background: rgba(140, 160, 180, 0.25); border: 1px solid #8ca0b4; color: #c8d8e8; }
.medalla-oro    { background: rgba(212, 175, 55, 0.25); border: 1px solid #D4AF37; color: #f0d060; }

/* --- Botones de acción principales --- */
.btn-primario {
  background: linear-gradient(135deg, #D4AF37, #C9A227);
  color: #0B2447;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 24px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-primario:hover  { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4); }
.btn-primario:active { transform: translateY(0); }

.btn-secundario {
  background: rgba(255,255,255,0.08);
  color: #F5F0E8;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secundario:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.25); }

/* --- Animación de entrada para modales/paneles --- */
@keyframes aparecer {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aparecer { animation: aparecer 0.3s ease-out; }

@keyframes snap-rebote {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(212,175,55,0); }
  45% { transform: scale(1.1); box-shadow: 0 0 14px rgba(212,175,55,0.65); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(212,175,55,0); }
}

@keyframes shake-error {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes dorado-destello {
  0% { box-shadow: 0 0 0 rgba(212,175,55,0); filter: brightness(1); }
  45% { box-shadow: 0 0 28px rgba(212,175,55,0.8); filter: brightness(1.35); }
  100% { box-shadow: 0 0 0 rgba(212,175,55,0); filter: brightness(1); }
}

@keyframes xp-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.snap-rebote { animation: snap-rebote 0.22s ease-out; }
.shake-error { animation: shake-error 0.36s ease-in-out; }
.destello-dorado { animation: dorado-destello 0.9s ease-out; }
.xp-pop { animation: xp-pop 0.35s ease-out; }

.flow-sidebar {
  position: fixed;
  top: 72px;
  right: 16px;
  width: min(280px, calc(100vw - 32px));
  z-index: 40;
  background: rgba(6, 26, 51, 0.96);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.35);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.flow-sidebar.collapsed {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

.flow-sidebar h2 {
  color: #D4AF37;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.flow-sidebar-close {
  position: absolute;
  top: 8px;
  right: 10px;
  color: rgba(245,240,232,0.65);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.concept-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: rgba(245,240,232,0.55);
  font-size: 0.9rem;
}

.concept-row.unlocked { color: #F5F0E8; }
.concept-row.starred { color: #f0d060; }
.concept-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(212,175,55,0.12);
  border: 1px solid rgba(212,175,55,0.2);
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
}

/* --- Tooltip de pista --- */
.tooltip-pista {
  position: absolute;
  background: rgba(11, 36, 71, 0.97);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.85rem;
  max-width: 280px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* --- Input numérico de repetición dentro de bloques --- */
.input-repetir {
  width: 44px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  color: #F5F0E8;
  text-align: center;
  font-size: 0.85rem;
  padding: 2px 4px;
  font-family: 'Courier New', monospace;
}

.input-repetir:focus { outline: none; border-color: rgba(212, 175, 55, 0.5); }

/* --- Scrollbar personalizada --- */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(11, 36, 71, 0.4); }
::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212, 175, 55, 0.5); }
