/* Paco motion system: see paco-motion.js and docs/MOTION-PLAN.md. Only opacity, translate, scale and clip-path are animated. */
:root { --pm-ease: cubic-bezier(.16, 1, .3, 1); --pm-ease-soft: cubic-bezier(.22, 1, .36, 1); }

/* Hold the page content back for the first frame only. The animation shows it after 1.8 s if the script never runs. */
html.pm-js:not(.pm-ready) main,
html.pm-js:not(.pm-ready) [role="main"] { visibility: hidden; animation: pm-unhide 1ms linear 1800ms forwards; }
@keyframes pm-unhide { to { visibility: visible; } }

/* Header slides in once, on a full page load. */
html.pm-js.pm-first .paco-shared-header { animation: pm-header .8s var(--pm-ease) both; }
@keyframes pm-header { from { opacity: 0; translate: 0 -14px; } to { opacity: 1; translate: 0 0; } }

/* Blocks: fade up. */
.pm-t:not(.pm-in):not(.pm-done) { opacity: 0; translate: 0 26px; }
.pm-t.pm-in:not(.pm-done) {
  opacity: 1; translate: 0 0;
  transition: opacity .9s var(--pm-ease) var(--pm-d, 0ms), translate .9s var(--pm-ease) var(--pm-d, 0ms);
}

/* Images, films and figures: soft clip and settle. */
.pm-m:not(.pm-in):not(.pm-done) { opacity: 0; translate: 0 34px; scale: 1.035; clip-path: inset(0 0 14% 0); }
.pm-m.pm-in:not(.pm-done) {
  opacity: 1; translate: 0 0; scale: 1; clip-path: inset(0 0 0 0);
  transition: opacity 1s var(--pm-ease) var(--pm-d, 0ms), translate 1.1s var(--pm-ease) var(--pm-d, 0ms),
              scale 1.4s var(--pm-ease) var(--pm-d, 0ms), clip-path 1.2s var(--pm-ease) var(--pm-d, 0ms);
}

/* Headings: each word rises out of a mask. The heading block itself stays put. */
.pm-h.pm-t:not(.pm-in):not(.pm-done) { opacity: 1; translate: 0 0; }
.pm-h.pm-t.pm-in:not(.pm-done) { transition: none; }
.pm-w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .14em; margin-bottom: -.14em; }
.pm-wi { display: inline-block; will-change: translate; }
.pm-t:not(.pm-in):not(.pm-done) .pm-wi { translate: 0 112%; }
.pm-t.pm-in:not(.pm-done) .pm-wi {
  translate: 0 0;
  transition: translate .95s var(--pm-ease) calc(var(--pm-d, 0ms) + var(--i, 0) * 55ms);
}
.pm-w:has(.pm-wi) { clip-path: inset(-.1em -.05em -.18em -.05em); }

/* Leaving a page: quick, quiet fade. */
html.pm-leaving main, html.pm-leaving [role="main"], html.pm-leaving .paco-global-footer {
  opacity: 0; translate: 0 -8px; transition: opacity .17s ease-in, translate .17s ease-in;
}

/* Buttons and links: small, consistent feedback. */
.paco-action span[aria-hidden], .paco-action svg { transition: translate .3s var(--pm-ease-soft); }
.paco-action:hover span[aria-hidden], .paco-action:hover svg { translate: 3px -3px; }
.paco-action:active, .mos-button:active, .apps-action:active { scale: .985; }
.paco-action, .mos-button, .apps-action { transition: color .25s, background-color .3s, border-color .3s, scale .18s var(--pm-ease-soft); }
:is(.text-action, .portfolio-text-link, .mc-text-link, .apps-text-link, .paco-footer-grid a) { background-image: linear-gradient(currentColor, currentColor); background-repeat: no-repeat; background-position: 0 100%; background-size: 0 1px; transition: background-size .35s var(--pm-ease-soft), color .2s; }
:is(.text-action, .portfolio-text-link, .mc-text-link, .apps-text-link, .paco-footer-grid a):hover { background-size: 100% 1px; }

/* Cards that lead somewhere: the picture breathes in on hover (precise pointers only). */
@media (hover: hover) and (pointer: fine) {
  :is(.journal-card, .maigia-card, .work-feature, .work-index-card, [class*="show-card"]) :is(img, video) { transition: scale .9s var(--pm-ease); }
  :is(.journal-card, .maigia-card, .work-feature, .work-index-card, [class*="show-card"]):hover :is(img, video) { scale: 1.035; }
}

@media (prefers-reduced-motion: reduce) {
  .pm-t, .pm-m, .pm-wi, .pm-w { opacity: 1 !important; translate: none !important; scale: none !important; clip-path: none !important; transition: none !important; }
  html.pm-js:not(.pm-ready) main { visibility: visible; animation: none; }
  html.pm-leaving main { opacity: 1; translate: none; }
}
@media print { .pm-t, .pm-m, .pm-wi { opacity: 1 !important; translate: none !important; scale: none !important; clip-path: none !important; } }

