/* DIGITHRONEX · The Cut · invisible cuts. Every page change is a cut hidden inside a camera move, the way editors
   hide cuts in a long take, so the whole site plays as one shot. The page you leave notes which cut the link asked
   for; the page you arrive on plays it (Base.astro's head script sets the type):
   - dx-next / dx-prev  next door: the next page in the running order waits to the right, as the next shot waits on
                        a timeline, and slides in (the one before comes in from the left, going back)
   - dx-push            through the picture you pressed: it grows until it's the next page (a[data-cut="push"])
   - dx-whip-l / -r     a whip pan, for jumps across the site and the menu: the cut hides in the motion
   - dx-glass           Start a project: the glass slab crosses in front of the lens at 45° and the page changes behind it
   - dx-same            the next page's opening was already on screen (the post-credits scene): nothing moves; the last
                        frame holds until the new page's film shows the same moment (title-window.js lets it go)
   The top bar never moves: it's drawn live on top through every cut. Browsers without cross-page transitions get
   an instant cut. With reduced motion, every change is an instant cut. Loaded on every page, after its styles. */

@view-transition { navigation: auto; }

.topbar { view-transition-name: dx-bar; }
::view-transition-group(dx-bar) { animation: none; }
::view-transition-old(dx-bar) { display: none; }
::view-transition-new(dx-bar) { animation: none; }

/* no cut chosen: a plain cut */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* Same: the page you left stays on screen, still, until the film on this page has found the moment it was showing,
   then it's gone at once. title-window.js ends the hold the moment the film shows it; never longer than 20 frames. */
html:active-view-transition-type(dx-same)::view-transition-old(root) { animation: dx-hold 833ms steps(1, end) both; }
@keyframes dx-hold { from, to { opacity: 1; } }

/* Next door: 22 frames, with the weight of the site's own scroll. The camera moves right to the next page in the running
   order (left, going back); the post-credits scene makes the same move inside the page (next-scene.js). */
html:active-view-transition-type(dx-next)::view-transition-old(root) { animation: dx-leave-left 917ms cubic-bezier(.65, 0, .25, 1) both; }
html:active-view-transition-type(dx-next)::view-transition-new(root) { animation: dx-enter-right 917ms cubic-bezier(.65, 0, .25, 1) both; }
html:active-view-transition-type(dx-prev)::view-transition-old(root) { animation: dx-leave-right 917ms cubic-bezier(.65, 0, .25, 1) both; }
html:active-view-transition-type(dx-prev)::view-transition-new(root) { animation: dx-enter-left 917ms cubic-bezier(.65, 0, .25, 1) both; }
@keyframes dx-leave-left { to { transform: translateX(-100%); } }
@keyframes dx-enter-right { from { transform: translateX(100%); } }
@keyframes dx-leave-right { to { transform: translateX(100%); } }
@keyframes dx-enter-left { from { transform: translateX(-100%); } }

/* Push through the frame: 20 frames. The page you leave grows around the picture you pressed, and the next page
   shows through a window that is exactly that picture, brand cut and all, growing with it. The head script
   measures the picture and the scale that makes it fill the screen (--dx-*). */
html:active-view-transition-type(dx-push)::view-transition-old(root) {
  transform-origin: var(--dx-ox, 50%) var(--dx-oy, 50%);
  animation: dx-push-out 833ms cubic-bezier(.6, 0, .2, 1) both;
}
html:active-view-transition-type(dx-push)::view-transition-new(root) { animation: dx-push-in 833ms cubic-bezier(.6, 0, .2, 1) both; }
@keyframes dx-push-out { 0% { transform: scale(1); opacity: 1; } 82% { opacity: 1; } 100% { transform: scale(var(--dx-s, 3)); opacity: 0; } }
@keyframes dx-push-in {
  from { clip-path: polygon(var(--dx-l) var(--dx-t), calc(var(--dx-r) - var(--dx-c)) var(--dx-t), var(--dx-r) calc(var(--dx-t) + var(--dx-c)), var(--dx-r) var(--dx-b), var(--dx-l) var(--dx-b)); }
  to { clip-path: polygon(var(--dx-l2) var(--dx-t2), calc(var(--dx-r2) - var(--dx-c2)) var(--dx-t2), var(--dx-r2) calc(var(--dx-t2) + var(--dx-c2)), var(--dx-r2) var(--dx-b2), var(--dx-l2) var(--dx-b2)); }
}

