/*
 * Home page only: hero, services and why-us depth and motion (redesign Phase B).
 * Loaded by mts_assets() on the front page. Reads the tokens in style.css :root.
 *
 * Rules this file keeps to:
 *   - only transform (including the translate property) and opacity are animated;
 *   - every loop pauses when the hero is off-screen or the tab is hidden
 *     (js/hero.js sets .is-idle), and stops under prefers-reduced-motion;
 *   - nothing here hides content: with no JavaScript the artwork still draws and
 *     drifts, the stats show their real values and the tech names are all present.
 */

:root{
  /* Sampled from the original swoosh artwork, so the SVG matches it exactly. */
  --wave-1:#62ADE7;
  --wave-2:#3A8CCB;
  --wave-3:#07518E;
  --wave-4:#05437E;
  --wave-5:#003A6F;
  --wave-accent:#FE941F;
  --circuit:#7AB7DE;
}

/* ---------- layers ---------- */
.hero{position:relative;isolation:isolate}
.hero > .site-header{position:relative;z-index:3}
.hero-main{position:relative;z-index:2;padding-bottom:var(--space-10)}
.hero-art{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
/* A soft wash of the ribbon colours behind the artwork, so the ribbons sit in
   light rather than on a flat ground. Static gradients: nothing here animates. */
.hero-art::before{content:"";position:absolute;inset:0;background:
  radial-gradient(46% 62% at 100% 46%,rgba(98,173,231,.26) 0%,rgba(98,173,231,0) 70%),
  radial-gradient(30% 34% at 92% 100%,rgba(254,148,31,.14) 0%,rgba(254,148,31,0) 72%)}

/* ---------- swoosh: five stacked SVG layers ----------
   Tapered, translucent gradient ribbons in the artwork's blues and orange.
   The box bleeds past the hero's right and bottom edges so a layer can drift or
   lag without ever uncovering its own edge. Each layer lags the scroll by a
   different share of its height (--depth), the furthest band the most. */
.hero-wave{position:absolute;right:-3%;bottom:-2%;width:84%;aspect-ratio:16/9}
.hero-band{position:absolute;inset:0;width:100%;height:100%;overflow:visible;will-change:transform;
  translate:0 calc(var(--hero-scroll,0) * var(--depth,0%));
  animation:heroDrift var(--drift,22s) ease-in-out infinite alternate}
.hero-band--1{--depth:8.5%;--drift:26s}
.hero-band--2{--depth:6.8%;--drift:21s;animation-delay:-6s}
.hero-band--3{--depth:5%;--drift:24s;animation-delay:-11s}
.hero-band--4{--depth:2.8%;--drift:19s;animation-delay:-3s}
.hero-band--5{--depth:1.4%;--drift:17s;animation-delay:-8s}
@keyframes heroDrift{from{transform:translate3d(.5%,-.6%,0)}to{transform:translate3d(-.9%,.7%,0)}}

/* ---------- accent lines ----------
   Lines in from the left edge with 45-degree jogs, ending in nodes: the routes of
   the original circuit artwork, in the line style of the Why Us illustration.
   The lines are "drawn" by a wipe (the outer box slides in from the left while
   its contents slide the opposite way, so only transform animates); the nodes
   then fade in. */
/* Sized from the space left of the headline, so the lines stop short of it. */
.hero-circuit{position:absolute;left:0;top:96px;width:clamp(200px,calc(50vw - 430px),540px);aspect-ratio:1200/667;overflow:hidden;opacity:.8}
.hero-lines,.hero-nodes{position:absolute;inset:0;display:block;width:100%;height:100%}
.hero-nodes{animation:heroNode .6s 1.6s var(--ease-std) both}
.hero-circuit-wipe,.hero-circuit-inner{position:absolute;inset:0}
.hero-circuit-wipe{overflow:hidden;animation:heroWipeOut 1.5s .25s var(--ease-out) both}
.hero-circuit-inner{animation:heroWipeIn 1.5s .25s var(--ease-out) both}
@keyframes heroWipeOut{from{transform:translate3d(-100%,0,0)}to{transform:none}}
@keyframes heroWipeIn{from{transform:translate3d(100%,0,0)}to{transform:none}}
@keyframes heroNode{from{opacity:0}to{opacity:1}}

/* Pulses: each is a layer the size of the circuit with a dot at its origin, so a
   percentage translate places the dot in circuit coordinates. */
.hero-pulse{position:absolute;inset:0;opacity:0;will-change:transform,opacity;animation:heroPulse1 9s 2.4s linear infinite}
.hero-pulse::before{content:"";position:absolute;left:-4px;top:-4px;width:8px;height:8px;border-radius:50%;background:#fff;box-shadow:0 0 0 3px rgba(74,124,158,.5),0 0 12px 4px rgba(98,173,231,.75)}
.hero-pulse--2{animation-name:heroPulse2;animation-duration:11s;animation-delay:4.6s}
.hero-pulse--3{animation-name:heroPulse3;animation-duration:10s;animation-delay:7.1s}
@keyframes heroPulse1{0%{opacity:0;transform:translate3d(0%,28.9%,0)}4%{opacity:1}20.3%{transform:translate3d(36.4%,28.9%,0)}25.1%{transform:translate3d(42.5%,17.8%,0)}38.7%{transform:translate3d(67.1%,17.8%,0)}41.8%{transform:translate3d(70.8%,10.5%,0)}46%{opacity:1;transform:translate3d(78.3%,10.5%,0)}50%,100%{opacity:0;transform:translate3d(78.3%,10.5%,0)}}
@keyframes heroPulse2{0%{opacity:0;transform:translate3d(0%,59.2%,0)}4%{opacity:1}17.1%{transform:translate3d(31.9%,59.2%,0)}23.9%{transform:translate3d(41%,75.4%,0)}42.3%{transform:translate3d(75.4%,75.4%,0)}46%{opacity:1;transform:translate3d(80.4%,84%,0)}50%,100%{opacity:0;transform:translate3d(80.4%,84%,0)}}
@keyframes heroPulse3{0%{opacity:0;transform:translate3d(0%,71.2%,0)}4%{opacity:1}15.5%{transform:translate3d(24.8%,71.2%,0)}28.1%{transform:translate3d(39.2%,97%,0)}46%{opacity:1;transform:translate3d(67.9%,97%,0)}50%,100%{opacity:0;transform:translate3d(67.9%,97%,0)}}

/* ---------- floating panels (illustrative, decorative) ----------
   Desktop only: there is no room beside the copy below 1240px. They follow the
   pointer by a few pixels (js/hero.js sets --mx / --my between -1 and 1) and rise
   slightly faster than the page on scroll. */
.hero-panels{display:none}
@media (min-width:1240px){
  .hero-panels{display:block;position:absolute;inset:0;z-index:1;pointer-events:none}
  .hero-panel{position:absolute;display:flex;align-items:center;gap:12px;width:236px;padding:14px 16px;
    background:var(--white);border:1px solid var(--line);border-radius:var(--radius-md);box-shadow:var(--shadow-3);
    color:var(--navy);text-align:left;will-change:transform;
    translate:calc(var(--mx,0) * var(--px,0px)) calc(var(--my,0) * var(--py,0px) + var(--hero-scroll,0) * var(--rise,0px));
    transition:translate .6s var(--ease-out);
    animation:mtsRise .7s var(--ease-out) both}
  /* Glass where a panel sits over the swoosh; solid white where the browser cannot blur. */
  @supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
    .hero-panel--glass{background:var(--glass-bg);-webkit-backdrop-filter:blur(var(--glass-blur));backdrop-filter:blur(var(--glass-blur));border-color:rgba(255,255,255,.7)}
  }
  /* Places, by slot. Left: 1 (and 4 below it). Right: 2 above 3. Slot 5 sits
     beside the headline and needs a very wide screen. */
  .hero-panel--p1{left:max(24px,calc(50% - 620px));top:404px;--px:-10px;--py:-8px;--rise:-26px;animation-delay:.5s}
  .hero-panel--p2{right:max(24px,calc(50% - 620px));top:338px;--px:14px;--py:10px;--rise:-40px;animation-delay:.62s}
  .hero-panel--p3{right:max(64px,calc(50% - 580px));top:496px;--px:22px;--py:16px;--rise:-64px;animation-delay:.74s;box-shadow:var(--shadow-4)}
  .hero-panel--p4{left:max(56px,calc(50% - 588px));top:510px;--px:-18px;--py:-14px;--rise:-52px;animation-delay:.86s;box-shadow:var(--shadow-4)}
  .hero-panels--left-two .hero-panel--p1{top:366px}
  .hero-panel--p5{display:none}
  .hero-panel--meter{flex-direction:column;align-items:stretch;gap:10px}

  .hp-icon{flex:none;display:flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:var(--radius-icon);background:var(--mist);color:var(--navy);font-size:15px;font-weight:700}
  .hp-text{display:flex;flex-direction:column;gap:2px;min-width:0}
  .hp-tag{font-size:10px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--steel)}
  .hp-title{font-size:14.5px;font-weight:600;letter-spacing:-.01em;line-height:1.3}
  .hp-sub{font-size:13px;line-height:1.4;color:var(--steel)}
  .hp-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
  .hp-meter{display:block;height:8px;border-radius:var(--radius-pill);background:var(--mist);overflow:hidden}
  .hp-meter span{display:block;width:78%;height:100%;border-radius:inherit;background:linear-gradient(to right,var(--steel),var(--navy))}
  .hp-dot{flex:none;display:block;width:10px;height:10px;border-radius:50%;background:var(--amber);box-shadow:0 0 0 4px rgba(245,166,35,.18)}
}
@media (min-width:1560px){
  .hero-panel--p5{display:flex;right:max(40px,calc(50% - 740px));top:196px;--px:10px;--py:8px;--rise:-30px;animation-delay:.98s}
}

