/* ============================================================================
   HOWE — GALLERY GRID (fixed-height · variable-width)
   A commerce-layer module composed ENTIRELY from howe.css tokens. Nothing
   here redefines a token, a font-family or a canonical component. It adds one
   thing the canonical sheet does not yet hold: a justified, fixed-height /
   variable-width product grid — the "gallery hang" — plus the toolbar that
   toggles density and the uniform-catalogue baseline.

   Model:
     · every product image renders at one common height (the hang line)
     · width = image's TRUE aspect ratio × that height — never cropped, never
       distorted, no letterbox frame, no fill behind the image
     · tiles flow left→right and rows are justified to the container width, so
       different rows hold different numbers of pieces
     · a maximum tile-width CAP stops a panoramic piece dominating a row
   Layout maths live in howe-gallery.js; this file is presentation only.
   ============================================================================ */

/* ---- toolbar : density + view, styled to match the canonical filter shelf -- */
.gg-toolbar{
  display:flex; align-items:center; gap:14px 26px; flex-wrap:wrap;
  padding:0 0 clamp(20px,2.4vw,30px);
}
/* D6: density/view segmented-control ("toggle UI") removed from the engine CSS.
   Density is build-time only, via data-default-density on the .gg-mount. */
.gg-toolbar .gg-note{
  font-family:var(--ff-ui); font-size:11.5px; color:var(--label);
  margin-left:auto; line-height:1.5; max-width:34ch;
}
.gg-toolbar .gg-note b{ color:#7c5a32; font-weight:500; }

/* ---- the grid : rows are written by JS, which sets per-tile width/height ---- */
.gg{ --gg-rowgap:64px; }
.gg-row{
  display:flex; align-items:flex-start; flex-wrap:nowrap;
  /* horizontal gap between tiles is set inline per render (--gg-hgap) */
  gap:var(--gg-hgap, 40px);
  margin-bottom:var(--gg-rowgap);
}
.gg-row:last-child{ margin-bottom:0; }

.gg-tile{
  display:flex; flex-direction:column;
  flex:0 0 auto;        /* never shrink or grow — the figure box keeps the image's TRUE ratio, so it is never cropped */
  min-width:0;
}
/* the image meets the page directly — no border, no background fill, no frame */
.gg-fig{
  position:relative; margin:0; overflow:hidden;
}
.gg-fig:where(:not(.img)){ background:transparent; }   /* R91: a card awaiting its photograph keeps the empty slot's ground (.img); :where keeps the old weight */
.gg-fig img{
  display:block; width:100%; height:100%;
  object-fit:cover; /* box matches the true ratio exactly, so this never crops */
}
.gg-fig .pc-select{ /* canonical bookmark, top-right */
  position:absolute; top:12px; right:12px;
}

/* card furniture beneath each tile, left-aligned to the tile */
.gg-card{ padding-top:16px; }
.gg-card .product-tag{ margin-top:0; }
.gg .product-name{ margin-bottom:7px; }
/* keep the metadata tidy under narrow tiles, never overflowing wide ones */
.gg-card .product-meta{ row-gap:4px; }
.product-price.por{ font-variant-numeric:normal; } /* "Price on request" — not numeric */

/* whole-tile link (canonical pattern) */
.gg-tile{ position:relative; }
.gg-tile .card-stretch{ position:absolute; inset:0; z-index:1; }
.gg-tile .pc-select,
.gg-tile .product-name a{ position:relative; z-index:2; }
.gg-tile .gg-card{ position:relative; z-index:2; pointer-events:none; }
.gg-tile .gg-card a{ pointer-events:auto; }

/* image-only hover lift (canonical .img-tile voice: image lifts, nothing else) */
@media (hover:hover){
  .gg-tile:hover .gg-fig img{ transform:scale(1.035); }
}
.gg-fig img{ transition:transform 460ms cubic-bezier(.2,.6,.2,1); }
@media (prefers-reduced-motion: reduce){ .gg-fig img{ transition:none; } .gg-tile:hover .gg-fig img{ transform:none; } }

/* ---- ADAPTED FOR EDITORIAL : curated horizontal rail ----
   The fixed-height / variable-width logic kept, but constrained to a single
   scrolling line of an editor-curated selection — true proportion preserved,
   editorial rhythm protected. */
.gg.is-rail{ overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; scroll-snap-type:x proximity; margin:0 calc(-1 * var(--gutter)); padding:0 var(--gutter) 4px; }
.gg.is-rail .gg-row{ flex-wrap:nowrap; margin-bottom:0; align-items:flex-start; width:max-content; }
.gg.is-rail .gg-tile{ scroll-snap-align:start; }
.gg.is-rail::-webkit-scrollbar{ height:2px; }
.gg.is-rail::-webkit-scrollbar-thumb{ background:var(--border); }

/* ---- SECONDARY, clearly-labelled : uniform catalogue grid (the baseline) ----
   shown only when the view toggle is set to "Catalogue". A fixed 4-column grid
   on the canonical 4:5 slot — every image cropped to one box. This is the
   model the gallery hang replaces; kept as a labelled comparison only. */
.gg.is-catalogue{ display:grid; grid-template-columns:repeat(4,1fr); gap:var(--gg-hgap,40px) var(--gg-hgap,40px); }
.gg.is-catalogue .gg-row{ display:contents; } /* flatten rows into the grid */
.gg.is-catalogue .gg-tile{ width:auto !important; }
.gg.is-catalogue .gg-fig{ height:auto !important; aspect-ratio:4/5; }
@media (max-width:1024px){ .gg.is-catalogue{ grid-template-columns:repeat(3,1fr); } }
@media (max-width:720px){ .gg.is-catalogue{ grid-template-columns:repeat(2,1fr); } }

/* ---- mobile reflow : single measured column, images at TRUE ratio ----
   On a narrow screen a multi-up justified hang shrinks tiles below legibility,
   so the fixed-height logic inverts: the COLUMN width becomes the constant and
   each image keeps its own true height. Driven by JS adding .is-stack. */
.gg.is-stack .gg-row{ display:block; margin-bottom:0; }
.gg.is-stack .gg-tile{ width:100% !important; margin-bottom:var(--gg-rowgap); }
.gg.is-stack .gg-tile:last-child{ margin-bottom:0; }
.gg.is-stack .gg-fig{ height:auto !important; }
.gg.is-stack .gg-fig img{ height:auto; }
.gg.is-stack .gg-fig img{ aspect-ratio:var(--gg-ar, auto); }   /* R19f: shape reserved from the tile data (ar); unchanged where no ar is given */

/* empty / loading shimmer so the page never flashes raw before layout runs */
.gg:empty::after{
  content:"Composing the hang…"; display:block;
  font-family:var(--ff-ui); font-size:12px; color:var(--label);
  padding:40px 0;
}

/* ---- R91 (module pack U2): a card whose photograph is still to come ----
   The figure is the site's one empty image slot (.img in howe.css: warm crosshatch) at the card's shape; the data's own note, where it
   has one, sits centred on it (same type as the materials note it replaces). */
.gg-fig--ph{ display:flex; align-items:center; justify-content:center; }
.gg-ph-note{ font-family:var(--ff-ui); font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--label); text-align:center; line-height:1.7; max-width:22ch; padding:0 20px; }

/* ---- R91: card rules moved here from howe-listing.css (they belong to the card wherever it appears) ---- */
/* R25t (Guy, 5 Oct): FEATURED sits on the parchment ground used by the Journal's "How HOWE began" module, so it reads apart from the
   collection name; no separator after it. Same 12px tag type, same line. */
.pc-feat{display:inline-block;padding:2px 7px 1px;margin-right:9px;background:var(--parchment);color:var(--ink);line-height:1.3;vertical-align:baseline;}
.product-tag:has(> .pc-feat:only-child){padding:0;}
/* R27c Q7: finish roundels sit above the stretched card link so they can be hovered and pressed */
.gg-tile .pc-swatches{position:relative;z-index:2;width:fit-content;pointer-events:auto;}
/* R27d: dummy colourway roundel (name known, swatch imagery to follow): an empty ring on the card ground */
.pc-swatch.pc-swatch--ph{background:transparent;border:1px solid var(--label);box-shadow:none;}
.pc-swatch.pc-swatch--ph.is-active{box-shadow:0 0 0 1px var(--ink);border-color:var(--ink);}
