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

/**
 * OptInWhatsapp — centered WhatsApp opt-in form (greeting + subtitle +
 * description + phone input + submit). Ports legacy
 * `creditas-site/src/sections/OptInAllowed`.
 *
 * Tokens inlined from @creditas-ui standard:
 *   colors.neutral.90 = #292929   colors.neutral.60 = #52605a
 *   colors.neutral.40 = #9fada7   colors.neutral.0  = #ffffff
 *   colors.primary.40 = #8edb00   colors.primary.60 = #4f9e00
 *   colors.primary.90 = #1c4200   colors.error.60   = #de3543
 *   colors.primary.20 = #e1ffa8 (success bg)  primary.80 = #317500
 *   heading.md = 28/36/0.5  heading.xl = 40/52/0.5 (>=1024)
 *   body.md = 16/24/0.3
 *   radius.lg = 8px   breakpoints.5xl = 1024px
 */

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

.optin-whatsapp {
  display: block;
  width: 100%;
  background: #ffffff;
  padding: 96px 20px;
  font-family: 'Helvetica Now Display', 'Helveticanowdisplay', sans-serif;

  .inner {
    max-width: 800px;
    margin: 0 auto;
  }

  .title {
    margin: 0 0 24px;
    color: #292929; /* neutral.90 */
    font-family: 'Maison Neue Extended', 'Maisonneueextended Book',
      'Maisonneueextended', 'Helvetica Now Display', 'Helveticanowdisplay',
      sans-serif;
    font-weight: 300;
    font-size: 28px;
    line-height: 36px;
    letter-spacing: 0.5px;

    @media (min-width: 1024px) {
      font-size: 40px;
      line-height: 52px;
    }
  }

  .subtitle {
    margin: 0 0 24px;
    color: #292929; /* neutral.90 */
    font-family: 'Maison Neue Extended', 'Maisonneueextended Book',
      'Maisonneueextended', 'Helvetica Now Display', 'Helveticanowdisplay',
      sans-serif;
    font-weight: 300;
    font-size: 24px;
    line-height: 32px;
    letter-spacing: 0.5px;
  }

  .description {
    margin: 0 0 48px;
    color: #52605a; /* neutral.60 */
    font-weight: 300;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.3px;
  }

  .field {
    display: block;
    max-width: 360px;

    &.error {
      .input {
        border-color: #de3543; /* error.60 */
      }
    }
  }

  .input {
    width: 100%;
    height: 56px;
    padding: 0 16px;
    border: 1px solid #9fada7; /* neutral.40 */
    border-radius: 8px;
    background: #ffffff;
    color: #292929;
    font-family: inherit;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.3px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;

    &:focus {
      outline: none;
      border-color: #4f9e00; /* primary.60 */
      box-shadow: 0 0 0 2px rgba(142, 219, 0, 0.4);
    }
  }

  .error {
    margin: 8px 0 0;
    color: #de3543; /* error.60 */
    font-size: 14px;
    line-height: 20px;
  }

  .submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 48px;
    padding: 18px 20px;
    border: 0;
    border-radius: 8px; /* radius.lg */
    background: #8edb00; /* primary.40 */
    color: #1c4200; /* primary.90 */
    font-family: inherit;
    font-weight: 500;
    font-size: 16px;
    line-height: 24px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;

    &:hover:not(:disabled) {
      background: #4f9e00; /* primary.60 */
      color: #ffffff;
    }

    &:focus-visible {
      outline: 2px solid #317500; /* primary.80 */
      outline-offset: 2px;
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
  }

  .feedback {
    margin-top: 32px;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 24px;

    &.success {
      background: #e1ffa8; /* primary.20 */
      color: #1c4200; /* primary.90 */
    }

    &.error {
      background: #fbe5e5; /* error.40 */
      color: #5c0008; /* error.80 */
    }
  }

  .feedback-title {
    margin: 0 0 4px;
    font-weight: 500;
  }

  .feedback-text {
    margin: 0;
  }

  .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(28, 66, 0, 0.3);
    border-top-color: #1c4200;
    border-radius: 50%;
    animation: optin-whatsapp-spin 0.7s linear infinite;

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

  /* ----------------------------------------------------------------------
   * Desktop adaptation (code-only)
   * The Figma design for this section only covers up to tablet. The rules
   * below are additive overrides for >=1024px / >=1440px so the section
   * scales up intentionally on desktop and ultrawide WITHOUT changing the
   * tablet/mobile (designed) layout above. Same tokens, larger rhythm.
   * -------------------------------------------------------------------- */
  @media (min-width: 1024px) {
    padding: 120px 32px;

    .inner {
      max-width: 840px;
    }
    /* subtitle gains a desktop step to match the title's md->xl jump */
    .subtitle {
      font-size: 28px;
      line-height: 36px;
    }
    .description {
      max-width: 640px; /* keep a comfortable measure on wide screens */
      margin-bottom: 56px;
      font-size: 18px;
      line-height: 28px;
    }
    .field {
      max-width: 420px;
    }
    .input {
      height: 60px;
    }
    .submit {
      margin-top: 56px;
    }
  }

  @media (min-width: 1440px) {
    padding: 140px 40px;

    .inner {
      max-width: 880px;
    }
  }
}

@keyframes optin-whatsapp-spin {
  to {
    transform: rotate(360deg);
  }
}

