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

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2d2d3d;
  --text: #e8e6f0;
  --text-dim: #9994b8;
  --accent-blue: #6ea8fe;
  --accent-purple: #b08cfe;
  --accent-green: #7ceda8;
  --accent-orange: #ffb86c;
  --accent-pink: #ff79c6;
  --accent-yellow: #f1fa8c;
  --accent-red: #ff6b6b;
  --accent-cyan: #8be9fd;
  --code-bg: #13131c;
  --tag-bg: rgba(110, 168, 254, 0.12);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  line-height: 1.6;
  padding: 32px;
  font-size: 18px;
}

/* ── NAV BAR ──────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
}
.nav-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--accent-purple); }
.nav-sep { color: var(--text-dim); }
.nav-current { color: var(--text-dim); font-weight: 500; }

/* ── HEADER ────────────────────────────────── */
.header {
  text-align: center;
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
}
.header h1 {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.header .subtitle {
  font-size: 1rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── GRID ──────────────────────────────────── */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin: 0 auto;
  padding: 0 20px;
  max-width: 1100px;
}

/* ── CARD ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
  min-width: 0;
  width: 520px;
  max-width: 100%;
}
.card:hover { border-color: var(--accent-blue); }

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  font-weight: 700;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.card-complexity {
  margin-left: auto;
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.tag-time { background: rgba(124, 237, 168, 0.15); color: var(--accent-green); }
.tag-space { background: rgba(255, 184, 108, 0.15); color: var(--accent-orange); }
.tag-logn { background: rgba(139, 233, 253, 0.15); color: var(--accent-cyan); }
.tag-nlogn { background: rgba(176, 140, 254, 0.15); color: var(--accent-purple); }

.card-body { font-size: 0.95rem; color: var(--text-dim); line-height: 1.6; }
.card-body strong { color: var(--text); font-weight: 600; }

/* ── WHEN TO USE BADGES ────────────────────── */
.when-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-purple);
  margin-bottom: 2px;
}
.use-cases {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.use-case {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--tag-bg);
  color: var(--accent-blue);
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  cursor: help;
  transition: background 0.2s, color 0.2s;
}
.use-case:hover {
  background: rgba(110, 168, 254, 0.25);
  color: #fff;
}
.use-case .tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #262636;
  border: 1px solid var(--accent-blue);
  border-radius: 10px;
  padding: 10px 14px;
  width: 280px;
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  white-space: normal;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
}
.use-case .tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--accent-blue);
}
.use-case .tip strong {
  color: var(--accent-blue);
  font-weight: 700;
}
.use-case:hover .tip {
  display: block;
}

/* ── VISUAL DIAGRAM ────────────────────────── */
.diagram {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--accent-cyan);
  white-space: pre-wrap;
  word-break: break-word;
}
.diagram .hl-green { color: var(--accent-green); }
.diagram .hl-orange { color: var(--accent-orange); }
.diagram .hl-pink { color: var(--accent-pink); }
.diagram .hl-purple { color: var(--accent-purple); }
.diagram .hl-yellow { color: var(--accent-yellow); }
.diagram .hl-blue { color: var(--accent-blue); }
.diagram .hl-red { color: var(--accent-red); }
.diagram .hl-dim { color: var(--text-dim); }

/* ── KEY POINTS ────────────────────────────── */
.key-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.key-points li {
  font-size: 0.9rem;
  color: var(--text-dim);
  padding-left: 16px;
  position: relative;
  line-height: 1.6;
}
.key-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-blue);
}
.key-points li strong { color: var(--text); }
.key-points li code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent-yellow);
}

/* ── CODE BLOCK ────────────────────────────── */
.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.code .kw { color: var(--accent-pink); }
.code .fn { color: var(--accent-green); }
.code .num { color: var(--accent-orange); }
.code .str { color: var(--accent-yellow); }
.code .cmt { color: #555570; font-style: italic; }
.code .typ { color: var(--accent-cyan); }
.code .op { color: var(--accent-red); }

/* ── FORMULA ───────────────────────────────── */
.formula {
  background: rgba(176, 140, 254, 0.08);
  border-left: 3px solid var(--accent-purple);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  color: var(--accent-purple);
  font-weight: 600;
}

/* ── STEP LIST ─────────────────────────────── */
.steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.steps li {
  counter-increment: step;
  font-size: 0.9rem;
  color: var(--text-dim);
  padding-left: 26px;
  position: relative;
  line-height: 1.6;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.66rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
}
.steps li strong { color: var(--text); }
.steps li code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent-yellow);
}

/* ── DIVIDER ROW ───────────────────────────── */
.section-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

/* ── FULL WIDTH CARD ───────────────────────── */
.card-full { width: 100%; }
.card-double { width: 100%; }

/* ── COMPLEXITY TABLE ──────────────────────── */
.complexity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.complexity-table th {
  text-align: left;
  padding: 6px 10px;
  font-weight: 700;
  color: var(--accent-blue);
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.complexity-table td {
  padding: 5px 10px;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(45, 45, 61, 0.5);
}
.complexity-table td:first-child { color: var(--text); font-weight: 600; }
.complexity-table td code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: var(--accent-green);
}
.complexity-table tr:last-child td { border-bottom: none; }

/* ── COLOR VARIANTS ────────────────────────── */
.icon-blue { background: rgba(110,168,254,0.15); color: var(--accent-blue); }
.icon-purple { background: rgba(176,140,254,0.15); color: var(--accent-purple); }
.icon-green { background: rgba(124,237,168,0.15); color: var(--accent-green); }
.icon-orange { background: rgba(255,184,108,0.15); color: var(--accent-orange); }
.icon-pink { background: rgba(255,121,198,0.15); color: var(--accent-pink); }
.icon-cyan { background: rgba(139,233,253,0.15); color: var(--accent-cyan); }
.icon-red { background: rgba(255,107,107,0.15); color: var(--accent-red); }
.icon-yellow { background: rgba(241,250,140,0.15); color: var(--accent-yellow); }

