@layer layout {
  .stage {
    --stage-max: 900px;
    --stage-min: 240px;
  }
}

@layer components {
  .product-card {
    --state: 0;
    transition: --state .2s ease-out;

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

    @container (width >= 320px) { --state: 1; }
    @container (width >= 560px) { --state: 2; }
    @container (width >= 800px) { --state: 3; }
    @container (width >= 1040px) { --state: 4; }
  }

  .state-pill span {
    @container (width < 320px) { &.s0 { display: inline; } }
    @container (320px <= width < 560px) { &.s1 { display: inline; } }
    @container (560px <= width < 800px) { &.s2 { display: inline; } }
    @container (800px <= width < 1040px) { &.s3 { display: inline; } }
    @container (width >= 1040px) { &.s4 { display: inline; } }
  }

  .fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-m);
    padding: var(--space-l);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-m);
    color: var(--color-text);
  }

  .f-name {
    font-weight: 600;
    margin-inline-end: auto;
  }

  .f-rating,
  .f-reviews {
    display: none;
    color: var(--color-muted);
    font-size: .9rem;
  }

  /* rating and review count are supplementary, not the primary task, so
     it's fine for them to be entirely absent at low states rather than
     always present in some minimal form (unlike the add-to-cart action
     below, which stays reachable at every state) */
  @container (width >= 320px) { .f-rating { display: inline; } }
  @container (width >= 560px) { .f-reviews { display: inline; } }

  .add-to-cart {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding-block: var(--space-2xs);
    padding-inline: var(--space-m);
    cursor: pointer;

    .btn-label {
      display: none;
    }
  }

  @container (width >= 800px) {
    .add-to-cart .btn-label { display: inline; }
  }
}
