/* ===================== RESET & BASE ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #c6ff4a;
  --accent-dim: #9fd93c;
  --ink: #0d0d0f;
  --ink-soft: #17171a;
  --card: #1c1c1f;
  --card-border: #2b2b2f;
  --cream: #f5f4ef;
  --muted: #9a9a9e;
  --muted-2: #6b6b70;
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-head: 'Poppins', 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-head);
  background: var(--ink);
  color: var(--cream);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
ul { list-style: none; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.02em; }

.pill-highlight {
  background: var(--accent);
  color: var(--ink);
  padding: 2px 14px;
  border-radius: 100px;
  display: inline-block;
}

/* ===================== BUTTONS ===================== */
.btn {
  padding: 14px 28px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary { background: var(--accent); color: var(--ink); }
.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost { background: var(--ink); color: var(--cream); }
.btn-ghost:hover { background: #000; }

.btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--cream); }

.btn-dark-outline { background: transparent; color: var(--cream); border: 1.5px solid var(--card-border); }
.btn-dark-outline:hover { background: var(--accent); color: var(--ink); border-color: var(--accent); }

/* ===================== HERO ===================== */
.hero-wrap {
  background: var(--cream);
  color: var(--ink);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  padding: 72px clamp(20px, 5vw, 64px) 56px;
  position: relative;
  overflow: hidden;
}

.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.logo-icon { width: 26px; height: 26px; border-radius: 6px; display: block; }

.hero-content { max-width: 1100px; margin: 0 auto; position: relative; }
.hero-copy { max-width: 720px; text-align: center; margin: 0 auto 36px; position: relative; }
.hero-copy h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.9; }

.hero-visual { display: flex; justify-content: center; position: relative; margin: 12px 0 36px; }
.hero-logo-img { width: 140px; height: 140px; border-radius: 24px; }

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

/* ===================== CATEGORIES ===================== */
.categories-section {
  padding: 60px clamp(20px, 5vw, 64px);
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
}
.categories-inner h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 12px; }
.categories-desc { color: var(--muted); max-width: 560px; margin-bottom: 32px; }

.service-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 32px; }
.service-item {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 8px;
  border-top: 1px solid var(--card-border);
  cursor: pointer;
  transition: background 0.2s ease, padding-left 0.2s ease;
}
.service-item:last-child { border-bottom: 1px solid var(--card-border); }
.service-num { font-family: var(--font-mono); color: var(--accent); font-size: 0.9rem; }
.service-name { flex: 1; font-size: 1.15rem; font-weight: 600; }
.service-arrow { color: var(--muted-2); transition: transform 0.2s ease, color 0.2s ease; }
.service-item:hover, .service-item.active {
  background: var(--ink-soft);
  padding-left: 20px;
}
.service-item:hover .service-arrow, .service-item.active .service-arrow {
  color: var(--accent);
  transform: translateX(4px);
}
.service-item.active .service-name { color: var(--accent); }

/* ===================== ALGO GRID ===================== */
.algo-grid-section { padding: 40px clamp(20px, 5vw, 64px) 70px; max-width: 1200px; margin: 0 auto; }
.algo-grid-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 28px;
}
.algo-grid-header h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); }

