/**
 * LOGIKRON - Stile "Game Arena"
 * =============================
 * Tema: Gara matematica, competizione, energia, divertimento
 * Target: Bambini scuola primaria + docenti
 */

/* ==========================================
   FONT IMPORT - Font più giocoso
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Space+Mono:wght@700&display=swap');

/* ==========================================
   VARIABILI - Palette vivace e energica
   ========================================== */
:root {
  /* Colori primari - Viola/Blu elettrico */
  --lk-primary: #6366f1;
  --lk-primary-dark: #4f46e5;
  --lk-primary-light: #a5b4fc;

  /* Accenti energici */
  --lk-accent-yellow: #fbbf24;
  --lk-accent-pink: #ec4899;
  --lk-accent-cyan: #22d3ee;
  --lk-accent-green: #34d399;
  --lk-accent-orange: #fb923c;

  /* Sfondo sfumato "arena" */
  --lk-bg-gradient: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
  --lk-bg-light: #f0f9ff;

  /* Testi */
  --lk-text: #1e293b;
  --lk-text-dark: #1e1b4b;
  --lk-text-light: #f8fafc;
  --lk-text-muted: #94a3b8;

  /* Effetti */
  --lk-glow-primary: 0 0 30px rgba(99, 102, 241, 0.4);
  --lk-glow-yellow: 0 0 20px rgba(251, 191, 36, 0.5);
  --lk-shadow-card: 0 20px 40px rgba(0, 0, 0, 0.15);
  --lk-shadow-float: 0 10px 30px rgba(99, 102, 241, 0.3);

  /* Border radius - Più morbidi */
  --lk-radius-sm: 12px;
  --lk-radius-md: 16px;
  --lk-radius-lg: 24px;
  --lk-radius-xl: 32px;
  --lk-radius-full: 9999px;
}

/* ==========================================
   RESET E BASE
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Fredoka', sans-serif;
  background: var(--lk-bg-gradient);
  color: var(--lk-text-light);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Pattern geometrico di sfondo */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(34, 211, 238, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(251, 191, 36, 0.05) 0%, transparent 30%);
  pointer-events: none;
  z-index: 0;
}

/* Sfondo animato: simboli matematici fluttuanti (generato da js/math-bg.js) */
.math-bg-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.math-bg-symbol {
  position: absolute;
  bottom: -50px;
  color: rgba(255, 255, 255, 0.04);
  font-family: 'Space Mono', 'Courier New', monospace;
  font-weight: 700;
  animation: mathFloat linear infinite;
}

@keyframes mathFloat {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  5% { opacity: 1; }
  95% { opacity: 1; }
  100% {
    transform: translateY(calc(-100vh - 100px)) rotate(360deg);
    opacity: 0;
  }
}

/* ==========================================
   LOGO LOGIKRON - Versione animata
   ========================================== */
.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  font-weight: 700;
  margin: 1.5rem 0;
  user-select: none;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.3));
}

.logo-container span {
  display: inline-block;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.logo-container:hover span {
  animation: bounce 0.5s ease;
}

.logo-container:hover span:nth-child(1) { animation-delay: 0s; }
.logo-container:hover span:nth-child(2) { animation-delay: 0.05s; }
.logo-container:hover span:nth-child(3) { animation-delay: 0.1s; }
.logo-container:hover span:nth-child(4) { animation-delay: 0.15s; }
.logo-container:hover span:nth-child(5) { animation-delay: 0.2s; }
.logo-container:hover span:nth-child(6) { animation-delay: 0.25s; }
.logo-container:hover span:nth-child(7) { animation-delay: 0.3s; }
.logo-container:hover span:nth-child(8) { animation-delay: 0.35s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px) scale(1.1); }
}

.logo-l { color: #818cf8; text-shadow: 0 0 20px rgba(129, 140, 248, 0.6); }
.logo-o1 { color: #c084fc; text-shadow: 0 0 20px rgba(192, 132, 252, 0.6); }
.logo-g { color: #22d3ee; text-shadow: 0 0 20px rgba(34, 211, 238, 0.6); }
.logo-sand {
  color: var(--lk-accent-yellow);
  text-shadow: 0 0 30px rgba(251, 191, 36, 0.8);
  animation: pulse-glow 2s ease-in-out infinite;
}
.logo-k { color: #34d399; text-shadow: 0 0 20px rgba(52, 211, 153, 0.6); }
.logo-r { color: #fb923c; text-shadow: 0 0 20px rgba(251, 146, 60, 0.6); }
.logo-o2 { color: #f87171; text-shadow: 0 0 20px rgba(248, 113, 113, 0.6); }
.logo-n { color: #f472b6; text-shadow: 0 0 20px rgba(244, 114, 182, 0.6); }

@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.15) rotate(10deg);
    filter: brightness(1.3);
  }
}

/* ==========================================
   CONTAINER
   ========================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.container-sm { max-width: 500px; }
.container-md { max-width: 700px; }

/* Su desktop le pagine si allargano: form e contenuti usano più spazio */
@media (min-width: 769px) {
  .container-sm { max-width: 860px; }
  .container-md { max-width: 1000px; }
}

/* ==========================================
   CARD - Stile Glass Morphism
   ========================================== */
.card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--lk-radius-lg);
  box-shadow: var(--lk-shadow-card);
  padding: 2rem;
  margin-bottom: 1.5rem;
  color: var(--lk-text-dark);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--lk-accent-pink),
    var(--lk-primary),
    var(--lk-accent-cyan),
    var(--lk-accent-green));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--lk-shadow-float);
}

.card:hover::before {
  opacity: 1;
}