/* ── MINI TABLE ────────────────────────────── */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.mini-table th {
  text-align: left;
  padding: 4px 8px;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.mini-table td {
  padding: 4px 8px;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(45,45,61,0.3);
}
.mini-table td:first-child { color: var(--text); font-weight: 500; }
.mini-table code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: var(--accent-green);
}

/* ── CROSS-REFERENCE CALLOUT ─────────────── */
.cross-ref {
  width: 100%;
  background: rgba(110, 168, 254, 0.06);
  border: 1px solid rgba(110, 168, 254, 0.2);
  border-radius: 10px;
  padding: 14px 18px;
  grid-column: 1 / -1;
}
.cross-ref-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 6px;
}
.cross-ref-body {
  font-size: 0.84rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.cross-ref-body a {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
}
.cross-ref-body a:hover { text-decoration: underline; }

/* ── HOME PAGE TOPIC CARDS ───────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.topic-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(110, 168, 254, 0.1);
}
.topic-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
}
.topic-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.topic-desc {
  font-size: 0.92rem;
  color: var(--text-dim);
  line-height: 1.65;
}
.topic-meta {
  display: flex;
  gap: 10px;
  margin-top: auto;
}
.topic-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}
.topic-card-coming {
  opacity: 0.4;
  pointer-events: none;
}

/* ── FOOTER ──────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px 0 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
}

/* ── VISUALIZE LINK ───────────────────────── */
.viz-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-blue);
  background: rgba(110, 168, 254, 0.12);
  padding: 5px 14px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.2s;
  margin-top: 4px;
}
.viz-link:hover {
  background: rgba(110, 168, 254, 0.25);
  color: #fff;
}
.viz-problems {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.viz-problems span {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(176, 140, 254, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(176, 140, 254, 0.15);
}

/* ── HOME NAV ─────────────────────────────── */
.home-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto 8px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
}
.home-nav-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-blue);
  text-decoration: none;
  letter-spacing: -0.3px;
}
.home-nav-brand:hover { color: var(--accent-purple); }
.home-nav-links {
  display: flex;
  gap: 24px;
}
.home-nav-links a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.home-nav-links a:hover { color: var(--accent-blue); }

/* ── AD CONTAINERS ────────────────────────── */
.ad-container {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}
.ad-container ins.adsbygoogle[data-ad-status="unfilled"],
.ad-container ins.adsbygoogle:not([data-ad-status]) {
  display: none !important;
}

/* ── HERO ─────────────────────────────────── */
.hero {
  text-align: center;
  padding: 16px 20px 32px;
  max-width: 1200px;
  margin: 0 auto;
}
.hero-img {
  width: 100%;
  max-width: 600px;
  margin-bottom: 16px;
  border-radius: 12px;
}
.hero-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
  line-height: 1.15;
}
.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 28px;
}
.hero-ctas {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-btn {
  font-size: 0.92rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s;
}
.hero-btn-primary {
  background: var(--accent-blue);
  color: var(--bg);
}
.hero-btn-primary:hover {
  background: var(--accent-purple);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(110, 168, 254, 0.3);
}
.hero-btn-secondary {
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}
.hero-btn-secondary:hover {
  background: rgba(110, 168, 254, 0.1);
  transform: translateY(-1px);
}

/* ── VISUALIZER SHOWCASE ──────────────────── */
.viz-showcase {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 32px 0;
  text-align: center;
}
.viz-showcase-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.viz-showcase-desc {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.viz-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.viz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.viz-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(110, 168, 254, 0.12);
}
.viz-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
}
.viz-card-name {
  font-size: 0.88rem;
  font-weight: 700;
}
.viz-card-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.viz-showcase-all {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-blue);
  text-decoration: none;
  padding: 8px 20px;
  border-radius: 8px;
  background: rgba(110, 168, 254, 0.1);
  transition: all 0.2s;
}
.viz-showcase-all:hover {
  background: rgba(110, 168, 254, 0.2);
  color: #fff;
}

/* ── TOPICS SECTION ───────────────────────── */
#topics {
  max-width: 1200px;
  margin: 0 auto 32px;
}
#topics .section-divider {
  margin: 32px 0 20px;
}
#topics .home-grid {
  margin-bottom: 8px;
}

/* ── HOME FOOTER ──────────────────────────── */
.home-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 0 16px;
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 24px;
}
.footer-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-blue);
  margin-bottom: 8px;
}
.footer-about {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.footer-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-col a {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-col a:hover { color: var(--accent-blue); }
.footer-bottom {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── VISUALIZATIONS INDEX ─────────────────── */
.viz-index {
  max-width: 1200px;
  margin: 0 auto;
}
.viz-index .section-divider {
  margin: 28px 0 14px;
}
.viz-index-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.viz-index-item {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s;
}
.viz-index-item:hover {
  border-color: var(--accent-blue);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(110, 168, 254, 0.1);
  color: var(--accent-blue);
}

/* ── SMOOTH SCROLL ────────────────────────── */
html { scroll-behavior: smooth; }

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 768px) {
  .card { width: 100%; }
  .card-double { width: 100%; }
  .home-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.8rem; }
  .hero-tagline { font-size: 0.95rem; }
  .hero { padding: 24px 10px 24px; }
  .viz-showcase-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .home-nav-links { gap: 16px; }
}
