/* ═══════════════════════════════════════════════════════════
   DSA Lab — Algorithm Observatory
   Deep slate + warm amber + scientific precision
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #0a0f1e;
  --bg-primary: #0f1729;
  --bg-card: #151d33;
  --bg-card-hover: #1a2440;
  --bg-elevated: #1e2a4a;
  --text-primary: #e8e6e1;
  --text-secondary: #8b95a8;
  --text-muted: #5a6478;
  --amber: #e8a838;
  --amber-dim: #c48a20;
  --amber-glow: rgba(232, 168, 56, 0.15);
  --cyan: #5bc0be;
  --cyan-dim: #3a9c9a;
  --cream: #f0ead2;
  --green: #6bcb77;
  --red: #ee6055;
  --purple: #b47ede;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(232, 168, 56, 0.2);
  --font-display: 'Instrument Sans', sans-serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --max-width: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Noise overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ── Grid background ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(91, 192, 190, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 192, 190, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--amber); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--cyan); }

/* ── Navigation ── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--amber), var(--cyan));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.nav-links {
  display: flex;
  gap: 8px;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: var(--amber-glow);
}

.nav-search {
  position: relative;
}

.nav-search input {
  font-family: var(--font-display);
  font-size: 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 14px 8px 36px;
  width: 200px;
  outline: none;
  transition: all 0.2s;
}

.nav-search input:focus {
  border-color: var(--amber);
  width: 280px;
  background: var(--bg-elevated);
}

.nav-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
}

.nav-hamburger span {
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.3s;
}

/* ── Hero Section ── */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 60px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg canvas {
  width: 100%;
  height: 100%;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 800px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-glow);
  border: 1px solid rgba(232, 168, 56, 0.2);
  border-radius: 100px;
  padding: 6px 16px;
  margin-bottom: 24px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--cream) 40%, var(--amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

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

.hero-stat {
  text-align: center;
}

.hero-stat .stat-number {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--amber);
}

.hero-stat .stat-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

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

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--amber), var(--amber-dim));
  color: var(--bg-deep);
  box-shadow: 0 4px 20px rgba(232, 168, 56, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(232, 168, 56, 0.4);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

/* ── Topic Grid ── */
.section {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 24px;
}

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

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 12px;
}

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

.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

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

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}

.topic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--amber), var(--cyan));
  opacity: 0;
  transition: opacity 0.3s;
}

.topic-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.topic-card:hover::before {
  opacity: 1;
}

.topic-card .card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.topic-card .card-icon.ds { background: rgba(91, 192, 190, 0.12); }
.topic-card .card-icon.algo { background: var(--amber-glow); }
.topic-card .card-icon.meta { background: rgba(180, 126, 222, 0.12); }

.topic-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.topic-card .card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}

.topic-card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-card .tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.topic-card .tag.easy { color: var(--green); background: rgba(107, 203, 119, 0.1); }
.topic-card .tag.medium { color: var(--amber); background: var(--amber-glow); }
.topic-card .tag.hard { color: var(--red); background: rgba(238, 96, 85, 0.1); }

/* ── Complexity Cheat Sheet Preview ── */
.complexity-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  overflow-x: auto;
}

.complexity-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.complexity-table th {
  font-family: var(--font-display);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.complexity-table td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}

.complexity-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.o-1 { color: var(--green) !important; }
.o-logn { color: #8dd88d !important; }
.o-n { color: var(--amber) !important; }
.o-nlogn { color: #d4a847 !important; }
.o-n2 { color: var(--red) !important; }

/* ── Footer ── */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.footer a {
  color: var(--text-secondary);
}

/* ── Content Pages ── */
.page-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 100px 24px 80px;
  position: relative;
  z-index: 1;
}

.page-breadcrumb {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.page-breadcrumb a { color: var(--text-secondary); }

.page-header {
  margin-bottom: 40px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: 12px;
}

.page-header .page-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.page-header .difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  margin-top: 12px;
}

.difficulty-badge.beginner { background: rgba(107, 203, 119, 0.12); color: var(--green); }
.difficulty-badge.intermediate { background: var(--amber-glow); color: var(--amber); }
.difficulty-badge.advanced { background: rgba(238, 96, 85, 0.12); color: var(--red); }

/* Content sections */
.content-section {
  margin-bottom: 48px;
}

.content-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content-section h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--amber);
}

