/* ==========================================================================
   Aqua Green: motion layer
   Heavy inertial scrolling (Lenis), a curtain between pages, scroll reveals,
   parallax and count-ups.

   Every hidden or animated state is scoped to html.agm. header.php adds that
   class only when the visitor has NOT asked their OS for reduced motion, so
   for them (and for anyone whose browser never runs the script) the site
   renders exactly as it did before this file existed.

   Reveal animations use the individual `translate` / `scale` properties and
   keyframes with `backwards` fill. That leaves each component's own
   `transform` and `transition` rules (card hovers, button nudges) untouched
   once the reveal has played.
   ========================================================================== */

:root{
  --agm-ease:cubic-bezier(.16,1,.3,1);      /* expo-out: long, soft landing */
  --agm-ease-io:cubic-bezier(.77,0,.18,1);  /* curtain */
  --agm-dur:1.35s;
}

/* ---- Lenis (stock rules for v1.3.27) ----------------------------------- */
html.lenis,html.lenis body{height:auto;}
.lenis:not(.lenis-autoToggle).lenis-stopped{overflow:clip;}
.lenis [data-lenis-prevent]{overscroll-behavior:contain;}
.lenis.lenis-smooth iframe{pointer-events:none;}
/* native smooth scrolling would fight the inertia engine */
html.agm{scroll-behavior:auto!important;}

