/* ==========================================================================
   home.css — the projects index: intro band, project thumbnails, client logos
   Only linked from ./index.html. Font sizes are in `em` against the 10px root
   (see base.css), so 7.6em is 76px and 3.75em is 37.5px.
   ========================================================================== */

.page.home {
  --page-background: var(--s-raised);
}

/* --- intro ------------------------------------------------------------- */

.block.intro-band .headline {
  font-size: 7.6em;
  line-height: 1.2;
  color: #333;
}

.block.intro-band .headline strong {
  font-weight: var(--title-weight);
}

/*
 * The original spaced this off the headline with two empty paragraphs; at
 * 2.4em / 1.25 that is 2 × 30px. Reproduced as a margin so the markup stays
 * semantic — same trick as --rhythm in base.css.
 */
.block.intro-band .standfirst {
  margin-top: 60px;
  font-size: 2.4em;
  line-height: 1.25;
}

/*
 * A 140px hairline under the intro. The original followed the copy with three
 * more empty paragraphs (3 × 30px) and then gave the rule a 20px top margin.
 *
 * The 12px box is not decoration: the original drew the rule as a 1px
 * `inline-block` inside a block, so it sat on a text baseline and its line box
 * reserved 12px, with the rule 9px down. Measured on the live page. Kept
 * because that space is real in the original's rhythm — see README, Known
 * artefacts.
 */
.block.intro-band .divider {
  position: relative;
  margin-top: 110px;
  height: 12px;
  opacity: 0.8;
}

.block.intro-band .divider::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 0;
  width: 140px;
  height: 1px;
  background: var(--color);
}

/* --- project thumbnails ------------------------------------------------ */

.block.thumbs {
  --thumb-overlay-color: #000;
  --thumb-overlay-opacity: 0.4;
}

.block.thumbs .thumb-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 2), 1fr);
  gap: var(--gap-y, 40px) var(--gap-x, 40px);
  width: 100%;
}

.thumb {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

/* The Under NDA tile has no page behind it, so it gets no pointer either. */
.thumb:not(a) {
  cursor: default;
}

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

/*
 * The title is held behind a scrim that both fade in together on hover, so the
 * grid reads as artwork at rest and as a list of projects under the pointer.
 * `visibility` is what keeps the hidden title out of the accessibility tree's
 * "is this visible" answer without removing it from the document — the link's
 * own text is still its accessible name.
 */
.thumb > .scrim,
.thumb > .label {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 500ms ease, visibility 500ms ease, transform 500ms ease;
}

.thumb > .scrim {
  background: var(--thumb-overlay-color);
  pointer-events: none;
}

.thumb > .label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #fff;
  font-size: 3.75em;
  line-height: 1.3;
  font-weight: var(--body-weight);
  text-align: center;
  transform: translateY(0.5em);
}

/*
 * Touch has no hover to reveal them with, so there the titles are simply always
 * on — a grid whose labels only appear under a pointer would be unreadable on a
 * phone.
 */
@media (hover: hover) and (pointer: fine) {
  .thumb:hover > .scrim {
    opacity: var(--thumb-overlay-opacity);
    visibility: visible;
  }

  .thumb:hover > .label {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

@media (hover: none), (pointer: coarse) {
  .thumb > .scrim {
    opacity: var(--thumb-overlay-opacity);
    visibility: visible;
  }

  .thumb > .label {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thumb > .scrim,
  .thumb > .label {
    transition: none;
  }
}

/* --- responsive -------------------------------------------------------- */

@media (max-width: 768px) {
  .block.intro-band .headline {
    font-size: clamp(1em, 7.6em, 7vw);
  }

  .block.intro-band .standfirst {
    margin-top: 30px;
    font-size: clamp(1em, 2.4em, 5vw);
  }

  .block.intro-band .divider {
    margin-top: 60px;
  }

  .block.thumbs .thumb-grid {
    --columns: 1;
  }

  .thumb > .label {
    font-size: 5vw;
  }
}

/* --- client logos ------------------------------------------------------- */
/*
 * The count and gaps live here rather than inline on the element: an inline
 * custom property beats a media query, so a grid whose columns are set in the
 * markup can never collapse on a phone.
 */
.block.logo-block .logo-grid {
  --columns: 5;
  --gap-x: 0px;
  --gap-y: 0px;
}

@media (max-width: 768px) {
  .block.logo-block .logo-grid {
    --columns: 2;
    --gap-x: 40px;
    --gap-y: 40px;
  }
}
