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

/**
 * HowItWorks — process section with four layouts (sidebar-list, cards-grid,
 * icon-columns, numbered-timeline) + a background variant (white/gray/dark).
 *
 * Class naming: single-class, no BEM `__` separator. Base element rules are
 * nested under `.how-it-works`; the header title/description are nested under
 * `.info` so their selectors don't reach the slotted steps (which carry their
 * own `.title`/`.description`). The CTA is `.button` (not `.cta`) to avoid the
 * global `.cta` block from the Cta component. Layout-specific rules stay flat
 * top-level, scoped by the unique `.how-it-works.<layout>` modifier class.
 *
 * Tokens inlined from @creditas-ui standard:
 *   colors.neutral.0=#ffffff neutral.10=#f1f3f2 neutral.90=#292929
 *   colors.primary.40=#8edb00
 *   heading.2xl 48/64/0.5 · heading.lg 32/40 · body.lg 18/26 · body.md 16/24
 *   breakpoints 2xl=600 3xl=768 5xl=1024
 */

:host,
.how-it-works {
  position: relative;
  display: block;
}

.how-it-works,
.how-it-works *,
.how-it-works *::before,
.how-it-works *::after {
  box-sizing: border-box;
}

.how-it-works {
  padding: 64px 0;
  font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;
  color: #292929;

  @media (min-width: 1024px) {
    padding: 96px 0;
  }

  /* ---------- background variants ---------------------------------- */

  &.bg-white {
    background-color: #ffffff;
  }
  &.bg-gray {
    background-color: #f1f3f2;
  }
  &.bg-dark {
    background-color: #292929;
    color: #ffffff;
  }

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

  .container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
  }

  /* ---------- header (scoped to .info so it never reaches steps) ---- */

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

    @media (min-width: 1024px) {
      font-size: 48px;
      line-height: 64px;
      letter-spacing: 0.5px;
    }
  }

  .info .description {
    margin: 0;
    font-weight: 400;
    font-size: 18px;
    line-height: 26px;
    letter-spacing: 0.3px;
    opacity: 0.85;
  }

  /* ---------- image (sidebar-list) -------------------------------- */

  .image {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: block;

    img {
      width: 100%;
      height: auto;
      display: block;
    }
  }

  /* ---------- steps ------------------------------------------------ */

  .steps {
    display: grid;
    gap: 24px;

    /* Flatten Webflow's slot wrapper so each child code-island becomes a
     * direct grid item of the steps container. */
    ::slotted(*) {
      display: contents;
    }

    /* Connector line for the numbered-timeline layout. 18px is the dot radius
     * (36px dot), so the line passes through the dot centres. */
    &.lined {
      /* Mobile: vertical line on the left */
      &::before {
        content: '';
        position: absolute;
        z-index: 0;
        background-color: #8edb00; /* primary.40 */
        left: 18px;
        top: 18px;
        bottom: 18px;
        width: 2px;
      }

      > * {
        position: relative;
        z-index: 1;
      }

      /* Desktop: horizontal line across the top, inset to first/last columns */
      @media (min-width: 768px) {
        &::before {
          left: calc(50% / var(--hiw-n, 1));
          right: calc(50% / var(--hiw-n, 1));
          top: 18px;
          bottom: auto;
          width: auto;
          height: 2px;
        }
      }
    }
  }

  /* ---------- CTA -------------------------------------------------- */
  /* The CTA is now the shared <CardCtaButton> (real @creditas-ui primary
     button, styled by the DS theme inside its own ShadowEmotionProvider).
     Per-layout placement is handled by the `.cta-wrap` rules below; the old
     hand-rolled `.button` styles were removed so nothing competes with the
     design-system button. */
}

/* ====================================================================
 * Layout: Sidebar list — mobile stacked; desktop 2-col, image on the right.
 * ================================================================== */

.how-it-works.sidebar-list {
  .grid {
    display: grid;
    gap: 32px;

    @media (min-width: 1024px) {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-areas:
        'info  image'
        'steps image'
        'cta   image';
      gap: 48px;
    }
  }

  @media (min-width: 1024px) {
    .info {
      grid-area: info;
    }
    .image {
      grid-area: image;
      align-self: start;
    }
    .steps {
      grid-area: steps;
    }
    .cta-wrap {
      grid-area: cta;
    }
  }
}

/* ====================================================================
 * Layout: Cards grid — centered intro + responsive card grid
 * ================================================================== */

.how-it-works.cards-grid {
  .info {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 32px;

    @media (min-width: 600px) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    @media (min-width: 1024px) {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 24px;
    }
  }
}

/* ====================================================================
 * Layout: Icon columns — centered intro + row of icon cards
 * ================================================================== */

.how-it-works.icon-columns {
  .info {
    max-width: 800px;
    margin: 0 auto 48px;
    text-align: center;
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 24px;

    @media (min-width: 600px) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    @media (min-width: 1024px) {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  .cta-wrap {
    display: flex;
    justify-content: center;
    margin-top: 32px;
  }
}

/* ====================================================================
 * Layout: Numbered timeline — cards joined by a numbered connector line.
 * Desktop: cards in N columns, horizontal line through the dots on top.
 * Mobile : cards stacked, vertical line down the left through the dots.
 * Each step renders its own dot (use the step "Timeline" variant); --hiw-n
 * (set by the parent from the step count) insets the line to the dot centres.
 * ================================================================== */

.how-it-works.numbered-timeline {
  .info {
    max-width: 800px;
    margin: 0 0 40px;
  }

  .steps {
    position: relative;
    grid-template-columns: 1fr;
    gap: 24px;

    /* One equal-width column per step in a single row. `grid-auto-flow: column`
     * keeps it a row regardless of the JS step count. */
    @media (min-width: 768px) {
      grid-template-columns: none;
      grid-auto-flow: column;
      grid-auto-columns: minmax(0, 1fr);
      gap: 24px;
    }
  }

  .cta-wrap {
    margin-top: 40px;
  }
}