/* A script carries itself onto the next page (the blog, 18 October 2026): the title page you pressed moves, turns
   square and settles exactly where the article's title page lies, while everything else dissolves under it.
   18 frames. blog-page.js names the page you pressed; the article names its own only when it's reached this way. */
html:active-view-transition-type(dx-script)::view-transition-old(root) { animation: dx-dissolve-out 500ms cubic-bezier(.6, 0, .2, 1) both; }
html:active-view-transition-type(dx-script)::view-transition-new(root) { animation: dx-dissolve-in 500ms cubic-bezier(.6, 0, .2, 1) both; }
html:active-view-transition-type(dx-script)::view-transition-group(dx-script) { z-index: 40; animation-duration: 750ms; animation-timing-function: cubic-bezier(.65, 0, .25, 1); }
html:active-view-transition-type(dx-script)::view-transition-old(dx-script) { animation: none; opacity: 0; }
html:active-view-transition-type(dx-script)::view-transition-new(dx-script) { animation: none; }
html:active-view-transition-type(dx-script) .open-page .tp { view-transition-name: dx-script; }
@keyframes dx-dissolve-out { to { opacity: 0; } }
@keyframes dx-dissolve-in { from { opacity: 0; } }

/* Whip pan: 10 frames, fastest in the middle, where the motion blur peaks and the cut hides */
html:active-view-transition-type(dx-whip-l)::view-transition-old(root) { animation: dx-whip-out-l 417ms cubic-bezier(.7, 0, .3, 1) both; }
html:active-view-transition-type(dx-whip-l)::view-transition-new(root) { animation: dx-whip-in-l 417ms cubic-bezier(.7, 0, .3, 1) both; }
html:active-view-transition-type(dx-whip-r)::view-transition-old(root) { animation: dx-whip-out-r 417ms cubic-bezier(.7, 0, .3, 1) both; }
html:active-view-transition-type(dx-whip-r)::view-transition-new(root) { animation: dx-whip-in-r 417ms cubic-bezier(.7, 0, .3, 1) both; }
@keyframes dx-whip-out-l { 0% { transform: none; filter: blur(0); } 50% { filter: blur(18px); } 100% { transform: translateX(-100%); filter: blur(18px); } }
@keyframes dx-whip-in-l { 0% { transform: translateX(100%); filter: blur(18px); } 50% { filter: blur(18px); } 100% { transform: none; filter: blur(0); } }
@keyframes dx-whip-out-r { 0% { transform: none; filter: blur(0); } 50% { filter: blur(18px); } 100% { transform: translateX(100%); filter: blur(18px); } }
@keyframes dx-whip-in-r { 0% { transform: translateX(-100%); filter: blur(18px); } 50% { filter: blur(18px); } 100% { transform: none; filter: blur(0); } }

/* Glass pass: 24 frames. A slab of graphite glass, cut at 45° with its polished edge catching the light, crosses in
   front of the lens; while it covers the whole screen the page changes behind it. It passes under the bar. */
html:active-view-transition-type(dx-glass)::view-transition-old(root) { animation: dx-out-at-half 1000ms linear both; }
html:active-view-transition-type(dx-glass)::view-transition-new(root) { animation: dx-in-at-half 1000ms linear both; }
@keyframes dx-out-at-half { 0%, 49.9% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes dx-in-at-half { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
.dx-slab {
  display: none; position: fixed; top: 0; left: 0; z-index: 45; width: calc(100vw + 200vh); height: 100vh; pointer-events: none;
  view-transition-name: dx-slab;
  clip-path: polygon(0 0, calc(100% - 100vh) 0, 100% 100%, 100vh 100%); /* both edges lean like the cut on our glass */
  background:
    linear-gradient(to top right, transparent calc(50% - 2px), rgba(214, 233, 255, .95) calc(50% - 2px), rgba(214, 233, 255, .95) 50%, transparent 50%) right top / 100vh 100vh no-repeat,
    linear-gradient(to top right, transparent 0, rgba(1, 128, 255, .22) 48%, transparent 50%) right top / 100vh 100vh no-repeat,
    linear-gradient(90deg, rgba(20, 23, 29, .97), rgba(30, 35, 44, .94) 55%, rgba(16, 18, 23, .98));
}
html.dx-glass .dx-slab { display: block; }
::view-transition-group(dx-slab) { animation: none; }
::view-transition-new(dx-slab) { animation: dx-slab-pass 1000ms cubic-bezier(.45, 0, .55, 1) both; }
@keyframes dx-slab-pass { from { transform: translateX(-100%); } to { transform: translateX(100vw); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
