/* ==========================================================================
   Project Qumran — motion system (site-motion variant ONLY)

   This file exists only in site-motion/. It layers a motion-design pass over
   the finished static site without changing any of its layout, type, copy,
   colours, or geometry.

   EVERYTHING here is gated behind `html.motion`, added by a tiny inline head
   snippet (and re-checked by js/motion.js) only when the visitor does NOT
   prefer reduced motion, JavaScript runs, and IntersectionObserver exists.
   Absent that class, every rule below is inert and the page renders exactly
   like the original site — progressive enhancement, no exceptions.

   The system:
   - tokens: one set of easings/durations/distances, so every page speaks the
     same motion language (never hard-code timings in page CSS; use these).
   - scroll reveals: [data-reveal="rise|fade|left|right"] + .is-in, driven by
     js/motion.js. Once-only; content the visitor already passed shows
     instantly. NEVER put data-reveal on an element that has its own hover/
     state transform (buttons, .field rows, .stamp-ghost uses fade only) —
     the reveal owns opacity+transform while it runs.
   - stagger: [data-reveal-group="90"] on a parent spaces its [data-reveal]
     children by that many ms (js sets --rv-delay inline, cleans up after).
   - ornament draw: every .ornament-center reveals from its centre diamond
     outward via clip-path (js adds .orn-in when it scrolls into view). This
     is the site's signature motion — automatic, no markup needed.
   - hero entrances: pages sequence their own hero copy with the shared
     mRise/mFade/mSettle keyframes and per-element delays in page CSS.
     mSettle (photo scale 1.035 → 1) MUST use transform-origin bottom center
     (top/side overflow leaves the page; bottom overflow would paint over the
     next section) and MUST be scoped to @media (min-width: 1201px).
   - micro-interactions: refined nav/button/link feedback, shared site-wide.
   ========================================================================== */

:root {
  /* decisive start, long expensive settle — the default for almost everything */
  --m-ease-out: cubic-bezier(.22, .61, .21, 1);
  /* symmetric drama for draws and section moves (the ornament uses this) */
  --m-ease-inout: cubic-bezier(.65, .05, .18, 1);

  --m-dur-micro: .22s;    /* hovers, presses, focus feedback */
  --m-dur-reveal: .8s;    /* scroll reveals */
  --m-dur-hero: 1s;       /* hero entrance items */
  --m-dur-orn: .95s;      /* ornament draw */
  /* hero photo settle; pages may re-tune it on their own settle rule
     (the site's hierarchy: 2.2s projects/gallery, 2.4s home, 2.6s watch) */
  --m-dur-settle: 2.2s;

  --m-rise: 18px;         /* standard reveal travel — keep distances small */
  --m-slide: 26px;        /* left/right reveal travel */
  --m-dur-wipe: 1.05s;    /* masked photographic reveals (data-reveal="wipe-up") */
}

/* --------------------------------------------------------------------------
   Page + nav entrance (site-wide, automatic)
   -------------------------------------------------------------------------- */
html.motion body { animation: mPage .4s ease-out both; }

.motion .nav { animation: mNavIn .8s var(--m-ease-out) .1s both; }

@keyframes mPage { from { opacity: 0; } }
@keyframes mNavIn { from { opacity: 0; transform: translateY(-8px); } }

/* Page-to-page: a cross-fade, not a blank-and-rebuild (owner, 2026-10-21:
   "it looks like the page flashes and changes"). Browsers with cross-
   document view transitions (Chrome/Edge, Safari 18.2+) blend the old page
   into the new one while the nav bar holds still as its own layer; the
   head gate marks such arrivals html.m-vt, which drops the fade-from-blank
   and the nav drop above (they only belong to a first arrival). Other
   browsers keep the original entrance. Reduced motion: none of this. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.motion .nav { view-transition-name: site-nav; }
html.motion.m-vt body,
.motion.m-vt .nav { animation: none; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .38s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}
/* the bar blends on its own layer: identical pixels stay perfectly still,
   and only what differs (the active link, the brand block the home page
   leaves out) fades across */
