/* ============================================================
   WORK  .work / .work-card
   "3. Selected Work": client case studies as a scroll-stacking
   deck. Each card sticks below the nav; the next card slides
   over it and js/modules/stacked-cards.js shrinks the covered
   cards slightly so the deck tapers.
   The stacking itself is pure CSS (position: sticky), so it
   still works without JS or with reduced motion.

   Tweak in index.html on <div class="work__stack">:
     data-scale-step="0.04"   how much each covered card shrinks
     data-darken="false"      also dim covered cards (true/false)
   Tweak here: --stack-top, --stack-step, card min-height.
   ============================================================ */

.work__header {
  padding-bottom: 4rem;
}

.work__stack {
  --stack-top: calc(var(--nav-offset) + 10px); /* where cards park, below the nav */
  --stack-step: 16px;                           /* each card parks this much lower */
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 6vh, 80px);
  gap: clamp(32px, 6svh, 80px);   /* svh: stays put when the mobile address bar moves */
}

.work-card {
  position: sticky;
  top: calc(var(--stack-top) + var(--i, 0) * var(--stack-step));
  display: grid;
  grid-template-columns: 1fr;
  min-height: clamp(360px, 58svh, 560px);
  overflow: hidden;
  padding: 0;
  will-change: transform;
}

.work-card__media {
  position: relative;
  min-height: 240px;
  margin: 0;
  background-color: var(--color-surface);
}

.work-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.work-card__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(24px, 4vw, 56px);
}

.work-card__tags {
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
}

.work-card__title {
  padding-bottom: 0.25rem;
  color: var(--color-gray);
  font-size: var(--fs-h5);
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.02rem;
}

/* the title link covers the whole card, so the card is clickable */
.work-card__link {
  color: inherit;
}

.work-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.work-card__desc {
  max-width: 80%;
  color: var(--color-gray);
  font-size: 1.1rem;
  line-height: 145%;
}

/* "Visit site": a duplicate link (hidden from screen readers and Tab,
   the title link already covers that) that sits ABOVE the card-wide
   link overlay, so it can have its own hover. */
.work-card__visit {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.25rem;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-primary);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: var(--fw-medium);
  transition: color var(--duration) ease;
}

/* Arrow that slides out right while a second one slides in:
   the same motion as the arrow in .btn (components.css).
   The arrows are the arrow-right.svg icon used as a mask, so they
   take the text colour (currentColor) and follow the hover colour. */
.work-card__visit-icon {
  display: flex;
  flex: none;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  width: 18px;
  height: 18px;
  overflow: hidden;
}

.work-card__visit-icon span {
  flex: none;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: url("../../icons/arrow-right.svg") center / contain no-repeat;
  mask: url("../../icons/arrow-right.svg") center / contain no-repeat;
  transition: transform var(--duration) ease;
}

/* Mouse: animate only while hovering "Visit site" itself, like a CTA */
@media (hover: hover) {
  .work-card__visit:hover {
    color: var(--color-primary-ink);
  }

  .work-card__visit:hover .work-card__visit-icon span {
    transform: translateX(22px);
  }
}

/* Keyboard focus on the card's title link */
.work-card:has(.work-card__link:focus-visible) .work-card__visit-icon span {
  transform: translateX(22px);
}

/* Touch screens: plays as each card scrolls into view
   (.is-visible is toggled by js/modules/visit-arrow.js) */
@media (hover: none) {
  .work-card.is-visible .work-card__visit-icon span {
    transform: translateX(22px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .work-card__visit-icon span {
    transition: none;
  }
}

@media (min-width: 768px) {
  .work-card {
    grid-template-columns: 1fr 1fr;
  }

  /* alternate image side: odd cards image left, even cards image right */
  .work-card:nth-child(even) .work-card__media {
    order: 2;
  }
}

@media (max-width: 991px) {
  .work__header {
    padding-bottom: 2rem;
  }

  .work-card__desc {
    font-size: 0.95rem;
  }
}

@media (max-width: 767px) {
  .work-card__desc {
    max-width: 95%;
  }
}
