/**
 * LAYOUT: PAIRS (opt-in; agilehardscape.com, 2026-11-07). Each scene beside a
 * square, top-down swatch of the material it is made from; the sides
 * alternate down the page (swatch first, then scene first). A piece with no
 * swatch takes the full width (solo). The description is not shown. On a
 * narrow screen the scene runs full width and the swatch sits under it at a
 * third of the width, beside nothing.
 * Built to dist/fluid-layout-pairs.min.css (export "./layout-pairs"); link it
 * after core. Pair it with the swatch board (dist/fluid-swatches.min.css,
 * src/components/swatches.css) and end the page with it: a swatch links to
 * its square there. Contract: _docs/layouts.md.
 *
 *   <div class="layout-pairs">
 *     <p class="layout-pairs__intro">What we build.<br>And what it is made of.</p>   (optional)
 *     <section class="layout-pairs__pair" id="terrace" aria-label="Terrace">
 *       <a class="layout-pairs__swatch" href="#limestone">                    (only with a swatch)
 *         <img src="limestone-top.jpg" alt="Limestone, seen from above" width="800" height="800" loading="lazy">
 *         <span>Limestone</span>
 *       </a>
 *       <figure class="layout-pairs__scene">
 *         <img src="terrace-wide.jpg" alt="…" width="1600" height="900">
 *         <figcaption class="layout-pairs__words piece-words">
 *           <span class="piece-words__kind">Terraces</span>
 *           <h2 class="piece-words__name">Terrace</h2>
 *           <span class="piece-words__shown">Shown: honed limestone</span>   (optional)
 *           <span class="piece-words__links">
 *             <a href="/inquiries/?about=terrace">Inquire →</a>
 *             <button type="button" data-photos="terrace">3 photos</button>   (2+ photos; assets/js/layouts.js)
 *           </span>
 *         </figcaption>
 *       </figure>
 *       <ul data-lightbox data-for="terrace" hidden> … </ul>                  (2+ photos)
 *     </section>
 *   </div>
 *
 * The sides alternate by themselves (every second pair puts the scene
 * first); a pair without a swatch is solo by itself (:has). The scene is
 * cropped to 16:9 (4:3 on a phone), so pass the landscape crop (imageWide)
 * when a piece has one; the swatch is cropped square. A piece with no photo
 * is left out. Look hooks, read with fallbacks and never declared:
 * --layout-bar (a sticky header's height, default 4rem), --layout-name-font,
 * --layout-swatch (the swatch column's share of the row, default 1 to the
 * scene's 2.4).
 */
