/* ========================================
   Scroll Timeline
   ========================================
   Alternating left/right timeline with
   scroll-driven progress line + dot markers.
   Cards use lazio-card--numbered-hiw styling.
   ======================================== */

/* ----------------------------------------
   Builder scaffolding: hide from layout
   ---------------------------------------- */
.scroll-timeline > .brx-nestable-children-placeholder,
.scroll-timeline > .brx-nestable-children {
  display: none;
}

/* ----------------------------------------
   Custom properties (defaults)
   ---------------------------------------- */
.scroll-timeline {
  --st-card-width: 47%;
  --st-item-spacing: 4rem;
  --st-track-color: var(--iron-t-2, rgba(142, 140, 139, 0.3));
  --st-progress-color: var(--lazio-orange, #F97316);
  --st-progress-width: 8px;
  --st-marker-size: 24px;
  --st-marker-border: var(--lazio-orange, #F97316);
  --st-marker-active: var(--lazio-orange, #F97316);

  position: relative;
  width: 100%;
}

/* ----------------------------------------
   Track (background line)
   ---------------------------------------- */
.scroll-timeline__track {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: var(--st-progress-width);
  transform: translateX(-50%);
  background-color: var(--st-track-color);
  z-index: 1;
  display: none;                          /* hidden until JS activates */
}

/* ----------------------------------------
   Progress line (fills on scroll)
   ---------------------------------------- */
.scroll-timeline__progress {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--st-progress-width);
  height: 0;
  transform: translateX(-50%);
  background-color: var(--st-progress-color);
  z-index: 2;
  transition: height 0.1s linear;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.3);
  display: none;                          /* hidden until JS activates */
}

/* Show track + progress only when JS has activated */
.scroll-timeline--animated .scroll-timeline__track,
.scroll-timeline--animated .scroll-timeline__progress {
  display: block;
}

/* ----------------------------------------
   Item layout (alternating)
   ---------------------------------------- */
.scroll-timeline__item {
  display: flex;
  width: 100%;
  position: relative;
  padding-bottom: var(--st-item-spacing);
  justify-content: flex-start; /* odd: card on left */
}

.scroll-timeline__item:nth-child(even of .scroll-timeline__item) {
  justify-content: flex-end; /* even: card on right */
}

/* Remove padding from last item */
.scroll-timeline__item:last-child {
  padding-bottom: 0;
}

/* ----------------------------------------
   Card sizing override
   ---------------------------------------- */
.scroll-timeline__card.lazio-card--numbered-hiw {
  width: var(--st-card-width);
  flex: none;
  min-width: 0;
  height: auto;
  text-align: left;
}

/* ----------------------------------------
   Markers (dots on the center line)
   ---------------------------------------- */
.scroll-timeline__marker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--st-marker-size);
  height: var(--st-marker-size);
  border-radius: 50%;
  background-color: var(--cream, #FFF7ED);
  border: 5px solid var(--st-marker-border);
  z-index: 10;
  transition: all 0.3s ease;
}

.scroll-timeline__item.active .scroll-timeline__marker {
  background-color: var(--st-marker-active);
  border-color: var(--st-marker-active);
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.5);
}

/* ----------------------------------------
   Card flip animation
   JS adds .scroll-timeline--animated on frontend only.
   Without it, cards are fully visible (safe for builder).
   Cards hinge from the edge nearest the timeline,
   flipping open like pages from a book spine.
   ---------------------------------------- */

/* 3D context on each item */
.scroll-timeline__item {
  perspective: 1200px;
}

.scroll-timeline__card {
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.22, 1.4),
              opacity 0.5s ease;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

/* Hidden state — only when JS has opted in */

/* Odd (left-side): hinge on right edge, flip away */
.scroll-timeline--animated .scroll-timeline__card {
  opacity: 0;
  transform: rotateY(90deg);
  transform-origin: right center;
}

/* Even (right-side): hinge on left edge, flip away */
.scroll-timeline--animated .scroll-timeline__item:nth-child(even of .scroll-timeline__item) .scroll-timeline__card {
  transform: rotateY(-90deg);
  transform-origin: left center;
}

/* Revealed state */
.scroll-timeline--animated .scroll-timeline__item.revealed .scroll-timeline__card,
.scroll-timeline--animated .scroll-timeline__item.revealed:nth-child(even of .scroll-timeline__item) .scroll-timeline__card {
  opacity: 1;
  transform: rotateY(0deg);
}

/* ----------------------------------------
   Deliverable line
   ---------------------------------------- */
.scroll-timeline__deliverable {
  color: rgba(251, 150, 80, 0.75);
  font-size: var(--text-ml, 1.175rem);
  line-height: 1.3;
  margin: 0;
}

/* ----------------------------------------
   Mobile (<=768px)
   ---------------------------------------- */
@media (max-width: 768px) {
  .scroll-timeline__item,
  .scroll-timeline__item:nth-child(even of .scroll-timeline__item) {
    justify-content: flex-start;
    flex-direction: column;
    padding-left: 50px;
  }

  .scroll-timeline__track,
  .scroll-timeline__progress {
    left: 20px;
  }

  .scroll-timeline__marker {
    left: 20px;
    top: 0;
    transform: translate(-50%, 0);
  }

  .scroll-timeline__item.active .scroll-timeline__marker {
    transform: translate(-50%, 0) scale(1.3);
  }

  .scroll-timeline__card.lazio-card--numbered-hiw {
    width: 100%;
  }

  /* Mobile: flip down from top edge instead of sideways */
  .scroll-timeline--animated .scroll-timeline__card,
  .scroll-timeline--animated .scroll-timeline__item:nth-child(even of .scroll-timeline__item) .scroll-timeline__card {
    transform: rotateX(-90deg);
    transform-origin: top center;
  }

  .scroll-timeline--animated .scroll-timeline__item.revealed .scroll-timeline__card {
    opacity: 1;
    transform: rotateX(0deg);
  }
}
