/* ==========================================================================
   Point of View Media — Motion System
   --------------------------------------------------------------------------
   Loaded after site.css. Owns every transition, reveal and scroll effect.

   Principle: this is a photography business, so motion behaves like a camera —
   a focus pull, a slow dolly, a print developing. Restraint reads as expensive.
   Nothing moves without a reason, and nothing moves for longer than it needs.

   Three rules the whole system obeys:
     1. Only transform and opacity animate. Never height, top, filter-on-scroll.
     2. The bigger the element, the slower it moves and the less far it travels.
        A 132px headline drifting 12px reads premium; the same headline flying
        60px reads like a template.
     3. Everything degrades. No JS -> content visible. No scroll-timeline ->
        static. Reduced motion -> near-instant, no transforms at all.
   ========================================================================== */

:root {
  /* ---- Easing -----------------------------------------------------------
     Expo is the workhorse: it leaves fast and settles slowly, which is what
     makes a movement feel weighted rather than linear and cheap.            */
  --ease-out-expo:     cubic-bezier(.16, 1, .3, 1);
  --ease-out-quart:    cubic-bezier(.25, 1, .5, 1);
  --ease-in-out-quint: cubic-bezier(.83, 0, .17, 1);
  --ease-lens:         cubic-bezier(.4, 0, .1, 1);
  /* Overshoot. Interactive confirmation ONLY — a button acknowledging a press.
     Never on content: content that bounces reads as a toy.                  */
  --ease-spring:       cubic-bezier(.34, 1.36, .64, 1);

  /* ---- Duration ---------------------------------------------------------
     A scale, not arbitrary numbers. Each step is roughly 1.7x the last.     */
  --t-instant: 120ms;   /* colour echo on hover                             */
  --t-quick:   220ms;   /* small UI, buttons, icons                         */
  --t-base:    420ms;   /* the default reveal                               */
  --t-slow:    720ms;   /* images, large cards                              */
  --t-cinema: 1200ms;   /* hero, scene changes                              */
  --t-drift:    24s;    /* ambient: hero zoom, marquee                      */

  /* ---- Travel -----------------------------------------------------------
     Inversely proportional to element size. See rule 2.                    */
  --d-sm: 8px;
  --d-md: 16px;
  --d-lg: 28px;
  --d-xl: 48px;

  /* ---- Choreography ---------------------------------------------------- */
  --stagger: 70ms;
  --parallax-range: 60px;  /* hard cap on total parallax travel             */
}

/* ==========================================================================
   0. FAILSAFE
   site.css sets .reveal { opacity: 0 } unconditionally, so a JS error or a
   blocked script leaves the entire page blank. Scope it to JS being alive.
   ========================================================================== */

html:not(.js) .reveal,
html:not(.js) [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
}

/* Belt and braces: if the observer never fires within 3s, show everything. */
html.js.motion-failsafe .reveal,
html.js.motion-failsafe [data-reveal] {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   1. LOADING SEQUENCE
   Not a spinner. A gold hairline draws across the top while fonts and the
   hero image resolve, then the hero settles like a camera finding focus.
   Hard-capped in JS at 2000ms — content is never held hostage to an asset.
   ========================================================================== */

.load-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 999;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-slow) var(--ease-out-expo),
              opacity var(--t-quick) linear;
  pointer-events: none;
}
html.loaded .load-bar { transform: scaleX(1); opacity: 0; }

/* The page holds still until ready, so the hero does not animate over a
   half-loaded image. Only the hero is gated — the rest of the page is free. */
html.js .hero-meta,
html.js .hero-h1,
html.js .hero-sub,
html.js .hero-actions,
html.js .hero-badges { animation-play-state: paused; }
html.js.loaded .hero-meta,
html.js.loaded .hero-h1,
html.js.loaded .hero-sub,
html.js.loaded .hero-actions,
html.js.loaded .hero-badges { animation-play-state: running; }

/* Nav arrives last, once the hero has spoken. */
html.js nav { opacity: 0; transition: opacity var(--t-slow) var(--ease-out-quart) 600ms; }
html.js.loaded nav { opacity: 1; }

/* ==========================================================================
   2. REVEAL SYSTEM
   .reveal stays the backward-compatible default (39 elements already use it).
   data-reveal adds the variants. .visible is applied by the observer.
   ========================================================================== */

