/*
 * Works listing.
 *
 * Page header and filter pills come from components.css. Below them one
 * section per category (.works-section, in three layouts) and one article
 * block (.works-item) in three variants: lead, card, case.
 * Distances are the ones of the 1440px mockup. Text sizes without a token
 * follow the rule of tokens.css: fixed from 1440px up, scaling with the
 * viewport below it, so lines keep breaking where the mockup breaks them.
 */

.works {
  --works-fs-text-l: clamp(16px, 1.389vw, 20px);
  --works-fs-text: clamp(15px, 1.181vw, 17px);
  padding-bottom: 188px;
}

/* ---------- Section ---------- */

.works-section {
  margin-top: 80px;
}
/* More air above the cases, unless the filter left them alone under the pills */
.works-section:not([hidden]) + .works-section--cases {
  margin-top: 180px;
}

/* Eyebrow in the first four columns of the grid, title from the fifth (x=520) */
.works-head {
  display: grid;
  grid-template-columns: 33.871% 1fr;
  align-items: start;
}
.works-head__title {
  font-size: var(--fs-h2);
  line-height: 1;
}
.works-head__text {
  grid-column: 2;
  font-size: var(--works-fs-text-l);
  line-height: 1.35;
}

/* "Load more" row */
.works-more {
  display: flex;
  justify-content: center;
  padding: 30px 0;
  border-top: 1px solid var(--c-line);
}
/* components.css animates the dot for links only; this one is a button */
.works-more .more:hover .dot::before {
  transform: scale(1.2);
}
.works-more .more:hover .dot svg {
  transform: translateX(2px);
}

/* ---------- Article block ---------- */

.works-item__link {
  display: block;
}

.works-item__media {
  position: relative;
  overflow: hidden;
  background: #ddd;
}
.works-item__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.works-item__link:hover .works-item__media img {
  transform: scale(1.04);
}

/* Chips over the image. Offsets are the mockup's, fractions included. */
.works-item__num,
.works-item__tag,
.works-item__credit {
  position: absolute;
  z-index: 1;
}
.works-item__num {
  top: 16px;
  left: 16px;
  padding: 6px 9px;
  background: var(--c-white);
  color: var(--c-black);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
/* Smaller than the shared .tag, which is sized for the home mosaic */
.works-item__tag {
  right: 17.4px;
  bottom: 17.5px;
  padding: 8px 11px 7px;
  font-size: 11px;
  line-height: 17px;
}
.works-item__credit {
  right: 23.4px;
  bottom: 7.5px;
  padding: 3px 5px;
  background: rgba(0, 0, 0, 0.72);
  color: rgba(255, 255, 255, 0.76);
  font-size: 9px;
  line-height: 14px;
}

/* Column, so the text link is a block of its own height instead of sitting on a text line */
.works-item__body {
  display: flex;
  flex-direction: column;
}
.works-item__body .more {
  align-self: flex-start;
}

.works-item__meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-line-strong);
  color: var(--c-text-meta);
  font-size: var(--fs-meta);
  font-weight: 500;
  line-height: 20px;
  text-transform: uppercase;
}

/* ---------- Lead: image beside the text ---------- */

.works-item--lead .works-item__link {
  display: grid;
  grid-template-columns: 666fr 540fr;
  column-gap: 34px;
}
.works-item--lead .works-item__media {
  aspect-ratio: 666 / 580;
}
.works-item--lead .works-item__title {
  margin: 28px 0;
  font-size: var(--fs-lead);
  line-height: 1.2778;
}
/* Excerpt and link sit on the bottom edge of the image */
.works-item--lead .works-item__excerpt {
  max-width: 537px;
  margin-top: auto;
  font-size: var(--works-fs-text-l);
  line-height: 1.35;
}
.works-item--lead .more {
  margin-top: auto;
}
.works-item--lead .works-item__excerpt + .more {
  margin-top: 24px;
}

/* ---------- Card: image above the text ---------- */

.works-item--card .works-item__media {
  aspect-ratio: 4 / 3;
}
.works-item--card .works-item__meta,
.works-item--case .works-item__meta {
  margin-top: 18px;
  line-height: 1.5;
}
/*
 * 24px under the rule, then the excerpt 51px lower for a one-line title and
 * 77px lower for a two-line one, as in the mockup (its title boxes are
 * shorter than their lines, so the gap is not constant).
 */
.works-item--card .works-item__title {
  min-height: 51px;
  margin-top: 24px;
  padding-bottom: 13px;
  font-size: var(--fs-body-l);
  line-height: 1.3333;
}
/* 324px of the 400px column */
.works-item--card .works-item__excerpt {
  max-width: 81%;
  font-size: var(--works-fs-text);
  line-height: 1.353;
}
.works-item--card .more {
  margin-top: 24px;
}

/* ---------- Case: large image, label, name ---------- */

.works-item--case .works-item__media {
  aspect-ratio: 684 / 423.328;
}
.works-item__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-top: 24px;
}
.works-item--case .works-item__title {
  font-size: var(--fs-lead);
  line-height: 1.1667;
}

/*
 * Hover (Figma components 16-21): a 40% black veil opens from the centre of
 * the image while the name, in white, rises from under its bottom edge.
 */
