/* Task X v5: reverse-entrance page transition (see JS) + hero-style entrances. */
:root {
  --x-ease: cubic-bezier(.25, 1, .5, 1);   /* L.A.B. exit / PageTransitionOverlay */
  --x-in: cubic-bezier(.16, 1, .3, 1);     /* hero entrance feel */
  --x-paper: #f5f5f5;
}

/* ---------- leave (motion itself is WAAPI in the JS) ---------- */
.x-veil {
  position: fixed; inset: 0; z-index: 99998;
  background: var(--x-paper);
  opacity: 0; pointer-events: none;
}
body.x-leaving { overflow: hidden !important; }
body.x-leaving #main, body.x-leaving .site-header { pointer-events: none; }
body.x-leaving .custom-cursor,
body.x-leaving .site-gate > div[style*="z-index: 999998"] { opacity: 0 !important; transition: opacity .3s ease-out !important; }

/* ---------- entrance keyframes (measured from the home hero) ---------- */
@keyframes x-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes x-title { from { opacity: 0; filter: blur(5px); translate: 0 22px; } to { opacity: 1; filter: blur(0); translate: 0 0; } }
@keyframes x-sub { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes x-veil-out { from { opacity: 1; } to { opacity: 0; } }

/* ---------- case arrival ---------- */
html.x-case-veil body::after {
  content: ""; position: fixed; inset: 0; z-index: 99998;
  background: var(--x-paper); pointer-events: none;
}

html.x-case-pre :is(.project-detail__back, .project-detail__title, .project-detail__summary, .project-detail__hero-media) { opacity: 0; }
html.x-case-arriving .site-header { animation: x-fade .5s ease-out both; }
html.x-case-arriving .project-detail__back { animation: x-fade .3s ease-out .05s both; }
html.x-case-arriving .project-detail__title { animation: x-title .65s var(--x-in) .15s both; }
html.x-case-arriving .project-detail__summary { animation: x-sub .45s var(--x-in) .3s both; }
html.x-case-arriving .project-detail__hero-media { animation: x-title .75s var(--x-in) .4s both; }

/* ---------- case chapters while scrolling ---------- */
.x-reveal { opacity: 0; translate: 0 22px; transition: opacity .7s var(--x-in), translate .8s var(--x-in), filter .7s var(--x-in); }
.x-reveal.q-chapter__intro { filter: blur(5px); }
.x-reveal.x-in { opacity: 1; translate: 0 0; filter: none; }
.q-media-grid > .x-reveal:nth-child(2) { transition-delay: .08s; }
.q-media-grid > .x-reveal:nth-child(3) { transition-delay: .16s; }

/* ---------- home arrival: the Selected Work screen assembles like the hero ---------- */
@keyframes x-media { from { opacity: 0; filter: blur(4px); translate: 0 10px; } to { opacity: 1; filter: blur(0); translate: 0 0; } }
/* the site's own from-lab paper overlay would wash everything out — not on our return */
html.x-home-pre div[style*="z-index: 99999;"] { display: none !important; }
html.x-home-pre :is(.site-header,.work-pin) { opacity:0; }
html.x-home-arriving .work-pin { opacity:1; }
html.x-home-arriving .site-header { animation:x-fade .45s ease-out both; }
html.x-home-arriving .work-media { animation:x-media .8s var(--x-in) .08s both; }
html.x-home-arriving .work-panel h2 { animation:x-fade .3s ease-out .1s both; }
html.x-home-arriving .work-row { animation:x-title .65s var(--x-in) .2s both; }
html.x-home-arriving .work-detail:not([inert]) > div { animation:x-sub .45s var(--x-in) .42s both; }
html.x-home-arriving .work-dock { animation:x-fade .4s ease-out .5s both; }

/* ---------- case pages: no footer, the page ends with Next project + All projects ---------- */
html.x-case-page #main > .site-footer,
html.x-case-page #main > #contact.footer-scroll-anchor { display: none !important; }
html.x-case-page .project-detail { padding-bottom: var(--grid-pad, 58px); }

@media (prefers-reduced-motion: reduce) {
  html :is(.x-case-pre, .x-home-pre) * { animation: none !important; opacity: 1 !important; }
  .x-reveal { opacity: 1; translate: none; filter: none; }
}