/* ---------- stats ---------- */
/* Fixed-width digits and a reserved width (set by js/hero.js) so counting up never moves anything. */
.stat-num{font-variant-numeric:tabular-nums;display:inline-block;text-align:center}

/* ---------- technology strip ----------
   A full-width glass band along the foot of the hero with the names moving slowly
   left. The list is printed twice (the second copy is aria-hidden) and the track
   slides by exactly half its width, so the loop is seamless. It pauses on hover,
   on keyboard focus and on tap. */
.hero-stack{position:relative;z-index:2;border-top:1px solid rgba(255,255,255,.65);background:rgba(245,244,242,.9);cursor:default}
@supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
  @media (min-width:861px){
    .hero-stack{background:rgba(255,255,255,.58);-webkit-backdrop-filter:blur(var(--glass-blur));backdrop-filter:blur(var(--glass-blur))}
  }
}
.hero-stack:focus-visible{outline:2px solid var(--amber);outline-offset:-2px}
.hero-stack-inner{display:flex;align-items:center;gap:var(--space-8);max-width:var(--wrap);height:64px;margin:0 auto;padding:0 var(--gutter)}
.hero-stack .stack-label{flex:none}
.stack-marquee{flex:1;min-width:0;overflow:hidden;
  -webkit-mask-image:linear-gradient(to right,transparent 0,#000 7%,#000 93%,transparent 100%);
  mask-image:linear-gradient(to right,transparent 0,#000 7%,#000 93%,transparent 100%)}
.stack-track{display:flex;width:max-content;margin:0;padding:0;list-style:none;will-change:transform;animation:heroMarquee var(--stack-dur,46s) linear infinite}
.stack-track li{flex:none;padding:0 30px;font-size:20px;font-weight:600;letter-spacing:-.02em;white-space:nowrap;color:var(--navy)}
@keyframes heroMarquee{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}
.hero-stack:hover .stack-track,.hero-stack:focus-within .stack-track,.hero-stack.is-paused .stack-track{animation-play-state:paused}

/* ---------- pause every loop when the hero is not being looked at ---------- */
.hero.is-idle .hero-band,.hero.is-idle .hero-pulse,.hero.is-idle .stack-track{animation-play-state:paused}

/* ---------- short laptop screens: keep the next section peeking ---------- */
@media (min-width:861px) and (max-height:780px){
  .hero-main{padding-top:var(--space-6);padding-bottom:var(--space-8)}
  .hero-title{font-size:clamp(40px,5.6vw,66px)}
  .hero-stats{margin-top:var(--space-6)}
  .hero-stack-inner{height:56px}
}

/* ---------- smaller screens ---------- */
/* Below this there is no clear space beside the headline. */
@media (max-width:1179px){
  .hero-circuit{display:none}
}
@media (max-width:860px){
  /* Keep the colour wash low and to the right, clear of the copy. */
  .hero-art::before{background:radial-gradient(70% 26% at 100% 94%,rgba(98,173,231,.22) 0%,rgba(98,173,231,0) 72%)}
  .hero-wave{width:70%}
  .hero-main{padding-bottom:var(--space-8)}
  .hero-stack-inner{gap:var(--space-4);height:56px}
  .stack-track li{padding:0 20px;font-size:18px}
}
@media (max-width:520px){
  .hero-wave{width:96%}
  .hero-stack .stack-label{display:none}
}

/* ---------- reduced motion: a calm, complete hero ---------- */
@media (prefers-reduced-motion:reduce){
  .hero-band,.hero-circuit-wipe,.hero-circuit-inner,.hero-nodes,.hero-panel,.stack-track{animation:none!important;translate:none;transition:none}
  .hero-pulse{display:none}
  /* No movement, so show every name once, wrapped and centred. */
  .stack-marquee{-webkit-mask-image:none;mask-image:none}
  .stack-track{width:auto;flex-wrap:wrap;justify-content:center;row-gap:6px}
  .stack-track li[aria-hidden="true"]{display:none}
  .hero-stack-inner{height:auto;padding-top:var(--space-4);padding-bottom:var(--space-4);flex-wrap:wrap;justify-content:center}
}

/* =====================================================================
   Phase B step 2: services, why us
   ===================================================================== */

/* ---------- services: ribbon artwork ----------
   Two clusters, each two stacked SVG layers. js/home.js writes --p on the
   section (0 as it enters the viewport, 1 as it leaves); the front layer
   travels further than the back one. Each cluster hangs slightly outside the
   section so the travel never uncovers an edge. */
.svc-art{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
.svc-art-cluster{position:absolute}
.svc-art-cluster--tl{left:0;top:-4%;width:clamp(230px,34vw,580px);aspect-ratio:8/7}
.svc-art-cluster--br{right:0;bottom:-3%;width:clamp(440px,78vw,1400px);aspect-ratio:16/9}
.svc-art-layer{position:absolute;inset:0;width:100%;height:100%;overflow:visible;will-change:transform}
.svc-art-layer--back{translate:0 calc((var(--p,.5) - .5) * -5%)}
.svc-art-layer--front{translate:0 calc((var(--p,.5) - .5) * -12%)}

/* ---------- services: cards ---------- */
.svc-card{position:relative;transition:transform var(--dur-fast) var(--ease-std)}
.svc-icon{transition:transform var(--dur-fast) var(--ease-std)}
/* Elevation rises by fading in a second, deeper shadow, so only opacity animates. */
.svc-card::after{content:"";position:absolute;inset:-1px;border-radius:inherit;box-shadow:var(--shadow-3);opacity:0;transition:opacity var(--dur-fast) var(--ease-std);pointer-events:none}
.svc-card:hover{box-shadow:none}
.svc-card:hover::after,.svc-card:focus-visible::after{opacity:1}
.svc-card:focus-visible{outline:2px solid var(--amber);outline-offset:3px}

/* Glass, so the ribbons read through the cards that sit over them. Desktop only:
   a blur behind seven cards is too much work for a phone. */
@media (min-width:861px){
  @supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
    .svc-card:not(.svc-card--navy){background:rgba(255,255,255,.8);-webkit-backdrop-filter:blur(var(--glass-blur));backdrop-filter:blur(var(--glass-blur));border-color:rgba(255,255,255,.75)}
    .svc-card:not(.svc-card--navy) .svc-points{background:rgba(245,244,242,.7)}
  }
}

/* Tilt towards the pointer: mouse only. js/home.js writes --rx / --ry. */
@media (hover:hover) and (pointer:fine){
  .svc-card:hover{transform:perspective(1100px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)) translate3d(0,-4px,0)}
  .svc-card:hover .svc-icon{transform:translate3d(0,-3px,0) scale(1.06)}
}
/* Touch: no tilt, a small press instead. */
@media (hover:none){
  .svc-card:hover{transform:none}
  .svc-card:active{transform:scale(.985)}
}

/* Navy featured card ('tone' => 'navy' in inc/services.php). */
.svc-card--navy{background:linear-gradient(135deg,#0E4A70 0%,var(--navy) 55%,var(--deep) 100%);border-color:rgba(255,255,255,.08);color:var(--bone)}
.svc-card--navy h3{color:#fff}
.svc-card--navy p{color:var(--on-navy)}
/* The tile stays light so the drawing reads on navy. */
.svc-card--navy .svc-icon{background:#EEF2F5}
.svc-card--navy .svc-more{color:#fff}
.svc-card--navy .svc-points{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.14)}
.svc-card--navy .svc-points-label{color:rgba(245,244,242,.62)}
.svc-card--navy .svc-point{color:var(--bone)}
.svc-card--navy .svc-points .check{background:rgba(255,255,255,.14);color:#fff}
.svc-card--navy:hover{border-color:rgba(255,255,255,.22)}

/* ---------- why us: layered illustration ----------
   Seven stacked SVGs. --p comes from js/home.js; --e turns it into "how far
   apart" (0 together, 1 fully separated, reached about half-way up the screen). */
.whyus-illus{position:relative;aspect-ratio:10/9;--e:clamp(0,calc((var(--p,0) - .18) / .34),1)}
.whyus-layer{position:absolute;inset:0;width:100%;height:100%;overflow:visible;will-change:transform;transition:translate .25s linear}
.whyus-layer--rings{translate:0 calc(var(--e) * 1.5%)}
.whyus-layer--shadow{translate:0 calc(var(--e) * 5%)}
.whyus-layer--back{translate:0 calc(var(--e) * -5.5%)}
.whyus-layer--mid{translate:0 calc(var(--e) * -1%)}
.whyus-layer--front{translate:0 calc(var(--e) * 3%)}
.whyus-layer--traces{translate:0 calc(var(--e) * -2.2%)}
.whyus-layer--amber{translate:0 calc(var(--e) * -2.2%);animation:whyusPulse 2.8s ease-in-out infinite}
@keyframes whyusPulse{0%,100%{opacity:1}50%{opacity:.45}}
.whyus-illus.is-idle .whyus-layer--amber{animation-play-state:paused}

/* Value cards: the accent bar draws in as its card rises (scroll-reveal.js
   staggers the cards). Kept shorter than the card's own rise on purpose. */
.value-card.mts-reveal .rule{transform:scaleX(0);transform-origin:left center}
.value-card.mts-reveal.is-in .rule{transform:scaleX(1);transition:transform .34s var(--ease-out) .16s}

/* ---------- services on small screens ---------- */
@media (max-width:860px){
  .services{padding-top:calc(var(--section-y) + 64px)}
  .svc-art-cluster--tl{width:66vw}
  .svc-art-cluster--br{display:none}
}

@media (prefers-reduced-motion:reduce){
  .svc-art-layer,.whyus-layer{translate:none;transition:none}
  .whyus-layer--amber{animation:none}
  .svc-card,.svc-icon,.svc-card::after{transition:none}
  .svc-card:hover,.svc-card:hover .svc-icon,.svc-card:active{transform:none}
  .value-card.mts-reveal .rule{transform:none}
}
