/* ═══════════════════════════════════════════
   Python Lab — Gamification Styles
   ═══════════════════════════════════════════ */

/* ── XP Popup ── */
.xp-popup {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #f59e0b;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(0);
    transition: all 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}
.xp-popup-animate {
    opacity: 1;
    transform: translateY(-60px);
    animation: xp-fade 1.5s ease forwards;
}
.xp-bonus {
    font-size: 13px;
    color: #ec4899;
    font-weight: 600;
}
@keyframes xp-fade {
    0%   { opacity: 0; transform: translateY(0) scale(0.5); }
    20%  { opacity: 1; transform: translateY(-20px) scale(1.2); }
    40%  { transform: translateY(-35px) scale(1); }
    100% { opacity: 0; transform: translateY(-70px) scale(0.8); }
}

/* ── Confetti ── */
.confetti-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Level Up Modal ── */
.level-up-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background 0.4s ease;
}
.level-up-overlay.level-up-visible {
    background: rgba(0, 0, 0, 0.5);
}
.level-up-modal {
    text-align: center;
    background: var(--surface);
    border-radius: 1.5rem;
    padding: 2.5rem 3rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.level-up-visible .level-up-modal {
    transform: scale(1);
    opacity: 1;
}
.level-up-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 0.75rem;
    animation: level-bounce 0.6s ease 0.3s both;
}
@keyframes level-bounce {
    0%   { transform: scale(0); }
    50%  { transform: scale(1.3); }
    70%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.level-up-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}
.level-up-level {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
    font-weight: 500;
}
.level-up-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.25rem 0 1.25rem 0;
}
.level-up-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.625rem 2rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.level-up-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* ── Badge Toast ── */
.badge-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: translateX(120%);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.badge-toast-visible {
    transform: translateX(0);
}
.badge-toast-exit {
    transform: translateX(120%) !important;
    transition: transform 0.4s ease-in;
}
.badge-toast-icon {
    font-size: 2rem;
    line-height: 1;
    animation: badge-spin 0.6s ease;
}
@keyframes badge-spin {
    0%   { transform: rotateY(0deg) scale(0); }
    60%  { transform: rotateY(360deg) scale(1.2); }
    100% { transform: rotateY(360deg) scale(1); }
}
.badge-toast-text {
    display: flex;
    flex-direction: column;
}
.badge-toast-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #f59e0b;
}
.badge-toast-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}
.badge-toast-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Streak Toast ── */
.streak-toast {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 9999px;
    padding: 0.5rem 1.25rem;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.streak-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.streak-fire {
    font-size: 1.25rem;
    animation: fire-pulse 0.8s ease infinite alternate;
}
@keyframes fire-pulse {
    0%   { transform: scale(1); }
    100% { transform: scale(1.15); }
}
.streak-count {
    font-size: 0.875rem;
    font-weight: 700;
    color: #92400e;
}

/* ── XP Bar (for header/profile) ── */
.xp-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
}
.xp-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}
.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%
    );
    animation: xp-shimmer 2s infinite;
}
@keyframes xp-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.2s ease;
}
.stat-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Badge Grid ── */
.badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s ease;
}
.badge-card.earned {
    border-color: #fde68a;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}
.badge-card.locked {
    opacity: 0.55;
    filter: grayscale(1);
}
.badge-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.badge-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
}
.badge-card-desc {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Evolving streak flame */
.streak-flame-sm { font-size: 1rem; }
.streak-flame-md { font-size: 1.25rem; }
.streak-flame-lg { font-size: 1.5rem; filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5)); }
.streak-flame-blue { font-size: 1.5rem; filter: hue-rotate(200deg) drop-shadow(0 0 6px rgba(59, 130, 246, 0.5)); }
.streak-flame-purple { font-size: 1.75rem; filter: hue-rotate(260deg) drop-shadow(0 0 8px rgba(139, 92, 246, 0.5)); animation: fire-pulse 1.5s ease-in-out infinite alternate; }

/* Lucky XP bonus animation */
.lucky-xp {
  color: #f59e0b;
  font-size: 1.25rem;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.6), 0 0 20px rgba(245, 158, 11, 0.3);
}

.lucky-xp.xp-popup-animate {
  animation: lucky-fade 2s ease-out forwards;
}

