/**
 * Fluid Framework - Swatches (opt-in module; agilehardscape.com, 2026-11-07)
 * @layer components
 *
 * dist/fluid-swatches.min.css (package export "./swatches"). Link it after
 * core. A board of square swatches, grouped: materials, finishes, fabrics,
 * colours, each with a name, an optional spec line, a link and an optional
 * credit (who supplies it or who took the photo). Ends a page of work (the
 * pairs layout links its swatches to the squares here) or stands alone as a
 * page. Without this file the markup is plain HTML: headings and lists.
 *
 *   <section class="swatches" id="materials" aria-labelledby="swatches-title">
 *     <div class="swatches__head">
 *       <h2 class="swatches__title" id="swatches-title">Materials</h2>
 *       <p class="swatches__note">Seen from above. Prices on request.</p>        (optional)
 *     </div>
 *     <div class="swatches__group">                                             (one per group)
 *       <h3 class="swatches__group-title">Natural stone</h3>                    (optional: leave it out with one group)
 *       <ul class="swatches__grid" role="list">
 *         <li class="swatch" id="limestone">
 *           <img src="limestone-top.jpg" alt="Limestone, seen from above" width="800" height="800" loading="lazy">
 *           (no photo: <span class="swatch__blank" aria-hidden="true"></span>)
 *           <p class="swatch__name">Limestone</p>
 *           <p class="swatch__spec">Honed, 30 mm, 600 × 400</p>                  (optional)
 *           <p class="swatch__links">
 *             <a href="/inquiries/?about=limestone">Ask for pricing<span class="sr-only"> on Limestone</span> →</a>
 *             <a class="swatch__credit" href="https://…" rel="noopener">Supplier</a>   (optional; a <span> without a link)
 *           </p>
 *         </li>
 *       </ul>
 *     </div>
 *   </section>
 *
 * Every swatch carries its slug as its id, so /materials/#limestone (or a
 * pair's swatch link) lands on it and outlines it (:target). Options:
 * data-head="plain" on .swatches drops the rule above the head (a page that
 * is only the board). Look hooks, read with fallbacks and never declared:
 * --swatch-min (the smallest square, default 11.25rem; two a row on a
 * phone), --layout-bar (a sticky header's height, default 4rem),
 * --layout-name-font.
 */

@layer components {
  .swatches {
    padding: clamp(3rem, 10vh, 7.5rem) var(--page-edge) clamp(3.5rem, 10vh, 7.5rem);
    background: var(--color-background);
    color: var(--color-text);
  }

  .swatches__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: end;
    gap: var(--space-2) var(--space-5);
    margin-block-end: clamp(1.5rem, 5vh, 3.5rem);
    padding-block-start: var(--space-4);
    border-block-start: 1px solid var(--color-border);
  }
  .swatches[data-head="plain"] .swatches__head { border-block-start: 0; padding-block-start: 0; }

  .swatches__title {
    margin: 0;
    font-family: var(--layout-name-font, var(--font-display));
    font-weight: var(--weight-light);
    font-size: clamp(1.8rem, 1.2rem + 1.6vw, 2.8rem);
    line-height: 1;
  }

  .swatches__note { margin: 0; color: var(--color-text-muted); font-size: var(--step--1); }

  .swatches__group + .swatches__group { margin-block-start: clamp(2rem, 6vh, 4.5rem); }

  .swatches__group-title {
    margin: 0 0 var(--space-3);
    font-family: var(--font-body);
    font-size: var(--step--2);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .swatches__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--swatch-min, 11.25rem)), 1fr));
    gap: clamp(0.875rem, 1.6vw, 1.5rem);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .swatch { min-inline-size: 0; scroll-margin-block-start: calc(var(--layout-bar, 4rem) + 1rem); }

  .swatch :is(img, .swatch__blank) {
    display: block;
    inline-size: 100%;
    block-size: auto;
    max-inline-size: 100%;
    max-block-size: none;
    aspect-ratio: 1;
    object-fit: cover;
    background: color-mix(in oklab, var(--color-text) 8%, var(--color-background));
  }

  .swatch__name {
    margin: var(--space-2) 0 0;
    font-family: var(--layout-name-font, var(--font-display));
    font-weight: var(--weight-light);
    font-size: var(--step-1);
    line-height: 1.15;
  }

  .swatch__spec { margin: 2px 0 0; font-size: var(--step--1); line-height: 1.4; color: var(--color-text-muted); }

  .swatch__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    align-items: baseline;
    margin: var(--space-2) 0 0;
    font-size: var(--step--2);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }
  .swatch__links a { color: inherit; text-decoration: none; border-block-end: 1px solid currentColor; padding-block-end: 1px; }
  .swatch__links a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

  .swatch__links .swatch__credit {
    border: 0;
    letter-spacing: 0.04em;
    text-transform: none;
    color: var(--color-text-muted);
  }
  a.swatch__credit { text-decoration: underline; text-underline-offset: 2px; }

  .swatch:target :is(img, .swatch__blank) { outline: 2px solid var(--color-text); outline-offset: 4px; }

  @media (max-width: 47.5rem) {
    .swatches__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
}
