/* 80-motion: DESIGN 6 (M1–M12) pre-states, keyframes, transitions; hook contract STYLEGUIDE 6. Notes: docs/CSS-NOTES.md
   Every pre-state is nested under html.js / html.ov-motion:not(.ov-reduced) inside prefers-reduced-motion: no-preference; only opacity,
   transform, clip-path, background-size, fill-opacity and colour ever animate. */

/* keyframes: every "to" is the settled value, so fill-mode: both leaves nothing behind */
@keyframes ov-word        { from { opacity: 0; transform: translateY(.3em); }                       to { opacity: 1; transform: none; } }
@keyframes ov-rise        { from { opacity: 0; transform: translateY(16px); }                       to { opacity: 1; transform: none; } }
@keyframes ov-rise-settle { from { opacity: 0; transform: translate(-6px, 16px) rotate(-.4deg); }   to { opacity: 1; transform: none; } }
@keyframes ov-draw        { from { transform: scaleX(0); }                                          to { transform: scaleX(1); } }
@keyframes ov-fade        { from { opacity: 0; }                                                    to { opacity: 1; } }
@keyframes ov-unveil      { from { clip-path: inset(100% 0 0 0 round var(--arch)); }                to { clip-path: inset(0 0 0 0 round var(--arch)); } }
@keyframes ov-mask-up   { from { -webkit-mask-size: 100% 0; mask-size: 100% 0; } to { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; } }
@keyframes ov-trace     { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ov-wipe        { from { clip-path: inset(0 100% 0 0); }                                  to { clip-path: inset(0 0 0 0); } }

/* M9 header: ov.js parks a 25px sentinel at the top of <body>; off screen = header.is-scrolled (shadow in 20-layout) */
.ov-sentinel { position: absolute; top: 0; left: 0; width: 1px; height: 25px; pointer-events: none; visibility: hidden; }

/* 180ms cross-fade between same-origin pages; off under reduced motion; ov.js skips it when ovMotion is paused */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: cubic-bezier(.65, 0, .35, 1); }