.content-section p {
  margin-bottom: 16px;
  font-size: 1.02rem;
}

.content-section ul, .content-section ol {
  margin: 0 0 16px 24px;
}

.content-section li {
  margin-bottom: 8px;
  font-size: 1rem;
}

/* Code blocks */
.code-block {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  margin: 16px 0 24px;
  overflow: hidden;
  position: relative;
}

.code-block pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-primary);
  padding: 20px;
  margin: 0;
  overflow-x: auto;
}

.code-block pre code {
  font-family: var(--font-mono);
  font-size: inherit;
}

.code-block .code-lang {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom-left-radius: var(--radius-sm);
  z-index: 2;
}

/* Collapsible code blocks */
.code-block.collapsible .code-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.code-block.collapsible .code-toggle:hover {
  background: rgba(255,255,255,0.04);
}

.code-block.collapsible .code-toggle::after {
  content: '▼';
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.code-block.collapsible.collapsed .code-toggle::after {
  transform: rotate(-90deg);
}

.code-block.collapsible.collapsed pre {
  display: none;
}

/* Syntax highlighting theme — Algorithm Observatory */
/* Inline code styling */
p code, li code, td code, .callout code, h2 code, h3 code, h4 code {
  background: rgba(232, 168, 56, 0.12);
  color: #e8a838;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  border: 1px solid rgba(232, 168, 56, 0.15);
}

/* Code tabs */
.code-tabs {
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-tabs .tab-bar {
  display: flex;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
}

.code-tabs .tab-btn {
  padding: 8px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.code-tabs .tab-btn:hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}

.code-tabs .tab-btn.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
  background: rgba(232, 168, 56, 0.05);
}

.code-tabs .tab-panel {
  display: none;
}

.code-tabs .tab-panel.active {
  display: block;
}

.code-tabs .tab-panel .code-block {
  border: none;
  border-radius: 0;
  margin: 0;
}

.hljs { background: transparent !important; color: var(--text-primary); }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #c792ea; }
.hljs-string, .hljs-attr { color: #c3e88d; }
.hljs-number, .hljs-literal { color: #f78c6c; }
.hljs-comment { color: #546e7a; font-style: italic; }
.hljs-function .hljs-title, .hljs-title.function_ { color: #82aaff; }
.hljs-class .hljs-title, .hljs-title.class_ { color: #ffcb6b; }
.hljs-params { color: var(--text-primary); }
.hljs-type { color: #ffcb6b; }
.hljs-meta { color: #89ddff; }
.hljs-variable, .hljs-template-variable { color: #f07178; }
.hljs-operator { color: #89ddff; }
.hljs-property { color: var(--text-primary); }
.hljs-punctuation { color: #89ddff; }
.hljs-regexp { color: #89ddff; }
.hljs-selector-class { color: #ffcb6b; }
.hljs-tag { color: #f07178; }
.hljs-name { color: #f07178; }
.hljs-symbol { color: #82aaff; }

/* Visualization container */
.viz-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
}

.viz-container .viz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.viz-container .viz-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}

.viz-controls {
  display: flex;
  gap: 8px;
}

.viz-controls button {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.viz-controls button:hover, .viz-controls button.active {
  background: var(--amber-glow);
  border-color: var(--amber);
  color: var(--amber);
}

.viz-canvas {
  width: 100%;
  max-width: 100%;
  height: 400px;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  display: block;
}

/* Callout boxes */
.callout {
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 16px 0 24px;
  border-left: 3px solid;
  font-size: 0.95rem;
}

.callout.tip {
  background: rgba(107, 203, 119, 0.06);
  border-color: var(--green);
}

.callout.warning {
  background: rgba(232, 168, 56, 0.06);
  border-color: var(--amber);
}

.callout.interview {
  background: rgba(91, 192, 190, 0.06);
  border-color: var(--cyan);
}

.callout strong {
  font-family: var(--font-display);
  display: block;
  margin-bottom: 4px;
}

/* Table of contents */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}

.toc h4 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li {
  margin-bottom: 6px;
}

.toc a {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toc a:hover {
  color: var(--amber);
}

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-search { display: none; }
  .nav-hamburger { display: flex; }
  
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(20px);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
  }
  
  .hero { padding: 80px 16px 40px; min-height: auto; }
  .hero h1 { font-size: 2rem; }
  .hero-stats { gap: 24px; }
  .hero-stat .stat-number { font-size: 1.5rem; }
  
  .section { padding: 48px 16px; }
  .topic-grid { grid-template-columns: 1fr; }
  
  .footer-inner { flex-direction: column; gap: 16px; }
  
  .page-wrapper { padding: 80px 16px 60px; }
  
  /* Tables: horizontal scroll on mobile */
  .complexity-table { font-size: 0.75rem; }
  .complexity-table th, .complexity-table td { padding: 8px; }
  /* Tables handled by JS wrapper (.table-scroll) for proper scrolling */
  
  /* Viz controls: wrap on mobile */
  .viz-container { padding: 12px; overflow: hidden; }
  .viz-container .viz-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .viz-controls { flex-wrap: wrap; gap: 6px; width: 100%; }
  .viz-controls button { padding: 6px 12px; font-size: 0.75rem; }
  .viz-controls input[type="number"],
  .viz-controls input[type="text"],
  .viz-controls select { max-width: 80px; font-size: 0.8rem; }
  .viz-canvas { height: 280px; }
  
  /* Code blocks: tighter on mobile */
  .code-block pre { padding: 14px; font-size: 0.8rem; }
  .code-tabs .tab-btn { padding: 6px 14px; font-size: 0.75rem; }
  
  /* Callouts: tighter padding */
  .callout { padding: 12px 14px; font-size: 0.9rem; }
  
  /* Prevent ANY horizontal overflow */
  .page-main, .page-wrapper, article, section, .content {
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* Code inline: prevent overflow */
  p code, li code, td code { word-break: break-all; }
  
  /* Pre blocks: always scrollable */
  pre { max-width: 100%; overflow-x: auto; }
}

@media (max-width: 480px) {
  .hero-stats { flex-direction: column; gap: 16px; }
  .hero-cta { flex-direction: column; align-items: center; }
  .btn { width: 100%; justify-content: center; }
  
  /* Even tighter on small phones */
  .viz-container { padding: 12px; }
  .viz-container .viz-header { flex-direction: column; align-items: flex-start; }
  .viz-controls { width: 100%; }
  .viz-controls button { flex: 1; min-width: 0; text-align: center; }
  
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  
  .code-block pre { padding: 10px; font-size: 0.78rem; }
}

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

@keyframes glow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.animate-in {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

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

/* Search results dropdown */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.search-results.active { display: block; }

.search-result-item {
  display: block;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.search-result-item .result-category {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Sidebar nav for content pages */
.page-layout {
  display: flex;
  gap: 40px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 88px 24px 80px;
  position: relative;
  z-index: 1;
}

.page-sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.page-sidebar h4 {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
  padding-left: 12px;
}

.sidebar-link {
  display: block;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 2px;
  transition: all 0.2s;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-link.active {
  color: var(--amber);
  border-left-color: var(--amber);
  background: var(--amber-glow);
}

.page-main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .page-layout { flex-direction: column; padding: 80px 16px 60px; }
  .page-sidebar { width: 100%; position: static; max-height: none; display: none; }
}
