/* Counters: trade and retail, side by side. A charcoal panel and a crimson
   panel meet at the centre hairline. Each holds a photograph in a window that
   opens on hover, and the hovered panel grows while the other gives way. */

#counters {
  display: grid;
  gap: clamp(1.25rem, 2.5vw, 2rem);
  padding-bottom: 0;
  overflow: hidden;
  /* The hero's grid on charcoal, so this reads as the same dark stage. */
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 1.75rem 1.75rem fixed,
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 1.75rem 1.75rem fixed,
    var(--charcoal);
  color: #fff;
}

#counters > h2 {
  color: #fff;
}

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

#counters > p {
  max-width: 44ch;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(15px, 1.3vw, 18px);
  font-weight: 400;
  line-height: 1.5;
}

#counters > p strong {
  color: #fff;
  font-weight: 500;
}

/* The panels run to both edges of the screen. */
#counters ul {
  display: flex;
  margin: clamp(1rem, 3vw, 2rem) calc(-1 * var(--pad)) 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

#counters li {
  --window: 44%;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  justify-items: start;
  flex: 1 1 0;
  min-width: 0;
  min-height: clamp(26rem, 74vh, 40rem);
  gap: 0.75rem;
  padding: clamp(1.5rem, 3.5vw, 3rem);
  overflow: hidden;
  isolation: isolate;
  transition:
    flex-grow 0.9s var(--ease-out),
    translate 1.1s var(--ease-out),
    opacity 0.9s var(--ease-out);
}

#counters li:first-child {
  padding-inline-start: var(--pad);
}

#counters li:last-child {
  padding-inline-end: var(--pad);
  background: var(--crimson);
}

#counters li:is(:hover, :focus-within) {
  --window: 0%;
}

#counters li > :not(figure) {
  position: relative;
  z-index: 1;
}

/* The photograph. Its top edge is a window that opens to fill the panel. */
#counters li figure {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: inherit;
  clip-path: inset(var(--window) 0 0 0);
  transition: clip-path 1.1s var(--ease-out);
}

#counters li figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.08) brightness(0.8);
  transition: scale 1.4s var(--ease-out);
}

/* On crimson the photograph multiplies into the colour, a one-colour print. */
#counters li:last-child figure img {
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.15) brightness(1.05);
}

#counters li:is(:hover, :focus-within) figure img {
  scale: 1.06;
}

/* Shade, so the type stays readable when the window is fully open. */
#counters li figure::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(var(--charcoal-rgb), 0.8),
    rgba(var(--charcoal-rgb), 0.25) 45%,
    rgba(var(--charcoal-rgb), 0.85)
  );
}

#counters li small {
  color: rgba(255, 255, 255, 0.72);
}

#counters li h3 {
  color: #fff;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

#counters li p {
  max-width: 30ch;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(13px, 1vw, 15px);
  font-weight: 400;
  line-height: 1.55;
}

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

#counters li a:hover,
#counters li a:focus-visible {
  translate: 0 -4px;
  background: #fff;
  color: var(--charcoal);
}

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

#counters :is(a, button):focus-visible {
  outline: 2px solid var(--light-crimson);
  outline-offset: 4px;
}

/* Entrance: the panels slide in from the edges and the windows open. */
html.js #counters:not(.is-revealed) li {
  --window: 100%;
  opacity: 0;
}

html.js #counters:not(.is-revealed) li:first-child {
  translate: -4rem 0;
}

html.js #counters:not(.is-revealed) li:last-child {
  translate: 4rem 0;
}

@media (hover: hover) and (min-width: 993px) {
  #counters ul:has(> li:is(:hover, :focus-within)) > li {
    flex-grow: 0.62;
  }

  #counters ul:has(> li:is(:hover, :focus-within)) > li:is(:hover, :focus-within) {
    flex-grow: 1.5;
  }
}

@media (max-width: 992px) {
  #counters ul {
    flex-direction: column;
  }

  #counters li {
    min-height: clamp(22rem, 60vh, 32rem);
  }

  #counters li:first-child,
  #counters li:last-child {
    padding-inline: var(--pad);
  }
}

@media (prefers-reduced-motion: reduce) {
  #counters li,
  #counters li figure,
  #counters li figure img,
  #counters li a {
    transition: none;
  }
}
