/* =============================================================================
   vr-enhance.css — ADDITIVE animation layer.

   The one part of the project that is NOT a reproduction of the reference.
   Loaded only when ENHANCEMENTS is on in src/config/site.mjs, so
   `npm run build:reference` still produces byte-identical output and the
   fidelity gate still passes.

   Two additions:
     1. A page scroller pinned to the bottom of the viewport, with a single
        chick that walks it from one side to the other.
     2. Directional entrance animations for section headings and side-by-side
        content.

   The chick is deliberately rendered without an outline. Form comes from a
   radial gradient and a contact shadow, because a uniform stroke is what
   makes small vector animals read as cartoons.

   Everything is wrapped in prefers-reduced-motion: no-preference. A visitor
   who has asked their OS for less motion gets the site exactly as the
   reference renders it.
   ========================================================================== */

:root {
  --vrp-h: 4px;                      /* track height                        */
  --vrp-mw: 56px;                    /* marker width                        */
  --vrp-mh: 48px;                    /* marker height                       */
  /* Below the floating action rail (40) so the chick passes behind the
     WhatsApp button at the far right rather than over it. */
  --vrp-z: 39;
  /* Space reserved at the right-hand end of the track. The theme parks its
     floating rail and back-to-top button in that corner, and without this the
     chick finishes hidden behind them. The fill still runs to 100%. */
  --vrp-gap: 86px;
  --vrp-ease: cubic-bezier(.2, .7, .2, 1);
}

@media (max-width: 760px) {
  :root { --vrp-mw: 46px; --vrp-mh: 40px; --vrp-gap: 72px; }
}

/* -----------------------------------------------------------------------
   1. Page scroller
   ----------------------------------------------------------------------- */

.vrp {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--vrp-h);
  z-index: var(--vrp-z);
  pointer-events: none;
  /* No track background: at scroll 0 the scroller must be entirely invisible. */
}

/* The theme pins a Call / WhatsApp / Get-a-Quote bar to the bottom of the
   viewport on mobile. vr-enhance.js measures it at runtime and sets an inline
   offset; this is only a pre-paint fallback for that measurement. */
@media (max-width: 760px) {
  .vrp { bottom: 67px; }
}

.vrp__fill {
  height: 100%;
  width: 100%;
  transform: scaleX(var(--vrp-p, 0));
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--navy, #03446A) 0%, var(--blue, #0087C1) 55%, var(--sky, #8FD3F0) 100%);
  border-radius: 0 2px 2px 0;
  will-change: transform;
}

/* The chick walks ON TOP of the line. Sitting it above rather than centred
   keeps it clear of the viewport edge, which would otherwise clip it. */
.vrp__marker {
  position: absolute;
  bottom: 100%;
  left: clamp(
    calc(var(--vrp-mw) / 2 + 4px),
    calc(var(--vrp-p, 0) * 100%),
    calc(100% - var(--vrp-mw) / 2 - var(--vrp-gap))
  );
  translate: -50% 2px;
  width: var(--vrp-mw);
  height: var(--vrp-mh);
  opacity: 0;
  transition: opacity .3s ease;
  will-change: left;
}

.vrp.is-moving .vrp__marker,
.vrp.is-end .vrp__marker { opacity: 1; }

.vrp__marker svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  /* A soft ambient shadow, not an outline: it lifts the bird off whatever
     section happens to be behind it without drawing a cartoon edge. */
  filter: drop-shadow(0 2px 4px rgba(7, 30, 46, .28));
  /* Turning, not snapping. `scale` is an individual transform property, so it
     composes with the `translate` and `rotate` used by the bob and the
     end-of-page flourish instead of overwriting them. */
  transition: scale .22s var(--vrp-ease);
}

/* Face the direction of travel: mirrored while the reader scrolls up. */
.vrp.is-reverse .vrp__marker svg { scale: -1 1; }

/* --- the bird ---------------------------------------------------------- */

