@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #10101f;
  --bg-card: #13132a;
  --bg-card-hover: #1a1a35;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.5);

  --text-primary: #f0f0ff;
  --text-secondary: #a0a0c0;
  --text-muted: #606080;

  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;

  --gradient-main: linear-gradient(135deg, #8b5cf6, #3b82f6);
  --gradient-card: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
  --gradient-text: linear-gradient(135deg, #8b5cf6, #06b6d4);

  --creational: #8b5cf6;
  --structural: #3b82f6;
  --behavioral: #10b981;

  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: 64px;
}
.nav-logo {
  font-size: 1.2rem; font-weight: 800;
  background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none; margin-right: auto;
  white-space: nowrap;
}
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; font-weight: 500;
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-glass);
}
.nav-link.active { color: var(--accent-purple); }

/* ── HERO ── */
.hero {
  position: relative; overflow: hidden;
  padding: 100px 32px 80px;
  text-align: center;
}
.hero::before {
  content: '';
  position: absolute; inset: -50%;
  background: radial-gradient(ellipse at 30% 40%, rgba(139, 92, 246, 0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 60%, rgba(59, 130, 246, 0.12) 0%, transparent 60%);
  animation: orb-drift 12s ease-in-out infinite;
}
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-20px, 15px); }
}
.hero-content { position: relative; max-width: 800px; margin: 0 auto; }
.hero-badge {
  display: inline-block; margin-bottom: 20px;
  padding: 6px 18px; border-radius: 100px;
  background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.3);
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em;
  color: var(--accent-purple); text-transform: uppercase;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem); font-weight: 800; line-height: 1.15;
  margin-bottom: 20px;
}
.hero h1 span {
  background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.1rem; color: var(--text-secondary); max-width: 580px; margin: 0 auto 40px;
}
.hero-cta {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 28px; border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif; font-size: 1rem; font-weight: 600;
  text-decoration: none; cursor: pointer; border: none;
  transition: all 0.25s;
}
.btn-primary {
  background: var(--gradient-main); color: white;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.55);
}
.btn-secondary {
  background: var(--bg-glass); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--border-active);
  background: rgba(139, 92, 246, 0.1);
}

/* ── MAIN WRAP ── */
.main { max-width: 1200px; margin: 0 auto; padding: 0 32px 80px; }

/* ── SECTION ── */
.section-title {
  font-size: 1.8rem; font-weight: 700; margin-bottom: 8px;
}
.section-sub {
  color: var(--text-secondary); margin-bottom: 40px; font-size: 1rem;
}

/* ── CARDS GRID ── */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px; margin-bottom: 60px;
}
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; cursor: pointer;
  transition: all 0.3s; position: relative; overflow: hidden;
  text-decoration: none; display: block; color: var(--text-primary);
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient-card); opacity: 0; transition: opacity 0.3s;
}
.card:hover { transform: translateY(-4px); border-color: var(--border-active); box-shadow: var(--shadow-glow); }
.card:hover::before { opacity: 1; }
.card-icon { font-size: 2.4rem; margin-bottom: 16px; display: block; position: relative; }
.card-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; position: relative; }
.card-desc { font-size: 0.9rem; color: var(--text-secondary); position: relative; line-height: 1.6; }

/* ── STATS BAR ── */
.stats-bar {
  display: flex; gap: 32px; padding: 28px 36px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 60px; flex-wrap: wrap;
}
.stat-item { display: flex; flex-direction: column; gap: 4px; }
.stat-num {
  font-size: 2rem; font-weight: 800;
  background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }
.stat-divider { width: 1px; background: var(--border); flex-shrink: 0; }

/* ── CATEGORY PILLS ── */
.category-pills { display: flex; gap: 12px; margin-bottom: 32px; flex-wrap: wrap; }
.pill {
  padding: 10px 24px; border-radius: 100px; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; border: 2px solid transparent; transition: all 0.25s;
  background: var(--bg-card); color: var(--text-secondary);
}
.pill.active-creational { background: rgba(139, 92, 246, 0.15); border-color: var(--creational); color: var(--creational); }
.pill.active-structural { background: rgba(59, 130, 246, 0.15); border-color: var(--structural); color: var(--structural); }
.pill.active-behavioral { background: rgba(16, 185, 129, 0.15); border-color: var(--behavioral); color: var(--behavioral); }
.pill:hover { border-color: var(--border-active); color: var(--text-primary); }

/* ── PATTERN CARD ── */
.pattern-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px; overflow: hidden;
  transition: border-color 0.2s;
}
.pattern-card:hover { border-color: rgba(139, 92, 246, 0.3); }
.pattern-header {
  display: flex; align-items: center; gap: 16px; padding: 20px 24px;
  cursor: pointer; transition: background 0.2s; user-select: none;
}
.pattern-header:hover { background: var(--bg-glass); }
.pattern-badge {
  padding: 4px 12px; border-radius: 100px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.badge-creational { background: rgba(139, 92, 246, 0.2); color: var(--creational); }
.badge-structural { background: rgba(59, 130, 246, 0.2); color: var(--structural); }
.badge-behavioral { background: rgba(16, 185, 129, 0.2); color: var(--behavioral); }
.pattern-name { font-size: 1.1rem; font-weight: 700; flex: 1; }
.pattern-summary { font-size: 0.85rem; color: var(--text-secondary); flex: 2; }
.pattern-arrow {
  color: var(--text-muted); transition: transform 0.3s; font-size: 1.1rem; flex-shrink: 0;
}
.pattern-arrow.open { transform: rotate(90deg); }

.pattern-body { display: none; padding: 0 24px 24px; }
.pattern-body.open { display: block; }

.pattern-section { margin-bottom: 24px; }
.pattern-section-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: 12px;
}
.usecase-tag {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.1); border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan); font-size: 0.8rem; margin: 4px; font-weight: 500;
}

