/*
 * Cinematic home page (assets/js/fl-cinema.js).
 * Everything that changes the static look lives under html.fl-cine (added by the script only
 * when motion is allowed), so no-JS and reduced-motion visitors keep the finished page.
 * Initial hidden states are set inline by GSAP, never here.
 */

/* ---------- Intro curtain ---------- */
/* Painted by CSS from the very first frame (class set by the inline head script), then handed to the real element. */
html.fl-cine-pre::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: linear-gradient(160deg, #101c30, #17253b 45%, #3a506b);
  animation: fl-cine-pre-out 0.01s linear 2.2s forwards; /* last resort if the script never arrives */
}
@keyframes fl-cine-pre-out {
  to { visibility: hidden; }
}
.fl-cine-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: linear-gradient(160deg, #101c30, #17253b 45%, #3a506b);
  color: #fff;
  will-change: transform;
}
/* Feathered lower edge: the curtain dissolves into the white page as it lifts. */
.fl-cine-intro::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16vh;
  background: linear-gradient(to bottom, rgba(58, 80, 107, 0.5), rgba(58, 80, 107, 0));
  pointer-events: none;
}
.fl-cine-intro__brand {
  display: flex;
  gap: 8px;
  font-size: clamp(30px, 4.4vw, 44px);
  letter-spacing: -0.02em;
}
.fl-cine-intro__a {
  font-weight: 600;
  text-transform: uppercase;
}
.fl-cine-intro__b {
  font-weight: 400;
  color: #8adbd6;
}
.fl-cine-intro__sub {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}
.fl-cine-intro__bar {
  width: min(220px, 52vw);
  height: 2px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
.fl-cine-intro__bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4a8db7, #22a6b3);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- Split text ---------- */
html.fl-cine .fl-cine-m {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* room for descenders and tight tracking inside the clip */
  padding: 0 0.06em 0.14em;
  margin: 0 -0.06em -0.14em;
}
html.fl-cine .fl-cine-w {
  display: inline-block;
  will-change: transform, opacity;
}

/* ---------- Hero ---------- */
html.fl-cine .fl-hero {
  position: relative;
  isolation: isolate;
}
.fl-cine-glows {
  position: absolute;
  inset: -80px 0 0;
  z-index: -1;
  pointer-events: none;
}
.fl-cine-glow {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.fl-cine-glow--1 {
  left: 2%;
  top: 4%;
  width: 62%;
  aspect-ratio: 1;
  background: radial-gradient(closest-side, rgba(34, 166, 179, 0.16), rgba(34, 166, 179, 0));
}
.fl-cine-glow--2 {
  right: 2%;
  top: 22%;
  width: 56%;
  aspect-ratio: 1;
  background: radial-gradient(closest-side, rgba(74, 141, 183, 0.18), rgba(74, 141, 183, 0));
}
.fl-cine-glow--3 {
  left: 28%;
  top: 58%;
  width: 46%;
  aspect-ratio: 1;
  background: radial-gradient(closest-side, rgba(58, 80, 107, 0.1), rgba(58, 80, 107, 0));
}
.fl-cine-cue {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  width: 1px;
  height: 44px;
  pointer-events: none;
}
.fl-cine-cue span {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: rgba(23, 37, 59, 0.14);
  animation: fl-cine-cue-in 0.8s ease 1.9s backwards;
}
.fl-cine-cue span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent, #22a6b3 50%, transparent);
  transform: translateY(-100%);
  animation: fl-cine-cue 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes fl-cine-cue-in {
  from { opacity: 0; }
}
@keyframes fl-cine-cue {
  to { transform: translateY(100%); }
}

/* ---------- The problem: the loop animation gives way to scroll-driven state ---------- */
html.fl-cine .fl-site.fl-js .fl-hproblem__step::after {
  opacity: 1;
  animation: none;
  background: linear-gradient(90deg, #4a8db7, #22a6b3);
  background-size: 100% 100%;
  background-position: 0 0;
  transform: scaleX(var(--fill, 1));
  transform-origin: left center;
}
html.fl-cine .fl-site.fl-js .fl-hproblem__step .fl-hproblem__icon::after {
  animation: none;
}
html.fl-cine .fl-site.fl-js .fl-hproblem__step .fl-hproblem__pain::before {
  transition: none;
  transform: scale(var(--pop, 1));
}
@media (max-width: 899px) {
  html.fl-cine .fl-site.fl-js .fl-hproblem__step::after {
    background: linear-gradient(180deg, #4a8db7, #22a6b3);
    transform: scaleY(var(--fill, 1));
    transform-origin: center top;
  }
}

/* ---------- Video ---------- */
html.fl-cine .fl-demo-video__frame {
  /* a large translucent blur re-rasterised on every scrubbed frame is the costly part; the page behind is plain white */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* ---------- Pillars: sticky stack (desktop; the class is toggled by the script) ---------- */
html.fl-cine-stack #pillars .fl-features {
  display: block;
}
html.fl-cine-stack #pillars .fl-features > li {
  position: sticky;
  top: calc(var(--fl-nav-h) + 24px + var(--k, 0) * 18px);
  display: block;
  margin-bottom: 14vh;
}
html.fl-cine-stack #pillars .fl-features > li:last-child {
  margin-bottom: 0;
}
html.fl-cine-stack #pillars .fl-features > li:focus-within {
  z-index: 5; /* a keyboard user reaching a covered card sees it in front */
}
html.fl-cine-stack #pillars .fl-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas:
    "i t l"
    "i t k";
  align-content: center;
  column-gap: 32px;
  row-gap: 12px;
  min-height: clamp(260px, 36vh, 330px);
  padding: 36px 40px;
  position: relative;
  transform-origin: 50% 0;
  /* cards overlap, so they cannot be see-through */
  background: #f8fafc;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
/* Receding is a tint, not transparency: a see-through card would show the one beneath it. */
html.fl-cine-stack #pillars .fl-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #17253b;
  opacity: var(--dim, 0);
  pointer-events: none;
}
html.fl-cine-stack #pillars .fl-card:hover {
  transform: none;
}
html.fl-cine-stack #pillars .fl-card > .fl-card__icon { grid-area: i; }
html.fl-cine-stack #pillars .fl-card > div:not(.fl-card__links) { grid-area: t; align-self: center; }
html.fl-cine-stack #pillars .fl-card > .fl-card__list { grid-area: l; align-self: end; }
html.fl-cine-stack #pillars .fl-card > .fl-card__links { grid-area: k; align-self: start; }
html.fl-cine-stack #pillars .fl-card__title {
  font-size: 28px;
  letter-spacing: -0.02em;
}
html.fl-cine-stack #pillars .fl-card__body {
  font-size: 16px;
  max-width: 44ch;
}

/* ---------- Journey ---------- */
html.fl-cine .fl-site.fl-js .fl-diagram [data-fl-step] {
  transition: none; /* scrubbed values must not be eased a second time by the CSS transition */
}
html.fl-cine .fl-site.fl-js .fl-diagram .fl-dg-token {
  opacity: 1;
  transform: none;
  transition: none;
}

/* ---------- Call to action ---------- */
.fl-cine-cta-bg {
  position: absolute;
  inset: -12% 0;
  pointer-events: none;
  background:
    radial-gradient(80% 50% at 20% 10%, var(--fl-cta-glow-1) 0%, transparent 70%),
    radial-gradient(70% 50% at 90% 95%, var(--fl-cta-glow-2) 0%, transparent 70%);
  will-change: transform;
}
html.fl-cine .fl-cta__panel.fl-cine-bg {
  background: var(--fl-cta-base);
}
html.fl-cine .fl-footer {
  overflow: clip;
}
