/* ============================================
   UI REVAMP - Reading progress, nav, animations
   ============================================ */

/* Reading Progress Bar */
#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, #a78bfa 50%, #38bdf8 100%);
  z-index: 99999;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ============================================
   Top Navigation Bar
   ============================================ */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .top-nav {
  background: rgba(15, 23, 42, 0.8);
}

.top-nav.scrolled {
  box-shadow: var(--shadow-md);
}

.top-nav-brand {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.top-nav-brand span {
  background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 2rem;
  flex: 1;
}

.top-nav-link {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: var(--transition);
  white-space: nowrap;
}

.top-nav-link:hover,
.top-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.top-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.top-nav-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary);
  background: var(--bg-secondary);
}

.top-nav-btn svg {
  flex-shrink: 0;
}

/* Theme toggle inside nav */
.top-nav .theme-toggle {
  position: static;
  width: 36px;
  height: 36px;
  box-shadow: none;
  border-color: var(--border-color);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .top-nav-links {
    display: none;
  }
  .top-nav {
    padding: 0 1rem;
  }
  .top-nav-btn span {
    display: none;
  }
  .top-nav-btn {
    padding: 0.4rem 0.5rem;
    border: none;
    background: transparent;
  }
}

/* ============================================
   Lightning Hero Section
   ============================================ */
.hero-lightning {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #050a14;
  padding-top: 56px;
}

[data-theme="dark"] .hero-lightning {
  background: #050a14;
}

#lightning-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Vignette — bottom fade to blend into page, soft top glow */
.hero-lightning::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 65%),
    linear-gradient(to bottom, transparent 55%, rgba(5, 10, 20, 0.85) 100%);
  pointer-events: none;
  z-index: 1;
}

.hero-lightning-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 820px;
  padding: 0 2rem;
}

.hero-lightning-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 50px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #93c5fd;
  margin-bottom: 1.75rem;
  letter-spacing: 0.02em;
  animation: fadeInDown 0.7s ease-out both;
}

.hero-lightning-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 1.25rem;
  color: #f1f5f9;
  animation: fadeInUp 0.7s ease-out 0.15s both;
}

.hero-lightning-title .gradient-word {
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-lightning-subtitle {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: #94a3b8;
  margin-bottom: 2.5rem;
  line-height: 1.7;
  animation: fadeInUp 0.7s ease-out 0.3s both;
}

.hero-lightning-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3rem;
  animation: fadeInUp 0.7s ease-out 0.45s both;
}

.btn-lightning-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 12px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.35);
}

.btn-lightning-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 36px rgba(37, 99, 235, 0.55);
}

.btn-lightning-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-lightning-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.hero-lightning-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  animation: fadeInUp 0.7s ease-out 0.6s both;
}

.lightning-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.lightning-stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.lightning-stat-label {
  font-size: 0.8125rem;
  color: #64748b;
  font-weight: 500;
}

/* Scroll indicator */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #475569;
  font-size: 0.75rem;
  animation: bounce 2s infinite;
}

