/* ==========================================================================
   Texium Solutions — Stacking Cards widget
   Full-bleed image-backed cards that stack on scroll. The background
   treatment is layered so the left stays calm enough for text while the
   right reads as a real photograph:

     __background-blur   soft, scaled copy that melts the image into the
                         light left side (no hard edge to the artwork)
     __background        the sharp image itself
     __gradient          white -> pale blue wash left-to-right, plus a
                         blue atmospheric fade on the right edge
     __content           the text, above all of it

   Consumes design tokens from theme.css only.
   ========================================================================== */

.texium-stacking {
  --texium-stack-offset: 24px;
  --texium-stack-top: 120px;
  --texium-stack-height: 420px;
  --texium-stack-radius: 24px;

  display: flex;
  flex-direction: column;
  gap: var(--texium-space-xl);
}

/* ---- The card ---- */

.texium-stacking-card {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--texium-stack-height);
  padding: var(--texium-space-2xl);
  border-radius: var(--texium-stack-radius);
  border: 1px solid var(--texium-border);
  background: var(--texium-background-soft);
  /* Clips every background layer to the rounded corners, so the image
     never squares off the card while stacking. */
  overflow: hidden;
  isolation: isolate;

  /* Stacking: each card sticks a little lower than the one before, so
     the previous card stays visible underneath as it is covered. */
  position: sticky;
  top: calc(var(--texium-stack-top) + var(--texium-stack-index, 0) * var(--texium-stack-offset));
  box-shadow: var(--texium-shadow-lg);
}

/* ---- Layer 1: blurred copy ----
   Sits behind the sharp image and bleeds past the card edges, so the
   artwork dissolves into the light side instead of ending abruptly. */

.texium-stacking-card__background-blur {
  position: absolute;
  inset: -8%;
  z-index: -3;
  background-image: var(--texium-stack-image, none);
  background-size: cover;
  background-position: var(--texium-stack-position, center right);
  background-repeat: no-repeat;
  filter: blur(18px);
  transform: scale(1.05);
  opacity: 0.55;
  pointer-events: none;
}

/* ---- Layer 2: the sharp image ---- */

.texium-stacking-card__background {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: var(--texium-stack-image, none);
  background-size: cover;
  background-position: var(--texium-stack-position, center right);
  background-repeat: no-repeat;
  transform: scale(var(--texium-stack-scale, 1));
  transform-origin: center right;
  /* Only this layer moves on hover, so the content never shifts. */
  transition: transform 700ms var(--texium-ease-out);
  pointer-events: none;
}

@media (hover: hover) {
  .texium-stacking-card:hover .texium-stacking-card__background {
    transform: scale(calc(var(--texium-stack-scale, 1) * 1.03));
  }
}

/* ---- Layer 3: the gradients ----
   Two stops in one element: a white-to-pale-blue wash running left to
   right (the text-safe area), and a blue atmospheric fade on the right
   edge so the photo reads as part of the UI rather than dropped in.
   The percentages are offset by --texium-stack-shield, which the editor
   can raise per card to push the light area further right when an image
   is busy behind the heading. */

.texium-stacking-card__gradient {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(255, 255, 255, 0.92) calc(22% + var(--texium-stack-shield, 0%)),
      rgba(235, 245, 255, 0.78) calc(42% + var(--texium-stack-shield, 0%)),
      rgba(190, 220, 250, 0.38) calc(65% + var(--texium-stack-shield, 0%)),
      rgba(80, 145, 220, 0.12) 100%
    ),
    linear-gradient(
      90deg,
      transparent calc(55% + var(--texium-stack-shield, 0%)),
      rgba(45, 125, 220, 0.08) calc(72% + var(--texium-stack-shield, 0%)),
      rgba(25, 100, 200, 0.22) 100%
    );
}

/* A card with no image still gets the wash, so the set stays coherent. */

.texium-stacking-card--no-image .texium-stacking-card__background,
.texium-stacking-card--no-image .texium-stacking-card__background-blur {
  display: none;
}

/* ---- Content ---- */

.texium-stacking-card__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--texium-space-sm);
  max-width: var(--texium-stack-content-width, 46%);
}

.texium-stacking-card__eyebrow {
  font-size: var(--texium-font-size-xs);
  font-weight: var(--texium-weight-bold);
  letter-spacing: var(--texium-tracking-wide);
  text-transform: uppercase;
  color: var(--texium-primary);
}

.texium-stacking-card__heading {
  margin: 0;
  font-family: var(--texium-font-heading);
  font-size: var(--texium-font-size-h3);
  font-weight: var(--texium-weight-bold);
  line-height: var(--texium-leading-heading);
  color: var(--texium-heading);
  text-wrap: balance;
}

.texium-stacking-card__description {
  margin: 0;
  font-size: var(--texium-font-size-md);
  line-height: var(--texium-leading-body);
  color: var(--texium-text-muted);
}

.texium-stacking-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--texium-space-xs);
  padding: 0.7rem 1.4rem;
  border-radius: var(--texium-radius-pill);
  background: var(--texium-primary);
  font-size: var(--texium-font-size-sm);
  font-weight: var(--texium-weight-semibold);
  color: var(--texium-text-inverse);
  text-decoration: none;
  transition: background-color var(--texium-transition-fast);
}

.texium-stacking-card__cta:hover {
  background: var(--texium-primary-dark);
}

.texium-stacking-card__cta-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  overflow: hidden;
}

.texium-stacking-card__cta-arrow svg {
  width: 100%;
  height: 100%;
  transform: rotate(-45deg);
}

.texium-stacking-card__cta:focus-visible {
  outline: 2px solid var(--texium-accent);
  outline-offset: 3px;
}

/* ---- Tablet ---- */

@media (max-width: 1024px) {
  .texium-stacking-card {
    padding: var(--texium-space-xl);
  }

  .texium-stacking-card__content {
    /* Overrides the widget's own width control on small screens, where a
       narrow text column would leave headings unreadable. */
    max-width: min(var(--texium-stack-content-width, 58%), 58%);
  }
}

/* ---- Mobile ----
   Same image-backed concept, but the text side is protected harder: the
   wash runs further across, the blur is lighter (it costs more on
   phones), and hover zoom is off since there is no hover. */

@media (max-width: 767px) {
  .texium-stacking {
    --texium-stack-height: 340px;
    --texium-stack-offset: 12px;
  }

  .texium-stacking-card {
    padding: var(--texium-space-lg);
  }

  .texium-stacking-card__content {
    max-width: 100%;
  }

  .texium-stacking {
    --texium-stack-content-width: 100%;
  }

  .texium-stacking-card__gradient {
    background:
      linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.99) 0%,
        rgba(255, 255, 255, 0.96) 45%,
        rgba(235, 245, 255, 0.88) 68%,
        rgba(190, 220, 250, 0.55) 88%,
        rgba(80, 145, 220, 0.18) 100%
      ),
      linear-gradient(
        90deg,
        transparent 70%,
        rgba(25, 100, 200, 0.18) 100%
      );
  }

  .texium-stacking-card__background-blur {
    filter: blur(10px);
    opacity: 0.4;
  }

  .texium-stacking-card__background {
    filter: saturate(0.9);
  }
}

/* ---- Reduced motion ----
   Sticky stacking is scroll-driven movement, so cards simply flow. */

@media (prefers-reduced-motion: reduce) {
  .texium-stacking-card {
    position: relative;
    top: auto;
  }

  .texium-stacking-card__background {
    transition: none;
  }
}
