/* ===================================================
   DS Assessment Prep — Shared Styles
   =================================================== */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-sidebar: #0f3460;
  --bg-card: #1e2a45;
  --bg-code: #0d1117;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  --border: #2d3748;
  --sidebar-width: 220px;
  --header-height: 56px;
  --content-max: 760px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Roboto Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.7;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Header ---- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
}
.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.site-title:hover { color: var(--accent); text-decoration: none; }
.topic-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}
.nav-arrow { color: var(--accent); font-weight: 500; white-space: nowrap; }
.nav-arrow:hover { color: var(--accent-hover); }
.current-topic {
  color: var(--text-secondary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Layout ---- */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar ul { list-style: none; }
.sidebar ul li a {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
}
.sidebar ul li a:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar ul li.active a {
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: calc(1.25rem - 3px);
  background: var(--accent-light);
}

/* ---- Main Content ---- */
.content {
  margin-left: var(--sidebar-width);
  padding: 2.5rem 2rem 4rem;
  max-width: calc(var(--sidebar-width) + var(--content-max));
  width: 100%;
}
.content > h1 {
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}
.content h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}
.content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1.5rem 0 0.5rem;
}
.content p { margin-bottom: 1rem; }
.content ul, .content ol { margin: 0.5rem 0 1rem 1.5rem; }
.content li { margin-bottom: 0.35rem; }

/* ---- Key Takeaways Box ---- */
.key-takeaways {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0 2rem;
}
.key-takeaways h2 {
  margin-top: 0;
  font-size: 1.1rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.key-takeaways ul { margin-left: 1.25rem; }
.key-takeaways li { font-size: 0.95rem; }

/* ---- Tables ---- */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}
.content th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-align: left;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.content td {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* ---- Code Blocks ---- */
pre {
  margin: 1rem 0 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  background: var(--bg-code) !important;
  border: 1px solid var(--border);
}
pre code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 1.25rem 1.5rem;
  display: block;
}
code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(255,255,255,0.07);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: #f8c555;
}

/* ---- Practice Questions ---- */
.practice-questions { margin: 2.5rem 0; }
.practice-questions details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.practice-questions details[open] { border-color: var(--accent); }
.practice-questions summary {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}
.practice-questions summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: var(--accent);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.practice-questions details[open] summary::before { transform: rotate(90deg); }
.practice-questions summary::-webkit-details-marker { display: none; }
.practice-questions .answer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ---- Action Items ---- */
.action-items { margin: 2.5rem 0; }
.checklist { list-style: none; margin-left: 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 0;
}
.checklist input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 0.3rem;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* ---- KaTeX ---- */
.katex-display { overflow-x: auto; padding: 0.25rem 0; }

/* ---- Home Page ---- */
.home-content {
  max-width: 940px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}
.home-intro {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin: 1.5rem 0 2.5rem;
  max-width: 640px;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  transition: border-color 0.15s, transform 0.15s;
  display: block;
  color: var(--text-primary);
}
.topic-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text-primary);
}
.topic-card .topic-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.topic-card .topic-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.topic-card .topic-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: var(--sidebar-width);
}
.site-footer.no-sidebar { margin-left: 0; }
.content section { margin-bottom: 2rem; }

/* ---- Mobile hamburger button (hidden on desktop) ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ---- Sidebar overlay (shown on mobile when sidebar is open) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 998;
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ---- Responsive: tablet and below ---- */
@media (max-width: 768px) {
  /* Sidebar slides off-screen by default */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 999;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  /* Remove sidebar offset from content and footer */
  .content {
    margin-left: 0;
    padding: 1.5rem 1rem 3rem;
    max-width: 100%;
  }
  .site-footer { margin-left: 0; }

  /* Show hamburger; hide full topic-nav (sidebar covers navigation) */
  .menu-toggle { display: flex; align-items: center; }
  .topic-nav { display: none; }
  .site-header { padding: 0 1rem; }
  .site-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Tables scroll horizontally */
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Slightly smaller headings */
  .content > h1 { font-size: 1.6rem; }
  .content h2   { font-size: 1.15rem; }

  /* Home page */
  .home-content { padding: 1.5rem 1rem 3rem; }
  .topic-grid   { grid-template-columns: 1fr; }
}

/* ---- Responsive: small phones ---- */
@media (max-width: 480px) {
  .site-title  { font-size: 0.95rem; }
  .nav-arrow   { font-size: 0.8rem; }
  .topic-nav   { gap: 0.5rem; }
}
