/* ========================================
   CP Algorithm Visualizer - Premium Dark Theme
   Purple & Teal Accent Colors
   ======================================== */

/* --- CSS Variables --- */
:root {
  --purple: #a855f7;
  --purple-bright: #c084fc;
  --purple-dim: #7c3aed;
  --purple-dark: #6d28d9;
  --purple-glow: rgba(168, 85, 247, 0.3);
  --purple-subtle: rgba(168, 85, 247, 0.1);
  --teal: #2dd4bf;
  --teal-bright: #5eead4;
  --teal-dim: #14b8a6;
  --teal-glow: rgba(45, 212, 191, 0.3);
  --teal-subtle: rgba(45, 212, 191, 0.1);
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.2);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --info: #3b82f6;
  --info-glow: rgba(59, 130, 246, 0.2);

  --bg-deep: #08081a;
  --bg: #0c0c24;
  --bg-card: #12122e;
  --bg-card-hover: #1a1a3e;
  --bg-elevated: #16163a;
  --bg-input: #0f0f28;
  --text: #e8eaf6;
  --text-secondary: #8b8fad;
  --text-tertiary: #5c5f7e;
  --border: #1e1e4a;
  --border-light: #2a2a5a;
  --border-glow: rgba(168, 85, 247, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(168, 85, 247, 0.15);
  --shadow-teal-glow: 0 0 20px rgba(45, 212, 191, 0.15);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --sidebar-width: 270px;
  --navbar-height: 64px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ========================================
   LANDING PAGE
   ======================================== */

.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Animated gradient mesh background */
.landing-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.landing-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: orbFloat 20s ease-in-out infinite;
}

.landing-bg .orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--purple) 0%, transparent 70%);
  top: -200px;
  left: -100px;
  animation-delay: 0s;
  animation-duration: 25s;
}

.landing-bg .orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--teal) 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
  animation-duration: 20s;
}

.landing-bg .orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--purple-dim) 0%, transparent 70%);
  top: 40%;
  right: 20%;
  animation-delay: -10s;
  animation-duration: 30s;
}

.landing-bg .orb-4 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--teal-dim) 0%, transparent 70%);
  top: 20%;
  left: 30%;
  animation-delay: -15s;
  animation-duration: 22s;
}

.landing-bg .grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(168, 85, 247, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
}

/* Landing navbar */
.landing-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 48px;
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-logo svg {
  filter: drop-shadow(0 0 12px var(--purple-glow));
}

.landing-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.landing-nav-links {
  display: flex;
  gap: 8px;
}

.landing-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.landing-nav-links a:hover {
  color: var(--text);
  background: var(--purple-subtle);
}

/* Hero section */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 80px;
  position: relative;
  z-index: 2;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--purple-subtle);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--purple-bright);
  margin-bottom: 24px;
  animation: fadeInUp 0.6s ease both;
  animation-delay: 0.1s;
}

.hero-badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: badgePulse 2s ease-in-out infinite;
}

.hero h1 {
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
  animation: fadeInUp 0.6s ease both;
  animation-delay: 0.2s;
}

.hero h1 .gradient-text {
  background: linear-gradient(135deg, var(--purple-bright) 0%, var(--teal) 50%, var(--purple-bright) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

.hero-subtitle {
  font-size: clamp(16px, 2vw, 20px);
  color: var(--text-secondary);
  max-width: 580px;
  line-height: 1.7;
  margin-bottom: 40px;
  animation: fadeInUp 0.6s ease both;
  animation-delay: 0.3s;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  animation: fadeInUp 0.6s ease both;
  animation-delay: 0.4s;
}

.btn-hero-primary {
  padding: 14px 36px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dim) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px var(--purple-glow);
  position: relative;
  overflow: hidden;
}

.btn-hero-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--purple-glow);
}

.btn-hero-primary:hover::before {
  transform: translateX(100%);
}

.btn-hero-secondary {
  padding: 14px 36px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-hero-secondary:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-subtle);
  transform: translateY(-2px);
}

/* Feature cards */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 0 48px 80px;
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.feature-card {
  background: rgba(18, 18, 46, 0.6);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fadeInUp 0.6s ease both;
}

