/* DevNinja design system — Interview Prep site */
:root {
  /* Primary — sky blue (matches devninja.in) */
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-900: #0c4a6e;

  /* Neutrals — GitHub/Vercel inspired */
  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;

  --surface: #ffffff;
  --surface-elevated: #fafafa;
  --surface-muted: #f4f4f5;
  --border: #e4e4e7;
  --border-light: #f4f4f5;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-accent: #0ea5e9;

  --cat-coding: #10b981;
  --cat-sd: #0ea5e9;
  --cat-ai: #8b5cf6;
  --cat-guide: #f59e0b;

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;

  --max-width: 1280px;
  --header-height: 64px;
  --sidebar-w: 280px;
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Compatibility aliases used by chapter/interview CSS */
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --paper: var(--gray-50);
  --paper-2: var(--gray-100);
  --mist: var(--gray-300);
  --accent: var(--primary-600);
  --accent-deep: var(--primary-700);
  --accent-glow: rgba(14, 165, 233, 0.14);
  --line: var(--border);
  --shadow: var(--shadow-md);
  --font-display: var(--font-sans);
  --font-body: var(--font-sans);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  background: var(--surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gray-900);
  color: white;
  padding: 0.6rem 1rem;
  z-index: 1000;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.container {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

/* ——— Header (DevNinja-style) ——— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand span {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary-600);
  letter-spacing: 0.04em;
  text-transform: none;
}

.nav-links {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-links > a:not(.btn) {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.nav-links > a:not(.btn):hover {
  color: var(--text-primary);
  background: var(--surface-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition-base);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-700);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-ghost:hover {
  border-color: var(--primary-500);
  background: var(--primary-50);
  color: var(--primary-700);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: var(--text-xs);
}

/* ——— Hero ——— */
.hero {
  position: relative;
  text-align: center;
  padding: clamp(3.5rem, 8vw, 6rem) 1rem clamp(3rem, 6vw, 4.5rem);
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--surface) 58%, #fff 100%);
  border-bottom: 1px solid var(--border-light);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -40% auto;
  width: min(520px, 70vw);
  height: min(520px, 70vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.16), transparent 68%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  margin-inline: auto;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
}

.hero-kicker a {
  color: var(--primary-600);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
}

.hero p {
  margin: 1rem auto 0;
  max-width: 38rem;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.75rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2rem;
  margin-top: 2.25rem;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.hero-stats strong {
  display: block;
  color: var(--text-primary);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ——— Sections ——— */
.section {
  padding: clamp(2.75rem, 6vw, 4.5rem) 0;
}

.section-alt {
  background: var(--surface-elevated);
  border-block: 1px solid var(--border-light);
}

.section-head {
  width: min(40rem, 100%);
  margin: 0 auto 2rem;
  text-align: center;
  padding-inline: 1rem;
}

.section-head h2 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.55rem, 3.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.section-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-base);
}

/* Interactive destination tiles */
.parts {
  display: grid;
  gap: 1rem;
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

@media (min-width: 760px) {
  .parts {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1100px) {
  .parts.parts-wide {
    grid-template-columns: repeat(3, 1fr);
  }
}

.part {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
  height: 100%;
}

.part:hover {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.part-label {
  display: inline-block;
  margin-bottom: 0.55rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: var(--text-xs);
  font-weight: 600;
}

.part-label.coding { background: #ecfdf5; color: #047857; }
.part-label.sd { background: var(--primary-50); color: var(--primary-700); }
.part-label.ai { background: #f5f3ff; color: #6d28d9; }
.part-label.guide { background: #fffbeb; color: #b45309; }

.part h3 {
  margin: 0 0 0.45rem;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.part h3 a {
  color: inherit;
}

.part h3 a:hover {
  color: var(--primary-700);
}

.part p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.ecosystem {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: min(100% - 2rem, 52rem);
  margin: 0 auto;
}

.ecosystem a {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: var(--transition-fast);
}

.ecosystem a:hover {
  border-color: var(--primary-500);
  color: var(--primary-700);
  background: var(--primary-50);
}

/* TOC */
.toc-grid {
  display: grid;
  gap: 1.25rem;
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

@media (min-width: 900px) {
  .toc-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .toc-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.toc-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1rem 0.75rem;
  box-shadow: var(--shadow-sm);
}

.toc-col h3 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.toc-col ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 22rem;
  overflow: auto;
}

.toc-col li a {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.35rem;
  padding: 0.38rem 0.2rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  transition: var(--transition-fast);
}

.toc-col li a:hover {
  color: var(--primary-700);
  padding-left: 0.25rem;
}

.toc-col li .num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--primary-600);
  padding-top: 0.15rem;
}

.diagram-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 280px);
  gap: 1rem;
  overflow-x: auto;
  padding: 0.25rem 1rem 0.75rem;
  width: min(100%, var(--max-width));
  margin-inline: auto;
  scroll-snap-type: x mandatory;
}

.diagram-card {
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.diagram-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-500);
  box-shadow: var(--shadow-md);
}

.diagram-card img {
  aspect-ratio: 16 / 10;
  object-fit: contain;
  object-position: center;
  background: var(--gray-50);
  padding: 0.65rem;
}

.diagram-card figcaption {
  padding: 0.7rem 0.85rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
}

.site-footer {
  padding: 2.5rem clamp(1rem, 3vw, 2rem) 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.footer-inner {
  width: min(100%, var(--max-width));
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.site-footer a:hover {
  color: var(--primary-700);
}

/* ——— Shared reader / sidebar chrome ——— */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.toc-group-title {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-700);
  padding: 0.45rem 0.65rem;
  font-weight: 700;
}

.toc-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text-secondary);
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
}

.toc-item:hover,
.toc-item.active {
  background: var(--primary-50);
  color: var(--primary-700);
}

.toc-item .num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-right: 0.4rem;
  opacity: 0.85;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.menu-toggle {
  display: none;
}

/* ——— Homepage product layout ——— */
.header-inner {
  width: min(100%, var(--max-width));
  margin-inline: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.home-page .site-header {
  padding-inline: clamp(1rem, 3vw, 1.5rem);
}

.hero-lead {
  margin: 1rem auto 0;
  max-width: 40rem;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.55;
}

.section-head-left {
  margin-left: 0;
  margin-right: 0;
  text-align: left;
  padding-inline: 0;
  width: min(42rem, 100%);
}

.feature-grid,
.lab-grid,
.guide-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 800px) {
  .feature-grid,
  .lab-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .guide-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1100px) {
  .guide-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.feature-card,
.lab-card,
.guide-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
  color: inherit;
  text-decoration: none;
  min-height: 100%;
}

.feature-card:hover,
.lab-card:hover,
.guide-card:hover {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.feature-index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary-600);
  margin-bottom: 0.85rem;
}

.feature-card h3,
.lab-card h3,
.guide-card h3 {
  margin: 0 0 0.45rem;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-primary);
}

.guide-card h3 {
  font-size: var(--text-base);
}

.feature-card p,
.lab-card p,
.guide-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.55;
  flex: 1;
}

.feature-cta {
  margin-top: 1.1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary-700);
}

.lab-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.lab-card-top .part-label {
  margin-bottom: 0;
}

.lab-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.lab-card.compact {
  padding: 1.15rem 1.1rem;
}

.guide-card {
  padding: 1.1rem 1rem;
}

.home-page .toc-grid {
  width: 100%;
}

.home-page .diagram-strip {
  width: min(100% - 2rem, var(--max-width));
}

.home-page .ecosystem {
  width: 100%;
  justify-content: flex-start;
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

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

@media (max-width: 900px) {
  .nav-links .hide-sm {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(24, 24, 27, 0.35);
    z-index: 70;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
}
