/* Legacy-parity text rendering: the old Creditas site sets
 * -webkit-font-smoothing: antialiased globally, which renders type
 * lighter/thinner on macOS. Webflow Code Components live in isolated
 * shadow roots, so this must be declared per-component on :host to
 * inherit into the shadow tree (the property does not cross the
 * shadow boundary). Without it, Blink defaults to subpixel smoothing
 * and identical 400-weight text looks heavier than the old site. */
:host {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/**
 * HeroSlide — single slide of the HeroSlideshow carousel.
 *
 * Class naming: single-class, no BEM `__` separator; element rules are
 * nested under the `.hero-slide` block. The CTA button is `.button`
 * (not `.cta`) to avoid colliding with the global `.cta` block from the
 * standalone Cta component when both render in the non-shadow playground.
 *
 * Visibility is driven by the parent HeroSlideshow which sets a
 * `data-active` attribute on this code-island host when the slide is
 * the current one. `:host([data-active])` reads that attribute from
 * inside the shadow DOM and toggles the article's opacity.
 *
 * The article is positioned absolutely so multiple slides can stack
 * inside the parent's `.slides-wrapper` container.
 *
 * Token values inlined from @creditas-ui/themes standard:
 *   colors.primary.40   = #8edb00
 *   colors.primary.60   = #4f9e00
 *   colors.primary.100  = #1c4200
 *   colors.neutral.0    = #ffffff
 *   colors.neutral.80   = #3b4540
 *   colors.neutral.90   = #292929
 *   radius.lg           = 8px
 *   breakpoints.2xl     = 600px
 *
 *   typography.heading.xl  → 40px / 52px / 0.5px / Maison Neue Extended / 400
 *   typography.heading.2xl → 48px / 64px / 0.5px / Maison Neue Extended / 400
 *   typography.body.lg     → 18px / 26px / 0.3px / Helvetica Now Display / 400
 */

@keyframes hero-slide-image-entrance {
  0% {
    transform: scale(1.2) translateY(10px);
    opacity: 0;
  }
  20%,
  100% {
    transform: scale(1.1) translateY(0);
    opacity: 1;
  }
}

@keyframes hero-slide-text-fade-in {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- slide container ------------------------------------------ */

.hero-slide {
  box-sizing: border-box;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* ----- image ---------------------------------------------------- */

  .image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Legacy parity (creditas-site SlideImage): the image rests zoomed-in at
     * scale(1.1) and eases to its true size on hover, over a slow 5s curve. */
    transform: scale(1.1);
    transition: transform 5s ease-in-out;
  }

  /* ----- inner content container ---------------------------------- */

  .container {
    position: relative;
    max-width: 1388px;
    margin: 250px auto 0;
    padding: 20px;

    @media (min-width: 600px) {
      margin-top: 255px;
      padding: 40px;
    }
  }

  /* ----- text content --------------------------------------------- */

  .content {
    position: relative;
    max-width: 410px;
    color: #ffffff;
    display: flex;
    flex-flow: column wrap;
    gap: 1rem;

    &::after {
      position: absolute;
      content: '';
      width: 100%;
      height: 100%;
      background-color: #000;
      inset: 0;
      z-index: -1;
      filter: blur(100px);
      opacity: 0.5;
    }
  }

  .title {
    margin: 0;
    font-family: 'Maison Neue Extended', 'Maisonneueextended Book',
      'Maisonneueextended', 'Helvetica Now Display', 'Helveticanowdisplay',
      sans-serif;
    font-weight: 400;
    font-size: 40px;
    line-height: 44px;
    letter-spacing: 0.5px;

    @media (min-width: 600px) {
      font-size: 48px;
      line-height: 52.8px;
    }
  }

  .description {
    margin: 0;
    font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 26px;
    letter-spacing: 0.3px;
  }

  /* ----- CTAs ----------------------------------------------------- */

  .ctas {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 264px;
    margin-top: 1rem;
  }

  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: 0;
    border-radius: 8px;
    font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.3px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s;

    &:focus-visible {
      outline: 2px solid #8edb00;
      outline-offset: 2px;
    }

    &.primary {
      background: #8edb00;
      color: #292929;
    }

    &.secondary {
      background: #292929;
      color: #ffffff;
    }

    &.primary:hover,
    &.secondary:hover {
      box-shadow: 0px 16px 12px -8px rgba(0, 0, 0, 0.16),
        0px 16px 8px -12px rgba(0, 0, 0, 0.12);
    }
  }
}

/* ----- active state (dual selector so it fires in both contexts) ----
 *  - Webflow runtime: parent sets `data-active` on the `<code-island>`
 *    host; `:host([data-active]) .hero-slide` matches inside the shadow DOM.
 *  - Vite playground: no shadow DOM, so the parent sets `data-active`
 *    directly on the `.hero-slide` article; `.hero-slide[data-active]`
 *    matches that. */