.feature-card:nth-child(1) { animation-delay: 0.5s; }
.feature-card:nth-child(2) { animation-delay: 0.6s; }
.feature-card:nth-child(3) { animation-delay: 0.7s; }

.feature-card:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
  background: rgba(26, 26, 62, 0.8);
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 22px;
}

.feature-icon.purple {
  background: var(--purple-subtle);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.feature-icon.teal {
  background: var(--teal-subtle);
  border: 1px solid rgba(45, 212, 191, 0.2);
}

.feature-icon.gradient {
  background: linear-gradient(135deg, var(--purple-subtle), var(--teal-subtle));
  border: 1px solid rgba(168, 85, 247, 0.15);
}

.feature-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Stats row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 60px;
  padding: 40px 24px 60px;
  position: relative;
  z-index: 2;
  animation: fadeInUp 0.6s ease both;
  animation-delay: 0.8s;
}

.stat {
  text-align: center;
}

.stat-number {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--purple-bright), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========================================
   MAIN APP (Visualizer)
   ======================================== */

.app-container {
  display: none;
}

.app-container.active {
  display: block;
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: rgba(12, 12, 36, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: opacity var(--transition);
}

.nav-brand:hover { opacity: 0.85; }

.nav-logo {
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px var(--purple-glow));
}

.nav-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: block;
  line-height: 1.2;
}

.nav-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  display: block;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  display: flex;
  align-items: center;
}

.nav-link:hover {
  color: var(--purple-bright);
  background: var(--purple-subtle);
}

/* --- Layout --- */
.layout {
  display: flex;
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: rgba(12, 12, 36, 0.9);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-inner {
  padding: 16px 12px;
}

.sidebar-category {
  margin-bottom: 4px;
}

.category-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.category-toggle svg { opacity: 0.6; }

.category-toggle:hover {
  background: var(--purple-subtle);
  color: var(--text-secondary);
}

.category-toggle .chevron {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.category-toggle.active .chevron {
  transform: rotate(180deg);
}

.category-items {
  display: none;
  padding: 2px 0 8px 0;
}

.category-items.active {
  display: block;
}

.algo-link {
  display: block;
  padding: 8px 12px 8px 36px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  position: relative;
}

.algo-link:hover {
  background: var(--purple-subtle);
  color: var(--purple-bright);
}

.algo-link.active {
  background: linear-gradient(135deg, var(--purple-dim), var(--purple-dark));
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 12px var(--purple-glow);
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 32px;
  max-width: 960px;
}

/* --- Cards --- */
.algo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.4s ease;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.algo-card:hover {
  border-color: var(--border-light);
}

.algo-header-card {
  border-left: 3px solid var(--purple);
  box-shadow: var(--shadow-sm), inset 0 0 30px rgba(168, 85, 247, 0.03);
}

.algo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.algo-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.algo-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--purple-subtle);
  color: var(--purple-bright);
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.algo-description {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--purple), var(--teal));
  border-radius: 2px;
}

/* --- Concept Card --- */
.concept-card {
  border-left: 3px solid var(--teal);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.04), var(--bg-card));
}

.concept-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.8;
}

/* --- Visualization Area --- */
.visualization-area {
  min-height: 350px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

.visualization-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(168, 85, 247, 0.05), transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(45, 212, 191, 0.05), transparent 60%);
  pointer-events: none;
}

.array-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 40px 20px 20px;
  width: 100%;
  height: 350px;
  position: relative;
}

.array-container.with-secondary {
  height: 250px;
}

.graph-container {
  width: 100%;
  height: 400px;
  position: relative;
  display: none;
}

/* --- Array Bars --- */
.array-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  max-width: 60px;
  min-width: 20px;
  position: relative;
}

.array-bar .bar-fill {
  width: 100%;
  background: var(--text-tertiary);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.3s ease,
              box-shadow 0.3s ease,
              transform 0.3s ease;
  position: relative;
}

.array-bar .bar-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  min-height: 18px;
  transition: color 0.3s ease;
}

