/* ============================================
   SYSTEM DESIGN MASTERY — ByteByteGo-inspired
   ============================================ */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1a2744;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== NAVBAR ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

[data-theme="light"] .navbar {
  background: rgba(248, 250, 252, 0.85);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-highlight {
  color: var(--accent);
}

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

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.nav-links a:hover {
  color: var(--accent-light);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s;
}

.nav-links a:hover::after {
  width: 100%;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.mobile-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ========== HERO ========== */
.hero {
  position: relative;
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
}

[data-theme="light"] .hero-bg {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

.hero-content {
  position: relative;
  max-width: 800px;
}

.hero-badge {
  display: inline-block;
  padding: 8px 20px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-light);
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 24px;
  letter-spacing: -0.03em;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 50%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 40px;
  line-height: 1.8;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-bottom: 40px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent-light);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ========== SECTIONS ========== */
.section {
  padding: 100px 0;
}

.section-alt {
  background: var(--bg-secondary);
}

.section-header {
  text-align: center;
  margin-bottom: 64px;
}

.section-badge {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ========== CONCEPT CARDS ========== */
.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
}

.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.concept-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow), 0 0 40px var(--accent-glow);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.concept-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.concept-card > p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0;
}

.card-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s;
}

.concept-card.expanded .card-content {
  max-height: 2000px;
  margin-top: 24px;
}

.card-tag {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
}

.tag-interview {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
}

.tag-hot {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

/* ========== DIAGRAMS ========== */
.diagram-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  margin-bottom: 20px;
  overflow-x: auto;
}

[data-theme="light"] .diagram-box {
  background: rgba(0, 0, 0, 0.04);
}

.architecture-diagram {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--green);
  white-space: pre;
  margin: 0;
}

[data-theme="light"] .architecture-diagram {
  color: #059669;
}

/* ========== KEY POINTS ========== */
.key-points {
  padding: 20px;
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.key-points h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent-light);
}

.key-points ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.key-points li {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding-left: 20px;
  position: relative;
  line-height: 1.6;
}

.key-points li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.key-points li strong {
  color: var(--text-primary);
}

/* ========== CHEAT SHEET ========== */
.cheatsheet-block {
  margin-bottom: 48px;
}

.cheatsheet-block > h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.framework-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.framework-step {
  display: flex;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.framework-step:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.step-number {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.step-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== TABLES ========== */
.cheatsheet-tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.cheat-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow-x: auto;
}

.cheat-table h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

tbody td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ========== NUMBERS GRID ========== */
.numbers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.number-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
}

.number-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.number {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.number-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ========== FOOTER ========== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 60px 0 30px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 8px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--accent-light);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  text-align: center;
}

.footer-bottom p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 16px 24px;
    gap: 16px;
  }

  .nav-links.active {
    display: flex;
  }

  .mobile-menu {
    display: block;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .hero-stats {
    gap: 24px;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

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

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

  .cheatsheet-tables {
    grid-template-columns: 1fr;
  }

  .numbers-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-content {
    flex-direction: column;
    gap: 24px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 16px;
  }

  .section-header h2 {
    font-size: 1.8rem;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.8rem;
  }

  .concept-card {
    padding: 24px;
  }

  .architecture-diagram {
    font-size: 0.65rem;
  }

  .numbers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

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

.concept-card {
  animation: fadeInUp 0.6s ease-out;
}

.concept-card:nth-child(2) { animation-delay: 0.1s; }
.concept-card:nth-child(3) { animation-delay: 0.2s; }
.concept-card:nth-child(4) { animation-delay: 0.3s; }
.concept-card:nth-child(5) { animation-delay: 0.4s; }
.concept-card:nth-child(6) { animation-delay: 0.5s; }

/* Expand/collapse indicator */
.concept-card::after {
  content: 'Click to expand ↓';
  display: block;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  opacity: 0.7;
  transition: var(--transition);
}

.concept-card.expanded::after {
  content: 'Click to collapse ↑';
}

.concept-card:hover::after {
  opacity: 1;
}

/* Search highlight for future */
.highlight {
  background: rgba(245, 158, 11, 0.3);
  border-radius: 2px;
  padding: 0 2px;
}
