/* Portfolio overview contact sheets: one band per discipline with a large
   name, its count and tagline, and a sheet of up to four projects. Bands
   alternate shade, and on wide screens alternate side, by rendered position
   (nth-of-type), so a hidden discipline never breaks the rhythm. The DOM is
   always text then sheet; the swap is grid placement, never `order`. */

.sheet-band {
  padding: clamp(56px, 7vw, 88px) 0;
  border-top: 1px solid var(--hair);
}
.sheet-band:nth-of-type(even) { background: var(--slate-deep); }

.sheet-band__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

.sheet-band__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(44px, 5vw, 72px);
  line-height: .95;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.sheet-band__count { margin-top: 16px; color: var(--paper-dim); font-size: 15px; }
.sheet-band__tagline { margin-top: 8px; color: var(--paper-dim); max-width: 30ch; }
.sheet-band__more { display: inline-block; margin-top: 22px; }

/* The sheet. Patterns by project count, so there is never an empty slot. */
.sheet { display: grid; gap: 14px; }
.sheet--n4 { grid-template-columns: 1.6fr 1fr 1fr; grid-template-rows: repeat(2, 150px); }
.sheet--n4 .sheet__item:nth-child(1) { grid-column: 1; grid-row: 1 / 3; }
.sheet--n4 .sheet__item:nth-child(4) { grid-column: 2 / 4; grid-row: 2; }
.sheet--n3 { grid-template-columns: 1.6fr 1fr; grid-template-rows: repeat(2, 150px); }
.sheet--n3 .sheet__item:nth-child(1) { grid-row: 1 / 3; }
.sheet--n2 { grid-template-columns: 1fr 1fr; grid-template-rows: 240px; }
.sheet--n1 { grid-template-columns: 1fr; grid-template-rows: 260px; }

.sheet__item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: var(--slate-raised);
  color: var(--paper);
  text-decoration: none;
}
.sheet__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.sheet__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 14px 12px;
  font-size: 14px;
  line-height: 1.35;
  /* Solid behind every line of text, however many lines the name wraps
     to; only the padding above the first line fades out. */
  background: linear-gradient(0deg, rgba(34, 41, 51, .92) 0, rgba(34, 41, 51, .92) calc(100% - 28px), rgba(34, 41, 51, 0) 100%);
  opacity: 0;
  transition: opacity .25s ease;
}
.sheet__item:hover img,
.sheet__item:focus-visible img { transform: scale(1.03); }
.sheet__item:hover .sheet__caption,
.sheet__item:focus-visible .sheet__caption { opacity: 1; }
.sheet__item:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

/* Touch screens have no hover, so client names are always shown. */
@media (hover: none) {
  .sheet__caption { opacity: 1; }
}

@media (min-width: 1100px) {
  .sheet-band__grid {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    gap: 56px;
    align-items: center;
  }
  .sheet-band:nth-of-type(even) .sheet-band__grid { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
  .sheet-band:nth-of-type(even) .sheet-band__text { grid-column: 2; grid-row: 1; }
  .sheet-band:nth-of-type(even) .sheet { grid-column: 1; grid-row: 1; }
  /* A band whose projects have no covers has no sheet: the text takes the
     full width instead of leaving an empty half. */
  .sheet-band--bare .sheet-band__grid,
  .sheet-band--bare:nth-of-type(even) .sheet-band__grid { grid-template-columns: minmax(0, 1fr); }
  .sheet-band--bare:nth-of-type(even) .sheet-band__text { grid-column: auto; }
  .sheet--n4, .sheet--n3 { grid-template-rows: repeat(2, 180px); }
  .sheet--n2 { grid-template-rows: 300px; }
  .sheet--n1 { grid-template-rows: 320px; }
}

/* Phones: a 2 by 2 sheet of 4:3 images, captions always shown since there
   is no hover. */
@media (max-width: 599px) {
  .sheet--n4, .sheet--n3, .sheet--n2, .sheet--n1 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }
  .sheet .sheet__item:nth-child(n) { grid-column: auto; grid-row: auto; aspect-ratio: 4 / 3; }
  .sheet--n1 .sheet__item:nth-child(n),
  .sheet--n3 .sheet__item:nth-child(1) { grid-column: 1 / -1; }
  .sheet__caption {
    opacity: 1;
    padding: 18px 10px 8px;
    font-size: 13px;
    background: linear-gradient(0deg, rgba(34, 41, 51, .92) 0, rgba(34, 41, 51, .92) calc(100% - 14px), rgba(34, 41, 51, 0) 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet__item img,
  .sheet__caption { transition: none; }
  .sheet__item:hover img,
  .sheet__item:focus-visible img { transform: none; }
}
