/* 章节切换时由页首承载转场，切换学习标签时正文保持平稳。 */
.chapter-content {
  animation: none;
}

.reading-progress {
  display: none;
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--reading-progress, 0));
  transform-origin: left center;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) {
    --cinema-ease: cubic-bezier(.22, .65, .3, 1);
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .reading-progress {
    display: block;
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .cinema-reveal {
    animation: cinema-reveal 500ms var(--cinema-ease) var(--cinema-stagger, 0ms) backwards;
  }

  /* 键盘焦点进入时立即显示完整内容。 */
  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .cinema-reveal:focus-within {
    animation: none;
  }

  .curriculum-grid > .chapter-card:nth-child(2n) {
    --cinema-stagger: 40ms;
  }

  @media (min-width: 901px) {
    .curriculum-grid > .chapter-card:nth-child(4n + 3) {
      --cinema-stagger: 80ms;
    }
    .curriculum-grid > .chapter-card:nth-child(4n + 4) {
      --cinema-stagger: 120ms;
    }
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .cinema-route-enter > img {
    animation: cinema-chapter-image 700ms var(--cinema-ease);
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .cinema-route-enter > :is(.eyebrow, h1, .chapter-subtitle) {
    animation: cinema-reveal 460ms var(--cinema-ease) backwards;
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .cinema-route-enter > .chapter-subtitle {
    animation-delay: 45ms;
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) :is(.button, .quiz-option, .reader-controls button, .page-grid button) {
    transition: background-color 180ms, border-color 180ms, color 180ms, transform 190ms var(--cinema-ease);
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) :is(.button, .quiz-option, .reader-controls button, .page-grid button):not(:disabled):active {
    transform: translateY(1px) scale(.985);
    transition-duration: 100ms;
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) :is(.button .arrow, .chapter-card .card-arrow) {
    transition: background-color 180ms, color 180ms, transform 240ms var(--cinema-ease);
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .button:focus-visible .arrow {
    transform: translate(3px, -2px);
  }

  html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .chapter-card:focus-visible .card-arrow {
    transform: translate(2px, -2px);
    background-color: var(--accent);
    color: var(--accentInk);
  }

  @media (hover: hover) and (pointer: fine) {
    html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .button:hover .arrow {
      transform: translate(3px, -2px);
    }
    html.cinema-motion-ready:not(.reading, .no-motion, .reduced-motion) .chapter-card:hover .card-arrow {
      transform: translate(2px, -2px);
      background-color: var(--accent);
      color: var(--accentInk);
    }
  }
}

@keyframes cinema-reveal {
  from { opacity: .64; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cinema-chapter-image {
  from { transform: scale(1.055); }
  to { transform: scale(1); }
}

@media print {
  html .reading-progress { display: none !important; }
  html :is(.cinema-reveal, .cinema-route-enter > *) { animation: none !important; }
}
