/* Cross-document transitions: every public page must load this file, both ends opt in.
   Two choreographies (types are set by js/indigo/page-transitions.mjs):
   - default (homepage <-> service page): the service media and title morph into place
     while the page dims to ink and the new page rises in under them.
   - "wipe" (reading page <-> reading page): an ink curtain crosses the content,
     right to left ("back" mirrors it), while the header stays still.
   The root snapshot carries the page body: a named <main> would be captured at its
   full scrolled height and fly thousands of pixels between two scroll positions. */
@view-transition { navigation: auto; }

body > :is(.indigo-header, .cinema-header, header.site) { view-transition-name: studio-header; }
body > header :is(.indigo-wordmark, .cinema-wordmark, .wordmark) { view-transition-name: studio-wordmark; }
body > main h1 { view-transition-name: page-title; }
[data-vt="title-ads"] { view-transition-name: title-ads; }
[data-vt="title-web"] { view-transition-name: title-web; }
[data-vt="title-content"] { view-transition-name: title-content; }
[data-vt="title-automation"] { view-transition-name: title-automation; }
[data-vt="title-persona"] { view-transition-name: title-persona; }
[data-vt="title-about"] { view-transition-name: title-about; }
[data-vt="media-ads"] { view-transition-name: media-ads; }
[data-vt="media-web"] { view-transition-name: media-web; }
[data-vt="media-content"] { view-transition-name: media-content; }
[data-vt="media-automation"] { view-transition-name: media-automation; }
[data-vt="media-persona"] { view-transition-name: media-persona; }
[data-vt^="media-"] { view-transition-class: vt-media; }
[data-vt^="title-"], body > main h1 { view-transition-class: vt-title; }

/* Default choreography. */
::view-transition-group(*) { animation-duration: 680ms; animation-timing-function: cubic-bezier(.7, 0, .15, 1); }
::view-transition-group(root) { background: var(--deep, #1e2150); }
::view-transition-old(root) { animation: vt-dim 300ms cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: vt-rise 520ms 220ms cubic-bezier(.2, .7, .2, 1) both; }
/* Media keeps filling its box while it changes size, instead of stretching. */
::view-transition-old(*.vt-media), ::view-transition-new(*.vt-media) { width: 100%; height: 100%; object-fit: cover; }
::view-transition-new(*.vt-media) { animation-duration: 680ms; }
/* A snapshot with no partner on the other page leaves or arrives with the page, quickly. */
::view-transition-old(*.vt-media):only-child, ::view-transition-old(*.vt-title):only-child { animation: vt-dim 180ms ease-in both; }
::view-transition-new(*.vt-media):only-child, ::view-transition-new(*.vt-title):only-child { animation: vt-rise 420ms 280ms cubic-bezier(.2, .7, .2, 1) both; }
/* The chrome stays still. */
::view-transition-group(studio-header), ::view-transition-group(studio-wordmark),
::view-transition-old(studio-header), ::view-transition-new(studio-header),
::view-transition-old(studio-wordmark), ::view-transition-new(studio-wordmark) { animation: none; mix-blend-mode: normal; }

/* Wipe: the old page is cut away from the right edge, a band of ink crosses,
   the new page is uncovered right behind it. */
:root:active-view-transition-type(wipe)::view-transition-old(root) { animation: vt-cut-old 440ms cubic-bezier(.75, 0, .3, 1) both; }
:root:active-view-transition-type(wipe)::view-transition-new(root) { animation: vt-cut-new 520ms 120ms cubic-bezier(.6, 0, .2, 1) both; }
:root:active-view-transition-type(wipe)::view-transition-group(*) { animation-duration: 600ms; }
:root:active-view-transition-type(wipe)::view-transition-group(root) { animation: none; }
:root:active-view-transition-type(wipe):active-view-transition-type(back)::view-transition-old(root) { animation-name: vt-cut-old-back; }
:root:active-view-transition-type(wipe):active-view-transition-type(back)::view-transition-new(root) { animation-name: vt-cut-new-back; }
:root:active-view-transition-type(wipe)::view-transition-group(studio-header),
:root:active-view-transition-type(wipe)::view-transition-group(studio-wordmark) { animation: none; }

@keyframes vt-dim { to { opacity: 0; transform: scale(.97); } }
@keyframes vt-rise { from { opacity: 0; transform: translateY(32px); } }
@keyframes vt-cut-old { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 100% 0 0); } }
@keyframes vt-cut-new { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes vt-cut-old-back { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 0 100%); } }
@keyframes vt-cut-new-back { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Fallback where cross-document transitions are missing (js/indigo/page-curtain.mjs):
   an ink curtain enters from the right, covers, and leaves to the left on arrival. */
.page-curtain { position: fixed; inset: 0; z-index: 1000; background: var(--deep, #1e2150); pointer-events: none; transform: translateX(100%); transition: transform 320ms cubic-bezier(.7, 0, .2, 1); }
.page-curtain[data-state="cover"] { transform: none; }
.page-curtain[data-state="leave"] { transform: translateX(-100%); }
@media (prefers-reduced-motion: reduce) { .page-curtain { display: none; } }

/* Snapshots live on the root, outside body: descendant motion rules cannot stop them. */
:root:has(.motion-off, .a11y-nomotion)::view-transition-group(*),
:root:has(.motion-off, .a11y-nomotion)::view-transition-old(*),
:root:has(.motion-off, .a11y-nomotion)::view-transition-new(*) { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