/* ---- Curtain ----------------------------------------------------------- */
.agm-curtain{display:none;}
html.agm .agm-curtain{
  display:flex;align-items:center;justify-content:center;
  position:fixed;inset:0;z-index:2147483000;pointer-events:none;
  background:linear-gradient(180deg,#ffffff 0%,#f3f9fd 100%);
  transform:translate3d(0,0,0);
  /* Fallback: lifts on its own if the script never signals that it is ready. */
  animation:agm-curtain-lift 1.1s var(--agm-ease-io) 2.6s forwards;
}
/* soft water-drop edges, outside the box so they only show while moving */
html.agm .agm-curtain::before,
html.agm .agm-curtain::after{content:"";position:absolute;left:-12%;right:-12%;height:14vh;}
html.agm .agm-curtain::before{bottom:100%;background:#fff;border-radius:50% 50% 0 0/100% 100% 0 0;}
html.agm .agm-curtain::after{top:100%;background:#f3f9fd;border-radius:0 0 50% 50%/0 0 100% 100%;}

.agm-curtain__mark{display:flex;flex-direction:column;align-items:center;gap:22px;}
.agm-curtain__mark img{width:clamp(150px,16vw,210px);height:auto;display:block;}
.agm-curtain__bar{width:120px;height:2px;border-radius:2px;overflow:hidden;background:rgba(12,111,180,.12);}
.agm-curtain__bar::after{content:"";display:block;height:100%;width:100%;
  background:linear-gradient(90deg,#1A9BDC,#3faa4a);transform-origin:left center;
  animation:agm-bar 1.6s var(--agm-ease) both;}
html.agm .agm-curtain__mark{animation:agm-mark-in .7s var(--agm-ease) both;}

/* Ready: the script adds .agm-go and the curtain lifts right away. A new
   keyframe name restarts the animation instead of re-timing the fallback. */
html.agm.agm-go .agm-curtain{animation:agm-curtain-ready 1.1s var(--agm-ease-io) .1s forwards;}
html.agm.agm-go .agm-curtain__mark{animation:agm-mark-out .8s var(--agm-ease-io) .1s forwards;}

/* Leaving: the curtain rises from below and covers the page before the next
   one loads, which then lifts its own curtain: one continuous movement. */
html.agm.agm-leaving .agm-curtain{pointer-events:auto;
  animation:agm-curtain-cover .62s var(--agm-ease-io) forwards;}
html.agm.agm-leaving .agm-curtain__mark{animation:agm-mark-in .5s var(--agm-ease) .22s both;}
html.agm.agm-leaving .agm-curtain__bar::after{animation:none;transform:scaleX(0);}

@keyframes agm-curtain-lift{to{transform:translate3d(0,-115%,0);visibility:hidden;}}
@keyframes agm-curtain-ready{from{transform:translate3d(0,0,0);}to{transform:translate3d(0,-115%,0);visibility:hidden;}}
@keyframes agm-curtain-cover{from{transform:translate3d(0,115%,0);}to{transform:translate3d(0,0,0);}}
@keyframes agm-mark-in{from{opacity:0;transform:translate3d(0,18px,0);}to{opacity:1;transform:none;}}
@keyframes agm-mark-out{to{opacity:0;transform:translate3d(0,-60px,0);}}
@keyframes agm-bar{from{transform:scaleX(0);}to{transform:scaleX(1);}}

/* ---- Hero background layers (desktop parallax + settle) ----------------- */
.agm-bg{position:absolute;inset:0;z-index:0;pointer-events:none;
  background-repeat:no-repeat;transform-origin:50% 35%;will-change:transform;}
.agm-has-bg{overflow:hidden;}
.ag-hero.agm-has-bg{position:relative;}
html.agm.agm-go .agm-bg--intro{animation:agm-settle 2.8s var(--agm-ease) .15s backwards;}
@keyframes agm-settle{from{scale:1.18;}}

/* ---- Scroll reveals ---------------------------------------------------- */
html.agm [data-agm="up"]:not(.agm-in),
html.agm [data-agm="fade"]:not(.agm-in),
html.agm [data-agm="img"]:not(.agm-in),
html.agm [data-agm="line"]:not(.agm-in){opacity:0;}
html.agm [data-agm="words"]:not(.agm-in) .agm-wi{translate:0 112%;}

html.agm [data-agm="up"].agm-in{
  animation:agm-up var(--agm-dur) var(--agm-ease) var(--agm-d,0s) backwards;}
html.agm [data-agm="fade"].agm-in{
  animation:agm-fade 1.6s var(--agm-ease) var(--agm-d,0s) backwards;}
html.agm [data-agm="img"].agm-in{
  animation:agm-img 1.7s var(--agm-ease) var(--agm-d,0s) backwards;}
html.agm [data-agm="line"].agm-in{
  animation:agm-line 1.4s var(--agm-ease) var(--agm-d,0s) backwards;}
html.agm [data-agm="words"].agm-in .agm-wi{
  animation:agm-word 1.3s var(--agm-ease) calc(var(--agm-d,0s) + var(--agm-i,0) * 60ms) backwards;}

@keyframes agm-up{from{opacity:0;translate:0 70px;}}
@keyframes agm-fade{from{opacity:0;translate:0 26px;}}
/* The inset/scale pair never paints outside the image's own box:
   1.08 x (1 - 2 x 4%) < 1 horizontally, 1.08 x (1 - 2 x 10%) < 1 vertically. */
@keyframes agm-img{
  from{opacity:0;scale:1.08;clip-path:inset(10% 4% round var(--agm-r,0px));}
  to{clip-path:inset(0 round var(--agm-r,0px));}}
@keyframes agm-line{from{opacity:0;scale:0 1;}}
@keyframes agm-word{from{translate:0 112%;}}

/* split headings: each word rises out of its own mask */
.agm-w{display:inline-block;overflow:hidden;vertical-align:top;
  padding-bottom:.16em;margin-bottom:-.16em;}
.agm-wi{display:inline-block;}

[data-agm="line"]{transform-origin:left center;}
.agp-head--center [data-agm="line"]{transform-origin:center;}

.agm-count{font-variant-numeric:tabular-nums;}

/* print, or anything else that needs the plain page */
@media print{
  .agm-curtain{display:none!important;}
  html.agm [data-agm],html.agm .agm-wi{opacity:1!important;translate:none!important;animation:none!important;}
}
