/* ============================================================
   CF Scroll Features — sticky-scroll feature showcase widget
   ============================================================ */

/* ── Outer: creates the scroll space ─────────────────────── */

.cfsf-outer {
  position: relative;
  /* Height is also enforced via JS to ensure CSS vars resolve in time */
  height: calc(100vh + var(--steps, 1) * var(--step-px, 450px));
}

/* ── Sticky panel ─────────────────────────────────────────── */

.cfsf-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Two-column layout ────────────────────────────────────── */

.cfsf-layout {
  display: grid;
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  width: 100%;
  max-width: 1200px;
  padding: 0 clamp(1.5rem, 4vw, 3rem);
}

.cfsf-phone-right {
  grid-template-columns: 1fr auto;
}
.cfsf-phone-right .cfsf-features-col { order: 1; }
.cfsf-phone-right .cfsf-phone-col    { order: 2; }

.cfsf-phone-left {
  grid-template-columns: auto 1fr;
}
.cfsf-phone-left .cfsf-features-col { order: 2; }
.cfsf-phone-left .cfsf-phone-col    { order: 1; }

/* ── Intro text ───────────────────────────────────────────── */

.cfsf-intro {
  margin-bottom: clamp(1.5rem, 3vh, 2.5rem);
}

.cfsf-intro-heading {
  margin: 0 0 0.5rem;
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.cfsf-intro-subheading {
  margin: 0;
  font-size: 1rem;
  opacity: 0.6;
  line-height: 1.6;
  max-width: 40ch;
}

/* ── Feature list ─────────────────────────────────────────── */

.cfsf-features-list {
  display: flex;
  flex-direction: column;
  gap: clamp(1.2rem, 2.5vh, 2rem);
}

.cfsf-feature {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  opacity: 0.35;
  transform: translateX(-4px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  cursor: default;
}

.cfsf-feature.active,
.cfsf-feature.done {
  opacity: 1;
  transform: translateX(0);
}

/* ── Check circle ─────────────────────────────────────────── */

.cfsf-check {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #d0d5dd;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.cfsf-feature.active .cfsf-check,
.cfsf-feature.done  .cfsf-check {
  background: #2050ce;
  border-color: #2050ce;
}

/* Use transition (not animation) so the tick reliably appears/disappears
   as classes are toggled during scroll */
.cfsf-check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(0.4) rotate(-20deg);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cfsf-feature.active .cfsf-check svg,
.cfsf-feature.done  .cfsf-check svg {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ── Feature text ─────────────────────────────────────────── */

.cfsf-feature-body {
  padding-top: 3px;
}

.cfsf-feature-title {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  transition: color 0.35s ease;
}

.cfsf-feature.active .cfsf-feature-title {
  color: #2050ce;
}

.cfsf-feature-subtitle {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  opacity: 0.6;
}

/* ── Progress bar (mobile only) ───────────────────────────── */

.cfsf-progress-bar {
  display: none;
  height: 3px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-top: 1.5rem;
  overflow: hidden;
}

.cfsf-progress-bar-fill {
  height: 100%;
  background: #2050ce;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ── Phone column ─────────────────────────────────────────── */

.cfsf-phone-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Phone frame ──────────────────────────────────────────── */

.cfsf-phone-frame {
  position: relative;
  /* phone width drives all other proportions via clamp + vw */
  width: clamp(200px, 20vw, 270px);
}

/* Side buttons */
.cfsf-phone-btn {
  position: absolute;
  background: #1c1c2a;
  border-radius: 2px;
  z-index: 0;
}
.cfsf-phone-btn--power {
  right: -4px; top: 28%;
  width: 4px; height: 14%;
  border-radius: 0 2px 2px 0;
}
.cfsf-phone-btn--vol-up {
  left: -4px; top: 22%;
  width: 4px; height: 9%;
  border-radius: 2px 0 0 2px;
}
.cfsf-phone-btn--vol-dn {
  left: -4px; top: 34%;
  width: 4px; height: 9%;
  border-radius: 2px 0 0 2px;
}

/* ── Phone body ───────────────────────────────────────────── */

.cfsf-phone-body {
  position: relative;
  isolation: isolate; /* own stacking context so ::after can sit above screenshots */
  width: 100%;
  /* Exact iPhone 15 screenshot ratio (1179 × 2556 px = 393 × 852 logical) */
  aspect-ratio: 393 / 852;
  background: #0f0f1a;
  /* Outer device corner radius scales with phone width:
     iPhone device ≈ 14% of body width → 14% × clamp(200,20vw,270) ≈ clamp(28px,2.8vw,38px) */
  border-radius: clamp(28px, 2.8vw, 38px);
  overflow: hidden; /* clips screenshots to rounded rect */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 32px 80px rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Bezel ring overlay — always paints above screenshots.
   Uses inset box-shadow so it renders inside the element
   but z-index: 10 keeps it above the phone-screen layer.
   border-radius matches the body via inherit. */
.cfsf-phone-body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 7px #1c1c2a,                    /* main bezel */
    inset 0 0 0 8px rgba(255, 255, 255, 0.06),   /* rim highlight */
    inset 0 1px 0 8px rgba(255, 255, 255, 0.04); /* top glare */
  pointer-events: none;
  z-index: 10;
}

/* ── Phone screen (clips screenshots) ────────────────────── */

.cfsf-phone-screen {
  position: absolute;
  inset: 0;
  /* Inner screen corner radius ≈ 11% of screen width (44pt / 393pt on iOS).
     After the 7px bezel: clamp(21px, 2.1vw, 29px). */
  border-radius: clamp(21px, 2.1vw, 29px);
  overflow: hidden;
  background: #0d0d12;
}

/* Dynamic island — sized to match iPhone 15 Pro proportions:
   ~126pt wide × 37pt tall on a 393pt-wide screen */
.cfsf-phone-island {
  position: absolute;
  top: 3.5%; left: 50%;
  transform: translateX(-50%);
  width: 32%;
  height: 0;
  /* Use padding-top to give pixel-accurate height relative to width */
  padding-top: calc(32% * 37 / 126);
  background: #0a0a12;
  border-radius: 100px;
  z-index: 20;
  pointer-events: none;
}

/* Home indicator */
.cfsf-phone-home {
  position: absolute;
  bottom: 2%; left: 50%;
  transform: translateX(-50%);
  width: 30%; height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  z-index: 20;
  pointer-events: none;
}

/* ── Screenshots ──────────────────────────────────────────── */

.cfsf-shot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* No fixed height — image fills the phone width and is as tall as the
     screenshot naturally is; phone-screen clips the bottom. */
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

.cfsf-shot[data-state="before"] {
  opacity: 0;
  transform: translateY(30px);
}

.cfsf-shot[data-state="active"] {
  opacity: 1;
  transform: translateY(0);
}

.cfsf-shot[data-state="after"] {
  opacity: 0;
  transform: translateY(-30px);
}

.cfsf-shot img {
  width: 100%;
  height: auto;
  display: block;
}

/* Placeholder when no screenshot uploaded */
.cfsf-shot-placeholder {
  width: 100%;
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #181075 0%, #2050ce 60%, #d516b1 100%);
  padding: 1rem;
}

.cfsf-shot-placeholder span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

/* ── Elementor editor: show full layout statically ────────── */

.elementor-editor-active .cfsf-outer  { height: auto !important; }
.elementor-editor-active .cfsf-sticky { position: relative; height: auto; padding: 4rem 0; }
.elementor-editor-active .cfsf-feature { opacity: 1; transform: none; }
.elementor-editor-active .cfsf-feature .cfsf-check svg { opacity: 1; transform: none; }
.elementor-editor-active .cfsf-feature .cfsf-check { background: #2050ce; border-color: #2050ce; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 900px) {
  .cfsf-outer  { height: auto !important; }

  .cfsf-sticky {
    position: relative;
    height: auto;
    padding: 3rem 0;
  }

  .cfsf-layout,
  .cfsf-phone-right,
  .cfsf-phone-left {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .cfsf-features-col { order: 2 !important; }
  .cfsf-phone-col    { order: 1 !important; }

  .cfsf-phone-frame { width: clamp(160px, 40vw, 220px); margin: 0 auto; }

  /* Show all features fully on mobile */
  .cfsf-feature { opacity: 1 !important; transform: none !important; }
  .cfsf-feature .cfsf-check { background: #2050ce; border-color: #2050ce; }
  .cfsf-feature .cfsf-check svg { opacity: 1; transform: scale(1) rotate(0deg); }

  .cfsf-progress-bar { display: block; }

  .cfsf-shot[data-state="before"],
  .cfsf-shot[data-state="after"]  { opacity: 0; transform: none; }
  .cfsf-shot[data-state="active"] { opacity: 1; }

  .cfsf-intro-heading { font-size: 1.6rem; }
}
