/* KinBridge care-team flip cards, replacing Lava's testimonial marquee (#testimonial).
   Mounted by kb-doctors.js after Framer hydrates.

   The flip is PITSTOP's merchant-hero card flip (Desktop/PITSTOP/home.html, .ps-rh__flip), itself the
   Fitness Connection / shopify.com pricing flip: rotateY 180deg over .8s cubic-bezier(.65,0,.35,1) with a
   12px lift; the slot (which never turns) takes the hover so the card can't slip out from under the
   cursor edge-on; perspective is 4 card widths; front and back swap with `visibility` as the card turns
   edge-on (.4s in), so nothing relies on backface-visibility (WebKit builds ignore it). Keyboard focus
   flips a card, a tap flips it on touch screens, and under reduced motion the back fades in.
   Card layout is PITSTOP's too: number top right, the word at the foot over a shade; the back is the
   solid brand navy with number, role row and the qualification at the foot. Type, radius and colours are Lava's (Rethink Sans, 16px). */

#testimonial [data-framer-name="Ticker Stack"] { display: none !important; }

/* the section takes one full screen: heading + cards, centred (Framer already centres its flex column).
   kb-doctors.js measures what's left under the heading and sets --kbd-h, the card height budget. */
#testimonial.framer-1l99pid { min-height: 100svh; padding-block: 96px 56px; box-sizing: border-box; }  /* top clears the fixed nav */
#testimonial [data-framer-name="Container"] { gap: 40px; }

