._4s-perfectly-paired {
  padding: 40px 0;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;

  @media (min-width: 768px) {
    .page-width {
      max-width: unset !important;
    }
  }

  @media (max-width: 768px) {
    padding: 24px 20px;

    .page-width {
      padding: 0;
    }
  }

  .perfectly-paired__title {
    text-align: center;
    font-family: "Libre Baskerville";
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 30px;
    color: #000;
  }

  .perfectly-paired__container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    /* Changed from 15px */
    flex-wrap: nowrap;

    @media (max-width: 1024px) {
      gap: 8px;
      flex-direction: column;
      /* Consistent gap */
    }
  }

  .perfectly-paired__item {
    position: relative;
    min-width: 280px;
    display: flex;
    flex-direction: column;

    @media (max-width: 768px) {
      width: 100%;
      min-width: unset;
    }
  }

  .perfectly-paired__image-wrapper {
    position: relative;
    width: 100%;
    height: 350px;
    /* Match summary height */
    overflow: hidden;
    margin-bottom: 0;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  .perfectly-paired__checkbox {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 1px solid #e1e1e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    padding: 0;

    input[type="checkbox"] {
      appearance: none;
      -webkit-appearance: none;
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      cursor: pointer;
      background-color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;

      &:checked::after {
        content: '';
        width: 10px;
        height: 6px;
        border-left: 1.5px solid #000;
        border-bottom: 1.5px solid #000;
        transform: rotate(-45deg);
        margin-bottom: 2px;
      }
    }
  }

  .perfectly-paired__bottom-bar {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: stretch;
    /* Ensure same height */
    justify-content: space-between;
    gap: 8px;
    z-index: 2;
  }

  .perfectly-paired__selectors {
    display: flex;
    gap: 4px;
    /* Reduced gap */
    flex: 1;

    select {
      appearance: none;
      -webkit-appearance: none;
      background-color: #fff;
      border: 1px solid #e1e1e1;
      padding: 0 20px 0 8px;
      /* Reduced padding */
      height: 32px;
      /* Fixed height */
      font-family: "Inter", sans-serif;
      font-size: 11px;
      /* Smaller font */
      color: #000;
      cursor: pointer;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23000000' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 6px center;
      min-width: 60px;
      /* Reduced min-width */
      text-transform: uppercase;
      display: flex;
      align-items: center;

      &:focus {
        outline: none;
        border-color: #000;
      }
    }
  }

  .perfectly-paired__price {
    font-family: "Inter", sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
    border: 1px solid #e1e1e1;
    padding: 0 10px;
    /* Adjusted padding */
    height: 32px;
    /* Fixed height matching select */
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .perfectly-paired__plus,
  .perfectly-paired__equal {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    font-size: 20px;
    color: #575656;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
    /* Very high z-index */
    position: absolute;
    aspect-ratio: 1/1;

    @media (max-width: 768px) {
      position: relative;
      margin: -22px auto;
      width: 32px;
      height: 32px;
      background: #fff;
      border-radius: 50%;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      z-index: 20;
      left: auto;
      top: auto;
      transform: none;

      &::before {
        display: none;
      }
    }
  }

  /* Reset for desktop layout */
  @media (min-width: 769px) {

    .perfectly-paired__plus,
    .perfectly-paired__equal {
      position: relative;
      width: 32px;
      height: 32px;
      margin-left: -16px;
      /* Half width overlap */
      margin-right: -16px;
      z-index: 20;
      left: auto;
      top: auto;
      transform: none;
      background: #fff;
      border-radius: 50%;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      aspect-ratio: 1/1;
    }
  }

  .perfectly-paired__summary {
    width: 280px;
    height: 350px;
    /* Approximate height matching cards */
    background-color: #C1A893;
    /* Example color from image */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: #fff;

    @media (max-width: 768px) {
      width: 100%;
      height: auto;
      padding: 40px 20px;
    }

    h3 {
      font-family: "Inter", sans-serif;
      font-size: 16px;
      font-weight: 400;
      margin-bottom: 8px;
      color: #fff;
    }

    .summary-total {
      font-family: "Inter", sans-serif;
      font-size: 40px;
      font-weight: 700;
      margin-bottom: 24px;
      color: #fff;
    }

    button {
      background: #fff;
      color: #C1A893;
      /* Match bg color for text */
      border: none;
      padding: 12px 24px;
      font-family: "Inter", sans-serif;
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      cursor: pointer;
      width: 100%;
      transition: opacity 0.3s;
      letter-spacing: 1px;

      &:hover {
        opacity: 0.9;
      }

      &[disabled] {
        opacity: 0.7;
        cursor: not-allowed;
      }
    }
  }

  /* Compact mobile view */
  .perfectly-paired__compact {
    display: none;
  }

  .perfectly-paired__compact-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 16px;
  }

  .perfectly-paired__compact-img {
    flex: 1;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f3f3f3;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }
  }

  .perfectly-paired__compact-plus {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    margin: 0 -16px;
    z-index: 2;
    position: relative;
  }

  .perfectly-paired__compact-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: #c1a893;
    color: #fff;
    border: none;
    padding: 14px 18px;
    font-family: "Inter", sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: opacity 0.2s ease;

    &:hover {
      opacity: 0.9;
    }
  }

  .perfectly-paired__compact-cta-label {
    flex: 1;
    text-align: left;
  }

  .perfectly-paired__compact-chevron {
    flex-shrink: 0;
    margin-left: 12px;
  }

  @media (max-width: 768px) {
    .perfectly-paired__compact {
      display: block;
    }
    .perfectly-paired__container {
      display: none !important;
    }
    &.is-expanded .perfectly-paired__compact {
      display: none;
    }
    &.is-expanded .perfectly-paired__container {
      display: flex !important;
    }
  }
}
// ------------------------------------------------------------------
// "cards" layout — Figma "Te encantará con" (node 1:901 desktop / 1:402 mobile)
// Desktop: 3 bordered cards (image, uppercase title, price, black ATC).
// Mobile: horizontal cards (image left, content right).
// ------------------------------------------------------------------
._4s-perfectly-paired--cards {
  padding: 44px 0 64px;
  max-width: none;

  @media (max-width: 749px) {
    padding: 24px 0 32px;
  }

  .perfectly-paired__cards-wrap {
    max-width: none;
    padding: 0 60px;

    @media (min-width: 1255px) {
      padding: 0 140px;
    }

    @media (min-width: 1600px) {
      // .page-width max-width is forced to unset above, so center via padding
      padding: 0 calc((100% - 1306px) / 2);
    }

    @media (max-width: 749px) {
      padding: 0 12px;
    }
  }

  .perfectly-paired__title--cards {
    margin: 0 0 20px;
    color: #000;

    // Figma 1:901: title left edge lines up with the centered cards block (850px)
    @media (min-width: 750px) {
      max-width: 850px;
      margin-left: auto;
      margin-right: auto;
    }

    font-family: 'Libre Baskerville', serif;
    font-size: 24px;
    font-weight: 400;
    line-height: normal;
    letter-spacing: 0.4px;
    text-align: left;

    // Feedback (mobile Figma 1:404): serif title, no uppercase.
    @media (max-width: 749px) {
      font-size: 20px;
      line-height: 25px;
      text-transform: none;
      margin-bottom: 12px;
    }
  }

  .perfectly-paired__cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    justify-content: center;

    @media (min-width: 750px) {
      max-width: 850px;
      margin: 0 auto;

      &[data-count="1"] {
        grid-template-columns: minmax(0, 275px);
      }

      &[data-count="2"] {
        grid-template-columns: repeat(2, minmax(0, 275px));
      }

      &[data-count="4"] {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        max-width: none;
      }
    }

    @media (max-width: 749px) {
      grid-template-columns: 1fr;
      gap: 8px;
    }
  }

  .perfectly-paired__card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 4px 10px;
    border: 1px solid #d9cdb4;
    border-radius: 4px;
    background: #fff;
    height: 100%; // grid stretch → equal card heights

    @media (max-width: 749px) {
      flex-direction: row;
      gap: 12px;
      padding: 4px;
      border: 1px solid #121212;
    }
  }

  .perfectly-paired__card-media {
    display: block;
    width: 100%;
    aspect-ratio: 265 / 246;
    overflow: hidden;
    flex-shrink: 0;

    img,
    svg {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    @media (max-width: 749px) {
      flex: 0 0 150px;
      width: 150px;
      aspect-ratio: 1;
    }
  }

  .perfectly-paired__card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 6px;
    flex: 1 1 auto;
    min-width: 0;

    @media (max-width: 749px) {
      padding: 8px 8px 8px 0;
      justify-content: space-between;
    }
  }

  .perfectly-paired__card-title {
    color: #121212;
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    text-decoration: none;

    @media (max-width: 749px) {
      font-size: 14px;
      line-height: 18px;
    }
  }

  .perfectly-paired__card-price {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    line-height: 16px;

    @media (max-width: 749px) {
      flex-direction: column;
      align-items: flex-start;
      gap: 2px;
    }

    .perfectly-paired__card-current {
      color: #121212;
      font-weight: 600;

      &.is-sale {
        color: #ac462c;
      }

      @media (max-width: 749px) {
        font-size: 14px;
      }
    }

    .perfectly-paired__card-compare {
      color: rgba(18, 18, 18, 0.5);
      font-weight: 400;
      text-decoration: line-through;
      order: 2;

      @media (max-width: 749px) {
        order: 0;
        font-size: 11px;
      }
    }
  }

  .perfectly-paired__card-form,
  .perfectly-paired__card-atc--link {
    margin-top: auto; // pin the button to the bottom
    padding-top: 4px;

    .product-form__error-message-wrapper {
      font-size: 11px;
      color: #ac462c;
      margin-bottom: 4px;
    }
  }

  .perfectly-paired__card-atc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 22px;
    padding: 6px 12px;
    margin: 0;
    border: 0;
    border-radius: 2px;
    background: #000;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 400;
    line-height: normal;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;

    svg {
      width: 11px;
      height: 13px;
      flex-shrink: 0;
    }

    .loading__spinner {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;

      svg {
        width: 16px;
        height: 16px;
      }
    }

    &:hover {
      background: #333;
    }

    &[aria-disabled='true'] {
      opacity: 0.7;
    }

    @media (max-width: 749px) {
      min-height: 30px;
      font-size: 12px;
    }

    &--link {
      background: #8a8a8a;
    }
  }
}

// Title alignment (section settings: title_alignment / title_alignment_mobile)
._4s-perfectly-paired {
  @media (min-width: 750px) {
    &.perfectly-paired--title-left .perfectly-paired__title { text-align: left; }
    &.perfectly-paired--title-center .perfectly-paired__title { text-align: center; }
    &.perfectly-paired--title-right .perfectly-paired__title { text-align: right; }
  }

  @media (max-width: 749px) {
    &.perfectly-paired--title-mobile-left .perfectly-paired__title { text-align: left; }
    &.perfectly-paired--title-mobile-center .perfectly-paired__title { text-align: center; }
    &.perfectly-paired--title-mobile-right .perfectly-paired__title { text-align: right; }
  }
}
