/* ==========================================
   政治史纲互动记忆轴 - Editorial Design 风格
   一本可以互动的精致电子书
   ========================================== */

/* CSS 变量定义 - 编辑设计系统 */
:root {
  /* 原有配色保留 */
  --color-primary: #B22222;           /* 学术红 */
  --color-bg: #F5F5DC;                /* 米色纸张 */
  --color-highlight: #DAA520;         /* 金色荧光笔 */
  
  /* 编辑设计色彩系统 */
  --color-paper: #FFFAF0;             /* 纸张白 */
  --color-ink: #2C2C2C;               /* 墨水黑 */
  --color-ink-light: #5A5A5A;         /* 浅墨色 */
  --color-ink-lighter: #8A8A8A;       /* 更浅墨色 */
  
  /* 书页阴影系统 */
  --shadow-page: 1px 4px 12px rgba(178, 34, 34, 0.08), 
                 1px 10px 24px rgba(0, 0, 0, 0.02);
  --shadow-page-hover: 2px 8px 20px rgba(178, 34, 34, 0.12), 
                       2px 16px 32px rgba(0, 0, 0, 0.04);
  --shadow-header: 0 2px 16px rgba(178, 34, 34, 0.1);
  
  /* 字体系统 */
  --font-serif: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  
  /* 排版系统 */
  --line-height-tight: 1.4;
  --line-height-normal: 1.8;
  --line-height-loose: 2.0;
  --letter-spacing-tight: -0.02em;
  --letter-spacing-normal: 0.02em;
  --letter-spacing-wide: 0.08em;
  
  /* 圆角系统 - 纸张边缘 */
  --radius-paper: 2px;
  --radius-card: 4px;
  
  /* 过渡系统 */
  --ease-paper: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 纸张纹理背景 */
body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  /* 添加微弱噪点纹理，模拟纸张质感 */
  background-image: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.01) 2px,
      rgba(0, 0, 0, 0.01) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.01) 2px,
      rgba(0, 0, 0, 0.01) 4px
    );
  color: var(--color-ink);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-normal);
  overflow-x: hidden;
  font-weight: 400;
}

/* ==========================================
   顶部控制栏 - 书籍封面风格
   ========================================== */
.header {
  background: linear-gradient(135deg, 
    rgba(178, 34, 34, 0.95) 0%, 
    rgba(158, 29, 29, 0.95) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-paper);
  padding: 2rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-header);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 3px solid rgba(218, 165, 32, 0.3);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.header.collapsed {
  transform: translateY(-85%);
}

.header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: var(--letter-spacing-wide);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  line-height: var(--line-height-tight);
}

/* 背诵模式开关 - 书签风格 */
.recitation-toggle {
  display: flex;
  align-items: center;
}

.toggle-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.3s var(--ease-paper);
}

.toggle-container:hover {
  transform: translateY(-2px);
}

.toggle-input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 52px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  transition: all 0.4s var(--ease-paper);
  margin-right: 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-paper);
  top: 1px;
  left: 2px;
  transition: all 0.4s var(--ease-paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.toggle-input:checked + .toggle-slider {
  background: var(--color-highlight);
  border-color: var(--color-highlight);
}

.toggle-input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.toggle-label {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: var(--letter-spacing-normal);
}

/* Header 收起/展开按钮 */
.header-toggle {
  position: fixed;
  top: 0;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, 
    rgba(178, 34, 34, 0.9) 0%, 
    rgba(158, 29, 29, 0.9) 100%);
  border: 2px solid rgba(218, 165, 32, 0.5);
  color: var(--color-paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s var(--ease-paper);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  padding: 0;
  font-weight: bold;
}

.header-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, 
    rgba(178, 34, 34, 1) 0%, 
    rgba(158, 29, 29, 1) 100%);
}

.header-toggle:active {
  transform: scale(0.95);
}

.header-toggle .icon {
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.header.collapsed .header-toggle .icon {
  transform: rotate(180deg);
}

/* ==========================================
   主容器布局 - 书籍内页
   ========================================== */
.main-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem;
  gap: 3rem;
  min-height: calc(100vh - 100px);
}

/* ==========================================
   左侧时间线 - 目录索引风格
   ========================================== */
.timeline {
  width: 240px;
  background: var(--color-paper);
  border-radius: var(--radius-card);
  overflow-y: auto;
  position: sticky;
  top: 120px;
  height: calc(100vh - 160px);
  padding: 2.5rem 0;
  box-shadow: var(--shadow-page);
  border-left: 4px solid var(--color-primary);
}

.timeline-item {
  padding: 1rem 2rem;
  cursor: pointer;
  transition: all 0.3s var(--ease-paper);
  position: relative;
  text-align: right;
  border-right: 3px solid transparent;
}

.timeline-item:hover {
  background: linear-gradient(270deg, 
    rgba(178, 34, 34, 0.05) 0%, 
    transparent 100%);
  border-right-color: var(--color-primary);
}