.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.algo-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.algo-card:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--ink-soft); }
.algo-card-top { display: flex; align-items: center; justify-content: space-between; }
.algo-card-cat { font-size: 0.7rem; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.algo-card-play {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  background: var(--ink); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  flex-shrink: 0;
}
.algo-card-play svg { display: block; margin-left: 1px; }
.algo-card h3 { font-size: 1.15rem; }
.algo-card p { color: var(--muted); font-size: 0.85rem; flex: 1; }
.algo-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.algo-card-tags span {
  font-family: var(--font-mono); font-size: 0.7rem;
  background: var(--ink-soft); border: 1px solid var(--card-border);
  padding: 4px 8px; border-radius: 6px; color: var(--muted);
}
.algo-card.hidden { display: none; }

/* ===================== FOOTER ===================== */
.footer { background: var(--accent); color: var(--ink); padding: 60px clamp(20px, 5vw, 64px) 20px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; margin-top: 40px; }
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-brand .logo { color: var(--ink); margin-bottom: 12px; }
.footer-brand p { font-size: 0.85rem; opacity: 0.75; max-width: 320px; }
.footer-bottom {
  max-width: 1200px; margin: 40px auto 0; padding-top: 20px;
  border-top: 1px solid rgba(13,13,15,0.2);
  font-size: 0.8rem; opacity: 0.7;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.social-link {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(13,13,15,0.15); color: var(--ink);
  transition: background 0.2s ease, transform 0.15s ease;
  opacity: 1;
}
.social-link:hover { background: var(--ink); color: var(--accent); transform: translateY(-2px); }

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--ink-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  max-width: 1100px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 20px; right: 20px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); color: var(--cream);
  border: 1px solid var(--card-border); font-size: 1rem;
}
.modal-close:hover { background: var(--accent); color: var(--ink); }
.modal-category { color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.modal-head h3 { font-size: 1.8rem; margin: 6px 0 8px; }
.modal-head p { color: var(--muted); max-width: 640px; }
.modal-context {
  margin-top: 10px !important; padding: 8px 14px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 10px;
  font-family: var(--font-mono); font-size: 0.8rem !important; color: var(--cream) !important;
  display: inline-block; max-width: 100%;
}
.modal-context:empty { display: none; }

.modal-body { margin-top: 24px; }

.modal-viz-row { display: flex; gap: 20px; align-items: stretch; }
.viz-col { flex: 1 1 52%; min-width: 0; display: flex; flex-direction: column; }
.code-col { flex: 1 1 380px; min-width: 0; display: flex; flex-direction: column; }

.viz-stage {
  background: var(--ink); border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  min-height: 280px;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: auto;
}
.viz-stage canvas { max-width: 100%; }

.viz-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px;
}
.viz-btn {
  width: 40px; height: 40px; min-width: 40px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--cream); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 0;
}
.viz-btn svg { display: block; flex-shrink: 0; }
.viz-btn:hover { border-color: var(--accent); color: var(--accent); }
.viz-btn-play { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.viz-speed { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); margin-left: 8px; }
.viz-progress { margin-left: auto; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }

/* ===================== CODE PANEL ===================== */
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 8px;
}
.code-tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--card-border); border-radius: 100px; padding: 4px; }
.code-tab {
  background: transparent; color: var(--muted);
  font-size: 0.8rem; font-weight: 600; padding: 6px 14px; border-radius: 100px;
}
.code-tab.active { background: var(--accent); color: var(--ink); }
.code-copy {
  background: var(--card); border: 1px solid var(--card-border);
  color: var(--muted); font-size: 0.75rem; font-weight: 600;
  padding: 7px 14px; border-radius: 100px;
}
.code-copy:hover { border-color: var(--accent); color: var(--accent); }
.code-copy.copied { border-color: var(--accent); color: var(--accent); }

.code-block {
  flex: 1;
  position: relative;
  background: var(--ink); border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 10px 0;
  overflow: auto;
  min-height: 280px;
  max-height: 420px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
}
.code-line { display: flex; padding: 0 14px; white-space: pre; transition: background 0.15s ease; }
.code-line.active { background: rgba(198, 255, 74, 0.12); box-shadow: inset 3px 0 0 var(--accent); }
.code-ln-num { flex: 0 0 28px; color: var(--muted-2); user-select: none; text-align: right; margin-right: 14px; }
.code-ln-text { color: var(--cream); }
.tok-kw { color: #ff9d6a; }
.tok-num { color: var(--accent); }

.viz-info {
  display: grid; grid-template-columns: auto 1fr; gap: 24px;
  margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--card-border);
}
.viz-complexity { display: flex; gap: 20px; }
.viz-complexity div { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 12px 18px; text-align: center; min-width: 90px; }
.viz-complexity span { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.viz-complexity strong { font-family: var(--font-mono); color: var(--accent); }
.viz-howitworks h4 { font-size: 0.9rem; margin-bottom: 10px; color: var(--muted); }
.viz-howitworks ol { padding-left: 18px; font-size: 0.9rem; color: var(--cream); display: flex; flex-direction: column; gap: 6px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 800px) {
  .viz-info { grid-template-columns: 1fr; }
  .viz-complexity { justify-content: center; }
  .modal-viz-row { flex-direction: column; }
  .code-block { max-height: 260px; }
}