::view-transition-group(site-nav),
::view-transition-old(site-nav),
::view-transition-new(site-nav) {
  animation-duration: .38s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   Scroll reveals
   js/motion.js adds .is-in when the element enters the viewport (once), and
   .rv-done after the transition ends so stagger delays never leak into later
   hover feedback. .m-instant marks content revealed without animation
   (already scrolled past, bfcache restore).
   -------------------------------------------------------------------------- */
.motion [data-reveal] {
  transition:
    opacity var(--m-dur-reveal) var(--m-ease-out) var(--rv-delay, 0ms),
    transform var(--m-dur-reveal) var(--m-ease-out) var(--rv-delay, 0ms);
}

.motion [data-reveal="rise"]:not(.is-in)  { opacity: 0; transform: translateY(var(--m-rise)); }
.motion [data-reveal="fade"]:not(.is-in)  { opacity: 0; }  /* for elements with their own transforms */
.motion [data-reveal="left"]:not(.is-in)  { opacity: 0; transform: translateX(calc(-1 * var(--m-slide))); }
.motion [data-reveal="right"]:not(.is-in) { opacity: 0; transform: translateX(var(--m-slide)); }

/* masked photographic reveal: the element uncovers bottom-up inside its own
   silhouette (clip-path, no opacity), for photography that should participate
   in its transition rather than fade into existence. Pair with an inner
   scale-settle on the image where the page wants it (see editorial.css). */
.motion [data-reveal="wipe-up"] {
  transition: clip-path var(--m-dur-wipe) var(--m-ease-inout) var(--rv-delay, 0ms);
}
.motion [data-reveal="wipe-up"]:not(.is-in) { clip-path: inset(100% 0 0 0); }
.motion [data-reveal="wipe-up"].is-in { clip-path: inset(0 0 0 0); }

.motion [data-reveal].rv-done { transition-delay: 0ms; }

.motion [data-reveal].m-instant,
.motion .ornament-center.m-instant {
  transition: none !important;
  animation: none !important;
}

/* --------------------------------------------------------------------------
   Ornament draw — the signature motion
   The 1px rule + centre diamond reveals outward from the middle: the diamond
   appears first (it sits at the centre), then the line extends to both ends.
   Pure clip-path, so the pinned widths and drop-shadow are untouched (filter
   applies after clipping — the shadow is never cut). -8px vertical overshoot
   keeps the 7px rotated diamond clear of the clip at every stage.
   -------------------------------------------------------------------------- */
.motion .ornament-center {
  clip-path: inset(-8px 50% -8px 50%);
  transition: clip-path var(--m-dur-orn) var(--m-ease-inout) var(--orn-delay, 0ms);
}
.motion .ornament-center.orn-in { clip-path: inset(-8px 0% -8px 0%); }

/* --------------------------------------------------------------------------
   Shared entrance keyframes for page-CSS hero sequences
   -------------------------------------------------------------------------- */
@keyframes mRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes mFade { from { opacity: 0; } to { opacity: 1; } }
/* photo settle: pair with transform-origin: bottom center on the same rule,
   and desktop-only (min-width: 1201px) — see the header note */
@keyframes mSettle { from { transform: scale(1.035); } to { transform: none; } }

/* --------------------------------------------------------------------------
   Micro-interactions (site-wide)
   -------------------------------------------------------------------------- */

/* nav links: a hairline gold underline grows from the left on hover; the
   active link keeps its diamond marker and skips the hover line */
.motion .nav ul a:not(.nav-cta)::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--gold-bright);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s var(--m-ease-out);
}
.motion .nav ul a:not(.nav-cta):hover::before { transform: scaleX(1); }
.motion .nav ul a.active::before { display: none; }

/* gold buttons: slower, more deliberate easing and a 1px lift with a deeper
   shadow — the face still carries itself (no glow, and per the standing
   lesson their text-shadow stays none) */
.motion .btn-gold {
  transition:
    filter var(--m-dur-micro) var(--m-ease-out),
    transform var(--m-dur-micro) var(--m-ease-out),
    box-shadow var(--m-dur-micro) var(--m-ease-out);
}
.motion .btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 240, 210, .45);
}
.motion .btn-gold:active {
  transform: translateY(1px);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 240, 210, .45);
}
.motion .btn-gold .chev { transition: transform var(--m-dur-micro) var(--m-ease-out); }
.motion .btn-gold:hover .chev { transform: translateX(3px); }

/* the nav pill matches the buttons' pacing */
.motion .nav ul a.nav-cta { transition: filter var(--m-dur-micro) var(--m-ease-out); }

/* outline buttons: the border warms with the fill */
.motion .btn-line {
  transition:
    background var(--m-dur-micro) var(--m-ease-out),
    color var(--m-dur-micro) var(--m-ease-out),
    border-color var(--m-dur-micro) var(--m-ease-out);
}
.motion .btn-line:hover { border-color: rgba(210, 162, 76, .85); }

/* form fields: the hairline warms toward gold while typing (the global
   focus-visible ring is untouched — this is polish, not the focus indicator) */
.motion input[type="email"],
.motion input[type="text"],
.motion textarea {
  transition: border-color var(--m-dur-micro) var(--m-ease-out);
}
.motion .field input:focus,
.motion .field textarea:focus,
.motion .nl-form input[type="email"]:focus {
  border-color: var(--gold-deep);
}

/* --------------------------------------------------------------------------
   Small screens: shorter travel, quicker reveals, side-slides become rises
   (a phone viewport has no room for lateral motion)
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root {
    --m-rise: 12px;
    --m-dur-reveal: .55s;
    --m-dur-hero: .7s;
    --m-dur-wipe: .7s;
  }
  .motion [data-reveal="left"]:not(.is-in),
  .motion [data-reveal="right"]:not(.is-in) {
    transform: translateY(var(--m-rise));
  }
}

/* --------------------------------------------------------------------------
   Reduced motion: style.css already collapses all durations to .01ms, but
   this variant must be inert even if .motion ever slips in — everything
   lands visible with no travel.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .motion [data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; clip-path: none !important; }
  .motion .ornament-center { clip-path: none !important; transition: none !important; }
  html.motion body, .motion .nav { animation: none !important; }
}

/* --------------------------------------------------------------------------
   Prerender hold (speed pass 2, 2026-10-21): a page the browser prepared in
   the background (js/prefetch.js speculation rules) carries html.m-held
   until it is shown - every entrance waits, paused at its first frame, and
   plays the moment the visitor arrives. The head gate adds/removes it. */
.motion.m-held *,
.motion.m-held *::before,
.motion.m-held *::after { animation-play-state: paused !important; }