.reveal,
[data-reveal] {
  opacity: 0;
  transition:
    opacity   var(--t-slow) var(--ease-out-quart) var(--reveal-delay, 0ms),
    transform var(--t-slow) var(--ease-out-expo)  var(--reveal-delay, 0ms);
}
.reveal.visible,
[data-reveal].visible { opacity: 1; transform: none; }

/* -- fade-rise (default). Body copy, cards, most things. ------------------ */
.reveal,
[data-reveal="rise"] { transform: translate3d(0, var(--d-lg), 0); }

/* -- mask-rise. Display headings only. The line is clipped by its own box
      and slides up from beneath it — the single most cinematic reveal there
      is, and the fastest to become tiresome. Headings only.                 */
[data-reveal="mask"] {
  clip-path: inset(0 0 100% 0);
  transform: translate3d(0, .35em, 0);
  transition:
    clip-path var(--t-cinema) var(--ease-out-expo) var(--reveal-delay, 0ms),
    transform var(--t-cinema) var(--ease-out-expo) var(--reveal-delay, 0ms),
    opacity   var(--t-base)   linear                var(--reveal-delay, 0ms);
}
[data-reveal="mask"].visible { clip-path: inset(0 0 -20% 0); }

/* -- quiet. Large elements: they fade and barely move. Rule 2 in practice. */
[data-reveal="quiet"] { transform: translate3d(0, var(--d-sm), 0); }

/* -- image. A curtain lifts while the frame eases out of a slight push-in,
      like a print coming up in the tray.                                    */
[data-reveal="image"] {
  opacity: 1;
  overflow: hidden;
  position: relative;
}
[data-reveal="image"] > img,
[data-reveal="image"] > picture > img {
  transform: scale(1.06);
  transition: transform var(--t-cinema) var(--ease-lens) var(--reveal-delay, 0ms);
}
[data-reveal="image"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--black);
  transform-origin: bottom;
  transition: transform var(--t-slow) var(--ease-in-out-quint) var(--reveal-delay, 0ms);
  pointer-events: none;
}
[data-reveal="image"].visible > img,
[data-reveal="image"].visible > picture > img { transform: scale(1); }
[data-reveal="image"].visible::after { transform: scaleY(0); }

/* -- rd-1..4. The pre-existing stagger convention, still emitted by
      admin/render.php. Re-expressed against the token scale so generated and
      hand-written markup share one rhythm, and re-pointed at --reveal-delay
      so it composes with every variant instead of fighting the shorthand. */
.rd-1 { --reveal-delay: calc(1 * var(--stagger)); transition-delay: 0s; }
.rd-2 { --reveal-delay: calc(2 * var(--stagger)); transition-delay: 0s; }
.rd-3 { --reveal-delay: calc(3 * var(--stagger)); transition-delay: 0s; }
.rd-4 { --reveal-delay: calc(4 * var(--stagger)); transition-delay: 0s; }

/* -- Stagger. The observer writes --i on each child of [data-stagger].
      Index is capped in JS at 8 so a 20-item grid never takes two seconds. */
[data-stagger] > * { --reveal-delay: calc(var(--i, 0) * var(--stagger)); }

/* Pricing deliberately breaks its own rhythm: the featured tier lands last
   and from slightly higher, so the eye finishes on it. Motion doing
   commercial work rather than decoration. */
[data-stagger] > .featured,
[data-stagger] > .pkg.featured {
  --reveal-delay: calc(9 * var(--stagger));
  transform: translate3d(0, var(--d-xl), 0);
}

/* ==========================================================================
   3. DEPTH & PARALLAX
   Scroll-driven, so it runs off the compositor with no scroll listener.
   Browsers without scroll-timeline simply get a static, correct layout.
   ========================================================================== */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {

    /* Hero background drifts slower than the page. Capped travel. */
    .hero-bg {
      animation: parallax-drift linear both;
      animation-timeline: view();
      animation-range: entry 0% exit 100%;
    }
    @keyframes parallax-drift {
      to { transform: translate3d(0, var(--parallax-range), 0); }
    }

    /* Focus falloff: sections soften very slightly as they leave. Reads as
       depth of field, which is the correct metaphor for this business. */
    [data-depth] {
      animation: depth-falloff linear both;
      animation-timeline: view();
      animation-range: exit 0% exit 90%;
    }
    @keyframes depth-falloff {
      to { opacity: .55; transform: scale(.985); }
    }
  }
}

