/* ========================================
   ylearner – Learn to Code | Main Stylesheet
   ======================================== */

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

/* ========================
   CSS Custom Properties
   ======================== */
:root {
  --python-blue: #4a8c3f;
  --python-yellow: #FFD43B;
  --python-blue-light: #6aad5a;
  --python-blue-dark: #2d6b24;
  --python-yellow-dark: #c9a800;

  /* Light Theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-code: #1e1e2e;
  --bg-inline-code: #f1f5f9;
  --bg-tip: #eff6ff;
  --bg-warning: #fffbeb;
  --bg-danger: #fff1f2;
  --bg-success: #f0fdf4;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-code: #e2e8f0;
  --text-inline-code: #be185d;

  --border-color: #e2e8f0;
  --border-radius: 8px;

  --link-color: #2d7d1f;
  --link-hover: #1f5c14;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);

  --sidebar-width: 272px;
  --right-sidebar-width: 240px;
  --header-height: 64px;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-code: 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --transition: all 0.2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-sidebar: #1c2128;
  --bg-card: #1c2128;
  --bg-header: #161b22;
  --bg-code: #161b22;
  --bg-inline-code: #21262d;
  --bg-tip: #0c1929;
  --bg-warning: #1a1400;
  --bg-danger: #1a0005;
  --bg-success: #041a10;

  --text-primary: #e6edf3;
  --text-secondary: #8d96a0;
  --text-muted: #6e7681;
  --text-inline-code: #f97316;

  --border-color: #30363d;

  --link-color: #6cc95b;
  --link-hover: #8fd97f;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.6);
}

/* ========================
   Reset & Base
   ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--link-color); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ========================
   Header
   ======================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo:hover { text-decoration: none; color: var(--python-blue); }

.logo-icon {
  width: 40px;
  height: 40px;
  background: url('../assets/logo.png') center / contain no-repeat;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0;
}

.logo-text { color: var(--text-primary); }
.logo-text span { color: var(--python-blue); }

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  transition: var(--transition);
}

.header-search input:focus {
  outline: none;
  border-color: var(--python-blue);
  box-shadow: 0 0 0 3px rgba(74, 140, 63, 0.15);
}

.header-search input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1001;
}

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

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  transition: var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-secondary); text-decoration: none; }
.search-result-item .result-title { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.search-result-item .result-category { font-size: 0.75rem; color: var(--python-blue); }
.search-result-item .result-desc { font-size: 0.8rem; color: var(--text-secondary); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1rem;
}

.btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--python-blue); }

.menu-toggle {
  display: none;
}

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

/* ========================
   Sidebar Navigation
   ======================== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.nav-section { margin-bottom: 0.25rem; }

.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.nav-section-title:hover { color: var(--text-secondary); }
.nav-section-title .arrow { transition: transform 0.2s ease; font-size: 0.65rem; }
.nav-section.collapsed .arrow { transform: rotate(-90deg); }
.nav-section.collapsed .nav-links { display: none; }

.nav-links { list-style: none; }

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.25rem 0.4rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: var(--transition);
  line-height: 1.4;
}

.nav-links a:hover {
  color: var(--python-blue);
  background: rgba(74, 140, 63, 0.06);
  text-decoration: none;
  border-left-color: rgba(74, 140, 63, 0.3);
}

.nav-links a.active {
  color: var(--python-blue);
  background: rgba(74, 140, 63, 0.1);
  font-weight: 600;
  border-left-color: var(--python-blue);
}

[data-theme="dark"] .nav-links a.active {
  background: rgba(88, 166, 255, 0.1);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  font-weight: 600;
}

.badge-new { background: #dcfce7; color: #16a34a; }
.badge-hot { background: #fff1f2; color: #e11d48; }
[data-theme="dark"] .badge-new { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-hot { background: #1c0010; color: #fb7185; }

/* ========================
   Main Content
   ======================== */
.content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2.5rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--python-blue); }
.breadcrumb .separator { color: var(--border-color); }
.breadcrumb .current { color: var(--text-secondary); }

/* Page Header */
.lesson-header { margin-bottom: 2rem; }

.lesson-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: rgba(74, 140, 63, 0.1);
  color: var(--python-blue);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

