/* ============================================================
   Phase 1 — Extended Design Tokens & HTMX Integration Styles
   NileGameAcademy Gamified LMS
   ============================================================ */

/* === Gamification Semantic Colors === */
:root {
  /* XP & Level - Brushed Gold and Nile Blue */
  --xp-gold: #C89A43;
  --xp-gold-glow: rgba(200, 154, 67, 0.25);
  --gradient-xp: linear-gradient(135deg, #9C6E2E 0%, #E5BE6A 50%, #C89A43 100%);
  --gradient-level: linear-gradient(135deg, #2E79C7, #56A7FF);

  /* Rank Tiers */
  --tier-common: #9ca3af;
  --tier-uncommon: #2E79C7;
  --tier-rare: #56A7FF;
  --tier-legendary: #C89A43;
  --tier-legendary-glow: 0 0 15px rgba(200, 154, 67, 0.3);

  /* Streak */
  --streak-fire: #C89A43;
  --streak-fire-glow: rgba(200, 154, 67, 0.2);
  --streak-frozen: #56A7FF;
  --gradient-streak: linear-gradient(135deg, #9C6E2E, #E5BE6A);

  /* Quests */
  --quest-active: #2E79C7;
  --quest-complete: #C89A43;
  --quest-locked: #2C3E61;
  --gradient-mastery: linear-gradient(135deg, #2E79C7, #E5BE6A);

  /* Surface Hierarchy (Luxury Midnight Navy / Slate Enhancement) */
  --surface-0: #07111F;
  --surface-1: #0D1A2D;
  --surface-2: #13233A;
  --surface-3: #1A2D4A;
  --surface-4: #2C3E61;

  /* HTMX Loading Bar - Nile Blue to Brushed Gold sweep */
  --loading-bar-gradient: linear-gradient(90deg, #2E79C7, #C89A43, #2E79C7);
}


/* === HTMX Loading Bar === */
#htmx-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#htmx-loading-bar.htmx-request {
  opacity: 1;
}

#htmx-loading-bar .bar-inner {
  height: 100%;
  width: 30%;
  background: var(--loading-bar-gradient);
  border-radius: 0 2px 2px 0;
  animation: htmx-loading-sweep 1.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  box-shadow: 0 0 10px rgba(46, 121, 199, 0.4), 0 0 5px rgba(200, 154, 67, 0.3);
}

@keyframes htmx-loading-sweep {
  0%   { transform: translateX(-100%); width: 30%; }
  50%  { width: 60%; }
  100% { transform: translateX(400%); width: 30%; }
}


/* === Skeleton Loading (Solid Slate Chamfered block) === */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-muted, rgba(230, 226, 217, 0.5)) 25%,
    var(--surface, rgba(255, 255, 255, 0.3)) 50%,
    var(--surface-muted, rgba(230, 226, 217, 0.5)) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 0.75rem;
  color: transparent !important;
}

.skeleton * {
  visibility: hidden;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(27, 45, 74, 0.4) 25%,
    rgba(19, 35, 58, 0.6) 50%,
    rgba(27, 45, 74, 0.4) 75%
  );
  background-size: 200% 100%;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton specific shapes */
.skeleton-text {
  height: 0.875rem;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 90%; }

.skeleton-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 0.75rem;
}

.skeleton-card {
  height: 12rem;
  border-radius: 1.25rem;
}

.skeleton-stat {
  height: 5rem;
  border-radius: 1rem;
}


/* === HTMX Transition Animations === */

/* Content swap — crossfade */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.15s ease-in;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

/* Content area entrance */
.htmx-added {
  animation: content-enter 0.3s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}

@keyframes content-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* === Dashboard Shell Persistent Sidebar === */
.dashboard-sidebar {
  transition: width 0.3s cubic-bezier(0.215, 0.61, 0.355, 1), 
              transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.dashboard-sidebar.collapsed {
  width: 4rem;
}

.dashboard-sidebar.collapsed .sidebar-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.dashboard-sidebar .sidebar-link {
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.dashboard-sidebar .sidebar-link:hover {
  transform: translateX(2px);
}

.dashboard-sidebar .sidebar-link.active {
  background: rgba(46, 121, 199, 0.1);
  color: #2E79C7;
  font-weight: 800;
  border-right: 3px solid #2E79C7;
}


/* === Toast System === */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
  max-width: 24rem;
}

.toast {
  pointer-events: auto;
  animation: toast-enter 0.35s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
  max-width: 100%;
}

.toast.toast-exit {
  animation: toast-exit 0.25s ease-in forwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-exit {
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
}


/* === XP Floating Label === */
.xp-float {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--xp-gold);
  text-shadow: 0 0 8px var(--xp-gold-glow), 0 2px 4px rgba(0,0,0,0.4);
  animation: xp-float-up 1.4s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
}

@keyframes xp-float-up {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  60%  { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}


/* === Stat Card Glow Effects === */
.stat-glow-xp {
  box-shadow: 0 0 0 0 var(--xp-gold-glow);
  transition: box-shadow 0.4s ease;
}

.stat-glow-xp.pulsing {
  animation: glow-pulse-xp 1s ease-out;
}

@keyframes glow-pulse-xp {
  0%   { box-shadow: 0 0 0 0 var(--xp-gold-glow); }
  50%  { box-shadow: 0 0 20px 4px var(--xp-gold-glow); }
  100% { box-shadow: 0 0 0 0 var(--xp-gold-glow); }
}

.stat-glow-streak {
  box-shadow: 0 0 0 0 var(--streak-fire-glow);
}

.stat-glow-streak.pulsing {
  animation: glow-pulse-streak 1s ease-out;
}

@keyframes glow-pulse-streak {
  0%   { box-shadow: 0 0 0 0 var(--streak-fire-glow); }
  50%  { box-shadow: 0 0 20px 4px var(--streak-fire-glow); }
  100% { box-shadow: 0 0 0 0 var(--streak-fire-glow); }
}


/* === Dashboard Tab Active Indicator (HTMX-aware) === */
.dash-nav-link {
  position: relative;
  transition: color 0.2s ease, background 0.2s ease;
}

.dash-nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 60%;
  height: 3px;
  background: var(--primary-color, #2E79C7);
  border-radius: 3px 3px 0 0;
  transition: transform 0.25s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.dash-nav-link.active::after {
  transform: translateX(-50%) scaleX(1);
}


/* === Reduced Motion Safety === */
@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .dark .skeleton {
    animation: none;
  }

  #htmx-loading-bar .bar-inner {
    animation: none;
    width: 100%;
    opacity: 0.5;
  }

  .htmx-swapping,
  .htmx-settling,
  .htmx-added {
    transition: none;
    animation: none;
    opacity: 1;
    transform: none;
  }

  .toast {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .xp-float {
    animation: none;
  }

  .stat-glow-xp.pulsing,
  .stat-glow-streak.pulsing {
    animation: none;
  }
}