:host([data-active]) .hero-slide,
.hero-slide[data-active] {
  opacity: 1;
  pointer-events: auto;
}

/* Replay the entrance animations whenever the slide becomes active.
 * `backwards` (not `both`): the entrance fills before it starts but does NOT
 * forwards-fill the transform after it ends — a forwards fill would pin
 * `transform` at the final keyframe and override the :hover zoom below. Its
 * end keyframe (scale 1.1) matches the image's resting transform, so there's
 * no jump when it releases. */
:host([data-active]) .image,
.hero-slide[data-active] .image {
  animation: hero-slide-image-entrance 5s backwards ease-in-out;
}

:host([data-active]) .content,
.hero-slide[data-active] .content {
  animation: hero-slide-text-fade-in 0.8s 1s both ease-out;
}

:host([data-active]) .title,
.hero-slide[data-active] .title {
  animation: hero-slide-text-fade-in 0.8s both ease-out;
}

:host([data-active]) .description,
.hero-slide[data-active] .description {
  animation: hero-slide-text-fade-in 0.8s 1.25s both ease-out;
}

:host([data-active]) .ctas,
.hero-slide[data-active] .ctas {
  animation: hero-slide-text-fade-in 0.8s 1.25s both ease-out;
}

/* Image hover zoom (rests at scale 1.1, eases to 1 on hover). */
.hero-slide:hover .image {
  transform: scale(1);
}

/* Legacy-parity text rendering: the old Creditas site sets
 * -webkit-font-smoothing: antialiased globally, which renders type
 * lighter/thinner on macOS. Webflow Code Components live in isolated
 * shadow roots, so this must be declared per-component on :host to
 * inherit into the shadow tree (the property does not cross the
 * shadow boundary). Without it, Blink defaults to subpixel smoothing
 * and identical 400-weight text looks heavier than the old site. */
:host,
div.hero-slideshow {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/**
 * HeroSlideshow — slider container that hosts HeroSlide children.
 *
 * Class naming: single-class, no BEM `__` separator; element rules are
 * nested under the `.hero-slideshow` block, which scopes the short names.
 *
 * Layout responsibility:
 *   - `.hero-slideshow` is `position: relative` so HeroSlide articles
 *     (positioned absolute inside their own shadow DOMs) use this as
 *     their containing block.
 *   - `.slides-wrapper` is also `position: relative` and full-size so
 *     the slides stack correctly.
 *   - Webflow inserts a slot wrapper around slotted children; we
 *     flatten it with `display: contents` so the code-islands become
 *     direct layout children of the wrapper.
 *
 * Pagination indicators per spec:
 *   - 40px × 4px, 20px border-radius
 *   - Inactive: rgba(255, 255, 255, 0.4)
 *   - Active: rgba(255, 255, 255, 1.0) + green fill (#8edb00)
 *     animating from 0% → 100% width over 5 seconds (matching the
 *     slide auto-advance).
 */

.hero-slideshow {
  box-sizing: border-box;
  position: relative;
  margin: 0 auto;
  max-width: 1920px;
  height: 693px;
  overflow: hidden;
  contain: content;

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  @media (min-width: 600px) {
    height: 798px;
  }

  /* ----- slides wrapper ------------------------------------------ */

  .slides-wrapper {
    position: relative;
    width: 100%;
    height: 100%;

    /* Flatten Webflow's slot wrapper so code-islands become direct
     * children of the slides wrapper. Children themselves use
     * `position: absolute` (inside HeroSlide.css) to stack. */
    ::slotted(*) {
      display: contents;
    }
  }

  /* ----- pagination indicators ----------------------------------- */

  .pagination {
    position: absolute;
    bottom: 42px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    z-index: 10;
  }

  .indicator {
    width: 40px;
    height: 4px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.4);
    border: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: background-color 0.2s ease;

    &:hover {
      background: rgba(255, 255, 255, 0.7);
    }

    &:focus-visible {
      outline: 2px solid #8edb00;
      outline-offset: 4px;
    }

    &.active {
      background: #ffffff;

      &:hover {
        background: #ffffff;
      }
    }
  }

  /* The fill span only renders for the active indicator. React
   * remounts it (via `key`) every time the active slide changes,
   * which restarts this CSS animation from 0% width. */
  .indicator-fill {
    position: absolute;
    inset: 0;
    left: 0;
    width: 0;
    background: #8edb00;
    border-radius: inherit;
    animation: hero-slideshow-indicator-fill 5s linear forwards;
  }
}

@keyframes hero-slideshow-indicator-fill {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

/* If the user prefers reduced motion, don't animate the fill — just
 * show the active indicator fully green so the visual hierarchy still
 * reads. */
@media (prefers-reduced-motion: reduce) {
  .hero-slideshow .indicator-fill {
    animation: none;
    width: 100%;
  }
}