@keyframes lucky-fade {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  30% { transform: translateY(-20px) scale(1.3); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* Level Perks */
/* Profile border colours (Level 2) */
.perk-border-blue { border-color: #3b82f6 !important; border-width: 3px !important; }
.perk-border-green { border-color: #22c55e !important; border-width: 3px !important; }
.perk-border-purple { border-color: #8b5cf6 !important; border-width: 3px !important; }
.perk-border-red { border-color: #ef4444 !important; border-width: 3px !important; }
.perk-border-gold { border-color: #f59e0b !important; border-width: 3px !important; }

/* Flame colour overrides (Level 4) */
.perk-flame-green { filter: hue-rotate(80deg) !important; }
.perk-flame-blue { filter: hue-rotate(200deg) !important; }
.perk-flame-pink { filter: hue-rotate(300deg) !important; }
.perk-flame-gold { filter: saturate(2) brightness(1.2) !important; }

/* Animated badge pulse (Level 5) */
.perk-badge-animate { animation: badge-pulse 2s ease-in-out infinite; }
@keyframes badge-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Landing page gradients (Level 6) */
.perk-gradient-sunset { background: linear-gradient(135deg, #fff7ed, #fef3c7, #fce7f3) !important; }
.perk-gradient-ocean { background: linear-gradient(135deg, #eff6ff, #e0f2fe, #f0f9ff) !important; }
.perk-gradient-forest { background: linear-gradient(135deg, #f0fdf4, #ecfdf5, #f7fee7) !important; }

/* Python Master frame (Level 10) */
.perk-master-frame {
  border: 3px solid transparent !important;
  background-clip: padding-box !important;
  box-shadow: 0 0 0 3px #f59e0b, 0 0 15px rgba(245, 158, 11, 0.3) !important;
}

/* Level-up perk text */
.level-up-perk {
  color: #f59e0b;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ═══════════════════════════════════════
   CTF / HACKER MODE STYLES
   ═══════════════════════════════════════ */

/* CTF badge card variant */
.badge-card.ctf-badge {
  background: #0a0a0a;
  border-color: #22c55e;
  color: #22c55e;
}
.badge-card.ctf-badge.earned {
  background: #0a0a0a;
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}
.badge-card.ctf-badge.locked {
  background: #111;
  border-color: #333;
  color: #555;
}
.badge-card.ctf-badge .badge-card-title,
.badge-card.ctf-badge .badge-card-desc {
  color: inherit;
}

/* Terminal card on landing page */
.hacker-card {
  background: #0a0a0a;
  border: 2px solid #22c55e;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  animation: hacker-pulse 3s ease-in-out infinite;
}
@keyframes hacker-pulse {
  0%, 100% { border-color: #22c55e; box-shadow: 0 0 5px rgba(34, 197, 94, 0.2); }
  50% { border-color: #4ade80; box-shadow: 0 0 15px rgba(34, 197, 94, 0.4); }
}

/* Scanline overlay for challenges page */
.scanline-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.05) 2px,
    rgba(0, 0, 0, 0.05) 4px
  );
}

/* Matrix rain animation */
.matrix-rain {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10000;
  overflow: hidden;
}
.matrix-char {
  position: absolute;
  top: -20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: #22c55e;
  text-shadow: 0 0 8px #22c55e;
  animation: matrix-fall linear forwards;
}
@keyframes matrix-fall {
  0% { top: -20px; opacity: 1; }
  80% { opacity: 1; }
  100% { top: 100vh; opacity: 0; }
}

/* Secrets section terminal style */
.secrets-section {
  background: #0a0a0a;
  border: 1px solid #22c55e;
  border-radius: 12px;
  padding: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  color: #22c55e;
}
.secrets-section input {
  background: #111;
  border: 1px solid #333;
  color: #22c55e;
  font-family: 'JetBrains Mono', monospace;
}
.secrets-section input:focus {
  border-color: #22c55e;
  outline: none;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.3);
}

/* Challenge cards */
.challenge-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 12px;
  transition: border-color 0.2s;
}
.challenge-card:hover {
  border-color: #333;
}
.challenge-card.completed {
  border-color: #22c55e;
}
.tier-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 4px;
}
.tier-script-kiddie { background: #22c55e20; color: #22c55e; }
.tier-hacker { background: #f59e0b20; color: #f59e0b; }
.tier-elite { background: #ef444420; color: #ef4444; }

/* ── Spin Wheel ── */
.wheel-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.wheel-container {
  text-align: center;
  padding: 2rem;
}
.wheel-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  margin-bottom: 1.5rem;
}
.wheel {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 4px solid white;
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}
.wheel-inner {
  width: 100%;
  height: 100%;
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}
.wheel-segment {
  position: absolute;
  width: 50%;
  height: 50%;
  top: 0;
  right: 0;
  transform-origin: bottom left;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.wheel-pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 20px solid white;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.wheel-spin-btn {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  border: none;
  padding: 0.75rem 2.5rem;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}
.wheel-spin-btn:hover { transform: scale(1.05); }
.wheel-spin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.wheel-result {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fbbf24;
  margin-top: 1rem;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.wheel-result.visible { opacity: 1; }

/* ── Loot Chest ── */
.chest-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.chest-container {
  text-align: center;
  padding: 2rem;
}
.chest-icon {
  font-size: 5rem;
  line-height: 1;
  animation: chest-shake 0.5s ease;
}
.chest-icon.opened {
  animation: chest-open 0.8s ease forwards;
}
@keyframes chest-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
}
@keyframes chest-open {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); filter: brightness(1.5); }
  100% { transform: scale(1); }
}
.chest-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  margin-top: 1rem;
}
.chest-result {
  font-size: 2rem;
  font-weight: 800;
  color: #fbbf24;
  margin-top: 0.75rem;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}
.chest-close-btn {
  margin-top: 1.5rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  padding: 0.625rem 2rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* ═══════════════════════════════════════
   REDUCED MOTION — Accessibility
   Disables all animations for users who
   prefer reduced motion in OS settings.
   ═══════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .xp-popup,
  .xp-popup-animate,
  .confetti-piece,
  .level-up-icon,
  .badge-toast-icon,
  .streak-fire,
  .xp-bar-fill::after,
  .perk-badge-animate,
  .streak-flame-purple,
  .lucky-xp.xp-popup-animate,
  .hacker-card,
  .matrix-char {
    animation: none !important;
  }
  .chest-icon,
  .chest-icon.opened,
  .wheel-inner {
    animation: none !important;
    transition-duration: 0.01s !important;
  }
  .xp-popup-animate {
    opacity: 1;
    transform: translateY(-60px);
  }
  .level-up-modal,
  .level-up-overlay,
  .badge-toast,
  .streak-toast,
  .stat-card,
  .badge-card,
  .level-up-btn {
    transition-duration: 0.01s !important;
  }
}
