/* 教学系统共享样式 - Tufte 风格 */

@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;1,300;1,400&family=Source+Code+Pro:wght@400;500&display=swap');

:root {
  --color-bg: #fefefe;
  --color-text: #111;
  --color-text-secondary: #555;
  --color-accent: #b51b2e;
  --color-accent-light: #fceef0;
  --color-border: #ddd;
  --color-code-bg: #f5f5f5;
  --font-serif: 'Merriweather', Georgia, serif;
  --font-mono: 'Source Code Pro', monospace;
  --max-width: 700px;
}

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

body {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  padding: 2rem 1rem;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* 标题 */
h1 {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  color: var(--color-text);
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
  color: var(--color-text);
}

/* 段落 */
p {
  margin-bottom: 1rem;
  text-align: justify;
}

/* 侧边注 */
.sidenote {
  float: right;
  clear: right;
  width: 200px;
  margin-right: -240px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
  vertical-align: baseline;
  position: relative;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 0.7rem;
  top: -0.3rem;
  left: 0.1rem;
}

/* 代码 */
code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--color-code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
}

pre {
  background: var(--color-code-bg);
  padding: 1rem;
  border-radius: 5px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-left: 3px solid var(--color-accent);
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* 表格 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th, td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 700;
  background: var(--color-accent-light);
  border-bottom: 2px solid var(--color-accent);
}

/* 列表 */
ul, ol {
  margin: 1rem 0 1rem 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* 引用块 */
blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--color-accent);
  background: var(--color-accent-light);
  font-style: italic;
}

/* 提醒框 */
.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-radius: 5px;
  background: #e8f4f8;
  border-left: 4px solid #2b6cb0;
}

.callout.warning {
  background: #fffbeb;
  border-left-color: #d69e2e;
}

.callout.danger {
  background: #fff5f5;
  border-left-color: #c53030;
}

/* 链接 */
a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

a:hover {
  border-bottom-color: var(--color-accent);
}

/* 页脚 */
.footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* 打印优化 */
@media print {
  body {
    padding: 0;
  }
  
  .sidenote {
    display: none;
  }
  
  a {
    color: var(--color-text);
  }
}

/* 响应式 */
@media (max-width: 1100px) {
  .sidenote {
    float: none;
    width: 100%;
    margin: 1rem 0;
    display: block;
    background: #f9f9f9;
    padding: 0.8rem;
    border-radius: 3px;
  }
}