[data-theme="dark"] .lesson-tag { background: rgba(88, 166, 255, 0.1); color: #58a6ff; }

.lesson-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.lesson-intro {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
}

.lesson-meta span { display: flex; align-items: center; gap: 0.35rem; }

/* Typography */
.lesson-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.lesson-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text-primary);
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.lesson-body h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-secondary);
}

.lesson-body p { margin-bottom: 1.25rem; color: var(--text-secondary); font-size: 1rem; }
.lesson-body ul, .lesson-body ol { margin: 0 0 1.25rem 1.5rem; color: var(--text-secondary); }
.lesson-body li { margin-bottom: 0.4rem; }
.lesson-body strong { color: var(--text-primary); font-weight: 600; }

/* Inline Code */
code:not([class]) {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: var(--bg-inline-code);
  color: var(--text-inline-code);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Code Blocks */
.code-block {
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #12121a;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.code-lang {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-lang::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--python-blue-light);
}

.copy-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #8b949e;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.copy-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.copy-btn.copied { border-color: #4ade80; color: #4ade80; }

pre {
  margin: 0;
  padding: 1.25rem;
  background: var(--bg-code);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.9rem;
  line-height: 1.65;
}

pre code { background: none; padding: 0; border: none; color: inherit; font-size: inherit; }

/* Output blocks */
.output-block {
  background: #0a0a14;
  border: 1px solid rgba(255,255,255,0.08);
  border-top: 3px solid var(--python-yellow);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  padding: 1rem 1.25rem;
  font-family: var(--font-code);
  font-size: 0.875rem;
  color: #a8ff78;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}

.output-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--python-yellow);
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-family: var(--font-body);
}

/* Callout Boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
  border-left: 4px solid;
  display: flex;
  gap: 0.75rem;
}

.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }
.callout-content { flex: 1; }
.callout-content p:last-child { margin-bottom: 0; }
.callout strong { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; }

.callout-tip { background: var(--bg-tip); border-color: #3b82f6; }
.callout-tip strong { color: #3b82f6; }

.callout-warning { background: var(--bg-warning); border-color: #f59e0b; }
.callout-warning strong { color: #d97706; }

.callout-danger { background: var(--bg-danger); border-color: #ef4444; }
.callout-danger strong { color: #dc2626; }

.callout-success { background: var(--bg-success); border-color: #22c55e; }
.callout-success strong { color: #16a34a; }

/* Tables */
.table-wrapper { overflow-x: auto; margin: 1.5rem 0; border-radius: var(--border-radius); border: 1px solid var(--border-color); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--bg-secondary); }
th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  font-size: 0.85rem;
}
td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-secondary); }

/* Highlight.js override for Python */
.hljs { background: transparent; }

/* ========================
   Specific Sections
   ======================== */

/* Info Cards */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.info-card:hover { box-shadow: var(--shadow-md); border-color: var(--python-blue); transform: translateY(-2px); }

.info-card-icon { font-size: 1.75rem; margin-bottom: 0.75rem; }
.info-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; margin-top: 0; }
.info-card p { font-size: 0.85rem; color: var(--text-secondary); margin: 0; }

/* Steps */
.steps { counter-reset: step; list-style: none; margin: 1.5rem 0; padding: 0; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}
.steps li::before {
  content: counter(step);
  width: 28px;
  height: 28px;
  background: var(--python-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* FAQ */
.faq-section { margin: 2.5rem 0; }
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--bg-card);
  transition: var(--transition);
  user-select: none;
  gap: 0.75rem;
}

.faq-question:hover { background: var(--bg-secondary); color: var(--python-blue); }

.faq-toggle {
  width: 22px;
  height: 22px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.faq-item.open .faq-toggle { transform: rotate(45deg); color: var(--python-blue); }

.faq-answer {
  padding: 0 1.25rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
  max-height: 500px;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.faq-answer p { color: var(--text-secondary); font-size: 0.95rem; margin: 0; }

/* Exercise Box */
.exercise-box {
  background: linear-gradient(135deg, rgba(74, 140, 63, 0.08), rgba(255, 212, 59, 0.05));
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 2rem 0;
}

.exercise-box h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0;
  color: var(--python-blue);
}

.challenge-box {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(239, 68, 68, 0.02));
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 2rem 0;
}

.challenge-box h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0;
  color: #dc2626;
}

/* Interview questions */
.interview-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.interview-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.interview-list li:last-child { border-bottom: none; }

