/* Preview-only correction shared by the homepage and the draft editor.
   Zero track/item minima prevent a photo's intrinsic width sizing the grid. */
#work .cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#work .cards > .card,
#work .card .photo {
  min-width: 0;
}

#work .card .photo > img {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  object-fit: cover;
}

/* Keep the existing tablet/phone columns, padding and photo-frame heights.
   The narrower layout already uses minmax(0, 1fr) in the original page. */
@media (max-width: 900px) {
  #work .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 350px) {
  #work .cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Align the two outer Loft labels with its existing centred content wrapper. */
#loft-project > .house-part-label,
#loft-project > .house-chapter-label {
  width: min(1180px, 90%);
}

/* Contact colours only; shared by the preview page and draft editor. */
#contact {
  background: #676756 !important;
}

#contact > .eyebrow {
  color: var(--gold-soft, #f1e6cc);
}

#contact > h2 {
  color: #F5EBD7;
}

#contact > p:first-of-type {
  color: #E8E4DC;
}

/* Follow the paragraph's position, so edited contact details keep the colour. */
#contact > a.btn + p {
  color: #E8E4DC;
}

/* Below-ground section colours only; retain its existing gallery and layout. */
#underground-work {
  background-color: #676756;
}

#underground-work > h2,
#underground-work > .intro {
  color: var(--champagne, #e9ddc7);
}

#underground-work > .intro {
  opacity: 1;
}

#underground-work > .eyebrow {
  color: var(--gold-soft, #f1e6cc);
}

/* Turf section colours only; keep its existing bounds, spacing and gallery. */
#turf-laying-project {
  background-color: #676756;
}

#turf-laying-project > h2,
#turf-laying-project > .turf-intro {
  color: var(--champagne, #e8dcc5);
}

#turf-laying-project > .turf-kicker {
  color: var(--gold-soft, #f1e6cc);
}

/* Keep the original craft mosaic's photo sizes, reserving its original
   single-line caption space (12px × 1.65 line-height + 10px/14px padding).
   Additional caption lines grow the figure, never consume the image. */
#craft .brick-mosaic > figure[class] {
  --craft-frame-height: 210px;
  --craft-caption-space: calc(12px * 1.65 + 24px);
  height: auto;
}

#craft .brick-mosaic > figure.wall,
#craft .brick-mosaic > figure.entrance {
  --craft-frame-height: 330px;
}

#craft .brick-mosaic > figure.person,
#craft .brick-mosaic > figure.twotone,
#craft .brick-mosaic > figure.traditional {
  --craft-frame-height: 245px;
}

#craft .brick-mosaic > figure > img {
  flex: 0 0 auto;
  height: calc(var(--craft-frame-height) - var(--craft-caption-space));
}

#craft .brick-mosaic > figure > figcaption {
  flex: 0 0 auto;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  #craft .brick-mosaic > figure[class] {
    --craft-frame-height: 190px;
    /* Original mobile caption: 10px × 1.65 line-height + 8px padding. */
    --craft-caption-space: calc(10px * 1.65 + 16px);
  }

  #craft .brick-mosaic > figure.wall {
    --craft-frame-height: 235px;
  }
}

/* Approved work-section colours; card backgrounds and lettering stay unchanged. */
#work {
  background: #676756 !important;
}

#work > .wrap > .section-head > h2 {
  color: #F5EBD7 !important;
}

#work > .wrap > .section-head > p {
  color: #E8E4DC !important;
}

#work > .wrap > .section-head > .eyebrow {
  color: #F1E6CC !important;
}