.array-bar .bar-index {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Bar states with glow effects */
.array-bar.active .bar-fill { background: var(--purple); box-shadow: 0 0 12px var(--purple-glow); }
.array-bar.active .bar-value { color: var(--purple-bright); }
.array-bar.comparing .bar-fill { background: var(--warning); box-shadow: 0 0 12px var(--warning-glow); }
.array-bar.comparing .bar-value { color: var(--warning); }
.array-bar.sorted .bar-fill { background: var(--teal); box-shadow: 0 0 10px var(--teal-glow); }
.array-bar.sorted .bar-value { color: var(--teal); }
.array-bar.pivot .bar-fill { background: var(--danger); box-shadow: 0 0 12px var(--danger-glow); }
.array-bar.pivot .bar-value { color: var(--danger); }
.array-bar.found .bar-fill { background: var(--teal); box-shadow: 0 0 20px var(--teal-glow); transform: scaleY(1.05); }
.array-bar.found .bar-value { color: var(--teal-bright); }
.array-bar.lo .bar-fill { background: var(--success); box-shadow: 0 0 10px var(--success-glow); }
.array-bar.hi .bar-fill { background: var(--danger); box-shadow: 0 0 10px var(--danger-glow); }
.array-bar.mid .bar-fill { background: var(--warning); box-shadow: 0 0 14px var(--warning-glow); }
.array-bar.left-ptr .bar-fill { background: var(--info); box-shadow: 0 0 10px var(--info-glow); }
.array-bar.right-ptr .bar-fill { background: var(--danger); box-shadow: 0 0 10px var(--danger-glow); }
.array-bar.in-window .bar-fill { background: var(--purple); box-shadow: 0 0 10px var(--purple-glow); }
.array-bar.eliminated .bar-fill { background: var(--text-tertiary); opacity: 0.2; }
.array-bar.eliminated .bar-value { opacity: 0.3; }
.array-bar.current .bar-fill { background: var(--warning); box-shadow: 0 0 12px var(--warning-glow); }
.array-bar.key-element .bar-fill { background: var(--warning); }
.array-bar.shifting .bar-fill { background: #fb923c; }
.array-bar.left-part .bar-fill { background: var(--info); box-shadow: 0 0 8px var(--info-glow); }
.array-bar.right-part .bar-fill { background: var(--purple); box-shadow: 0 0 8px var(--purple-glow); }
.array-bar.merging .bar-fill { background: var(--warning); }
.array-bar.lis-member .bar-fill { background: var(--teal); box-shadow: 0 0 12px var(--teal-glow); }
.array-bar.dp-current .bar-fill { background: var(--warning); box-shadow: 0 0 12px var(--warning-glow); }
.array-bar.dp-compare .bar-fill { background: var(--info); }

/* Secondary array (prefix sums, DP) */
.secondary-array-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 10px 20px;
  width: 100%;
}

.secondary-array-container .array-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 60px;
  min-width: 20px;
}

.array-cell .cell-value {
  padding: 6px 4px;
  background: var(--purple-subtle);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  color: var(--purple-bright);
  text-align: center;
  width: 100%;
  transition: all 0.3s ease;
}