.interview-list li::before {
  content: 'Q.';
  font-weight: 700;
  color: var(--python-blue);
  flex-shrink: 0;
}

/* Summary box */
.summary-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin: 2rem 0;
}

.summary-box h3 { margin-top: 0; display: flex; align-items: center; gap: 0.5rem; }

/* Related topics */
.related-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.topic-tag:hover {
  background: rgba(74, 140, 63, 0.1);
  border-color: var(--python-blue);
  color: var(--python-blue);
  text-decoration: none;
}

/* ========================
   Right Sidebar / TOC
   ======================== */
.right-sidebar {
  width: var(--right-sidebar-width);
  flex-shrink: 0;
  padding: 1.5rem 1rem;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  border-left: 1px solid var(--border-color);
  display: none;
  scrollbar-width: thin;
}

@media (min-width: 1200px) { .right-sidebar { display: block; } }

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

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

.toc-list li { margin-bottom: 0.1rem; }

.toc-list a {
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
}

.toc-list a:hover { color: var(--python-blue); border-left-color: var(--python-blue); text-decoration: none; }
.toc-list a.toc-active { color: var(--python-blue); border-left-color: var(--python-blue); font-weight: 600; }

.toc-list .toc-h3 a { padding-left: 1.25rem; font-size: 0.77rem; }

.sidebar-ad-box {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================
   Prev/Next Navigation
   ======================== */
.lesson-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 3rem 0 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.lesson-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  text-decoration: none;
  transition: var(--transition);
  background: var(--bg-card);
}

.lesson-nav-link:hover {
  border-color: var(--python-blue);
  background: rgba(74, 140, 63, 0.05);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.lesson-nav-link.next { text-align: right; }
.lesson-nav-link .nav-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.lesson-nav-link .nav-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.lesson-nav-link .nav-arrow { font-size: 0.85rem; color: var(--python-blue); }

/* ========================
   Homepage Specific
   ======================== */
.hero {
  padding: 5rem 2rem 4rem;
  text-align: center;
  background: linear-gradient(160deg, rgba(74, 140, 63, 0.06) 0%, rgba(255, 212, 59, 0.04) 100%);
  border-bottom: 1px solid var(--border-color);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(74, 140, 63, 0.1);
  border: 1px solid rgba(74, 140, 63, 0.2);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--python-blue);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}

.hero h1 .accent { color: var(--python-blue); }
.hero h1 .accent-yellow { color: var(--python-yellow-dark); }