@media (prefers-reduced-motion: no-preference) {

  /* M1 headline hold + word reveal, M2 arch unveil + arc wipe: armed by html.js (inline head script, before first paint); ov.js refines */
  html.js:not(.ov-reduced) {
    .ov-hero .ov-hero__title:not(.is-split) { animation: ov-fade 500ms var(--ease-out) 1200ms both; }
    .ov-hero__title.is-split .ov-w { display: inline-block; opacity: 0; transform: translateY(.3em); }
    .ov-hero__title.is-split.is-on .ov-w { animation: ov-word var(--t-reveal) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms); }
    .ov-hero .is-style-ov-arch img, .ov-hero .is-style-ov-arch-keyline img { animation: ov-unveil var(--t-draw) var(--ease-inout) 250ms both; }
    .ov-hero .is-style-ov-arch:not(.is-style-ov-arch-keyline) img, .ov-hero figure.ov-arch > :is(img, video) { animation: ov-mask-up var(--t-draw) var(--ease-inout) 250ms both; -webkit-mask: linear-gradient(#000, #000) 0 100% / 100% 0 no-repeat; mask: linear-gradient(#000, #000) 0 100% / 100% 0 no-repeat; }
    .ov-frame-line path { stroke-dasharray: 1; animation: ov-trace calc(var(--t-draw) + 400ms) var(--ease-inout) 250ms both; }
    .ov-hero__media .ov-arc--hairline polygon { opacity: 0; animation: ov-fade 600ms var(--ease-out) 3200ms both; }   /* failsafe: ov.js flies them in; if it never runs they still appear */
    .ov-hero.is-waiting :is(.is-style-ov-arch img, .is-style-ov-arch-keyline img, figure.ov-arch > :is(img, video), .ov-frame-line path) { animation-play-state: paused; }
    /* phones: the portrait is first under the fold, so it opens in 700ms with no delay (ov.js skips the decode hold below 782) */
    @media (max-width: 781px) {
      .ov-hero .is-style-ov-arch img, .ov-hero .is-style-ov-arch-keyline img, .ov-hero figure.ov-arch > :is(img, video), .ov-frame-line path { animation-duration: var(--t-slow); animation-delay: 0ms; }
    }
  }

  html.ov-motion:not(.ov-reduced) {
    /* M3 section reveal (engine A: scroll-driven; engine B: IntersectionObserver adds .is-in) + M4 heading settle. Opt-outs: .ov-static, .is-settled, rules */
    @supports (animation-timeline: view()) {
      .ov-chapter > .ov-inner > :not(.ov-static, .is-settled, .is-style-ov-rule) {
        animation: ov-rise var(--ease-out) both;
        animation-timeline: view();
        animation-range: entry 0% entry 35%;
        animation-range: entry 0% entry clamp(120px, 35%, 260px);
      }
      .ov-chapter > .ov-inner > h2:not(.ov-static, .is-settled) { animation-name: ov-rise-settle; animation-timing-function: var(--ease-settle); }
    }
    @supports not (animation-timeline: view()) {
      .ov-chapter:not(.is-in) > .ov-inner > :not(.ov-static, .is-settled, .is-style-ov-rule) { opacity: 0; transform: translateY(16px); }
      .ov-chapter:not(.is-in) > .ov-inner > h2:not(.ov-static, .is-settled) { transform: translate(-6px, 16px) rotate(-.4deg); }
      .ov-chapter.is-in > .ov-inner > :not(.ov-static, .is-settled, .is-style-ov-rule) { animation: ov-rise var(--t-reveal) var(--ease-out) both; }
      .ov-chapter.is-in > .ov-inner > h2:not(.ov-static, .is-settled) { animation: ov-rise-settle 1000ms var(--ease-settle) both; }
      .ov-chapter.is-in > .ov-inner > :nth-child(2) { animation-delay: var(--stagger); }
      .ov-chapter.is-in > .ov-inner > :nth-child(3) { animation-delay: calc(2 * var(--stagger)); }
      .ov-chapter.is-in > .ov-inner > :nth-child(4) { animation-delay: calc(3 * var(--stagger)); }
      .ov-chapter.is-in > .ov-inner > :nth-child(n+5) { animation-delay: calc(4 * var(--stagger)); }
    }
    /* M4 nested h2s (split column, card, row) and the CTA h2 */
    :is(.ov-chapter, .ov-cta) :not(.ov-inner) > h2:not(.ov-static, .is-settled), .ov-cta > .ov-inner > h2:not(.ov-static, .is-settled) { transition: transform 1000ms var(--ease-settle); }
    :is(.ov-chapter, .ov-cta):not(.is-in) :not(.ov-inner) > h2:not(.ov-static, .is-settled), .ov-cta:not(.is-in) > .ov-inner > h2:not(.ov-static, .is-settled) { transform: translateX(-6px) rotate(-.4deg); }
    /* M5 hairline draw: rules, the facts-row top rule, hairline/sage arcs (ov.js adds .is-in); the statement's second rule follows by 200ms */
    .is-style-ov-rule:not(.is-in, .is-settled, .ov-static) { transform: scaleX(0); }
    .is-style-ov-rule.is-in:not(.is-settled) { animation: ov-draw var(--t-draw) var(--ease-inout) both; }
    .ov-statement + .is-style-ov-rule.is-in:not(.is-settled) { animation-delay: 200ms; }
    .ov-facts:not(.is-in, .is-settled, .ov-static)::before { transform: scaleX(0); }
    .ov-facts.is-in:not(.is-settled)::before { animation: ov-draw var(--t-draw) var(--ease-inout) both; }
    :is(.ov-chapter, .ov-cta) :is(.ov-arc--hairline, .ov-arc--sage) { clip-path: inset(0 0 0 0); transition: clip-path var(--t-draw) var(--ease-inout) 200ms; }
    :is(.ov-chapter, .ov-cta):not(.is-in) :is(.ov-arc--hairline, .ov-arc--sage) { clip-path: inset(0 100% 0 0); }
    /* M7 chapter mark fills 300ms after it has risen */
    .ov-chapter-mark__hex polygon { transition: fill-opacity 400ms var(--ease-out) 300ms; }
    .ov-chapter:not(.is-in) .ov-chapter-mark__hex polygon { fill-opacity: 0; }
    /* M8 lit arc: each hexagon grows in place from small and fades up, left to right, 110ms apart */
    .ov-arc--lit polygon { transform-box: fill-box; transform-origin: center; transition: opacity 700ms var(--ease-out), transform 1000ms var(--ease-settle); }
    .ov-arc--lit:not(.is-in) polygon { opacity: 0; transform: scale(.15); }
    .ov-arc--lit.is-out polygon { transition: none; }
    .ov-arc--lit polygon:nth-child(2) { transition-delay: 110ms; }
    .ov-arc--lit polygon:nth-child(3) { transition-delay: 220ms; }
    .ov-arc--lit polygon:nth-child(4) { transition-delay: 330ms; }
    .ov-arc--lit polygon:nth-child(5) { transition-delay: 440ms; }
    .ov-arc--lit polygon:nth-child(6) { transition-delay: 550ms; }
    .ov-arc--lit polygon:nth-child(7) { transition-delay: 660ms; }
    .ov-arc--lit polygon:nth-child(8) { transition-delay: 770ms; }
    .ov-arc--lit polygon:nth-child(9) { transition-delay: 880ms; }
    /* M10 accordion content fades in (marker in 40-blocks; height never animates); M11 video fade uses the house easing */
    .wp-block-details[open] > :not(summary) { animation: ov-fade var(--t-base) var(--ease-out) both; }
    .ov-slot__video { transition-timing-function: var(--ease-out); }
  }
}

/* settled, always: anything ov.js marked is-settled (on the first screen at load) */
html.ov-motion .is-settled, html.ov-motion .is-settled::before { animation: none; transition: none; opacity: 1; transform: none; }

/* reduced motion (OS preference or ovMotion paused): hover/focus moves become colour-only (M6, M12); 10-base removes every transition/animation */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .wp-block-button .wp-block-button__link:hover::after, .ov-textlink a:hover::after, .ov-btn:hover .ov-btn__arrow,
  .ov-row:hover .ov-row__title a::after, .ov-row:focus-within .ov-row__title a::after,
  .ov-row:hover .is-style-ov-plate img, .ov-row:focus-within .is-style-ov-plate img { transform: none; }
}
html.ov-reduced *, html.ov-reduced *::before, html.ov-reduced *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
html.ov-reduced .wp-block-button .wp-block-button__link:hover::after, html.ov-reduced .ov-textlink a:hover::after, html.ov-reduced .ov-btn:hover .ov-btn__arrow,
html.ov-reduced .ov-row:hover .ov-row__title a::after, html.ov-reduced .ov-row:focus-within .ov-row__title a::after,
html.ov-reduced .ov-row:hover .is-style-ov-plate img, html.ov-reduced .ov-row:focus-within .is-style-ov-plate img { transform: none; }

/* print: paper never waits for a scroll */
@media print {
  .ov-hero__title, .ov-w, .ov-chapter > .ov-inner > *, .ov-chapter h2, .ov-cta h2, .is-style-ov-rule, .ov-facts::before, .ov-chapter-mark__hex polygon, .ov-arc--lit polygon,
  .ov-hero img, .ov-hero video, .ov-hero figure.ov-arch, .ov-arc--hairline, .ov-arc--hairline polygon, .ov-arc--sage, .ov-frame-line path { -webkit-mask: none !important; mask: none !important; stroke-dasharray: none !important; animation: none !important; transition: none !important; opacity: 1 !important; transform: none !important; clip-path: none !important; fill-opacity: 1 !important; }
}