.timeline-item.active {
  background: linear-gradient(270deg, 
    rgba(178, 34, 34, 0.1) 0%, 
    transparent 100%);
  border-right-color: var(--color-primary);
}

/* 目录箭头装饰 */
.timeline-item::after {
  content: '▶';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--color-primary);
  opacity: 0;
  transition: all 0.3s var(--ease-paper);
}

.timeline-item.active::after {
  opacity: 1;
  right: 0.75rem;
}

.timeline-year {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--color-ink);
  font-weight: 700;
  letter-spacing: var(--letter-spacing-normal);
  font-style: italic;
}

.timeline-item:hover .timeline-year,
.timeline-item.active .timeline-year {
  color: var(--color-primary);
  font-weight: 900;
}

/* ==========================================
   右侧内容面板 - 书页翻阅区
   ========================================== */
.content-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem 2rem 0;
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

/* ==========================================
   事件卡片 - 纸张页面效果
   ========================================== */
.event-card {
  background: var(--color-paper);
  border-radius: var(--radius-card);
  padding: 2.5rem 3rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-page);
  transition: all 0.4s var(--ease-paper);
  border-left: 4px solid var(--color-primary);
  position: relative;
  opacity: 0;
  transform: translateY(20px);
}

.event-card:hover {
  box-shadow: var(--shadow-page-hover);
  transform: translateY(-2px);
}

/* 年份装饰 - 巨大的衬线斜体数字 */
.event-year {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--color-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  margin-bottom: 1rem;
  display: inline-block;
  padding: 0.35rem 0.85rem;
  background: linear-gradient(135deg, 
    rgba(178, 34, 34, 0.08) 0%, 
    rgba(218, 165, 32, 0.08) 100%);
  border-radius: var(--radius-paper);
  position: relative;
}

/* 年份背景装饰 - 巨大的水印数字 */
.event-year::before {
  content: attr(data-year);
  position: absolute;
  top: -80px;
  left: -20px;
  font-size: 8rem;
  font-weight: 900;
  font-style: italic;
  color: rgba(178, 34, 34, 0.03);
  z-index: -1;
  pointer-events: none;
  line-height: 1;
}

/* 事件标题 - 庄重的衬线体 */
.event-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--color-ink);
  font-weight: 900;
  margin-bottom: 0.75rem;
  letter-spacing: var(--letter-spacing-tight);
  line-height: var(--line-height-tight);
}

/* 日期 - 优雅的斜体 */
.event-date {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--color-ink-light);
  margin-bottom: 1.5rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: var(--letter-spacing-normal);
}

/* 核心意义 - 疏朗的正文排版 */
.event-significance {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  color: var(--color-ink);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-normal);
  text-align: justify;
  word-break: break-word;
  white-space: normal;
}

/* 分行排版 - 清单式布局 */
.event-significance br {
  display: block;
  content: '';
  margin: 0.5rem 0;
}

/* 段落块 - 分组显示 */
.text-block {
  display: block;
  width: 100%;
}

/* 分段标题 - 加粗的方括号标签 */
.section-label {
  color: var(--color-primary);
  font-weight: 900;
  font-family: var(--font-serif);
  letter-spacing: var(--letter-spacing-normal);
  display: inline;
  margin-right: 0.25rem;
}

/* 强调标签 - 确保加粗显示 */
.event-significance strong {
  font-weight: 900;
  color: var(--color-primary);
  font-family: var(--font-serif);
  letter-spacing: var(--letter-spacing-normal);
}

/* ==========================================
   关键词高亮 - 荧光笔涂抹效果
   ========================================== */
.keyword {
  color: var(--color-ink);
  font-weight: 700;
  background: linear-gradient(to top, 
    rgba(218, 165, 32, 0.4) 0%, 
    rgba(218, 165, 32, 0.4) 40%, 
    transparent 40%);
  padding: 0 0.2rem;
  border-radius: var(--radius-paper);
  transition: all 0.3s var(--ease-paper);
  display: inline;
  position: relative;
}

.keyword:hover {
  background: linear-gradient(to top, 
    rgba(218, 165, 32, 0.6) 0%, 
    rgba(218, 165, 32, 0.6) 50%, 
    transparent 50%);
}

/* ==========================================
   背诵模式 - 纸张遮盖效果
   ========================================== */
.blur-content {
  filter: blur(6px);
  opacity: 0.5;
  transition: all 0.5s var(--ease-paper);
  cursor: pointer;
  user-select: none;
  position: relative;
  background: rgba(245, 245, 220, 0.3);
  padding: 0.5rem;
  border-radius: var(--radius-paper);
}

.blur-content::after {
  content: '👆 悬停揭开';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--color-ink-lighter);
  opacity: 0;
  transition: opacity 0.3s var(--ease-paper);
  pointer-events: none;
  white-space: nowrap;
  font-style: italic;
}