.card-header {
  border-bottom: 2px dashed rgba(99, 102, 241, 0.2);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--lk-primary-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title::before {
  content: '▸';
  color: var(--lk-accent-yellow);
}

/* ==========================================
   PULSANTI - Stile Arcade/Game
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  border-radius: var(--lk-radius-full);
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--lk-primary), var(--lk-primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, var(--lk-accent-green), #10b981);
  color: white;
  box-shadow: 0 4px 15px rgba(52, 211, 153, 0.4);
}

.btn-success:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(52, 211, 153, 0.5);
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: white;
  box-shadow: 0 4px 15px rgba(248, 113, 113, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, var(--lk-accent-yellow), var(--lk-accent-orange));
  color: var(--lk-text-dark);
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--lk-primary);
  color: var(--lk-primary);
}

.btn-outline:hover {
  background: var(--lk-primary);
  color: white;
  transform: translateY(-3px);
}

.btn-lg {
  padding: 1.1rem 2.2rem;
  font-size: 1.1rem;
}

.btn-block {
  width: 100%;
}

/* ==========================================
   FORM - Stile moderno e friendly
   ========================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--lk-text-dark);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border: 2px solid #e2e8f0;
  border-radius: var(--lk-radius-md);
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--lk-primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
  color: #94a3b8;
}

.form-hint {
  color: var(--lk-text-muted);
  font-size: 0.85rem;
  margin-top: 0.375rem;
}

.form-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-error::before {
  content: '⚠';
}

/* ==========================================
   GRIGLIA ADMIN - Card interattive
   ========================================== */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.admin-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--lk-radius-lg);
  padding: 1.75rem;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  color: var(--lk-text-dark);
  position: relative;
  overflow: hidden;
}

.admin-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    transparent,
    rgba(99, 102, 241, 0.1),
    transparent 30%
  );
  animation: rotate 4s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.admin-card:hover::before {
  opacity: 1;
}

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

.admin-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--lk-primary);
  box-shadow: var(--lk-shadow-float);
}

.admin-card-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.admin-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--lk-primary-dark);
}

.admin-card-desc {
  color: var(--lk-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ==========================================
   BADGE E TAG
   ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--lk-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-live {
  background: #ef4444;
  color: white;
  animation: pulse-badge 2s infinite;
}

.badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.phase-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--lk-radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.phase-1 { background: linear-gradient(135deg, #818cf8, #6366f1); color: white; }
.phase-2 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1e1b4b; }
.phase-3 { background: linear-gradient(135deg, #34d399, #10b981); color: white; }
.phase-4 { background: linear-gradient(135deg, #f472b6, #ec4899); color: white; }
.phase-5 { background: linear-gradient(135deg, #22d3ee, #06b6d4); color: #1e1b4b; }

/* ==========================================
   TIMER - Stile digitale arcade
   ========================================== */
.timer {
  font-family: 'Space Mono', monospace;
  font-size: 4rem;
  font-weight: 700;
  color: var(--lk-accent-yellow);
  text-shadow: var(--lk-glow-yellow);
  letter-spacing: 4px;
}

.timer-sm {
  font-size: 2rem;
}

/* ==========================================
   STATISTICHE
   ========================================== */
.stat-card {
  background: linear-gradient(135deg, var(--lk-primary), #8b5cf6);
  border-radius: var(--lk-radius-lg);
  padding: 1.5rem;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.stat-value {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==========================================
   ALERT BOX
   ========================================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--lk-radius-md);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-info {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border-left: 4px solid var(--lk-primary);
  color: #1e40af;
}

.alert-warning {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-left: 4px solid var(--lk-accent-yellow);
  color: #92400e;
}

.alert-success {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-left: 4px solid var(--lk-accent-green);
  color: #065f46;
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-left: 4px solid #ef4444;
  color: #991b1b;
}

/* ==========================================
   TABELLONE GARA
   ========================================== */
.tabellone {
  overflow-x: auto;
  border-radius: var(--lk-radius-md);
}

.tabellone table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
}

.tabellone th {
  background: linear-gradient(135deg, var(--lk-primary), var(--lk-primary-dark));
  color: white;
  padding: 0.75rem;
  font-weight: 600;
  border-radius: var(--lk-radius-sm);
  font-size: 0.85rem;
}

.tabellone td {
  padding: 0.625rem;
  text-align: center;
  border-radius: var(--lk-radius-sm);
  font-weight: 500;
  transition: all 0.2s ease;
}

.cell-correct {
  background: linear-gradient(135deg, var(--lk-accent-green), #10b981) !important;
  color: white;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
}

.cell-wrong {
  background: linear-gradient(135deg, #f87171, #ef4444) !important;
  color: white;
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.3);
}

.cell-pending {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  animation: pulse 1.5s ease-in-out infinite;
}

.cell-empty {
  background: #f1f5f9;
  color: #94a3b8;
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-top: 2rem;
}

.footer a {
  color: var(--lk-accent-cyan);
  text-decoration: none;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--lk-accent-yellow);
}

/* ==========================================
   UTILITIES
   ========================================== */
.text-center { text-align: center; }
.text-muted { color: var(--lk-text-muted); }
.text-gradient {
  background: linear-gradient(135deg, var(--lk-primary), var(--lk-accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.hidden { display: none !important; }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
  .logo-container {
    font-size: 2.2rem;
  }

  .container {
    padding: 1rem;
  }

  .card {
    padding: 1.25rem;
    border-radius: var(--lk-radius-md);
  }

  .timer {
    font-size: 2.5rem;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
}

/* ==========================================
   ANIMAZIONI EXTRA
   ========================================== */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slideUp {
  animation: slideUp 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

/* Effetto "confetti" per vittoria */
@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-500px) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--lk-accent-yellow);
  animation: confetti 3s ease-out forwards;
}