/* ── CODE TOGGLE ── */
.code-toggle {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.toggle-btn {
  padding: 8px 20px; border-radius: var(--radius-sm); border: 2px solid;
  font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.toggle-before { border-color: rgba(239, 68, 68, 0.4); color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.toggle-before.active { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; }
.toggle-after { border-color: rgba(16, 185, 129, 0.4); color: var(--accent-green); background: rgba(16, 185, 129, 0.08); }
.toggle-after.active { background: rgba(16, 185, 129, 0.15); border-color: var(--accent-green); }

.code-block-wrap { position: relative; }
.code-copy-btn {
  position: absolute; top: 12px; right: 12px;
  padding: 4px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-muted); font-size: 0.78rem; cursor: pointer;
  transition: all 0.2s; font-family: 'Outfit', sans-serif;
}
.code-copy-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.code-copy-btn.copied { border-color: var(--accent-green); color: var(--accent-green); }

pre {
  background: #0d0d1a; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px;
  overflow-x: auto; font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem; line-height: 1.7;
}
code { font-family: 'JetBrains Mono', monospace; }
.code-label {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.75rem; font-weight: 600;
}
.code-label.before { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.code-label.after { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }

/* ── CONCEPT CARD ── */
.concept-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; margin-bottom: 20px;
}
.concept-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; cursor: pointer; }
.concept-icon { font-size: 1.8rem; }
.concept-title { font-size: 1.15rem; font-weight: 700; }
.concept-tag {
  margin-left: auto; padding: 4px 12px; border-radius: 100px;
  font-size: 0.75rem; font-weight: 700;
  background: var(--gradient-main); color: white;
}
.concept-desc { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.95rem; }
.concept-keyword {
  display: inline-block; background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3); color: var(--accent-purple);
  padding: 2px 10px; border-radius: 4px; font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem; margin: 2px;
}

/* ── PLAYGROUND ── */
.playground-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; height: 70vh;
}
.editor-pane, .output-pane {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
}
.pane-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.pane-title { font-size: 0.9rem; font-weight: 600; color: var(--text-secondary); }
.pane-dots { display: flex; gap: 6px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
}
.dot-red { background: #ff5f57; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #28c841; }
.code-editor {
  flex: 1; background: #0a0a14; border: none; outline: none; resize: none;
  color: #e0e0ff; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem;
  line-height: 1.7; padding: 20px; tab-size: 2;
}
.output-content {
  flex: 1; padding: 20px; font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem; line-height: 1.7; overflow-y: auto; color: var(--accent-green);
}
.output-content .out-error { color: #ef4444; }
.output-content .out-log { color: #e0e0ff; }
.output-content .out-warn { color: var(--accent-orange); }

.run-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-top: 1px solid var(--border); background: var(--bg-secondary);
}
.template-select {
  flex: 1; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--bg-primary); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 0.85rem; font-family: 'Outfit', sans-serif; outline: none;
}
.template-select option { background: var(--bg-primary); }
.btn-run {
  padding: 9px 24px; border-radius: var(--radius-sm); border: none;
  background: var(--gradient-main); color: white; font-family: 'Outfit', sans-serif;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
.btn-run:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-clear {
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary); font-family: 'Outfit', sans-serif;
  font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
}
.btn-clear:hover { border-color: var(--border-active); color: var(--text-primary); }

/* ── INFO BOX ── */
.info-box {
  padding: 16px 20px; border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.2);
  color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px;
}
.info-box strong { color: var(--accent-purple); }

/* ── FOOTER ── */
.footer {
  border-top: 1px solid var(--border); padding: 32px;
  text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 40px;
}
.footer a { color: var(--accent-purple); text-decoration: none; }

/* ── SEARCH BAR ── */
.search-wrap { position: relative; margin-bottom: 24px; max-width: 480px; }
.search-input {
  width: 100%; padding: 12px 20px 12px 44px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.95rem; font-family: 'Outfit', sans-serif; outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--border-active); }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ── PAGE TITLE ── */
.page-hero {
  padding: 60px 32px 40px;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.05) 0%, transparent 100%);
  border-bottom: 1px solid var(--border); margin-bottom: 48px; position: relative; overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute; top: -80px; right: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
}
.page-hero-inner { max-width: 1200px; margin: 0 auto; position: relative; }
.page-hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 10px; }
.page-hero h1 span {
  background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-hero p { font-size: 1rem; color: var(--text-secondary); max-width: 600px; }

/* ── SYNTAX HIGHLIGHT (manual) ── */
.kw { color: #c792ea; }
.cls { color: #82aaff; }
.fn { color: #82aaff; }
.str { color: #c3e88d; }
.num { color: #f78c6c; }
.cm { color: #546e7a; font-style: italic; }
.tp { color: #ffcb6b; }
.op { color: #89ddff; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav { padding: 0 16px; }
  .nav-logo { font-size: 1rem; }
  .nav-link { padding: 6px 10px; font-size: 0.82rem; }
  .hero { padding: 60px 16px 50px; }
  .main { padding: 0 16px 60px; }
  .stats-bar { gap: 20px; }
  .stat-divider { display: none; }
  .playground-wrap { grid-template-columns: 1fr; height: auto; }
  .editor-pane, .output-pane { height: 350px; }
  .page-hero { padding: 40px 16px 30px; }
}