.hero p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto 2rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: var(--python-blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-primary:hover { background: var(--python-blue-dark); text-decoration: none; color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 140, 63, 0.4); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-secondary:hover { background: var(--bg-secondary); text-decoration: none; color: var(--text-primary); }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.hero-stat { text-align: center; }
.hero-stat .stat-number { font-size: 1.75rem; font-weight: 800; color: var(--python-blue); }
.hero-stat .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Homepage sections */
.home-section {
  padding: 4rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.home-section-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.home-section-desc {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  font-size: 1.05rem;
}

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

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  border-color: var(--python-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
}

.course-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.card-blue { background: rgba(74, 140, 63, 0.1); }
.card-green { background: rgba(34, 197, 94, 0.1); }
.card-orange { background: rgba(249, 115, 22, 0.1); }
.card-purple { background: rgba(168, 85, 247, 0.1); }
.card-red { background: rgba(239, 68, 68, 0.1); }
.card-yellow { background: rgba(234, 179, 8, 0.1); }
.card-teal { background: rgba(20, 184, 166, 0.1); }
.card-pink { background: rgba(236, 72, 153, 0.1); }

.course-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.course-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  flex: 1;
}

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.course-card-count {
  background: var(--bg-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-weight: 600;
}

/* Difficulty badges */
.difficulty-beginner { color: #16a34a; background: #dcfce7; }
.difficulty-intermediate { color: #ca8a04; background: #fef9c3; }
.difficulty-advanced { color: #dc2626; background: #fee2e2; }
[data-theme="dark"] .difficulty-beginner { background: #052e16; color: #4ade80; }
[data-theme="dark"] .difficulty-intermediate { background: #1a1000; color: #fbbf24; }
[data-theme="dark"] .difficulty-advanced { background: #1a0000; color: #f87171; }

/* ========================
   Ad Placeholder Styles
   ======================== */
.ad-container {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-header { min-height: 90px; margin-bottom: 1.5rem; }
.ad-footer { min-height: 90px; margin-top: 1.5rem; }
.ad-in-content { min-height: 280px; margin: 2rem 0; }
.ad-sidebar { min-height: 250px; }

/* ========================
   Footer
   ======================== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 3rem 2rem 2rem;
}

.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-brand p { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.75rem; max-width: 280px; }

.footer-col h4 { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.75rem; }

.footer-links { list-style: none; padding: 0; }
.footer-links li { margin-bottom: 0.4rem; }
.footer-links a { font-size: 0.875rem; color: var(--text-secondary); text-decoration: none; transition: var(--transition); }
.footer-links a:hover { color: var(--python-blue); }

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-bottom a { color: var(--text-muted); }
.footer-bottom a:hover { color: var(--python-blue); }

/* ========================
   Responsive
   ======================== */
@media (max-width: 1024px) {
  .sidebar { width: 240px; }
  .right-sidebar { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: -100%;
    height: calc(100vh - var(--header-height));
    z-index: 999;
    transition: left 0.3s ease;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { left: 0; }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,0.5);
    z-index: 998;
    display: none;
  }

  .sidebar-overlay.active { display: block; }

  .menu-toggle { display: flex; }

  .main-content { padding: 1.5rem 1.25rem; }

  .lesson-header h1 { font-size: 1.75rem; }

  .hero { padding: 3rem 1.5rem 2.5rem; }
  .hero h1 { font-size: 2rem; }

  .footer-grid { grid-template-columns: 1fr 1fr; }

  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav-link.next { text-align: left; }

  .hero-stats { gap: 1.5rem; }

  /* Search moves below header on mobile */
  .header-search {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    padding: 0.5rem 1rem;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    max-width: 100%;
    z-index: 999;
    box-shadow: var(--shadow-sm);
  }

  .header-search input {
    border-radius: 8px;
  }

  /* Push page content down so it's not under the search bar */
  body { padding-top: 48px; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; align-items: center; }
  .ad-container { padding: 0.5rem; font-size: 0.75rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .course-grid { grid-template-columns: 1fr; }
}

/* Ad containers responsive */
.ad-container {
  overflow: hidden;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.ad-header, .ad-footer { max-width: 728px; margin-left: auto; margin-right: auto; }
.ad-in-content { max-width: 336px; margin-left: auto; margin-right: auto; }
.ad-sidebar { max-width: 250px; }

@media (max-width: 768px) {
  .ad-header, .ad-footer { max-width: 100%; }
  .ad-in-content { max-width: 100%; }
}

/* ========================
   Utilities
   ======================== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@media (max-width: 768px) { .hidden-mobile { display: none; } }

/* ========================
   Multi-course Logo
   ======================== */

/* ========================
   Footer Algorid Credit
   ======================== */
.algorid-credit a { color: var(--python-blue); font-weight: 600; }
.footer-bottom { flex-wrap: wrap; gap: 0.75rem; }

/* ========================
   Course Sidebar Label
   ======================== */
.course-sidebar-label { border-bottom: 1px solid var(--border-color); margin-bottom: 0.25rem; }

/* ========================
   JS course accent colors (future)
   ======================== */
.card-yellow { background: rgba(247, 223, 30, 0.12); }
[data-theme="dark"] .card-yellow { background: rgba(247, 223, 30, 0.08); }

/* Skip to content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--python-blue);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  z-index: 9999;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* Progress bar */
.reading-progress {
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: 3px;
  background: linear-gradient(to right, var(--python-blue), var(--python-yellow));
  z-index: 1001;
  width: 0%;
  transition: width 0.1s linear;
}

/* Scroll to top */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 42px;
  height: 42px;
  background: var(--python-blue);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}

.scroll-top.visible { opacity: 1; pointer-events: auto; }
.scroll-top:hover { background: var(--python-blue-dark); transform: translateY(-3px); }

/* Print */
@media print {
  .site-header, .sidebar, .right-sidebar, .site-footer, .ad-container, .lesson-nav, .reading-progress, .scroll-top { display: none !important; }
  .main-content { max-width: 100%; padding: 0; }
  pre { white-space: pre-wrap; }
  a[href]::after { content: " (" attr(href) ")"; }
}
