/* 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). */
:host {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/**
 * AppDownloadOld — the OLD creditas-site AppDownload section.
 * Ports `creditas-site/src/sections/AppDownload/styles.js` +
 * `components/ContainerText/styles.js`, driven by native
 * `animation-timeline: view()` instead of the legacy IntersectionObserver.
 *
 * Tokens resolved from the @creditas-ui `standard` theme (verified by
 * resolving each token/selectTheme/getTypography call against the actual
 * package build — NOT guessed from names):
 *   colors.neutral.90  = #292929   (section background)
 *   colors.neutral.0   = #ffffff   (description text)
 *   colors.primary.40  = #8edb00   (title color + button fill)
 *   radius.4xl         = 16px      (ButtonCTA border-radius override)
 *   spacingY.14xl      = 56px  ·  spacingX.3xl = 16px  ·  spacingX.4xl = 18px
 *   spacingX.5xl       = 20px  ·  spacingY.6xl = 24px  (ContainerText gap)
 *   heading2xlMedium   → Helvetica Now Display / 48 / 64 / 0.5px / weight 500
 *                        (getTypography default family = 'base', so this
 *                        heading variant renders in the BASE font, not the
 *                        Maison Neue heading font — matches the live site)
 *   bodyMdRegular      → Helvetica Now Display / 16 / 24 / 0.3px
 *
 * ButtonPrimaryTextOnly (size "medium", width "flexible") base + override:
 *   font-color #292929 · fill #8edb00 · font 14/20 weight 400 · ls 0.3px
 *   width auto (stretches to the text column via the flex-column stretch)
 *   hover/focus = box-shadow (shadow.md); there is NO hover color change.
 *
 * NOTE: `Content` in the old source used `max-width: selectTheme('Breakpoints5Xl')`
 * and `min-width: selectTheme('BreakpointsMd')`, but neither is a top-level
 * theme key, so both resolve to `undefined` and render as no constraint on
 * the live site. Reproduced faithfully here (no max-width / min-width) —
 * children are centered via `justify-content: center`, so the visible
 * cluster is identical.
 *
 * Media breakpoints (creditas-ui `standard`, px): xl = 480, 2xl = 600,
 * 3xl = 768, 4xl = 880, 5xl = 1024. `media.down(b)` = max-width of the NEXT
 * breakpoint minus 0.02px, so down('3xl') = 879.98px, down('xl') = 599.98px.
 */

.app-download-old,
.app-download-old *,
.app-download-old *::before,
.app-download-old *::after {
  box-sizing: border-box;
}

/* ----- Container (old: section, neutral.90) ---------------------- */
.app-download-old {
  margin: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #292929;
  font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;
  position: relative;
  /* `overflow: clip` (not `hidden`) so children's `animation-timeline: view()`
   * still resolves against the viewport — `hidden` would create a frozen
   * scroll container and pin the entrance animation at its end state. */
  overflow: clip;

  @media (min-width: 880px) {
    max-height: 700px;
  }

  /* ----- Content (old: gap 63px, padding 56px 16px, column-reverse) -----
   * `max-width` / `min-width` intentionally omitted — the old source's
   * `selectTheme('Breakpoints5Xl')` / `selectTheme('BreakpointsMd')` both
   * resolve to `undefined`, so the live site renders no width constraint. */
  .content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    gap: 63px;
    padding: 56px 16px; /* spacingY.14xl spacingX.3xl */

    @media (min-width: 880px) {
      flex-direction: row;
      justify-content: center;
    }
  }

  /* ----- Text block (old ContainerText) ---------------------------
   * old: width 383px · gap spacingY.6xl (24px) · padding 0 spacingX.3xl.
   * No align-items set → default `stretch`, which is what makes the CTA
   * span the full column width. */
  .text {
    width: 383px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 0 16px;

    /* old: media.down('3xl') → max-width 879.98px → width 536px */
    @media (max-width: 879.98px) {
      width: 536px;
    }

    /* old: media.down('xl') → max-width 599.98px → width 100% */
    @media (max-width: 599.98px) {
      width: 100%;
    }
  }

  .title {
    margin: 0;
    color: #8edb00; /* primary.40 */
    /* Maison Neue Extended stack — matches the heading font registered in the
     * Webflow project and the sibling AppDownload component. (The raw
     * heading2xlMedium token resolves to the base font, but that font renders
     * poorly for this title in the isolated component context.) */
    font-family: 'Maison Neue Extended', 'Maisonneueextended Book',
      'Maisonneueextended', 'Helvetica Now Display', 'Helveticanowdisplay',
      sans-serif;
    font-weight: 500;
    font-size: 48px;
    line-height: 64px; /* lineHeight.6xl override (== variant lh) */
    letter-spacing: 0.5px;
  }

  /* bodyMdRegular at all widths. The old source's `media.up('2xl')`
   * bump used `selectTheme('bodyLgRegular')`, which resolves to `undefined`
   * (not a top-level theme key), so NO responsive font change happens on the
   * live site — the description stays 16/24 everywhere. */
  .description {
    margin: 0;
    color: #ffffff; /* neutral.0 */
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.3px;
  }

  /* ----- CTA (old ButtonPrimaryTextOnly, size "medium") -----------
   * The old button's base is `display: flex; width: auto;` (width
   * "flexible"). Inside the text block's stretch flex-column that makes it
   * span the FULL column width, with the label centered — so `display: flex`
   * (block-level), no width, is required here (NOT inline-flex/fit-content).
   * Padding/radius are the ContainerText overrides (spacingX.4xl spacingX.5xl
   * = 18px 20px; radius.4xl = 16px). Everything else is the resolved
   * ButtonPrimaryTextOnly "medium" theme. */
  .cta-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 18px 20px; /* spacingX.4xl spacingX.5xl */
    background: #8edb00; /* primary.color */
    color: #292929; /* primary.fontColor */
    border: none;
    border-radius: 16px; /* radius.4xl */
    font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;
    font-weight: 400; /* primary.fontWeight.medium */
    font-size: 14px; /* primary.fontSize.medium */
    line-height: 20px; /* primary.lineHeight.medium */
    letter-spacing: 0.3px; /* primary.letterSpacing */
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.2s ease;

    /* old hover/focus: box-shadow only (shadow.md) — no color change. */
    &:hover,
    &:focus {
      box-shadow: 0px 16px 12px -8px rgba(0, 0, 0, 0.16),
        0px 16px 8px -12px rgba(0, 0, 0, 0.12);
      outline: 0;
    }

    /* Keyboard-only affordance (additive; invisible to pointer users). */
    &:focus-visible {
      outline: 2px solid #ffffff;
      outline-offset: 2px;
    }
  }

  /* ----- Phone + overlay box (old AppExample) ---------------------- */
  .media {
    position: relative;
    width: fit-content;
    /* 3D perspective so the phone-flip renders with depth. */
    perspective: 1200px;
    /* Reserve space for the box overlaid 5rem below the phone's top. */
    min-height: 580px;

    /* ----- Scroll-driven entrance (old phoneFlip) --------------------
     * Ported 1:1 from the legacy keyframes. The legacy site also faded the
     * phone to 20% opacity mid-scroll (phoneOpacity); that was dropped from
     * the Figma port by client request and is intentionally kept out. */
    @supports (animation-timeline: view()) {
      animation: app-download-old-phone-flip both;
      animation-range: entry 50% entry 100%;
      animation-timeline: view();
    }

    @media (prefers-reduced-motion: reduce) {
      animation: none;
    }
  }

  .phone {
    display: block;
    width: 321px;
    height: auto;
    position: relative;
  }

  .box {
    width: 335px;
    height: auto;
    position: absolute;
    left: 50%;
    top: 5rem;
    translate: -50%;

    @supports (animation-timeline: view()) {
      animation: app-download-old-box-appear both;
      animation-range: entry 50% entry 100%;
      animation-timeline: view();
    }

    @media (prefers-reduced-motion: reduce) {
      animation: none;
    }
  }
}

@keyframes app-download-old-phone-flip {
  0%,
  30% {
    transform-style: preserve-3d;
    transform: rotateX(25deg) rotateZ(-15deg) rotateY(15deg) translateX(-100px);
    scale: 0.8;
  }
  100% {
    transform-style: preserve-3d;
    transform: rotateX(0deg) rotateZ(0deg) rotateY(0deg) translateX(0px);
    scale: 1;
  }
}

@keyframes app-download-old-box-appear {
  0%,
  50% {
    scale: 0.8;
  }
  100% {
    scale: 1;
  }
}