.kbd {
  --kbd-gap: 20px;
  --kbd-radius: 16px;
  --kbd-ease: cubic-bezier(.65, 0, .35, 1);
  --kbd-h: 600px;                 /* card height budget, set by kb-doctors.js */
  --kbd-w: calc(var(--kbd-h) * 720 / 1016);
  width: 100%;
  max-width: 1440px;              /* Lava's grid: lines up with the nav's logo and button */
  margin: 0 auto;
  padding: 0 80px;
  box-sizing: border-box;
  font-family: "Rethink Sans", "Rethink Sans Placeholder", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.kbd-row {
  display: grid;
  /* as big as the screen allows: an equal share of the row (one column per card, --kbd-cols set by
     kb-doctors.js), or what the height budget allows */
  grid-template-columns: repeat(var(--kbd-cols, 3), min(calc((100% - (var(--kbd-cols, 3) - 1) * var(--kbd-gap)) / var(--kbd-cols, 3)), var(--kbd-w)));
  justify-content: center;
  gap: var(--kbd-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- slot: the hover / focus / tap target. It never turns. ---- */
.kbd-slot {
  position: relative;
  aspect-ratio: 720 / 1016;
  container-type: inline-size;
  perspective: 400cqw;            /* 4 card widths, as PITSTOP */
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kbd-slot:focus-visible .kbd-flip { box-shadow: 0 0 0 3px rgb(255 214 0), 0 0 0 5px rgb(20 43 111); border-radius: var(--kbd-radius); }

/* entrance: the cards slide in from the right and settle, one after another
   (PITSTOP's side cards slide in; Lava's appear effects rise 40px) */
.kbd.is-ready .kbd-slot {
  opacity: 0;
  translate: 48px 0;
  scale: .92;
  transition: opacity .7s cubic-bezier(.25, .8, .25, 1), translate .7s cubic-bezier(.25, .8, .25, 1), scale .7s cubic-bezier(.25, .8, .25, 1);
  transition-delay: calc(var(--i) * 110ms);
}
.kbd.is-ready.is-in .kbd-slot { opacity: 1; translate: 0 0; scale: 1; }

.kbd-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .8s var(--kbd-ease), translate .8s cubic-bezier(.25, .8, .25, 1);
}
.kbd-face,
.kbd-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--kbd-radius);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ---- front: portrait, number top right, name + role at the foot ---- */
.kbd-face { background: #142b6f; transition: visibility 0s .4s; }
.kbd-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}
.kbd-word {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8% 9% 9%;
  box-sizing: border-box;
  color: #fff;
  background: linear-gradient(to bottom, rgb(0 0 0 / .18), transparent 22%, transparent 52%, rgb(0 0 0 / .62));
  border-radius: var(--kbd-radius);   /* the shade must take the card's corners, or it shows square ones */
  pointer-events: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: visibility 0s .4s;
}
.kbd-n {
  align-self: flex-end;
  font-weight: 600;
  font-size: 13cqw;
  line-height: 1;
  letter-spacing: -.03em;
  text-shadow: 0 1px 12px rgb(0 0 0 / .25);
}
.kbd-foot { display: flex; flex-direction: column; gap: 1.5cqw; }
.kbd-name { font-size: max(13px, 5cqw); font-weight: 500; line-height: 1.2; opacity: .88; }
.kbd-role { font-size: 11.5cqw; font-weight: 600; line-height: 1; letter-spacing: -.035em; }

/* ---- back ---- */
.kbd-back {
  visibility: hidden;
  transition: visibility 0s .4s;
  transform: rotateY(180deg);
  color: #fff;
  background: #142b6f;            /* solid brand navy, no photo on the back */
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12);
}
.kbd-bk {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8% 9% 9%;
  box-sizing: border-box;
  text-align: start;
}
.kbd-bk .kbd-n { margin-bottom: 7cqw; }
.kbd-bk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: max(13px, 4.6cqw);
  line-height: 1.3;
  font-weight: 600;
}
.kbd-bk-name { display: flex; align-items: center; gap: max(8px, 2.6cqw); }
.kbd-bk-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: max(26px, 9.5cqw);
  height: max(26px, 9.5cqw);
  border-radius: 50%;
  background: rgb(255 255 255 / .16);
}
.kbd-bk-ic svg { width: 54%; height: 54%; }
.kbd-bk-feats {
  display: flex;
  flex-direction: column;
  row-gap: max(8px, 2.8cqw);
  margin-top: auto;
  padding-top: max(12px, 4cqw);
  border-top: 1px solid rgb(255 214 0 / .55);   /* gold rule over the qualification, the card's one fact */
  font-size: max(19px, 8.4cqw);   /* the card's one fact, at headline size */
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.kbd-bk-feats p { margin: 0; padding-bottom: max(8px, 2.8cqw); border-bottom: 1px solid rgb(255 255 255 / .12); }
.kbd-bk-feats p:last-child { padding-bottom: 0; border-bottom: 0; }
/* several qualifications: one per line, smaller than the single-fact headline size */
.kbd-bk-feats--list { font-size: max(14px, 5.6cqw); line-height: 1.2; letter-spacing: -.01em; row-gap: max(6px, 2.2cqw); }
.kbd-bk-feats--list p { padding-bottom: max(6px, 2.2cqw); }

/* ---- turned states ---- */
.kbd-slot:is(:focus-visible, .is-flipped) .kbd-back { visibility: visible; }
.kbd-slot:is(:focus-visible, .is-flipped) .kbd-flip { transform: rotateY(180deg); }
@media (prefers-reduced-motion: no-preference) {
  .kbd-slot:is(:focus-visible, .is-flipped) :is(.kbd-face, .kbd-word) { visibility: hidden; }
}
@media (hover: hover) {
  .kbd-slot:hover .kbd-back { visibility: visible; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .kbd-slot:hover :is(.kbd-face, .kbd-word) { visibility: hidden; }
  .kbd-slot:hover .kbd-flip { transform: rotateY(180deg); translate: 0 -12px; }
}

/* reduced motion: no turn, the back fades in over the front */
@media (prefers-reduced-motion: reduce) {
  .kbd-flip { transition: none; }
  .kbd-back { transform: none; opacity: 0; transition: opacity .2s ease, visibility 0s; }
  .kbd-slot:is(:hover, :focus-visible, .is-flipped) .kbd-back { opacity: 1; visibility: visible; }
  .kbd-slot:is(:hover, :focus-visible, .is-flipped) .kbd-flip { transform: none; translate: none; }
  .kbd.is-ready .kbd-slot { transition: opacity .4s ease; translate: none; scale: none; }
}

/* ---- tablet + phone: one swipeable row (Lava's marquee was a row too) ---- */
@media (max-width: 1199.98px) {
  /* break out of Lava's padded container so cards slide in from the screen edge */
  #testimonial.framer-1l99pid { padding-block: 88px 48px; }
  #testimonial [data-framer-name="Container"] { gap: 24px; }
  .kbd { padding: 0; width: 100vw; max-width: none; margin-inline: calc(50% - 50vw); }
  .kbd-row {
    display: flex;
    justify-content: flex-start;    /* centring an overflowing flex row pushes the first cards out of reach */
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 24px;
    padding: 16px 24px 20px;        /* room for the 12px lift and the focus ring */
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .kbd-row::-webkit-scrollbar { display: none; }
  .kbd-slot { flex: 0 0 max(240px, min(82vw, var(--kbd-w), 440px)); scroll-snap-align: start; }
  .kbd-row::after { content: ""; flex: 0 0 8px; }   /* end padding that survives overflow */
}
