.product-card-container {
  container: product-card / inline-size;
}

.product-card {
  /* default layout is the horizontal card */
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 10rem;
  gap: 0.5rem;
  padding-block: 0.5rem;
  padding-inline: 0.5rem 0.75rem;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--surface-3);
  border-radius: var(--brand-border_radius);

  &:focus-within {
    border-color: var(--text-2);
  }

  & > figcaption {
    display: grid;
    text-align: end;
    justify-content: end;

    > * {
      display: grid;
    }

    > .product-meta {
      place-self: start;
    }

    > .product-cost {
      place-self: end;
    }
  }

  & > button {
    padding: 0;
  }

  & :is(p, small) {
    margin: 0;
  }

  & a {
    text-wrap: balance;
    color: var(--text-1);
    font-size: 1.5rem;
    font-weight: 300;
    line-height: 1.1;

    @media (min-resolution: 1.25dppx) {
      font-weight: 400;
    }
  }

  & picture {
    display: flex;
  }

  & img {
    width: 10rem;
    height: auto;
    object-fit: contain;
  }

  & small {
    margin-block-start: 0.25rem;
    color: var(--text-2);
  }

  & p {
    font-size: 0.8rem;
    color: var(--text-1);
    margin-block-end: 0.25rem;

    flex: 2;
    display: inline-flex;
    align-items: flex-start;
  }

  & span {
    font-size: 0.8rem;
    color: var(--brand-primary);
    margin-block-end: 0.25rem;
  }

  /* square layout */
  @container (25rem <= inline-size < 30rem) {
    aspect-ratio: 1;
    grid: 1fr / 1fr;
    block-size: 100%;
    place-items: end stretch;
    padding: 0.5rem;

    > * {
      grid-area: 1 / 1;
    }

    img {
      inline-size: 100%;
    }

    > figcaption {
      z-index: 1;
      display: flex;
      justify-content: space-between;
      padding: 1rem;
      padding-block-start: 3rem;
      background: linear-gradient(to top, #000e, 50%, #0003, #0000);

      > .product-meta {
        text-align: start;
      }

      > :is(.product-meta, .product-cost) {
        align-content: space-between;
        place-self: end;
      }
    }

    a {
      font-size: 1.75rem;
    }

    a,
    [money] {
      color: var(--color-1);
    }

    p,
    small {
      color: var(--color-4);
    }

    [money] > sup {
      color: var(--color-4);
    }
  }

  /* portrait layout */
  @container (25rem < inline-size < 40rem) {
    aspect-ratio: 3/4;
    grid: auto 1fr / 1fr;
    block-size: 100%;
    place-items: end stretch;

    img {
      inline-size: 100%;
    }

    figcaption {
      display: flex;
      justify-content: space-between;
      padding: 1rem;

      > .product-meta {
        text-align: start;
        max-inline-size: 50cqi;
      }

      > .product-cost {
        > span {
          margin: 0;
        }
      }
    }

    a {
      font-size: 2rem;
    }
  }
}
