/* =========================================================
   Scroll Cards Section
   DOM order: [Title col] | [Cards col] | [Progress col]
   RTL flex-direction: row → visual: Title=RIGHT | Cards=CENTER | Progress=LEFT
   ========================================================= */

.scroll-cards-section {
  position: relative;
  width: 100%;
  background-color: #000000;
}

/* Tall wrapper — JS sets height = count × 100vh */
.scroll-cards-wrapper {
  position: relative;
}

/* Sticky viewport-height shell */
.scroll-cards-sticky {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: row; /* RTL page reverses to: title→RIGHT  progress→CENTER  cards→LEFT */
  align-items: stretch;
  overflow: hidden;
}

/* Rotating background image layer */
.scroll-cards-bg {
  position: absolute;
  /* inset: -20%; */
  inset: 0%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 0;
}

/* Dark overlay when a background image is set */
.scroll-cards-section.has-bg .scroll-cards-sticky::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.scroll-cards-section.has-bg .scroll-cards-title-col,
.scroll-cards-section.has-bg .scroll-cards-progress-col,
.scroll-cards-section.has-bg .scroll-cards-content-col {
  position: relative;
  z-index: 2;
}

/* ── Title column ── */
.scroll-cards-title-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  text-align: center;
}

.scroll-section-title {
  margin: 0 0 16px;
  transition: color 0.3s ease;
}

.scroll-section-subtitle {
  line-height: 1.7;
  color: var(--color-dark);
  opacity: 0.6;
  max-width: 520px;
  margin: 0;
  transition: color 0.3s ease;
  text-align: right;
}

.scroll-cards-section.has-bg .scroll-section-title,
.scroll-cards-section.has-bg .scroll-section-subtitle {
  color: #fff;
  opacity: 1;
}

/* ── Progress column ── */
.scroll-cards-progress-col {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-progress-track {
  position: relative;
  width: 3px;
  height: min(55vh, 380px);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

.scroll-cards-section.has-bg .scroll-progress-track {
  background: rgba(255, 255, 255, 0.25);
}

.scroll-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: height 0.18s ease;
  z-index: 1;
}

.scroll-cards-section.has-bg .scroll-progress-fill {
  background: #fff;
}

.scroll-progress-dot {
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #ddd;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition:
    background 0.3s ease,
    transform 0.3s ease;
  z-index: 2;
}

.scroll-progress-dot.is-passed {
  background: var(--color-primary);
  transform: translate(-50%, -50%) scale(1.25);
}

.scroll-cards-section.has-bg .scroll-progress-dot {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.3);
}

.scroll-cards-section.has-bg .scroll-progress-dot.is-passed {
  /* background: #fff; */
  background: var(--color-primary);
}

/* ── Cards column ── */
.scroll-cards-content-col {
  flex: 1;
  min-height: 0; /* allow flex item to shrink below content size */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  gap: 32px;
}

/* Grid stacks all cards in the same cell */
.scroll-cards-list {
  display: grid;
  width: 100%;
  max-width: 480px;
  min-height: 0; /* allow grid to shrink inside flex */
  overflow: hidden;
}

/* ── Individual card ── */
.scroll-card {
  grid-area: 1 / 1;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
}

.scroll-card.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Card image — constrained so it never exceeds available viewport height */
.scroll-card-image {
  max-width: 450px;
  width: 100%;
  max-height: 55vh;
  overflow: hidden;
}

.scroll-card-image img {
  width: 100%;
  height: 100%;
  max-height: 55vh;
  object-fit: contain;
  display: block;
}

/* Content area — padded when there's text/HTML */
.scroll-card-description,
.scroll-card-html {
  padding: 0 36px;
  color: var(--color-white);
}

/* First content child gets top padding; last gets bottom padding */
.scroll-card-image + .scroll-card-description,
.scroll-card-image + .scroll-card-html {
  padding-top: 28px;
}

.scroll-card > :first-child:not(.scroll-card-image) {
  padding-top: 36px;
}

.scroll-card > :last-child {
  padding-bottom: 36px;
}

.scroll-card-description {
  line-height: 1.75;
  color: var(--color-white);
  opacity: 0.8;
  margin: 0 0 16px;
}

.scroll-card-description:last-child {
  margin-bottom: 0;
}

.scroll-card-html {
  line-height: 1.75;
  color: var(--color-white);
}

.scroll-card-html p {
  margin: 0 0 12px;
}

.scroll-card-html p:last-child {
  margin-bottom: 0;
}

.scroll-card-html ul,
.scroll-card-html ol {
  margin: 0;
  padding-right: 20px; /* RTL list indent */
  padding-left: 0;
}

.scroll-card-html li {
  margin-bottom: 8px;
  line-height: 1.6;
}

/* ── Enter / exit animations ── */
@keyframes sc-enter-below {
  from {
    opacity: 0;
    transform: translateY(52px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sc-enter-above {
  from {
    opacity: 0;
    transform: translateY(-52px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sc-exit-above {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-52px);
  }
}

@keyframes sc-exit-below {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(52px);
  }
}

.scroll-card.entering-from-below {
  animation: sc-enter-below 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.scroll-card.entering-from-above {
  animation: sc-enter-above 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.scroll-card.exiting-to-above {
  animation: sc-exit-above 0.4s ease forwards;
  pointer-events: none;
}

.scroll-card.exiting-to-below {
  animation: sc-exit-below 0.4s ease forwards;
  pointer-events: none;
}

/* ── Counter ── */
.scroll-cards-counter {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.counter-current {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-dark);
  line-height: 1;
}

.counter-sep {
  font-size: 1rem;
  color: var(--color-dark);
  opacity: 0.35;
}

.counter-total {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-dark);
  opacity: 0.35;
}

.scroll-cards-section.has-bg .counter-current,
.scroll-cards-section.has-bg .counter-sep,
.scroll-cards-section.has-bg .counter-total {
  color: #fff;
  opacity: 1;
}

.scroll-cards-section.has-bg .counter-sep,
.scroll-cards-section.has-bg .counter-total {
  opacity: 0.6;
}

/* =========================================================
   Mobile — stack vertically, show all cards
   ========================================================= */
@media (max-width: 768px) {
  .scroll-cards-wrapper {
    height: auto !important;
    overflow: hidden;
  }

  .scroll-cards-sticky {
    position: relative;
    height: auto;
    flex-direction: column;
    overflow: visible;
  }

  .scroll-cards-title-col {
    padding: 48px 24px 24px;
    text-align: right;
  }

  .scroll-section-subtitle {
    max-width: 100%;
  }

  .scroll-cards-progress-col {
    display: none;
  }

  .scroll-cards-content-col {
    padding: 0 24px 48px;
    gap: 24px;
  }

  .scroll-cards-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 100%;
    counter-reset: card-index;
  }

  .scroll-card {
    grid-area: unset;
    opacity: 1 !important;
    pointer-events: auto !important;
    animation: none !important;
  }

  .scroll-card:not(:last-child) {
    border-bottom: 1px solid;
  }

  /* Persian index number above each card's content — skips the last card */
  .scroll-card:not(:last-child)::before {
    counter-increment: card-index;
    content: counter(card-index, persian);
    display: block;
    font-size: 4rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    padding: 28px 36px 0;
  }

  /* Reduce top gap on first content element when the number already sits above it */
  .scroll-card:not(:last-child) > :first-child:not(.scroll-card-image) {
    padding-top: 10px;
  }

  .scroll-cards-counter {
    display: none;
  }

  .scroll-card-image {
    max-width: 100%;
    width: 100%;
    max-height: 55vh;
    overflow: hidden;
  }
}