.array-cell .cell-label {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.array-cell.active .cell-value {
  background: var(--warning-glow);
  border-color: var(--warning);
  color: var(--warning);
}

.array-cell.highlight .cell-value {
  background: var(--teal-subtle);
  border-color: var(--teal);
  color: var(--teal);
}

.secondary-label {
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 8px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Pointer labels */
.pointer-label {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 5;
  letter-spacing: 0.03em;
}

.pointer-label.top { top: 8px; }
.pointer-label.bottom { bottom: -4px; }
.pointer-label.lo { background: rgba(34, 197, 94, 0.2); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.pointer-label.hi { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.pointer-label.mid { background: rgba(245, 158, 11, 0.2); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.pointer-label.left { background: rgba(59, 130, 246, 0.2); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.3); }
.pointer-label.right { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* --- Graph Visualization --- */
.graph-node {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  z-index: 3;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  box-shadow: var(--shadow);
}

.graph-node.in-queue {
  background: var(--info-glow);
  border-color: var(--info);
  color: var(--info);
  box-shadow: 0 0 16px var(--info-glow);
}

.graph-node.current {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
  color: var(--warning);
  box-shadow: 0 0 20px var(--warning-glow);
  animation: nodePulse 1.2s ease-in-out infinite;
  z-index: 4;
}

.graph-node.visited, .graph-node.finalized {
  background: var(--teal-subtle);
  border-color: var(--teal);
  color: var(--teal);
  box-shadow: 0 0 12px var(--teal-glow);
}

.graph-node.on-stack {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--purple);
  color: var(--purple-bright);
  box-shadow: 0 0 16px var(--purple-glow);
}

.graph-node.in-degree-zero {
  background: var(--warning-glow);
  border-color: var(--warning);
}

.graph-edge {
  position: absolute;
  height: 2px;
  background: var(--border-light);
  transform-origin: left center;
  z-index: 1;
  transition: all 0.4s ease;
}

.graph-edge.visited { background: var(--teal); height: 2px; box-shadow: 0 0 6px var(--teal-glow); }
.graph-edge.active { background: var(--warning); height: 2px; box-shadow: 0 0 6px var(--warning-glow); }
.graph-edge.relaxed { background: var(--purple); height: 2px; box-shadow: 0 0 6px var(--purple-glow); }

.graph-edge-label {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  z-index: 2;
}

.graph-edge-arrow {
  position: absolute;
  z-index: 2;
  transition: all 0.4s ease;
}

/* DSU visualization */
.dsu-container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  width: 100%;
  min-height: 300px;
}

.dsu-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: rgba(168, 85, 247, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.4s ease;
}

.dsu-group.active {
  border-color: var(--purple);
  background: var(--purple-subtle);
  box-shadow: 0 0 16px var(--purple-glow);
}

.dsu-node {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  transition: all 0.3s ease;
}

.dsu-node.root {
  border-color: var(--purple);
  background: var(--purple-subtle);
  color: var(--purple-bright);
  box-shadow: 0 0 10px var(--purple-glow);
}

.dsu-group-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
}

/* --- Status Bar --- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  color: var(--purple-bright);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.status-bar svg { opacity: 0.7; flex-shrink: 0; }

.status-bar.success {
  background: rgba(45, 212, 191, 0.08);
  border-color: rgba(45, 212, 191, 0.2);
  color: var(--teal);
}

.status-bar.warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

/* --- Controls --- */
.controls-card {
  padding: 18px 24px;
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-group input[type="text"],
.control-group input[type="number"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  transition: all var(--transition);
  width: 200px;
}

.control-group input[type="number"] {
  width: 80px;
}

.control-group input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

/* Speed slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--purple);
  cursor: pointer;
  box-shadow: 0 0 8px var(--purple-glow);
  transition: all var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--purple-bright);
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--purple-glow);
}

#speedValue {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  min-width: 40px;
  font-family: var(--mono);
}

.controls-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-dim));
  color: white;
  box-shadow: 0 2px 12px var(--purple-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px var(--purple-glow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--purple);
  color: var(--purple-bright);
}

.btn-success {
  background: linear-gradient(135deg, var(--teal-dim), var(--teal));
  color: white;
  box-shadow: 0 2px 12px var(--teal-glow);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 20px var(--teal-glow);
}

.btn-danger {
  background: var(--bg-elevated);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

/* --- Complexity Grid --- */
.complexity-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.complexity-item {
  text-align: center;
  padding: 16px 12px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.complexity-item:hover {
  border-color: var(--purple);
  box-shadow: 0 0 12px var(--purple-glow);
}

.complexity-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.complexity-value {
  display: block;
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--purple-bright), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--mono);
}

/* --- Code Section --- */
.code-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--purple-bright);
}

.tab-btn.active {
  color: var(--purple-bright);
  border-bottom-color: var(--purple);
  font-weight: 600;
}

.code-block-wrapper {
  position: relative;
}

.code-block {
  background: var(--bg-deep);
  color: var(--text-secondary);
  padding: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  margin: 0;
  tab-size: 4;
  border: 1px solid var(--border);
  border-top: none;
}

.code-block code {
  font-family: inherit;
  display: block;
}

