/* ==========================================================================
   Contributor sections

   Each contributor gets a block on the thank-you page, composed in the admin
   console: a title, a body, some photographs, and a choice of how the two sit
   together. This file is the whole vocabulary of those choices.

   Its own file so the composer and the page can be worked on without touching
   components.css. Reads semantic tokens only; no hex value belongs here.

   THE LAYOUT CHOICES, which are the values the composer writes into
   data-layout on .contrib-body:

     wrap-left    one photo indented into the left of the text, text flows round
     wrap-right   the same on the right
     above        photographs full width, above the text
     below        photographs full width, beneath the text
     gallery      photographs as an even grid beneath the text

   Wrapping is done with float rather than a grid on purpose. Float is the only
   mechanism in CSS where running text actually flows around a shape; a grid
   column would put the text beside the photo in a rigid column and leave a hole
   under a short caption.
   ========================================================================== */

@layer components {

.contrib {
  padding-block: var(--space-section);
  border-top: var(--hairline) solid var(--color-border);
}

.contrib:first-of-type { border-top: 0; }

.contrib-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--step-2) var(--step-4);
  margin-bottom: var(--step-5);
}

.contrib-title { font-size: var(--size-xl); }

/* What they did, in the monospace label voice the rest of the site uses for
   metadata. Optional: a contributor may have only a name. */
.contrib-role {
  font-family: var(--font-mono);
  font-size: var(--size-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-accent);
}

.contrib-date {
  font-family: var(--font-mono);
  font-size: var(--size-2xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-left: auto;
}

/* The body is capped in characters rather than pixels, the same as every other
   piece of prose here, so a wrapped photo does not push the measure past what is
   comfortable to read. */
.contrib-body {
  max-width: var(--measure);
  font-size: var(--size-base);
  color: var(--color-text-muted);
}

.contrib-body > p + p { margin-top: var(--step-4); }

/* The float has to be cleared or the next contributor's heading rides up beside
   the previous one's photograph. flow-root is the modern, side-effect-free way
   to do that: no clearfix pseudo-element, no overflow hack. */
.contrib-body { display: flow-root; }

.contrib-figure { margin: 0 0 var(--step-4) 0; }

.contrib-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-card);
  border: var(--hairline) solid var(--color-border);
}

.contrib-caption {
  margin-top: var(--step-2);
  font-size: var(--size-xs);
  color: var(--color-text-faint);
}

/* --------------------------------------------------------------------------
   wrap-left and wrap-right

   Only applied from 40rem up. Below that a floated image leaves a column of
   text three or four words wide beside it, which is unreadable, so on a phone
   every layout collapses to the photograph sitting above its text.
   -------------------------------------------------------------------------- */
/* The child combinator matters. Only the figure that is a direct child of the
   body is the one being floated into the text; a wrap layout with more than one
   photograph puts the rest inside .contrib-figures, and those must stay in the
   grid rather than each floating and stacking against the first. */
@media (min-width: 40rem) {
  [data-layout='wrap-left'] > .contrib-figure,
  [data-layout='wrap-right'] > .contrib-figure {
    width: min(48%, 18rem);
  }

  [data-layout='wrap-left'] > .contrib-figure {
    float: left;
    margin-right: var(--step-5);
  }

  [data-layout='wrap-right'] > .contrib-figure {
    float: right;
    margin-left: var(--step-5);
  }

  /* A wrapped block gets more room than the reading measure, because the text
     column is only part of the width once a photo is floated into it. */
  [data-layout='wrap-left'],
  [data-layout='wrap-right'] { max-width: 52rem; }
}

/* --------------------------------------------------------------------------
   above and below
   -------------------------------------------------------------------------- */
[data-layout='above'] .contrib-figure { margin-bottom: var(--step-5); }
[data-layout='below'] .contrib-figure { margin-top: var(--step-5); margin-bottom: 0; }

/* --------------------------------------------------------------------------
   gallery
   -------------------------------------------------------------------------- */
/* Not scoped to the gallery layout. A wrap layout floats its first photograph
   and puts any others in this same grid, so the grid has to hold wherever it
   appears rather than only under one data-layout value. */
.contrib-figures {
  display: grid;
  gap: var(--step-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  margin-top: var(--step-5);
}

.contrib-figures .contrib-figure { margin: 0; }

/* --------------------------------------------------------------------------
   The composer preview in the admin console

   Same classes as the public page, at a smaller scale, so what is being
   composed is what will be published rather than an approximation of it.
   -------------------------------------------------------------------------- */
.contrib-preview {
  padding: var(--step-5);
  background: var(--color-surface);
  border: var(--hairline) solid var(--color-border-strong);
  border-radius: var(--radius-card);
}

.contrib-preview .contrib { padding-block: 0; border-top: 0; }

} /* @layer components */
