/* ============================================================
   arrival.css: Arrival, the journey between pages (phase 3, 2026-11-01)
   ============================================================
   Cross-document View Transitions for every same-language link on the
   site. arrival.js picks the choreography on the page you reach, by a
   class on <html>: arr-in (through a door), arr-out (folding back into
   it), arr-base (blooming out of the spot you touched), arr-back (Back
   with no door), arr-fade (reduced motion). split-locales.mjs injects this
   file and arrival.js into every page.
   Browsers without cross-document View Transitions ignore `@view-transition`
   and navigate as they always have.
   ============================================================ */

@view-transition { navigation: auto; }

:root {
  --arr-in-dur: 980ms;
  --arr-out-dur: 720ms;
  --arr-base-dur: 480ms;
  /* a walk: unhurried start, a soft landing */
  --arr-ease: cubic-bezier(0.6, 0.02, 0.16, 1);
  --arr-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* The two page snapshots are laid one over the other, never added together
   (the default plus-lighter would glow where they overlap), and each is
   backed by the night, so WebKit's see-through gaps never show the other. */
html.arr-in::view-transition-old(root),
html.arr-in::view-transition-new(root),
html.arr-out::view-transition-old(root),
html.arr-out::view-transition-new(root),
html.arr-base::view-transition-old(root),
html.arr-base::view-transition-new(root) {
  mix-blend-mode: normal;
  background: #131f52;
  transform-origin: 0 0;
}

/* Fixed furniture (the bell, the wordmark, the EN|JP pill) stays where it
   is while the page changes beneath it. */
::view-transition-group(arrival-bell),
::view-transition-group(arrival-mark),
::view-transition-group(arrival-lang) {
  animation-duration: var(--arr-base-dur);
  animation-timing-function: var(--arr-ease-out);
}

/* ── in: through the door ───────────────────────────────────
   The place you are in comes toward you, centred on the door, and only
   softly darkens (a step into a doorway, not a lights-down: the 0.35 dim
   of the prototype read as a modal). The new page starts as a window the
   shape of the door, around its own head art, sitting on the door; it
   fades up over the painted door, grows with it, and then opens to the
   whole page. */
html.arr-in::view-transition-old(root) {
  animation: arr-zoom-in var(--arr-in-dur) var(--arr-ease) both;
}
html.arr-in::view-transition-new(root) {
  animation:
    arr-grow var(--arr-in-dur) var(--arr-ease) both,
    arr-open var(--arr-in-dur) var(--arr-ease) both,
    arr-show calc(var(--arr-in-dur) * 0.36) ease-out both;
}
@keyframes arr-zoom-in {
  from { transform: translate(0px, 0px) scale(1); filter: brightness(1); }
  to   { transform: var(--arr-zoom); filter: brightness(0.9); }
}
@keyframes arr-grow {
  from { transform: var(--arr-map); }
  to   { transform: translate(0px, 0px) scale(1); }
}
@keyframes arr-open {
  0%, 46% { clip-path: inset(var(--arr-t) var(--arr-rr) var(--arr-b) var(--arr-l) var(--arr-round)); }
  100%    { clip-path: inset(0px 0px 0px 0px round 0px 0px 0px 0px / 0px 0px 0px 0px); }
}
@keyframes arr-show {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* The painting that travels (arrival-art): the door's picture and its
   counterpart in the head, named by arrival.js for this one navigation.
   It flies on the same clock and curve as the page around it, so it stays
   glued inside the opening; where the two are the same painting the swap
   between them is invisible, otherwise the door crossfades into the head. */
html.arr-in::view-transition-group(arrival-art) {
  animation-duration: var(--arr-in-dur);
  animation-timing-function: var(--arr-ease);
}
html.arr-out::view-transition-group(arrival-art) {
  animation-duration: var(--arr-out-dur);
  animation-timing-function: var(--arr-ease);
}
html.arr-in::view-transition-old(arrival-art),
html.arr-in::view-transition-new(arrival-art),
html.arr-out::view-transition-old(arrival-art),
html.arr-out::view-transition-new(arrival-art) {
  animation-duration: calc(var(--arr-in-dur) * 0.45);
}
html.arr-out::view-transition-group(arrival-art) { z-index: 2; }
/* A match is one painting in two sizes: the door's picture carries the whole
   flight, and the head's own (sharper) copy settles over it at the end.
   (WebKit captures the new page before its head picture has painted, so a
   crossfade at the start would fly an empty frame.) */
html.arr-match::view-transition-old(arrival-art),
html.arr-match::view-transition-new(arrival-art) { mix-blend-mode: normal; }
html.arr-match::view-transition-old(arrival-art) { animation: none; opacity: 1; height: 100%; object-fit: contain; }
html.arr-match::view-transition-new(arrival-art) { height: 100%; object-fit: contain; }
html.arr-match.arr-in::view-transition-new(arrival-art) {
  animation: arr-show calc(var(--arr-in-dur) * 0.25) ease-out calc(var(--arr-in-dur) * 0.75) both;
}
html.arr-match.arr-out::view-transition-new(arrival-art) {
  animation: arr-show calc(var(--arr-out-dur) * 0.25) ease-out calc(var(--arr-out-dur) * 0.75) both;
}

/* While a transition runs, pinned sheets cast a box-shadow instead of the
   kit's two drop-shadow filters (same offsets, blur and colour; a sheet is a
   rectangle, so they look alike). WebKit redraws the arriving page on every
   frame of the transition, and on Coloring and Letter paper (about twenty
   filtered sheets, the head pile fanning out) re-rasterising those filters
   cut the transition to 3-10 frames a second (measured, 2026-11-02). The
   filter comes back the moment the transition ends. */
html:is(.arr-in, .arr-out, .arr-base, .arr-back, .arr-fade) .sb-sheet {
  filter: none;
  box-shadow: 0 18px 22px rgba(4, 8, 32, 0.5), 0 3px 4px rgba(4, 8, 32, 0.35);
}

/* ── out: back into the door ────────────────────────────────
   The page closes around its head art, shrinks back onto the door it came
   out of and fades into it; the place behind settles back around you. */
html.arr-out::view-transition-old(root) {
  z-index: 1;
  animation:
    arr-shrink var(--arr-out-dur) var(--arr-ease) both,
    arr-close var(--arr-out-dur) var(--arr-ease) both,
    arr-hide var(--arr-out-dur) ease-in both;
}
html.arr-out::view-transition-new(root) {
  animation: arr-zoom-out var(--arr-out-dur) var(--arr-ease) both;
}
@keyframes arr-shrink {
  from { transform: translate(0px, 0px) scale(1); }
  to   { transform: var(--arr-map); }
}
@keyframes arr-close {
  0%       { clip-path: inset(0px 0px 0px 0px round 0px 0px 0px 0px / 0px 0px 0px 0px); }
  48%, 100% { clip-path: inset(var(--arr-t) var(--arr-rr) var(--arr-b) var(--arr-l) var(--arr-round)); }
}
@keyframes arr-hide {
  0%, 70% { opacity: 1; }
  100%    { opacity: 0; }
}
@keyframes arr-zoom-out {
  from { transform: var(--arr-zoom); filter: brightness(0.9); }
  to   { transform: translate(0px, 0px) scale(1); filter: brightness(1); }
}

/* ── base: every other link ─────────────────────────────────
   The new page blooms out of the spot you touched, over the same sky:
   where the two pages share the night, nothing moves at all. */
html.arr-base::view-transition-old(root) {
  animation: arr-dim var(--arr-base-dur) var(--arr-ease-out) both;
}
html.arr-base::view-transition-new(root) {
  animation:
    arr-bloom var(--arr-base-dur) var(--arr-ease-out) both,
    arr-show calc(var(--arr-base-dur) * 0.55) ease-out both;
}
@keyframes arr-bloom {
  from { clip-path: circle(0px at var(--arr-x) var(--arr-y)); }
  to   { clip-path: circle(var(--arr-r) at var(--arr-x) var(--arr-y)); }
}
@keyframes arr-dim {
  from { filter: brightness(1); }
  to   { filter: brightness(0.86); }
}

/* ── back with no door, and reduced motion: a crossfade ─── */
html.arr-back::view-transition-old(root),
html.arr-back::view-transition-new(root) {
  animation-duration: 340ms;
  animation-timing-function: ease;
}
html.arr-fade::view-transition-group(*),
html.arr-fade::view-transition-old(*),
html.arr-fade::view-transition-new(*) {
  animation-duration: 180ms;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-duration: 180ms !important;
    animation-timing-function: ease !important;
  }
  ::view-transition-old(root) { animation-name: -ua-view-transition-fade-out !important; transform: none !important; filter: none !important; }
  ::view-transition-new(root) { animation-name: -ua-view-transition-fade-in !important; clip-path: none !important; transform: none !important; }
}
