/* 微积分入门课程共享样式 */

:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --secondary-color: #64748b;
  --accent-color: #f59e0b;
  --success-color: #10b981;
  --error-color: #ef4444;
  --bg-color: #ffffff;
  --surface-color: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border-color: #e2e8f0;
  --border-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-color);
  display: flex;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 主内容容器：保持原有的 840px 阅读宽度 */
.content-wrap {
  max-width: 840px;
  margin: 0 auto;
  padding: 48px 24px;
  width: 100%;
}

/* 侧边栏课程目录 */
.sidebar {
  width: 260px;
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  padding: 40px 24px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  top: 0;
  left: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

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

.course-contents a {
  display: block;
  padding: 9px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: 4px;
  border-radius: 0 6px 6px 0;
}

.course-contents a:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.course-contents a.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 500;
}

.course-contents a .lesson-number {
  font-size: 12px;
  color: var(--secondary-color);
  margin-right: 8px;
}

/* 主内容区域 */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-width: 0;
}

@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
    padding: 30px 16px;
  }

  .main-content {
    margin-left: 220px;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
  }

  .main-content {
    margin-left: 0;
  }
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.75rem;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.375rem;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
}

p {
  margin-bottom: 1rem;
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* 课程介绍区域 */
.lesson-intro {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 2rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
}

.lesson-intro h1 {
  color: white;
  margin-bottom: 0.75rem;
}

.lesson-intro p {
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 0.5rem;
}

/* 通用内容盒子 */
.content-box {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin: 1.5rem 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.story-box {
  background-color: #fffbeb;
  border-color: #fde68a;
  padding: 1.75rem;
  margin: 2rem 0;
}

.story-box h2 {
  color: #92400e;
  margin-top: 0;
}

.concept-box {
  background-color: var(--surface-color);
  border-left: 4px solid var(--primary-color);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.concept-box h3 {
  color: var(--primary-color);
  margin-top: 0;
}

.activity-box {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
  padding: 1.75rem;
  margin: 2rem 0;
}

.activity-box h3 {
  color: #166534;
  margin-top: 0;
}

/* 可视化容器 */
.visualization-container {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 2rem;
  margin: 2rem 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.visualization-container canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: white;
}

/* 测验区域 */
.quiz-section {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 2rem;
  margin: 2rem 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

.quiz-section h3 {
  margin-top: 0;
  color: var(--primary-color);
}

.quiz-question {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.quiz-question p {
  margin-bottom: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

.quiz-options {
  display: grid;
  gap: 0.75rem;
}

.quiz-option {
  padding: 0.875rem 1rem;
  background-color: white;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: left;
  color: var(--text-primary);
}

.quiz-option:hover:not(:disabled) {
  background-color: var(--surface-color);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.quiz-option:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.quiz-option.correct {
  background-color: #ecfdf5;
  border-color: var(--success-color);
  color: #065f46;
}

.quiz-option.incorrect {
  background-color: #fef2f2;
  border-color: var(--error-color);
  color: #991b1b;
}

/* 生活应用区域 */
.real-life-box {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  padding: 1.75rem;
  margin: 2rem 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

.real-life-box h3 {
  color: white;
  margin-top: 0;
}

.real-life-box ul {
  list-style: none;
  padding-left: 0;
}

.real-life-box li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.real-life-box li::before {
  content: "•";
  position: absolute;
  left: 0;
  font-weight: bold;
  font-size: 1.2em;
}

/* 总结区域 */
.summary-box {
  background-color: var(--primary-color);
  color: white;
  padding: 2rem;
  margin: 2.5rem 0;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

.summary-box h2 {
  color: white;
  margin-top: 0;
  margin-bottom: 1rem;
}

.summary-box ul {
  list-style: none;
  padding-left: 0;
}

.summary-box li {
  padding: 0.625rem 0;
  padding-left: 1.75rem;
  position: relative;
}

.summary-box li::before {
  content: "✓";
  position: absolute;
  left: 0;
  font-weight: bold;
  color: var(--accent-color);
}

.summary-box p {
  color: rgba(255, 255, 255, 0.95);
  margin-top: 1rem;
}

/* 下一课区域 */
.next-lesson {
  background-color: var(--surface-color);
  border: 2px solid var(--primary-color);
  padding: 1.5rem;
  text-align: center;
  border-radius: var(--border-radius);
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
}

.next-lesson p {
  margin-bottom: 1rem;
  font-weight: 500;
  color: var(--primary-color);
}

.next-lesson a {
  display: inline-block;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid var(--primary-color);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.next-lesson a:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* 询问老师区域 */
.ask-teacher {
  background-color: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: var(--border-radius);
  text-align: center;
}

.ask-teacher p {
  color: #9a3412;
  margin-bottom: 0.75rem;
}

/* 按钮样式 */
button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 24px 16px;
  }

  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .lesson-intro,
  .visualization-container,
  .quiz-section {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 20px 12px;
  }

  h1 {
    font-size: 1.5rem;
  }

  p {
    font-size: 1rem;
  }

  .quiz-options {
    grid-template-columns: 1fr;
  }
}

/* 平滑动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-box,
.story-box,
.concept-box,
.activity-box,
.quiz-section {
  animation: fadeIn 0.4s ease-out;
}

/* 改善焦点可见性 */
a:focus,
button:focus,
.quiz-option:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* 链接样式 */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}