/* ==========================================================================
   4. PINNED SECTIONS
   position: sticky only. The wheel is never hijacked — the page always
   scrolls at the speed the visitor's own device decided it should.
   ========================================================================== */

[data-pin] { position: relative; }
[data-pin] .pin-stage {
  position: sticky;
  top: 0;
  min-height: 100svh;
  display: flex;
  align-items: center;
}
[data-pin] .pin-step {
  opacity: .25;
  transform: translate3d(0, var(--d-md), 0);
  transition: opacity var(--t-base) var(--ease-out-quart),
              transform var(--t-base) var(--ease-out-expo);
}
[data-pin] .pin-step.active { opacity: 1; transform: none; }

/* ==========================================================================
   5. HOVER & INTERACTION
   Gated behind (hover: hover) — without this, touch devices latch a hover
   state on first tap and never release it.
   ========================================================================== */

@media (hover: hover) and (pointer: fine) {
  .g, .portfolio-item {
    overflow: hidden;
    transition: transform var(--t-base) var(--ease-out-expo);
  }
  .g img, .portfolio-item img {
    transition: transform var(--t-slow) var(--ease-lens),
                opacity   var(--t-base) linear;
  }
  /* Slow hover reads expensive; fast hover reads cheap. */
  .g:hover img, .portfolio-item:hover img { transform: scale(1.045); }

  .pkg, .card, .step {
    transition: transform var(--t-quick) var(--ease-out-expo),
                border-color var(--t-base) linear;
  }
  .pkg:hover, .card:hover, .step:hover {
    transform: translate3d(0, -4px, 0);
    border-color: var(--border-warm);
  }
}

/* Press. Applies on touch too — tactile confirmation is not decoration. */
.hero-cta:active, .nav-book:active, .form-submit:active, .drawer-book:active {
  transform: translate3d(0, 1px, 0) scale(.985);
  transition-duration: var(--t-instant);
}

/* ==========================================================================
   6. FOCUS
   Focus is never animated away and never hidden. A keyboard visitor must be
   able to see where they are at all times.
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--gold-lt);
  outline-offset: 3px;
  border-radius: 1px;
}
.lightbox:focus { outline: none; }

/* ==========================================================================
   7. PERFORMANCE
   ========================================================================== */

/* content-visibility: auto is deliberately NOT used here.

   It looks like free performance, but a section that stops rendering while a
   transition is mid-flight freezes that transition: scroll past a section
   quickly and its content sticks at whatever opacity it had reached — 0.45,
   0.56 — and never finishes arriving. Measured in Chromium on this page.

   The weight on these pages is photographs, and loading="lazy" already
   defers those. Correctness wins over a marginal paint saving. */

/* will-change is added by JS only while an element is actually in flight and
   removed afterwards. A permanent will-change is a permanent memory cost. */
.is-animating { will-change: transform, opacity; }

/* ==========================================================================
   8. REDUCED MOTION
   Honour the preference completely: no transforms, no parallax, no pinning,
   no ambient loops, no smooth scroll. Opacity only, and fast.
   This is the whole point of the system, not an afterthought at the bottom.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }

  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 150ms !important;
    scroll-behavior: auto !important;
  }

  /* Content appears; it does not travel. */
  .reveal, [data-reveal] {
    transform: none !important;
    clip-path: none !important;
    transition: opacity 150ms linear !important;
  }
  [data-reveal="image"]::after { display: none; }
  [data-reveal="image"] > img,
  [data-reveal="image"] > picture > img { transform: none !important; }

  /* Ambient loops stop entirely — a marquee cannot be made accessible by
     slowing it down, it has to not run. */
  .marquee-track { animation: none !important; transform: none !important; }
  .hero-bg img   { animation: none !important; transform: scale(1.05) !important; }
  .hero-bg       { animation: none !important; transform: none !important; }

  [data-depth] { opacity: 1 !important; transform: none !important; }
  [data-pin] .pin-step { opacity: 1 !important; transform: none !important; }
  [data-pin] .pin-stage { position: static; min-height: 0; }

  .load-bar { display: none; }
  html.js nav { opacity: 1 !important; transition: none !important; }

  @media (hover: hover) {
    .g:hover img, .portfolio-item:hover img,
    .pkg:hover, .card:hover, .step:hover { transform: none !important; }
  }
}