@layer components {
  .layout-pairs {
    display: grid;
    gap: clamp(3.5rem, 12vh, 8.75rem);
    padding: clamp(1rem, 4vh, 3rem) var(--page-edge) clamp(2rem, 6vh, 4.5rem);
  }

  .layout-pairs__intro {
    margin: 0 0 calc(-1 * clamp(1.75rem, 8vh, 6.25rem));
    max-inline-size: 26ch;
    font-family: var(--layout-name-font, var(--font-display));
    font-weight: var(--weight-light);
    font-size: var(--step-1);
    line-height: 1.35;
  }

  .layout-pairs__pair {
    display: grid;
    grid-template-columns: minmax(0, var(--layout-swatch, 1fr)) minmax(0, 2.4fr);
    gap: clamp(0.875rem, 2vw, 1.75rem);
    align-items: end;
    scroll-margin-block-start: calc(var(--layout-bar, 4rem) + 1rem);
  }

  /* Every second pair: the scene first, the swatch after it. */
  .layout-pairs__pair:nth-of-type(even) { grid-template-columns: minmax(0, 2.4fr) minmax(0, var(--layout-swatch, 1fr)); }
  .layout-pairs__pair:nth-of-type(even) .layout-pairs__swatch { order: 2; }
  .layout-pairs__pair:not(:has(.layout-pairs__swatch)) { grid-template-columns: minmax(0, 1fr); }

  .layout-pairs__pair img {
    display: block;
    inline-size: 100%;
    block-size: auto;
    max-inline-size: 100%;
    max-block-size: none;
    object-fit: cover;
    background: color-mix(in oklab, var(--color-text) 8%, var(--color-background));
  }

  .layout-pairs__scene { margin: 0; min-inline-size: 0; }
  .layout-pairs__scene img { aspect-ratio: 16 / 9; }

  .layout-pairs__swatch {
    display: grid;
    gap: var(--space-2);
    /* lines the square's foot up with the scene's, above the words */
    margin-block-end: 3.25rem;
    color: var(--color-text-muted);
    text-decoration: none;
  }
  .layout-pairs__swatch img { aspect-ratio: 1; }
  .layout-pairs__swatch span { font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  .layout-pairs__swatch:is(:hover, :focus-visible) { color: var(--color-text); }
  .layout-pairs__swatch:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

  /* The words: one row under the scene, the link at its far end (scoped,
     so it beats the .piece-words grid at the end of this file). */
  .layout-pairs .layout-pairs__words {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-5);
    align-items: baseline;
    max-inline-size: none;
    margin-block-start: var(--space-3);
    color: var(--color-text);
  }
  .layout-pairs__words .piece-words__name { font-size: clamp(1.5rem, 1.1rem + 1vw, 2.2rem); line-height: 1.1; }
  .layout-pairs :is(.piece-words__kind, .piece-words__shown) { color: var(--color-text-muted); opacity: 1; }
  .layout-pairs .piece-words__shown { font-size: var(--step--2); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  .layout-pairs__words .piece-words__links { margin: 0 0 0 auto; }
  .layout-pairs .piece-words__links button { color: var(--color-text-muted); opacity: 1; }
  .layout-pairs .piece-words__links button:is(:hover, :focus-visible) { color: var(--color-text); }

  /* Narrow: the scene full width, the swatch under it at a third. */
  @media (max-width: 47.5rem) {
    .layout-pairs__pair,
    .layout-pairs__pair:nth-of-type(even) { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }
    .layout-pairs__pair:not(:has(.layout-pairs__swatch)) { grid-template-columns: minmax(0, 1fr); }
    .layout-pairs__pair:nth-of-type(even) .layout-pairs__swatch { order: 0; }
    .layout-pairs__scene { grid-column: 1 / -1; grid-row: 1; }
    .layout-pairs__swatch { grid-row: 2; margin: 0; }
    .layout-pairs__scene img { aspect-ratio: 4 / 3; }
    .layout-pairs__words .piece-words__links { margin-inline-start: 0; }
  }

  /* ---------- Piece words (every layout file carries this block) ---------- */
  .piece-words { display: grid; gap: var(--space-1); font-style: normal; text-align: start; }

  .piece-words__kind {
    margin: 0;
    font-size: var(--step--2);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    opacity: 0.85;
  }

  .piece-words__name {
    margin: 0;
    font-family: var(--layout-name-font, var(--font-display));
    font-weight: var(--weight-light);
    font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.6rem);
    line-height: 1.05;
  }

  .piece-words__shown { margin: 0; font-size: var(--step--1); opacity: 0.9; }

  .piece-words__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    align-items: center;
    margin: var(--space-2) 0 0;
    font-size: var(--step--2);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .piece-words__links a { color: inherit; text-decoration: none; border-block-end: 1px solid currentColor; padding-block-end: 2px; }

  .piece-words__links button {
    all: unset;
    /* core's button hover paints the accent; these stay text */
    --_btn-bg-hover: transparent;
    --_btn-color-hover: currentColor;
    cursor: pointer;
    opacity: 0.85;
    border-block-end: 1px solid transparent;
    padding-block-end: 2px;
  }

  .piece-words__links button:is(:hover, :focus-visible) { opacity: 1; border-block-end-color: currentColor; }
  /* The ring is the words' own colour: light over photos, ink on paper. */
  .piece-words__links :is(a, button):focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
}