.scroll-indicator svg {
  opacity: 0.5;
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

@media (max-width: 768px) {
  .hero-lightning-stats {
    gap: 1.5rem;
  }
  .lightning-stat-value {
    font-size: 1.75rem;
  }
  .hero-lightning-actions {
    flex-direction: column;
    align-items: center;
  }
  .btn-lightning-primary,
  .btn-lightning-secondary {
    width: 100%;
    max-width: 320px;
    justify-content: center;
  }
}

/* ============================================
   Page body offset for fixed nav
   ============================================ */
body.has-top-nav .hero-compact,
body.has-top-nav .problems-list-header {
  padding-top: calc(56px + 1rem);
}

/* category hero — enough top padding so icon clears the sticky breadcrumb */
body.has-top-nav .category-hero {
  margin-top: 0;
  padding-top: 3.5rem;
}

/* breadcrumb top offset — sticky just below the fixed nav */
body.has-top-nav nav.breadcrumb {
  top: 56px;
}

body.has-top-nav .problem-layout .breadcrumb {
  top: 56px;
}

body.has-top-nav .sidebar {
  top: 56px;
  height: calc(100vh - 56px);
}

body.has-top-nav .main-content .content-header {
  /* breadcrumb is ~52px tall, nav is 56px */
  margin-top: calc(56px + 52px);
}

/* ============================================
   Category accent colors
   ============================================ */
.category-card[data-category="social-feeds"]       { --cat-color: #f59e0b; }
.category-card[data-category="messaging"]          { --cat-color: #10b981; }
.category-card[data-category="ecommerce"]          { --cat-color: #ef4444; }
.category-card[data-category="infrastructure"]     { --cat-color: #8b5cf6; }
.category-card[data-category="events-queues"]      { --cat-color: #f97316; }
.category-card[data-category="data-analytics"]     { --cat-color: #06b6d4; }
.category-card[data-category="coordination"]       { --cat-color: #ec4899; }
.category-card[data-category="advanced"]           { --cat-color: #6366f1; }

.category-card::before {
  background: linear-gradient(90deg, var(--cat-color, var(--primary)) 0%, var(--primary) 100%) !important;
}

.category-card:hover {
  border-color: var(--cat-color, var(--primary)) !important;
}

/* ============================================
   Content fade-in transition
   ============================================ */
.content-fade {
  animation: contentFadeIn 0.35s ease-out both;
}

@keyframes contentFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Sidebar reading progress
   ============================================ */
.sidebar-progress-wrap {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 0.4rem;
}

.sidebar-progress-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 50px;
  overflow: hidden;
}

.sidebar-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #a78bfa 100%);
  border-radius: 50px;
  transition: width 0.4s ease;
}

/* ============================================
   Improved markdown reading typography
   ============================================ */
.markdown-content {
  font-size: 1.0625rem !important;
  line-height: 1.85 !important;
}

.markdown-content h2 {
  position: relative;
  padding-left: 1rem;
}

.markdown-content h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.2em;
  bottom: 0.2em;
  width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, #a78bfa 100%);
  border-radius: 2px;
}

.markdown-content h3 {
  color: var(--primary);
}

/* Code block header */
.markdown-content pre {
  position: relative;
}

.markdown-content pre::before {
  content: 'code';
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================
   Smooth section transitions (homepage)
   ============================================ */
.about,
.categories {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.about.visible,
.categories.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Feature cards — subtle icon glow
   ============================================ */
.feature-card .feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--bg-secondary);
  border-radius: 14px;
  font-size: 1.75rem;
  margin-bottom: 1rem;
  transition: transform 0.3s ease;
}

.feature-card:hover .feature-icon {
  transform: none;
}

/* ============================================
   Difficulty badge colors (problems list)
   ============================================ */
.difficulty-easy   { background: #d1fae5; color: #065f46; border-color: #10b981; }
.difficulty-medium { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.difficulty-hard   { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
.difficulty-expert { background: #e0e7ff; color: #3730a3; border-color: #6366f1; }

[data-theme="dark"] .difficulty-easy   { background: #064e3b; color: #6ee7b7; border-color: #10b981; }
[data-theme="dark"] .difficulty-medium { background: #78350f; color: #fcd34d; border-color: #f59e0b; }
[data-theme="dark"] .difficulty-hard   { background: #7f1d1d; color: #fca5a5; border-color: #ef4444; }
[data-theme="dark"] .difficulty-expert { background: #312e81; color: #c7d2fe; border-color: #6366f1; }

/* ============================================
   Scroll to top FAB — cleaner
   ============================================ */
.fab-container {
  bottom: 1.5rem;
  right: 1.5rem;
}

.fab {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 44px;
  height: 44px;
}

.fab:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   Animations (shared)
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
