/* CENSENSE — one motion language for the whole site.

   Durations   160 ms feedback · 320 ms state change · 640 ms reveal · 800 ms first-screen entrance
   Curves      --m-out    arrive and settle, no overshoot
               --m-in-out symmetrical moves (page change, dissolve)
   Distances   18 px for blocks, 12 px for small items; parallax never more than 22 px
   Stagger     70 ms per step, never more than five steps
   Rules       transform and opacity only · nothing moves continuously except the dossier folder's slow drift
               nothing delays content for more than a second · scroll is never intercepted
               every rule below is progressive: without the script, without the gate, or with reduced motion, the page is simply shown. */

:root {
  --m-out: cubic-bezier(.22, .72, .2, 1);
  --m-in-out: cubic-bezier(.65, 0, .35, 1);
  --m-fast: 160ms;
  --m-base: 320ms;
  --m-slow: 640ms;
  --m-enter: 800ms;
  --m-shift: 18px;
  --m-shift-sm: 12px;
  --m-step: 70ms;
  --m-par: 22px;
}

@media (prefers-reduced-motion: no-preference) {

  /* ---------- 1. First screen: the copy settles in, one step after another (pure CSS, no script needed) ---------- */
  /* The copy is never fully transparent: it is on screen from the first paint (soft, a little low) and settles. A fade from 0 held the phone's largest-contentful-paint
     back to the end of the animation (0.2 s -> 1.2 s in the local measurement); starting at .6 keeps the entrance and removes that cost. */
  @keyframes m-enter {
    from { opacity: .6; transform: translate3d(0, var(--m-shift-sm), 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
  }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > * {
    animation: m-enter var(--m-enter) var(--m-out) backwards;
    animation-delay: calc(var(--m-hero-delay, 0ms) + var(--i, 0) * var(--m-step));
  }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(1) { --i: 0; }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(2) { --i: 1; }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(3) { --i: 2; }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(4) { --i: 3; }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(5) { --i: 4; }
  :is(.home-book-copy, .book-hero-copy, .page-hero:not(.prive-hero):not(.book-hero) > .container) > :nth-child(n + 6) { --i: 5; }

  /* ---------- 2. Below the first screen: each block is revealed once, as it arrives (the script adds and removes these classes) ---------- */
  .m-hide { opacity: 0; transform: translate3d(0, var(--m-shift), 0); }
  .m-show {
    transition: opacity var(--m-slow) var(--m-out), transform var(--m-slow) var(--m-out);
    transition-delay: calc(var(--i, 0) * var(--m-step));
  }

  /* ---------- 3. Changing page: the header stays where it is, the page beneath it crosses over (progressive; browsers without it just navigate) ---------- */
  @view-transition { navigation: auto; }
  .site-header { view-transition-name: site-header; }
  ::view-transition-group(root) { animation-duration: var(--m-base); animation-timing-function: var(--m-in-out); }

  /* ---------- 4. Introduction of the logo: first arrival of a session on a homepage only (the gate script sets html.m-intro before the first paint) ---------- */
  html.m-intro { --m-hero-delay: 900ms; --m-mark: min(66vw, 460px); }
  html.m-intro::before, html.m-intro::after { content: ""; position: fixed; z-index: 9000; pointer-events: none; }
  html.m-intro::before { inset: 0; background: #041a40; animation: m-veil 1650ms var(--m-in-out) both; }
  html.m-intro::after {
    inset: 0; margin: auto; width: var(--m-mark); height: calc(var(--m-mark) * 250 / 1110);
    background: url("/assets/censense-wordmark-transparent.webp") center / contain no-repeat;
    animation: m-mark 1650ms linear both;
  }
  @keyframes m-veil {
    0%, 55% { opacity: 1; visibility: visible; }
    99%     { opacity: 0; visibility: visible; }
    100%    { opacity: 0; visibility: hidden; }
  }
  @keyframes m-mark {
    0%, 9% { opacity: 0; clip-path: inset(0 100% 0 0); transform: translate3d(0, 6px, 0); animation-timing-function: cubic-bezier(.22, .72, .2, 1); }
    40%    { opacity: 1; clip-path: inset(0 0 0 0); transform: translate3d(0, 0, 0); }
    64%    { opacity: 1; clip-path: inset(0 0 0 0); transform: translate3d(0, 0, 0) scale(1); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
    99%    { opacity: 0; clip-path: inset(0 0 0 0); transform: translate3d(0, 0, 0) scale(1.03); visibility: visible; }
    100%   { opacity: 0; clip-path: inset(0 0 0 0); transform: translate3d(0, 0, 0) scale(1.03); visibility: hidden; }
  }
}

/* ---------- 5. Depth while scrolling (progressive; only two quiet elements, never the book) ---------- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    @keyframes m-parallax {
      from { transform: translate3d(0, var(--m-par), 0); }
      to   { transform: translate3d(0, calc(var(--m-par) * -1), 0); }
    }
    .home-dossier-art, .prive-preview-visual {
      animation: m-parallax linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    @media (max-width: 760px) { :root { --m-par: 10px; } }
  }
}

@media print {
  .m-hide { opacity: 1 !important; transform: none !important; }
  html.m-intro::before, html.m-intro::after { display: none !important; }
}