.blur-content:hover::after {
  opacity: 1;
}

.blur-content:hover {
  filter: blur(0);
  opacity: 1;
  background: transparent;
}

.blur-content.revealed {
  filter: blur(0);
  opacity: 1;
  background: transparent;
}

.blur-content.revealed::after {
  display: none;
}

/* ==========================================
   响应式布局 - 移动端书籍模式
   ========================================== */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 2rem;
  }

  .header h1 {
    font-size: 1.5rem;
    text-align: center;
  }

  .main-container {
    flex-direction: column;
    padding: 2rem 1rem;
    gap: 2rem;
  }

  .timeline {
    width: 100%;
    height: auto;
    position: static;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border-left: none;
    border-top: 4px solid var(--color-primary);
    padding: 1rem 0;
    border-radius: var(--radius-card);
  }

  .timeline-item {
    flex-shrink: 0;
    padding: 0.75rem 1.5rem;
    text-align: center;
    border-right: none;
    border-bottom: 3px solid transparent;
    min-width: 100px;
  }

  .timeline-item:hover,
  .timeline-item.active {
    border-right: none;
    border-bottom-color: var(--color-primary);
    background: linear-gradient(180deg, 
      rgba(178, 34, 34, 0.1) 0%, 
      transparent 100%);
  }

  .timeline-item::after {
    content: '▼';
    right: auto;
    left: 50%;
    top: auto;
    bottom: -0.5rem;
    transform: translateX(-50%);
  }

  .timeline-item.active::after {
    bottom: -0.75rem;
  }

  .content-panel {
    padding: 0 0.5rem 1rem 0.5rem;
  }

  .event-card {
    padding: 2rem;
    border-radius: var(--radius-card);
  }

  .event-year::before {
    font-size: 5rem;
    top: -50px;
    left: -10px;
  }

  .event-title {
    font-size: 1.5rem;
  }

  /* 移动端模糊提示 */
  .blur-content::after {
    content: '👆 点击揭开';
  }

  /* 确保触摸目标尺寸 */
  .timeline-item,
  .toggle-container {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ==========================================
   滚动条 - 书籍翻页风格
   ========================================== */
.timeline::-webkit-scrollbar,
.content-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.timeline::-webkit-scrollbar-track,
.content-panel::-webkit-scrollbar-track {
  background: rgba(245, 245, 220, 0.3);
  border-radius: 4px;
}

.timeline::-webkit-scrollbar-thumb,
.content-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, 
    var(--color-primary) 0%, 
    var(--color-highlight) 100%);
  border-radius: 4px;
  transition: all 0.3s var(--ease-paper);
}

.timeline::-webkit-scrollbar-thumb:hover,
.content-panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, 
    #8B1A1A 0%, 
    #B8941F 100%);
}

/* ==========================================
   交错入场动画 - 书页翻开效果
   ========================================== */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px) rotateX(5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

.event-card {
  animation: slideUpFade 0.8s var(--ease-paper) forwards;
}

/* 页面加载动画 */
@keyframes headerFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  animation: headerFadeIn 0.6s var(--ease-paper);
}

@keyframes timelineFadeIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.timeline {
  animation: timelineFadeIn 0.8s var(--ease-paper) 0.2s backwards;
}

/* ==========================================
   印刷品细节优化
   ========================================== */

/* 首字下沉效果（可选） */
.event-significance::first-letter {
  font-family: var(--font-serif);
  font-size: 2.5em;
  font-weight: 900;
  float: left;
  line-height: 0.9;
  margin: 0.1em 0.1em 0 0;
  color: var(--color-primary);
}

/* 段落间距 */
.event-significance p + p {
  margin-top: 1em;
}

/* 引用样式 */
blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  border-left: 3px solid var(--color-highlight);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--color-ink-light);
}

/* 选中文本样式 */
::selection {
  background: rgba(218, 165, 32, 0.3);
  color: var(--color-ink);
}

::-moz-selection {
  background: rgba(218, 165, 32, 0.3);
  color: var(--color-ink);
}

/* 打印样式优化 */
@media print {
  body {
    background: white;
  }
  
  .header,
  .timeline {
    display: none;
  }
  
  .event-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* ==========================================
   微交互细节
   ========================================== */

/* 卡片拿起效果 */
.event-card:active {
  transform: translateY(-1px);
  box-shadow: 1px 2px 8px rgba(178, 34, 34, 0.06), 
              1px 6px 16px rgba(0, 0, 0, 0.01);
}

/* 时间线项目点击反馈 */
.timeline-item:active {
  transform: scale(0.98);
}

/* Toggle 开关点击反馈 */
.toggle-container:active {
  transform: translateY(0);
}

/* 平滑的焦点样式 */
*:focus {
  outline: 2px solid var(--color-highlight);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

/* 链接样式（如果有） */
a {
  color: var(--color-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease-paper);
}

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