/* ============================================================
   cognitive.css - 认知可访问性
   网站：kidsshoeshop.com
   组件：阅读进度条 / 预计阅读时间 / 目录导航 / 回到顶部 / 渐进式披露
   生成：建站AI · 2026-10-13
   ============================================================ */

/* ===== 1. 阅读进度条 ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: var(--z-fixed);
  pointer-events: none;
}

.reading-progress .progress-bar {
  height: 100%;
  background: var(--color-primary-500);
  width: 0%;
  transition: width var(--duration-fast) linear;
}

/* ===== 2. 预计阅读时间 ===== */
.reading-time {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--rhythm-normal);
}

.reading-time .icon {
  font-size: var(--text-base);
}

/* ===== 3. 目录导航 ===== */
.toc {
  background: var(--color-neutral-50);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--card-padding);
  margin-bottom: var(--rhythm-loose);
}

.toc h4 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
}

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

.toc li {
  margin-bottom: var(--space-2);
}

.toc a {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  display: block;
  padding: var(--space-1) 0;
  transition: color var(--duration-normal) var(--ease-out);
}

.toc a:hover,
.toc a.is-active {
  color: var(--color-primary-600);
  font-weight: var(--font-medium);
}

.toc .toc-h3 {
  padding-left: var(--space-4);
  font-size: var(--text-xs);
}

/* 桌面端 sticky 目录 */
@media (min-width: 1024px) {
  .toc-sticky {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* 移动端折叠 */
@media (max-width: 768px) {
  .toc {
    display: none;
  }
  .toc.is-open {
    display: block;
    margin-bottom: var(--rhythm-normal);
  }
}

/* ===== 4. 回到顶部 ===== */
.back-to-top {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-primary-500);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-out),
              visibility var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-spring);
  z-index: var(--z-fixed);
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .back-to-top {
    width: 44px;
    height: 44px;
    bottom: var(--space-4);
    right: var(--space-4);
  }
}

/* ===== 5. 渐进式披露 ===== */
.progressive-disclosure {
  margin: var(--rhythm-normal) 0;
}

.progressive-disclosure > summary {
  cursor: pointer;
  font-weight: var(--font-medium);
  color: var(--color-primary-600);
  padding: var(--space-3) 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.progressive-disclosure > summary::before {
  content: '▸';
  transition: transform var(--duration-normal) var(--ease-out);
  display: inline-block;
}

.progressive-disclosure[open] > summary::before {
  transform: rotate(90deg);
}

.progressive-disclosure > *:not(summary) {
  padding-left: var(--space-5);
  border-left: 2px solid var(--color-border);
  margin-left: var(--space-2);
}

/* ===== 6. 减少选项 - 折叠分组 ===== */
.filter-cluster {
  margin-bottom: var(--rhythm-normal);
}

.filter-cluster > summary {
  cursor: pointer;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  padding: var(--space-3);
  background: var(--color-neutral-100);
  border-radius: var(--radius-md);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-cluster > summary::after {
  content: '+';
  font-size: var(--text-lg);
  transition: transform var(--duration-normal) var(--ease-out);
}

.filter-cluster[open] > summary::after {
  transform: rotate(45deg);
}

.filter-cluster > *:not(summary) {
  padding: var(--space-3);
}

/* ===== 7. 章节锚点 ===== */
.anchor-link {
  opacity: 0;
  margin-left: var(--space-2);
  color: var(--color-text-tertiary);
  font-size: 0.8em;
  transition: opacity var(--duration-normal) var(--ease-out);
  text-decoration: none;
}

h2:hover .anchor-link,
h3:hover .anchor-link,
h4:hover .anchor-link {
  opacity: 1;
}

.anchor-link:hover {
  color: var(--color-primary-600);
}

/* ===== 8. 移动端阅读辅助 ===== */
@media (max-width: 768px) {
  .reading-time {
    font-size: var(--text-xs);
  }

  .toc-toggle {
    display: block;
    width: 100%;
    padding: var(--space-3);
    background: var(--color-neutral-100);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    margin-bottom: var(--rhythm-normal);
    min-height: 44px;
  }
}
