/* 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);
}

