/* Artwork card and grid. Used by the list, the home page, product and artist pages and the wishlist.
   No box: the artwork hangs on the canvas in a mat with a wall shadow and lifts on hover; the
   caption underneath is a museum label. */

@layer components {
  .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-8) var(--space-4);
    list-style: none;
    margin: 0;
    padding: 0;
  }

  @media (min-width: 820px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-12) var(--space-8); }
  }

  .product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .product-card:focus { outline: 2px solid var(--bp-focus); outline-offset: 6px; }

  /* The mat is a border, so the artwork (or placeholder) sits inside it. */
  .product-card__media {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: var(--mat) solid var(--bp-mat);
    background-color: var(--bp-mat);
    box-shadow: var(--shadow-hang);
    transition: box-shadow var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  }

  .product-card:hover .product-card__media { box-shadow: var(--shadow-lift); transform: translateY(-4px); }

  .product-card__media img { width: 100%; height: 100%; object-fit: cover; }

  .product-card__monogram {
    font-family: var(--font-display);
    font-size: 64px;
    font-style: italic;
    font-weight: 300;
    line-height: 1;
    color: var(--bp-brand-800);
    opacity: .28;
  }

  /* Stripes stand in for a photo until the seller uploads one. */
  .ph--lav { background-image: repeating-linear-gradient(135deg, var(--ph-lav-a) 0 12px, var(--ph-lav-b) 12px 24px); }
  .ph--sand { background-image: repeating-linear-gradient(135deg, var(--ph-sand-a) 0 12px, var(--ph-sand-b) 12px 24px); }
  .ph--sage { background-image: repeating-linear-gradient(135deg, var(--ph-sage-a) 0 12px, var(--ph-sage-b) 12px 24px); }
  .ph--sky { background-image: repeating-linear-gradient(135deg, var(--ph-sky-a) 0 12px, var(--ph-sky-b) 12px 24px); }
  .ph--rose { background-image: repeating-linear-gradient(135deg, var(--ph-rose-a) 0 12px, var(--ph-rose-b) 12px 24px); }
  .ph--gold { background-image: repeating-linear-gradient(135deg, var(--ph-gold-a) 0 12px, var(--ph-gold-b) 12px 24px); }

  .product-card__badges {
    position: absolute;
    bottom: 10px;
    inset-inline-start: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 20px);
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* "Sold" is a gallery's red dot on a small white label. */
  .badge--sold-out { background: var(--bp-mat); color: var(--bp-ink); box-shadow: var(--shadow-sm); }

  .badge--sold-out::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / .35), transparent 45%), var(--bp-brand-600);
  }

  .badge--low { background: var(--bp-marigold-100); color: var(--bp-marigold-800); }
  .badge--sale { background: var(--bp-marigold-400); color: var(--bp-on-accent); }
  .badge--new { background: var(--bp-leaf-50); color: var(--bp-leaf-700); }

  .product-card__wishlist {
    position: absolute;
    top: calc(var(--mat) + 6px);
    inset-inline-end: calc(var(--mat) + 6px);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--bp-mat);
    color: var(--bp-ink);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--dur-slow) var(--ease), color var(--dur), opacity var(--dur);
  }

  .product-card:hover .product-card__wishlist { transform: translateY(-4px); }
  .product-card__wishlist:hover { color: var(--bp-heart); }
  .product-card__wishlist .icon { font-size: 21px; }

  .product-card__wishlist[aria-pressed="true"] { color: var(--bp-heart); }
  .product-card__wishlist[aria-pressed="true"] .icon { font-variation-settings: 'FILL' 1; }
  .product-card__wishlist[aria-pressed="true"]:not(:hover) .icon { animation: heart-pop 320ms var(--ease); }

  @keyframes heart-pop {
    0% { transform: scale(.7); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
  }

  /* The label */
  .product-card__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    padding-inline: 2px;
  }

  .product-card__seller {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--bp-ink);
  }

  .product-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 19px;
    font-style: italic;
    font-weight: 300;
    line-height: 1.25;
    color: var(--bp-heading);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .product-card__category { font-size: 13px; color: var(--bp-ink-3); }

  /* The title link covers the whole card; the heart and the basket button sit above it. */
  .product-card__link { color: inherit; text-decoration: none; }
  .product-card__link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
  .product-card__link:hover { color: var(--bp-heading); }
  .product-card__link:focus-visible { outline: none; }
  .product-card:has(.product-card__link:focus-visible) { outline: 2px solid var(--bp-focus); outline-offset: 6px; }

  .product-card__wishlist,
  .product-card__cta { position: relative; z-index: 2; }

  .product-card__wishlist { position: absolute; }

  /* Always shown, in the brand red (button--primary), so every available work can be bought from its card. */
  .product-card__cta { align-self: flex-start; margin-top: var(--space-3); }
  .product-card__cta .icon { font-size: 17px; }

  .product-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 8px;
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--bp-line);
  }

  .product-card__price { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bp-ink); }

  .stock { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
  .stock .icon { font-size: 16px; }
  .stock--in { color: var(--bp-leaf-700); }
  .stock--low { color: var(--bp-marigold-800); }
  .stock--out { color: var(--bp-ink-2); }

  .product-card--sold-out .product-card__media img { filter: saturate(.85); }

  @media (min-width: 820px) {
    .product-card__title { font-size: 21px; }
  }

  /* A rail: a heading that links on, and one row of works (home page, product and artist pages). */
  .rail { display: flex; flex-direction: column; gap: var(--space-8); margin-top: var(--space-20); }

  .rail__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-3);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--bp-line);
  }

  .rail__heading { display: flex; flex-direction: column; gap: 6px; }

  .rail__eyebrow {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--bp-brand-600);
  }

  .rail__title { font-size: clamp(28px, 22px + 1.4vw, 40px); }

  .rail__title-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--bp-heading);
    text-decoration: none;
  }

  .rail__title-link .icon { font-size: 28px; color: var(--bp-brand-600); transition: transform var(--dur) var(--ease); }
  .rail__title-link:hover { color: var(--bp-heading); }
  .rail__title-link:hover .icon { transform: translateX(6px); }

  .rail__all {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--bp-ink);
  }

  .rail__all:hover { color: var(--bp-brand-600); }

  /* On phones a rail scrolls sideways instead of wrapping. */
  @media (max-width: 819.98px) {
    .rail__grid {
      grid-template-columns: none;
      grid-auto-flow: column;
      grid-auto-columns: 68%;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      margin-inline: calc(var(--gutter) * -1);
      padding: 6px var(--gutter) var(--space-8);
      scrollbar-width: none;
    }

    .rail__grid > * { scroll-snap-align: start; }
  }

  @media (min-width: 820px) {
    .rail__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
}
