/* Motion: page titles, scroll reveal, hover life, reading progress.
   Safe by construction: scroll-reveal classes are added by JavaScript, and only to elements that
   start below the fold, so nothing is ever hidden when JavaScript is off or has failed.
   Everything is switched off for visitors who ask for reduced motion. */

@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}
@keyframes line-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Page titles ---------- */
.page-head .breadcrumb,
.article-head .breadcrumb { animation: rise-in 0.8s var(--ease) both; }
.page-head h1,
.article-head h1,
.awards-hero h1,
.error-page h1 { animation: rise-in 0.95s var(--ease) 0.1s both; }
.page-head p,
.article-meta,
.error-page > p { animation: rise-in 0.95s var(--ease) 0.22s both; }

/* The rosette behind each masthead turns very slowly. */
.page-head::before,
.article-head::before,
.error-art { animation: drift 320s linear infinite; }

/* The gold rule under a masthead draws in from the left. */
.page-head::after,
.article-head::after,
.awards-hero::after { transform-origin: left; animation: line-grow 1.4s var(--ease) 0.3s both; }

/* ---------- First-screen entrance on listing pages ----------
   CSS only, so these always end visible (with or without JavaScript). Cards that start below
   the fold are handled by the scroll reveal further down, which switches this off for them. */
@keyframes media-wipe {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0); }
}
.category-links,
.archive-search { animation: rise-in 0.8s var(--ease) 0.15s both; }
.editorial-grid > .story,
.story-grid > .story,
.people-grid > .person-card,
.featureline { animation: rise-in 1s var(--ease) calc(0.3s + var(--n, 0) * 0.12s) both; }
.editorial-grid > :nth-child(2), .story-grid > :nth-child(2), .people-grid > :nth-child(2) { --n: 1; }
.editorial-grid > :nth-child(3), .story-grid > :nth-child(3), .people-grid > :nth-child(3) { --n: 2; }
.story-grid > :nth-child(4), .people-grid > :nth-child(4) { --n: 3; }
.story-grid > :nth-child(5), .people-grid > :nth-child(5) { --n: 4; }
.story-grid > :nth-child(n+6), .people-grid > :nth-child(n+6) { --n: 5; }
.editorial-grid > .story .story-media,
.story-grid > .story .story-media,
.people-grid > .person-card .person-media { animation: media-wipe 1.3s var(--ease) calc(0.4s + var(--n, 0) * 0.12s) both; }

/* ---------- Scroll reveal ---------- */
.asp-reveal {
  opacity: 0;
  transform: translateY(42px);
  transition: opacity 0.95s var(--ease), transform 0.95s var(--ease);
  transition-delay: calc(var(--i, 0) * 80ms);
}
.asp-reveal.is-visible { opacity: 1; transform: none; }
.editorial-grid > .story.asp-reveal,
.story-grid > .story.asp-reveal,
.people-grid > .person-card.asp-reveal,
.featureline.asp-reveal,
.story.asp-reveal .story-media,
.person-card.asp-reveal .person-media { animation: none; }

/* Photographs are drawn in with a wipe as their card appears. */
.asp-reveal .story-media,
.asp-reveal .person-media,
.asp-reveal .more-thumb,
.asp-reveal .featureline .image { clip-path: inset(0 0 100% 0); }
.asp-reveal.is-visible .story-media,
.asp-reveal.is-visible .person-media,
.asp-reveal.is-visible .more-thumb,
.asp-reveal.is-visible .featureline .image {
  clip-path: inset(0);
  transition: clip-path 1.2s var(--ease) calc(var(--i, 0) * 80ms + 150ms);
}

/* Photographs settle in as their card appears. */
.asp-reveal .story-media img,
.asp-reveal .person-media img,
.asp-reveal .more-thumb img,
.asp-reveal .featureline .image img { transform: scale(1.07); }
.asp-reveal.is-visible .story-media img,
.asp-reveal.is-visible .person-media img,
.asp-reveal.is-visible .more-thumb img,
.asp-reveal.is-visible .featureline .image img { transform: none; transition: transform 1.3s var(--ease), filter 0.6s var(--ease); }

/* ---------- Hover life ---------- */
.btn,
.verify-btn { transition: transform 0.25s var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.btn:hover { transform: translateY(-2px); }
.person-card { transition: transform 0.35s var(--ease); }
.person-card:hover { transform: translateY(-5px); }
.story > a h3,
.more-list h3 { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.5s var(--ease), color var(--dur) var(--ease); }
.story > a:hover h3,
.more-list a:hover h3 { background-size: 100% 1px; }

/* ---------- Reading progress (articles) ---------- */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 70;
  width: 100%;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .page-head .breadcrumb, .article-head .breadcrumb,
  .page-head h1, .article-head h1, .awards-hero h1, .error-page h1,
  .page-head p, .article-meta, .error-page > p,
  .page-head::before, .article-head::before, .error-art,
  .page-head::after, .article-head::after, .awards-hero::after,
  .category-links, .archive-search, .featureline,
  .editorial-grid > .story, .story-grid > .story, .people-grid > .person-card,
  .editorial-grid > .story .story-media, .story-grid > .story .story-media,
  .people-grid > .person-card .person-media { animation: none; }
  .asp-reveal .story-media, .asp-reveal .person-media,
  .asp-reveal .more-thumb, .asp-reveal .featureline .image { clip-path: none; }
  .asp-reveal { opacity: 1; transform: none; transition: none; }
  .asp-reveal .story-media img, .asp-reveal .person-media img,
  .asp-reveal .more-thumb img, .asp-reveal .featureline .image img { transform: none; }
  .btn:hover, .person-card:hover { transform: none; }
  .read-progress { display: none; }
}
