/* ==========================================================================
   "Services that work around you": the three ways a service is offered.
   - The dark panel carries three pins that jump to the cards and light up as
     you read down them.
   - Each card holds a layered illustration. js/modes.js sets, per card:
       --mx --my  pointer position over the picture, -1 to 1 (eased)
       --sy       how far the card is from the middle of the screen, -1 to 1
       --cv       how far the next card has covered this one, 0 to 1
     and every layer moves by its own --z, so the nearest layers move most.
   - On desktop the cards stack: each one slides up over the last, which
     steps back and dims.
   ========================================================================== */

/* ---- Header panel -------------------------------------------------------- */
.flex-panel {
  background: radial-gradient(120% 90% at 18% 0%, #2F5240 0%, var(--gg-forest) 62%);
  min-height: 22rem;
}

.flex-panel__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.flex-panel__grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.2) 1.5px, transparent 1.6px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(75% 80% at 50% 50%, #000 30%, transparent 100%);
  mask-image: radial-gradient(75% 80% at 50% 50%, #000 30%, transparent 100%);
}

.flex-mark {
  position: absolute;
  height: auto;
  filter: brightness(0) invert(1);
  opacity: 0.06;
}

.flex-mark--1 {
  width: 26rem;
  right: -6rem;
  bottom: -9rem;
  rotate: -14deg;
}

.flex-mark--2 {
  width: 13rem;
  left: -3rem;
  top: -2.5rem;
  rotate: 18deg;
}

.has-motion .flex-mark--1 { animation: mk-drift 22s ease-in-out infinite; }
.has-motion .flex-mark--2 { animation: mk-drift 17s ease-in-out -6s infinite reverse; }

@keyframes mk-drift {
  0%, 100% { translate: 0 0; }
  50% { translate: 18px -14px; }
}

/* ---- The network: a branch from the button to each pin ------------------------------ */
.flex-panel__net {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* contour rings around the button; the pins sit out on them */
.net__contour {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1.5;
}

.net__contour:nth-child(2) {
  stroke-dasharray: 3 9;
  stroke-linecap: round;
}

.net__branch {
  transition: opacity 0.4s ease;
}

.net__under,
.net__line {
  fill: none;
  stroke: var(--gg-green);
  stroke-linecap: round;
  transition: stroke-width 0.35s var(--ease-out), opacity 0.35s ease;
}

.net__under {
  stroke-width: 8;
  opacity: 0.16;
}

.net__line {
  stroke-width: 2.5;
}

/* the branch you point at comes forward and the others step back */
.net.has-lit .net__branch:not(.is-lit) {
  opacity: 0.35;
}

.net__branch.is-lit .net__under {
  stroke-width: 14;
  opacity: 0.3;
}

.net__branch.is-lit .net__line {
  stroke-width: 4.5;
}

.net__node {
  fill: var(--gg-green);
}

.net__node:last-of-type {
  fill: var(--gg-forest);
  stroke: var(--gg-green);
  stroke-width: 3;
}

.net__pulse,
.net__tail {
  fill: var(--gg-white);
}

.net__tail {
  opacity: 0;
}

/* a ring pops where a pulse arrives */
.net__ring {
  fill: none;
  stroke: var(--gg-green);
  stroke-width: 3;
  r: 7;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.net__ring.is-ping {
  animation: net-ping 0.7s ease-out;
}

@keyframes net-ping {
  0% { scale: 1; opacity: 0.9; }
  100% { scale: 4; opacity: 0; }
}

/* ---- Pins ---------------------------------------------------------------------------- */
.flex-panel__pins {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.flexpin {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1rem 0.4rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--gg-white);
  color: var(--gg-ink);
  font-weight: var(--fw-bold);
  font-size: var(--fs-small);
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  transition: background-color 0.3s ease, transform 0.3s var(--ease-spring), box-shadow 0.3s ease;
}

.flexpin__dot {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--gg-tint);
  color: var(--gg-green-deep);
  transition: background-color 0.3s ease, color 0.3s ease, rotate 0.5s var(--ease-spring);
}

.flexpin .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.flexpin__no {
  margin-left: 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(24, 37, 27, 0.18);
  font-size: 0.75rem;
  font-weight: var(--fw-heavy);
  letter-spacing: 0.1em;
  opacity: 0.55;
}

.flexpin:hover,
.flexpin:focus-visible,
.flexpin.is-on {
  background: var(--gg-green);
}

.flexpin:hover {
  transform: translateY(-3px);
}

.flexpin:hover .flexpin__dot,
.flexpin.is-on .flexpin__dot {
  background: var(--gg-ink);
  color: var(--gg-green);
}

.flexpin:hover .flexpin__dot {
  rotate: -12deg;
}

.flex-panel [data-flexhub] {
  transition: transform 0.4s var(--ease-spring);
}

.flex-panel [data-flexhub].is-linking {
  transform: scale(1.05);
}

@media (min-width: 1024px) {
  .flex-panel {
    min-height: 0;
    padding-block: var(--space-8) var(--space-7);
  }

  .flex-panel > h2,
  .flex-panel > .lead {
    max-width: 36rem;
  }

  .flex-panel__net {
    display: block;
  }

  /* the middle pin sits exactly under the button so its branch runs straight */
  .flex-panel__pins {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: min(100%, 60rem);
    margin-top: 8rem;
  }

  .flexpin--1 { justify-self: start; }
  .flexpin--2 { justify-self: center; }
  .flexpin--3 { justify-self: end; }

  .flexpin {
    font-size: 1rem;
    cursor: grab;
    touch-action: none;
    -webkit-user-drag: none;
    user-select: none;
    translate: var(--dx, 0px) var(--dy, 0px);
  }

  .flexpin.is-dragging {
    cursor: grabbing;
    z-index: 5;
  }
}

/* ---- Cards --------------------------------------------------------------- */
.split {
  position: relative;
}

.split::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--gg-ink);
  opacity: calc(var(--cv, 0) * 0.55);
  pointer-events: none;
}

