/* =========================================================================
   RHYTHM — the part that makes the site feel like a piece of music.
   Not a metaphor in the copy: a tempo every transition shares, dynamics that
   alternate loud and quiet, a hook that returns, and a resolve at the end of
   every page. Nothing here plays a sound.
   ========================================================================= */

:root {
  /* One pulse for the whole site. Beat = a state change, phrase = an
     entrance, breath = a section arriving. */
  --beat: 160ms;
  --phrase: 420ms;
  --breath: 900ms;

  /* One curve. Everything moves on the same rubber band. */
  --tempo: cubic-bezier(0.16, 0.84, 0.24, 1);

  /* Dynamics: how far a thing travels when it arrives. */
  --rise: 14px;
}

/* ---------- the whole site keeps time ------------------------------------ */

a,
button,
.btn,
.chip,
.card,
.list-item,
.icon-btn,
.segmented button,
.entry__link,
.contents__row {
  transition-duration: var(--beat);
  transition-timing-function: var(--tempo);
}

/* ---------- entrances ---------------------------------------------------
   A phrase, not a switch: the block rises a hand's width and settles. Large
   type travels further and takes longer than small type, the way a low note
   rings longer than a high one.
   ------------------------------------------------------------------------ */

/* Tune the existing reveal (base.css owns the mechanism) rather than
   re-declaring it: same trigger, slower phrase, longer travel for big type. */
.js [data-reveal].is-armed {
  transform: translateY(var(--rise, 14px));
  transition:
    opacity var(--phrase) var(--tempo),
    transform var(--phrase) var(--tempo);
  transition-delay: var(--reveal-delay, 0ms);
}

.js h1[data-reveal].is-armed,
.js .md-headline-large[data-reveal].is-armed,
.js .md-display[data-reveal].is-armed {
  --rise: 22px;
  transition-duration: var(--breath);
}

/* ---------- reading rhythm ----------------------------------------------
   Line breaks that do not leave a widow, a measure that stays singable, and
   hyphens only where the measure is narrow enough to need them.
   ------------------------------------------------------------------------ */

.body-copy p,
.page-head__deck,
.case-body__text p {
  text-wrap: pretty;
  max-width: 68ch;
}

@media (min-width: 900px) {
  .body-copy p { hyphens: auto; }
}

/* a paragraph that opens a movement gets a touch more air after it */
.body-copy p + p { margin-top: 1.15em; }

/* ---------- the coda -----------------------------------------------------
   Every page ends quietly: the hook returns as a single mark, one line, and
   a lot of air. This is the resolve — the reason a page does not feel like it
   stopped, but like it finished.
   ------------------------------------------------------------------------ */

.coda {
  padding-block: clamp(56px, 9vw, 132px) clamp(40px, 6vw, 88px);
  text-align: center;
}

.coda__mark {
  font-size: 0.75rem;
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0;
  margin-bottom: clamp(18px, 2.4vw, 28px);
}

.coda__line {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.028em;
  font-weight: 460;
  color: var(--ink);
  max-width: 26ch;
  margin-inline: auto;
  text-wrap: balance;
}

/* ---------- the quiet after ---------------------------------------------
   When the page is left alone nothing moves: no looping animation, no
   carousel, no blinking caret anywhere on the site.
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  :root {
    --beat: 1ms;
    --phrase: 1ms;
    --breath: 1ms;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* ---------- high contrast and forced colours ---------------------------- */

@media (prefers-contrast: more) {
  :root {
    --rule: var(--ink-faint);
    --rule-strong: var(--ink);
  }
  [data-reveal] { opacity: 1; transform: none; }
}

@media (forced-colors: active) {
  .coda__mark,
  .kicker,
  .section-label { forced-color-adjust: none; color: CanvasText; }
  .btn,
  .chip,
  .card { border: 1px solid ButtonBorder; }
}
