/* Catalogue index: the three supply lines. By default a plain grid of cards.
   With scripting and room, the list pins to the screen and scrolling steps
   through it: the active title darkens and opens, a photograph wipes in
   behind the others, and a rule on the left fills with the scroll. */

#showcase {
  position: relative;
  display: flow-root;
}

#showcase > h2 strong {
  color: var(--crimson);
}

#showcase ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: clamp(2rem, 4vw, 3rem) clamp(1.25rem, 2.5vw, 2rem);
  margin: clamp(1.75rem, 4vw, 3rem) 0 0;
  padding: 0;
  list-style: none;
}

#showcase li {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 0.75rem;
  min-width: 0;
}

#showcase li figure {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--charcoal);
}

#showcase li figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.7) contrast(1.05);
}

/* One colour cast over every photograph, so mixed stock reads as one set. */
#showcase li figure::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(var(--crimson-rgb), 0.32), transparent 62%);
  mix-blend-mode: multiply;
  pointer-events: none;
}

#showcase li > small:first-of-type {
  color: var(--crimson);
}

#showcase li h3 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}

#showcase li a {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.3rem;
  border-radius: 0.375rem;
  background: var(--dark-crimson);
  color: #fff;
  font-size: clamp(13px, 0.95vw, 15px);
  font-weight: 500;
  line-height: 1;
  transition:
    translate var(--duration-fast) var(--ease-out),
    background-color var(--duration-normal) var(--ease-out);
}

#showcase li a:hover,
#showcase li a:focus-visible {
  translate: 0 -4px;
  background: color-mix(in srgb, var(--dark-crimson) 80%, #fff);
}

#showcase li a svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

/* Pinned: the list becomes a screen-high stage that stays put while the
   section scrolls past it. showcase.js sets --active (the open item) and
   --progress (how far through the stage the scroll is). */
@media (min-width: 993px) {
  /* The section is made tall; the list sticks for the extra height. */
  html.js #showcase {
    min-height: calc(300svh + 12rem);
  }

  html.js #showcase ol {
    --active: 0;
    --progress: 0;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100svh;
    margin: 0;
    padding-block: 6.5rem 3rem;
    padding-inline-start: clamp(1.5rem, 2.4vw, 2.5rem);
  }

  /* The rule: a track, and a fill that follows the scroll. */
  html.js #showcase ol::before,
  html.js #showcase ol::after {
    content: "";
    position: absolute;
    inset-block: 6.5rem 3rem;
    inset-inline-start: 0;
    width: 1px;
    background: rgba(var(--charcoal-rgb), 0.14);
  }

  html.js #showcase ol::after {
    background: var(--crimson);
    transform: scaleY(var(--progress));
    transform-origin: top;
  }

  html.js #showcase li {
    max-width: 48%;
    gap: 0;
    padding-block: clamp(0.75rem, 1.8vh, 1.25rem);
    border-top: 1px solid rgba(var(--charcoal-rgb), 0.14);
  }

  html.js #showcase li:last-child {
    border-bottom: 1px solid rgba(var(--charcoal-rgb), 0.14);
  }

  html.js #showcase li h3 {
    color: rgba(var(--charcoal-rgb), 0.24);
    font-size: clamp(2rem, 4.4vw, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    transition: color 0.7s var(--ease-out);
  }

  html.js #showcase li[aria-current] h3 {
    color: var(--charcoal);
  }

  html.js #showcase li > small:first-of-type {
    color: rgba(var(--charcoal-rgb), 0.4);
    transition: color 0.7s var(--ease-out);
  }

  html.js #showcase li[aria-current] > small:first-of-type {
    color: var(--crimson);
  }

  /* The details are closed until the item is the active one. */
  html.js #showcase li > :is(p, small:last-of-type, a) {
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition:
      max-height 0.8s var(--ease-out),
      margin-top 0.8s var(--ease-out),
      opacity 0.6s var(--ease-out),
      visibility 0s linear 0.8s;
  }

  html.js #showcase li[aria-current] > :is(p, small:last-of-type, a) {
    margin-top: 0.75rem;
    opacity: 1;
    visibility: visible;
    transition-delay: 0.15s, 0.15s, 0.3s, 0s;
  }

  html.js #showcase li[aria-current] > p {
    max-height: 8rem;
  }

  html.js #showcase li[aria-current] > small:last-of-type {
    max-height: 2rem;
  }

  html.js #showcase li[aria-current] > a {
    max-height: 3.5rem;
    margin-top: 1.25rem;
  }

  /* The photographs stack on the right. Each one wipes down over the ones
     before it once the active item reaches it, and wipes back going up. */
  html.js #showcase li figure {
    position: absolute;
    top: 6.5rem;
    bottom: 3rem;
    inset-inline-end: 0;
    z-index: calc(var(--i) + 1);
    width: 46%;
    aspect-ratio: auto;
    clip-path: inset(0 0 calc(100% * (1 - clamp(0, var(--active) - var(--i) + 1, 1))) 0);
    transition: clip-path 1.2s var(--ease-out);
  }

  html.js #showcase li figure img {
    scale: calc(1 + 0.2 * (1 - clamp(0, var(--active) - var(--i) + 1, 1)));
    transition: scale 1.6s var(--ease-out);
  }
}

@media (prefers-reduced-motion: reduce) {
  #showcase li a,
  #showcase li h3 {
    transition: none;
  }
}