.split__text {
  position: relative;
}

.split__no {
  display: block;
  font-size: var(--fs-small);
  font-weight: var(--fw-heavy);
  letter-spacing: 0.14em;
  opacity: 0.7;
}

@media (min-width: 1024px) {
  .split {
    min-height: 28rem;
  }

  .split__text h3 {
    font-size: clamp(1.625rem, 1.1rem + 1.2vw, 2.25rem);
  }

  .split__text p {
    font-size: var(--fs-lead);
    max-width: 30ch;
  }

  .split__no {
    position: absolute;
    top: var(--space-5);
    left: var(--space-7);
    font-size: clamp(4rem, 7vw, 6.5rem);
    line-height: 1;
    letter-spacing: -0.02em;
    font-weight: var(--fw-heavy);
    opacity: 0.13;
    pointer-events: none;
  }

  .split--reverse .split__no {
    left: auto;
    right: var(--space-7);
  }

}

/* Not pinned (small screens, short windows): the cards simply ease in as they arrive */
.has-motion .modes--flow .split {
  opacity: 0;
  translate: 0 40px;
  transition: opacity 0.7s var(--ease-out), translate 0.8s var(--ease-out);
}

.has-motion .modes--flow .split.is-in {
  opacity: 1;
  translate: 0 0;
}

/* Stacked (desktop): each card comes up over the last as you scroll down. position: sticky does
   the holding; --e (arrival), --cv (covered) and --sy (parallax) come from js/modes.js. */
@media (min-width: 1024px) {
  .has-motion .modes--stack {
    gap: var(--space-8);
    padding-bottom: var(--space-6);
  }

  .has-motion .modes--stack .split {
    position: sticky;
    top: calc(var(--header-h) + 1.25rem + var(--n, 0) * 1rem);
    transform-origin: 50% 0;
    transform: scale(calc((0.94 + 0.06 * var(--e, 1)) * (1 - var(--cv, 0) * 0.06)));
    will-change: transform;
    box-shadow: 0 -14px 40px rgba(24, 37, 27, 0.16);
  }

  .has-motion .modes--stack .split:nth-child(2) { --n: 1; }
  .has-motion .modes--stack .split:nth-child(3) { --n: 2; }

  /* parallax: the text and the number drift against the card as it passes */
  .has-motion .modes--stack .split__text h3 { translate: 0 calc(var(--sy, 0) * -10px); }
  .has-motion .modes--stack .split__text p { translate: 0 calc(var(--sy, 0) * -22px); }
  .has-motion .modes--stack .split__no { translate: 0 calc(var(--sy, 0) * -48px); }
  .has-motion .modes--stack .mscene__l { will-change: translate; }
}

/* Smaller screens: the cards ease in as they arrive */
.has-motion .modes--flow .split {
  opacity: 0;
  translate: 0 40px;
  transition: opacity 0.7s var(--ease-out), translate 0.8s var(--ease-out);
}

.has-motion .modes--flow .split.is-in {
  opacity: 1;
  translate: 0 0;
}

/* ---- The illustration ----------------------------------------------------- */
.mscene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
}

.mscene__l {
  position: absolute;
  inset: -12%;
  pointer-events: none;
  translate: calc(var(--mx, 0) * var(--z, 0) * 1px) calc((var(--my, 0) + var(--sy, 0) * 0.6) * var(--z, 0) * 1px);
}

.mscene__l svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sc-ripple,
.sc-arc {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.has-motion .mscene__l--float svg {
  animation: gg-bob 4.5s ease-in-out infinite;
}

.has-motion .sc-ripple {
  animation: sc-ripple 2.4s ease-out infinite;
}

.has-motion .sc-arc {
  animation: sc-arc 2.2s ease-in-out infinite;
}

.has-motion .sc-arc--2 { animation-delay: 0.25s; }
.has-motion .sc-arc--3 { animation-delay: 0.5s; }

@keyframes sc-ripple {
  0% { scale: 0.4; opacity: 0.9; }
  100% { scale: 1.8; opacity: 0; }
}

@keyframes sc-arc {
  0%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.is-measuring .mscene__l {
  translate: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .net__ring,
  .flex-mark,
  .mscene__l svg,
  .sc-ripple,
  .sc-arc {
    animation: none !important;
  }
}

/* the third card is white so it stands out from the pale section behind it */
.split--white {
  background: var(--gg-white);
  --split-bg: var(--gg-white);
}