.vrp__down      { fill: url(#vrpDown); }
.vrp__downHead  { fill: url(#vrpDownHead); }
.vrp__shell     { fill: url(#vrpShellG); }

/* The wing is a tonal shape, slightly darker than the body and partly
   transparent, so it reads as a fold in the down rather than a drawn line. */
.vrp__wing {
  fill: #C9922F;
  opacity: .34;
}

/* Down wisps: hairline strokes that break the silhouette's clean curve. */
.vrp__wisp {
  fill: none;
  stroke: #E8C97A;
  stroke-width: .9;
  stroke-linecap: round;
  opacity: .95;
}

.vrp__beakUpper { fill: url(#vrpBeak); }
.vrp__beakLower { fill: #B86B1F; }

.vrp__eye   { fill: #241503; }
.vrp__glint { fill: #fff; opacity: .9; }

.vrp__shadow { fill: rgba(7, 30, 46, .22); }

.vrp__leg path {
  fill: none;
  stroke: #E09A45;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- walking ----------------------------------------------------------- */

.vrp__leg { transform-origin: 50% 0; transform-box: fill-box; }

.vrp.is-moving .vrp__leg--a { animation: vrpStepA .34s steps(2, end) infinite; }
.vrp.is-moving .vrp__leg--b { animation: vrpStepB .34s steps(2, end) infinite; }
.vrp.is-moving .vrp__down,
.vrp.is-moving .vrp__downHead,
.vrp.is-moving .vrp__wing,
.vrp.is-moving .vrp__wisp,
.vrp.is-moving .vrp__beakUpper,
.vrp.is-moving .vrp__beakLower,
.vrp.is-moving .vrp__eye,
.vrp.is-moving .vrp__glint { animation: vrpBob .34s ease-in-out infinite; }

@keyframes vrpStepA { 0% { rotate: -16deg; } 100% { rotate: 16deg; } }
@keyframes vrpStepB { 0% { rotate: 16deg; }  100% { rotate: -16deg; } }
@keyframes vrpBob   { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1.6px; } }

/* The egg has no legs, so it rocks instead. */
.vrp[data-style="egg"].is-moving .vrp__shell {
  animation: vrpRock 1.15s var(--vrp-ease) infinite;
  transform-origin: 50% 88%;
  transform-box: fill-box;
}

@keyframes vrpRock {
  0%, 100% { rotate: -6deg; }
  50%      { rotate: 6deg; }
}

/* --- arriving at the bottom of the page -------------------------------- */

.vrp.is-end .vrp__marker svg { animation: vrpFlourish .7s var(--vrp-ease); }

@keyframes vrpFlourish {
  0%   { translate: 0 0;    rotate: 0; }
  30%  { translate: 0 -9px; rotate: -5deg; }
  60%  { translate: 0 0;    rotate: 3deg; }
  100% { translate: 0 0;    rotate: 0; }
}

.vrp__ping {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 50%;
  border: 2px solid var(--blue, #0087C1);
  opacity: 0;
}

.vrp.is-end .vrp__ping { animation: vrpPing .9s var(--vrp-ease); }

@keyframes vrpPing {
  from { opacity: .7; transform: scale(.4); }
  to   { opacity: 0;  transform: scale(3.4); }
}

.vrp.is-end .vrp__fill {
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--blue, #0087C1) 65%, transparent);
}

/* --- line style: fill only, no marker ---------------------------------- */

.vrp[data-style="line"] .vrp__marker { display: none; }

/* -----------------------------------------------------------------------
   2. Directional entrance animations

   These re-point the theme's OWN reveal system. main.js already observes
   [data-reveal] and adds .is-in; all that changes here is the transform an
   element starts from, chosen per element by vr-enhance.js. No second
   observer, no competing timing.
   ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal][data-vr-dir] {
    transition: opacity .85s var(--vrp-ease), transform .85s var(--vrp-ease);
  }

  .js [data-reveal][data-vr-dir="left"]  { transform: translate3d(-46px, 0, 0); }
  .js [data-reveal][data-vr-dir="right"] { transform: translate3d(46px, 0, 0); }
  .js [data-reveal][data-vr-dir="up"]    { transform: translate3d(0, 34px, 0); }
  .js [data-reveal][data-vr-dir="zoom"]  { transform: scale(.955); }

  /* Headings travel a little further and lead their section. */
  .js [data-reveal][data-vr-dir][data-vr-lead] {
    transform: translate3d(var(--vr-lead-x, -62px), 0, 0);
  }

  .js [data-reveal][data-vr-dir].is-in { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal][data-vr-dir] { transform: none; opacity: 1; }
  .vrp__marker, .vrp__marker svg, .vrp__leg, .vrp__ping { animation: none !important; }
}

@media print {
  .vrp { display: none !important; }
  .js [data-reveal][data-vr-dir] { transform: none !important; opacity: 1 !important; }
}