/* Code line rendering */
.code-line {
  display: flex;
  padding: 0 16px 0 0;
  transition: background-color 0.3s ease;
  position: relative;
}

.code-line .line-number {
  display: inline-block;
  width: 40px;
  text-align: right;
  padding-right: 16px;
  color: var(--text-tertiary);
  user-select: none;
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 12px;
}

.code-line .line-content {
  flex: 1;
  white-space: pre;
}

.code-line.highlighted {
  background: rgba(168, 85, 247, 0.12);
  border-left: 2px solid var(--purple);
}

.code-line.highlighted .line-number {
  color: var(--purple-bright);
  opacity: 1;
}

.code-line.highlighted .line-content {
  color: var(--text);
}

/* Code step explanation */
.code-explanation {
  padding: 12px 16px;
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.15);
  border-radius: var(--radius-xs);
  margin-top: 12px;
  font-size: 13px;
  color: var(--teal);
  line-height: 1.6;
  display: none;
}

.code-explanation.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.code-explanation strong {
  color: var(--teal-bright);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 32px 0;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.footer p {
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
}

.footer .footer-sub {
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 40px) scale(0.95); }
  75% { transform: translate(30px, 20px) scale(1.02); }
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .main-content { padding: 20px; }
  .complexity-grid { grid-template-columns: repeat(2, 1fr); }
  .features { grid-template-columns: 1fr; padding: 0 24px 60px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; padding: 16px; }
  .algo-title { font-size: 22px; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .control-group { width: 100%; }
  .control-group input[type="text"] { flex: 1; width: auto; }
  .controls-buttons { justify-content: center; }
  .nav-subtitle { display: none; }
  .landing-nav { padding: 16px 20px; }
  .hero { padding: 40px 20px 60px; }
  .hero-buttons { flex-direction: column; width: 100%; max-width: 300px; }
  .hero-buttons button { width: 100%; }
  .stats-row { gap: 30px; flex-wrap: wrap; }
  .features { padding: 0 20px 40px; }
}

@media (max-width: 480px) {
  .complexity-grid { grid-template-columns: 1fr 1fr; }
  .controls-buttons .btn { flex: 1; justify-content: center; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* --- Vis wrapper --- */
.vis-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.vis-wrapper .array-container { flex: 1; }

/* Topo result */
.topo-result {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  flex-wrap: wrap;
}

.topo-result .topo-node {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal-subtle);
  border: 2px solid var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--teal);
  animation: fadeIn 0.3s ease;
}

.topo-result .topo-arrow {
  color: var(--text-tertiary);
  font-size: 18px;
}

/* Graph info overlay */
.graph-info-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(12, 12, 36, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 11px;
  z-index: 5;
  color: var(--text-secondary);
}

.graph-info-overlay .info-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 3px;
}

.graph-info-overlay .info-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Page transition */
.page-transition {
  animation: fadeIn 0.5s ease;
}

/* ========================================
   ABOUT PAGE
   ======================================== */

.about-page {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.about-content {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

.about-title {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  text-align: center;
  margin-bottom: 40px;
  background: linear-gradient(135deg, var(--purple-bright), var(--teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeInUp 0.5s ease both;
}

.about-card {
  background: rgba(18, 18, 46, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  animation: fadeInUp 0.5s ease both;
}

.about-card:nth-child(2) { animation-delay: 0.05s; }
.about-card:nth-child(3) { animation-delay: 0.1s; }
.about-card:nth-child(4) { animation-delay: 0.15s; }
.about-card:nth-child(5) { animation-delay: 0.2s; }
.about-card:nth-child(6) { animation-delay: 0.25s; }

.about-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.about-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.about-list {
  list-style: none;
  padding: 0;
}

.about-list li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  padding: 4px 0 4px 20px;
  position: relative;
}

.about-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--teal));
}

.about-list li strong {
  color: var(--text);
}

.about-algo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.about-algo-category {
  padding: 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.about-algo-category h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--purple-bright);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.about-algo-category p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-cta {
  text-align: center;
  padding: 32px 0;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.3s;
}

@media (max-width: 600px) {
  .about-algo-grid { grid-template-columns: 1fr; }
  .about-content { padding: 16px 16px 60px; }
}