/* =====================================================================================
   Scenes: richer, world-specific motion on top of the basic reveal above.
   Scroll-linked effects use CSS scroll timelines; browsers without them keep the basic reveal.
   ===================================================================================== */

/* Header: a thin progress line follows how far down the page you are. */
@supports (animation-timeline: scroll()) {
  html.pm-js .paco-shared-header { position: sticky; }
  html.pm-js .paco-shared-header::after {
    content: ""; position: absolute; inset: auto 0 -1px 0; height: 2px; pointer-events: none;
    background: linear-gradient(90deg, var(--paco-action, #78adff), var(--paco-blue, #8cc0f0));
    transform-origin: 0 50%; scale: 0 1;
    animation: pm-progress linear both; animation-timeline: scroll(root block);
  }
  @keyframes pm-progress { to { scale: 1 1; } }
}

/* Large pictures drift slowly against the scroll (parallax). */
@supports (animation-timeline: view()) {
  .pm-px { overflow: hidden; }
  .pm-px :is(img, video) { scale: 1.12; animation: pm-px linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; will-change: translate; }
  @keyframes pm-px { from { translate: 0 -5%; } to { translate: 0 5%; } }

  /* Films open up from a framed window to full width as they arrive. */
  .pm-ex { animation: pm-ex linear both; animation-timeline: view(); animation-range: entry 0% entry 80%; }
  @keyframes pm-ex { from { clip-path: inset(8% 6% round 24px); scale: .95; opacity: .6; } to { clip-path: inset(0 round 0); scale: 1; opacity: 1; } }
}

/* Pointer tilt on posters and hero pictures (precise pointers only). */
@media (hover: hover) and (pointer: fine) {
  [data-pm-tilt] { transform: perspective(1000px) rotateX(var(--pm-ry, 0deg)) rotateY(var(--pm-rx, 0deg)); transition: transform .6s var(--pm-ease-soft, ease); will-change: transform; }
  [data-pm-tilt].pm-tilting { transition: transform .12s linear; }
}

/* ---------- One signature entrance per world (same family, different feel) ---------- */
/* MAIGIA: pictures open like a curtain from the bottom, text rises a little further. */
body[data-world="maigia"] .pm-m:not(.pm-in):not(.pm-done) { opacity: 1; translate: 0 0; scale: 1.06; clip-path: inset(100% 0 0 0); }
body[data-world="maigia"] .pm-m.pm-in:not(.pm-done) { transition: clip-path 1.25s var(--pm-ease) var(--pm-d, 0ms), scale 1.6s var(--pm-ease) var(--pm-d, 0ms); }
body[data-world="maigia"] .pm-t:not(.pm-m):not(.pm-in):not(.pm-done) { translate: 0 34px; }

/* Masterclass: text slides in from the left, pictures wipe in from the left. */
body[data-world="training"] .pm-t:not(.pm-m):not(.pm-h):not(.pm-in):not(.pm-done) { translate: -30px 0; }
body[data-world="training"] .pm-m:not(.pm-in):not(.pm-done) { opacity: 1; translate: 0 0; scale: 1.04; clip-path: inset(0 100% 0 0); }
body[data-world="training"] .pm-m.pm-in:not(.pm-done) { transition: clip-path 1.2s var(--pm-ease) var(--pm-d, 0ms), scale 1.5s var(--pm-ease) var(--pm-d, 0ms); }

/* Journal: cards cascade, pictures reveal from the top edge down. */
body[data-world="journal"] .pm-m:not(.pm-in):not(.pm-done) { opacity: 1; translate: 0 0; scale: 1.05; clip-path: inset(0 0 100% 0); }
body[data-world="journal"] .pm-m.pm-in:not(.pm-done) { transition: clip-path 1.1s var(--pm-ease) var(--pm-d, 0ms), scale 1.5s var(--pm-ease) var(--pm-d, 0ms); }

/* Contact: calm, fade only. */
body[data-world="contact"] .pm-t:not(.pm-in):not(.pm-done) { translate: 0 10px; }

/* Footer wordmark: letters rise one by one. */
.pm-letters .pm-w { padding-bottom: .08em; margin-bottom: -.08em; }
.pm-letters .pm-wi { transition-duration: .8s; }

@media (max-width: 760px) {
  /* Phones: shorter travel, no pointer effects, lighter parallax. */
  .pm-t:not(.pm-in):not(.pm-done) { translate: 0 18px; }
  .pm-m:not(.pm-in):not(.pm-done) { translate: 0 20px; }
  @supports (animation-timeline: view()) { @keyframes pm-px { from { translate: 0 -3%; } to { translate: 0 3%; } } }
}
@media (prefers-reduced-motion: reduce) {
  .pm-px :is(img, video), .pm-ex, .paco-shared-header::after { animation: none !important; scale: none !important; clip-path: none !important; }
  [data-pm-tilt] { transform: none !important; }
}
