/* =========================================================
   BFI Scrollytelling — v1.1.7 (clean)
   - Focus band widens activation without stretching the card
   - Active panel only is interactive (fixes "clicking an image" issue)
   - Fade = pure opacity; slide/scale keep transforms
   ========================================================= */

.scrolly{
  /* Glass + text */
  --step-bg: rgba(255,255,255,0.12);
  --step-stroke: rgba(255,255,255,0.22);
  --outline-color: rgba(255,255,255,0.35);
  --text-invert: #1e1e1e;

  /* Layout */
  --step-gap: 60vh;
  --sticky-top: 0px;
  --section-bg: #fff;

  /* Figure */
  --figure-overlay: 0;          /* 0 = no dim */
  --progress-color: #111;
  --progress-width: 4px;

  /* Chart (Flourish/embeds) sizing */
  --figure-max-width: 100%;
  --figure-max-height: 60vh;
  --figure-object-fit: contain;

  /* Image-only sizing (falls back to chart values if unset) */
  --image-max-width: var(--figure-max-width);
  --image-max-height: var(--figure-max-height);

  /* Invisible focus padding (vh) to widen active zone */
  --focus-pad: 0vh;
}

/* Base + click-through */
.scrolly{
  position: relative;
  width: 100%;
  min-height: 200vh;
  background: var(--section-bg);
}
.scrolly.bfi-pass-through .scrolly__steps{ pointer-events: none; }
.scrolly.bfi-pass-through .scrolly__steps .step{ pointer-events: auto; }

/* Reassert Flourish interactivity */
.scrolly__figure,
.scrolly__figure * { pointer-events: auto; }

/* Progress bar */
.scrolly .scrolly__progress{
  position: fixed;
  top: var(--sticky-top);
  height: 100vh;
  width: var(--progress-width);
  left: 16px;
  z-index: 3;
  display: grid;
  align-items: start;
}
.bfi-progress-right .scrolly .scrolly__progress{ left: auto; right: 16px; }
.scrolly .scrolly__progress::before{
  content:""; display:block; width:100%; height:100%;
  opacity:.18; background:var(--progress-color); border-radius:999px;
}
.scrolly .scrolly__progress > span{
  position:absolute; inset:0; transform-origin: top; transform: scaleY(0);
  background: var(--progress-color); border-radius: 999px;
}

/* Figure (pinned) */
.scrolly__figure{
  position: sticky; top: var(--sticky-top);
  height: 100vh; width: 100%;
  overflow: hidden; z-index: 1;
  background: transparent;
}
.scrolly__figure::after{
  content:""; position:absolute; inset:0;
  background: rgba(0,0,0, calc(var(--figure-overlay,0)/100));
  pointer-events:none;
}

/* Panels: only the visible one should accept input */
.scrolly__figure .panel{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  opacity:0;
  pointer-events: none;    /* hidden panels can't intercept */
  z-index: 0;
}
.scrolly__figure .panel.is-visible{
  opacity:1;
  pointer-events: auto;    /* active Flourish is interactive */
  z-index: 1;
}

.panel__inner{
  width:100%; height:100%;
  margin:0 auto; display:flex; align-items:center; justify-content:center;
}

/* Image panels use image-specific max dims */
.panel--image .panel__inner{
  max-width: var(--image-max-width);
  max-height: var(--image-max-height);
}

/* Embed/Flourish panels use chart max dims */
.panel--embed .panel__inner{
  max-width: var(--figure-max-width);
  max-height: var(--figure-max-height);
}

/* Media sizing */
.panel--image img{
  width:100%; height:100%;
  object-fit: cover; /* Elementor control can override */
  border:0;
}
.panel--embed iframe,
.panel--embed .flourish-embed{
  width:100%; height:100%;
  object-fit: var(--figure-object-fit);
  border:0;
  pointer-events:auto;
}
/* Ensure Flourish remains interactive */
.scrolly .flourish-embed, .scrolly .flourish-embed iframe{ pointer-events:auto !important; }

/* Transitions */
/* Fade: opacity only */
.bfi-transition-fade .scrolly__figure .panel,
.bfi-transition-fade .scrolly__figure .panel.is-visible {
  transform: none !important;
  transition: opacity .35s ease;
}
/* Slide & scale keep transforms */
.bfi-transition-scale .scrolly__figure .panel{
  transform: scale(1.08);
  transition: opacity .35s ease, transform .6s ease;
}
.bfi-transition-scale .scrolly__figure .panel.is-visible{ transform: scale(1); }
.bfi-transition-slide .scrolly__figure .panel{
  transform: translateX(1.5%);
  transition: opacity .35s ease, transform .6s ease;
}
.bfi-transition-slide .scrolly__figure .panel.is-visible{ transform: translateX(0); }

/* Steps (focus band that doesn't stretch the card) */
.scrolly__steps{
  position:relative; z-index:2; max-width:780px;
  margin:0 auto; padding:10vh 1rem 20vh; color:var(--text-invert);
}
.step{
  margin-top:  calc( var(--step-gap) - (2 * var(--focus-pad)) );
  margin-bottom: calc( var(--step-gap) - (2 * var(--focus-pad)) );
  padding-top: var(--focus-pad);
  padding-bottom: var(--focus-pad);
  background: transparent; border: 0; box-shadow: none; backdrop-filter: none;
}
.step__inner{
  background: var(--step-bg);
  border: 1px solid var(--step-stroke);
  border-radius: 18px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  backdrop-filter: blur(10px);

  transform: translateY(10px);
  opacity: .4;
  transition: transform .4s ease, opacity .4s ease, outline .2s ease, box-shadow .4s ease;
}
.bfi-no-blur .step__inner{ backdrop-filter: none; }
.step.is-active .step__inner{
  transform: translateY(0);
  opacity: 1;
  outline: 2px solid var(--outline-color);
  box-shadow: 0 15px 35px rgba(0,0,0,0.3);
}
.step h2{ margin: 0 0 .35rem; font-size: clamp(1.4rem, 2vw, 2rem); }
.step__content{ line-height: 1.6; font-size: 1.05rem; }

/* Mobile + reduced motion */
@media (max-width:768px){
  .step__inner{ padding: 1.25rem; }
  .step{
    margin-top: calc( (var(--step-gap) * 0.9) - (2 * var(--focus-pad)) );
    margin-bottom: calc( (var(--step-gap) * 0.9) - (2 * var(--focus-pad)) );
  }
}
@media (max-width:768px){
  .bfi-reduce-mobile .step__inner,
  .bfi-reduce-mobile .scrolly__figure .panel{
    transition: none;
  }
}

/* Elementor overlay guard (prevents overlays from eating clicks) */
.elementor-section:has(.scrolly) > .elementor-background-overlay{
  pointer-events: none !important;
}