.works-item--case .works-item__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  clip-path: inset(0 50%);
  transition: clip-path 0.5s var(--ease);
}
.works-item__reveal {
  position: absolute;
  inset: 0;
  z-index: 1;
  color: var(--c-white);
  opacity: 0;
  /* a quarter of the image height: top goes from 100.89% to 75.89% in the component */
  transform: translateY(25%);
  transition: transform 0.5s var(--ease), opacity 0.3s;
}
.works-item__reveal-title {
  position: absolute;
  left: calc(3.93% + 10px);
  right: calc(3.93% + 10px);
  bottom: calc(9.89% + 10px);
  font-size: var(--fs-lead);
  line-height: 1.2778;
}
.works-item--case .works-item__link:hover .works-item__media::after,
.works-item--case .works-item__link:focus-visible .works-item__media::after {
  clip-path: inset(0);
}
.works-item--case .works-item__link:hover .works-item__reveal,
.works-item--case .works-item__link:focus-visible .works-item__reveal {
  opacity: 1;
  transform: none;
}

/* ---------- Layout: editorial (featured + three columns) ---------- */

.works-section--editorial .works-item--lead {
  margin-top: 140px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--c-line);
}
.works-section--editorial .works-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 50px var(--gutter);
  margin-top: 50px;
}
.works-section--editorial .works-more {
  margin-top: 51.5px;
}

/* ---------- Layout: cases (large cards, alternately left and right) ---------- */

.works-section--cases .works-list {
  display: flex;
  flex-direction: column;
  gap: 112px;
  margin-top: 80px;
}
/* 684px wide of 1240; the even ones start at 528px */
.works-item--case {
  width: 55.161%;
}
.works-item--case:nth-child(even) {
  margin-left: 42.581%;
}
.works-section--cases .works-more {
  margin-top: 70px;
}

/* ---------- Layout: stage (dark block) ---------- */

/* 1020px column inside the 1240px block */
.works-section--stage .works-section__inner {
  padding: 60px clamp(24px, 7.639vw, 110px) 98.4px;
  background: var(--c-night);
  color: var(--c-white);
}
/* The header is 1034px wide in the mockup: it hangs 7px out of the column on both sides */
.works-section--stage .works-head {
  grid-template-columns: 587fr 447fr;
  margin-inline: -7px;
}
.works-section--stage .eyebrow {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}
.works-section--stage .works-item__meta {
  color: rgba(255, 255, 255, 0.52);
}
.works-section--stage .more {
  color: var(--c-white);
}

.works-section--stage .works-item--lead {
  margin-top: 94px;
}
.works-section--stage .works-item--lead .works-item__link {
  grid-template-columns: 686fr 300fr;
}
.works-section--stage .works-item--lead .works-item__media {
  aspect-ratio: 16 / 9;
  background: #222;
}
.works-section--stage .works-item--lead .works-item__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.55));
}

.works-section--stage .works-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px 40px;
  margin-top: 60px;
}
.works-section--stage .works-item--card .works-item__media {
  aspect-ratio: 490 / 352.586;
  background: #242424;
}
.works-section--stage .works-item--card .works-item__meta {
  gap: 20px;
  margin-top: 0;
  padding-top: 18px;
  border-bottom-color: rgba(255, 255, 255, 0.25);
  line-height: 20px;
}
/* Title 476px and text 440px of the 490px column */
.works-section--stage .works-item--card .works-item__title {
  max-width: 97.143%;
  min-height: 0;
  margin-top: 25px;
  padding-bottom: 0;
  font-size: clamp(24px, 2.223vw, 32px);
  line-height: 1.1875;
}
.works-section--stage .works-item--card .works-item__excerpt {
  max-width: 89.796%;
  margin-top: 22px;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.4118;
}
.works-section--stage .works-item--card .more {
  margin-top: 34px;
}

/* ---------- Provisional small-screen rules (no mobile mockup yet) ---------- */

@media (max-width: 1000px) {
  .works {
    padding-bottom: 96px;
  }
  .works-section,
  .works-section:not([hidden]) + .works-section--cases {
    margin-top: 72px;
  }
  .works-head,
  .works-section--stage .works-head {
    grid-template-columns: 1fr;
    margin-inline: 0;
  }
  .works-head__text {
    grid-column: auto;
    margin-top: 20px;
  }

  .works-item--lead .works-item__link,
  .works-section--stage .works-item--lead .works-item__link {
    grid-template-columns: 1fr;
    row-gap: 24px;
  }
  .works-item--lead .works-item__title {
    margin: 20px 0;
  }
  /* The designer's line breaks are meant for the desktop column */
  .works-item__excerpt br {
    display: none;
  }
  .works-section--editorial .works-item--lead,
  .works-section--stage .works-item--lead {
    margin-top: 40px;
  }

  .works-section--cases .works-list {
    gap: 64px;
    margin-top: 40px;
  }
  .works-item--case {
    width: 78%;
  }
  .works-item--case:nth-child(even) {
    margin-left: 22%;
  }

  .works-section--stage .works-section__inner {
    padding-top: 32px;
    padding-bottom: 56px;
  }
}

@media (max-width: 760px) {
  .works-section--editorial .works-list,
  .works-section--stage .works-list {
    grid-template-columns: 1fr;
    row-gap: 48px;
  }
  .works-item--case,
  .works-item--case:nth-child(even) {
    width: 100%;
    margin-left: 0;
  }
  /* The dark block runs edge to edge so its content keeps the page margins */
  .works-section--stage .works-section__inner {
    width: 100%;
    padding-inline: var(--margin);
  }
}

@media (prefers-reduced-motion: reduce) {
  .works-item__media img,
  .works-item--case .works-item__media::after,
  .works-item__reveal {
    transition: none;
  }
}
