/* ============================================================
   cognitive.css · eatandbefit.com · 认知可访问性
   版本 V1.0 · 2026-10-16
   ============================================================ */

/* ============ 阅读进度条 ============ */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: var(--color-accent-brand);
  z-index: var(--z-fixed);
  transition: width 100ms linear;
}

/* ============ 预计阅读时间 ============ */
.reading-time {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-left: var(--space-3);
}
.reading-time::before { content: '⏱'; }

/* ============ 目录导航（桌面端 sticky，移动端折叠） ============ */
.table-of-contents {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: var(--rhythm-normal);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.table-of-contents h4 {
  margin-top: 0;
  font-size: var(--text-base);
  margin-bottom: var(--rhythm-tight);
}
.table-of-contents ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.table-of-contents li {
  margin-bottom: var(--space-1);
}
.table-of-contents a {
  display: block;
  padding: var(--space-1) var(--space-2);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
}
.table-of-contents a:hover,
.table-of-contents a.active {
  background: var(--color-accent-50);
  color: var(--color-accent-700);
  text-decoration: none;
}

/* 移动端折叠 */
@media (max-width: 768px) {
  .table-of-contents {
    position: static;
    max-height: none;
    margin-bottom: var(--rhythm-normal);
  }
  .table-of-contents details summary {
    cursor: pointer;
    font-weight: var(--font-semibold);
    padding: var(--space-2) 0;
  }
}

/* ============ 回到顶部按钮 ============ */
.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--color-accent-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-out),
              visibility var(--duration-normal) var(--ease-out);
  z-index: var(--z-fixed);
}
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--color-accent-600); color: #fff; }

@media (max-width: 768px) {
  .back-to-top { width: 44px; height: 44px; bottom: var(--space-4); right: var(--space-4); }
}

/* ============ 章节锚点 ============ */
.heading-anchor {
  color: var(--color-text-tertiary);
  margin-left: var(--space-2);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  font-size: 0.8em;
  text-decoration: none;
}
h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }

/* ============ 渐进式披露 ============ */
.progressive-disclosure > details {
  margin: var(--rhythm-tight) 0;
  padding-left: var(--rhythm-normal);
  border-left: 2px solid var(--color-border);
}
.progressive-disclosure > details > summary {
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding: var(--space-2) 0;
}
.progressive-disclosure > details[open] > summary {
  color: var(--color-accent-brand);
  font-weight: var(--font-semibold);
}

/* ============ 减少选项：折叠组 ============ */
.option-cluster > details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.option-cluster > details > summary {
  cursor: pointer;
  font-weight: var(--font-semibold);
}

/* ============ 认知负荷：每屏主要CTA限制提示 ============ */
.content-focus-area {
  max-width: var(--reading-max-width);
  margin: 0 auto;
}

/* ============ 渐进式披露配合视觉断点 ============ */
.visual-break {
  margin: var(--rhythm-loose) 0;
  padding: var(--rhythm-normal);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--color-primary-300);
}

/* ============ 禁止自动播放/自动滚动 ============ */
[autoplay], .auto-scroll { display: none !important; }

/* ============ 移动端 ============ */
@media (max-width: 768px) {
  .back-to-top { display: flex; }
  .reading-progress { height: 2px; }
}
