/*
 * Listing components for server-rendered product grids: card additions (template-parts/card-product.php;
 * the base .pcard styles live in components.css) and the mobile filter bottom sheet (.sheet) used by
 * the category and catalogue pages. Handle: stitchshell-cards (see stitchshell_enqueue_cards()).
 */

.pcard[hidden] { display: none; }
.pcard__img { height: 100%; }
.pcard__media img { width: 100%; height: 100%; }
.pcard__frame.is-specimen .pcard__img { padding: 4%; }

/* Code in the kicker sits on the same baseline as the category name. */
.pcard__kicker { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; }

/* Touch: swatches grow to a comfortable size and each gets a 44px hit area without overlapping. */
@media (pointer: coarse) {
  .pcard__swatches { gap: 10px; }
  .pcard__sw { position: relative; width: 32px; height: 32px; }
  .pcard__sw::after { content: ""; position: absolute; inset: -6px; }
  .pcard__more { min-height: 44px; display: inline-grid; place-items: center; padding-inline: var(--space-2); }
  .pcard__actions .btn { min-height: 44px; }
  .pcard__title a { display: inline; padding-block: 6px; }
}

/* Feature card on phones: tighter spec grid. */
@media (max-width: 560px) {
  .pcard--feature .pcard__title { font-size: var(--step-2); }
  .pcard__specs { grid-template-columns: 1fr; }
}

/* ---------- Bottom sheet (filters on phones) ---------- */
.sheet { position: fixed; inset: 0; z-index: 110; }
.sheet[hidden] { display: none; }
.sheet__scrim { position: absolute; inset: 0; background: rgb(17 11 48 / 0.45); opacity: 0; transition: opacity var(--dur-2) var(--ease-out); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: min(88dvh, 760px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-3);
  translate: 0 100%; transition: translate var(--dur-3) var(--ease-out); outline: none;
}
.sheet.is-open .sheet__scrim { opacity: 1; }
.sheet.is-open .sheet__panel { translate: 0 0; }
.sheet__head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-4) var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); }
.sheet__handle { position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-strong); }
.sheet__title { font: 700 var(--step-0)/1.2 var(--font-body); letter-spacing: 0; }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: var(--space-4) var(--space-5) var(--space-5); display: grid; gap: var(--space-5); align-content: start; }
.sheet__foot { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); padding: var(--space-3) var(--space-5) calc(var(--space-3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.sheet__foot .btn { min-height: 52px; }
.sheet__group { margin: 0; padding: 0 0 var(--space-4); border: 0; border-bottom: 1px solid var(--line); min-width: 0; }
.sheet__group:last-child { border-bottom: 0; }
.sheet__group legend, .sheet__legend { margin: 0 0 var(--space-2); padding: 0; font: 700 var(--step--2)/1 var(--font-body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-subtle); }
.sheet .check { min-height: 48px; padding-inline: var(--space-2); }
.sheet .check input { width: 22px; height: 22px; }
.sheet .chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sheet .chips .chip { min-height: 44px; }
html.sheet-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .sheet__panel, .sheet__scrim { transition: none; } }

/* Count badges inside filter buttons stay hidden until a filter is active. */
.fpop__count[hidden] { display: none; }

/* ---------- Phones: two products per row ----------
 * One full-width card per screen made long lists slow to scan. Two columns show four products per screen;
 * the summary and the second quick action step back, the shade swatches keep one row.
 */
@media (max-width: 560px) {
  .results__grid, .results__grid[data-density], .listing__grid, .listing__grid[data-count], .featured__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-3);
  }
  .listing__grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
  .pcard { gap: var(--space-3); }
  .pcard__frame, .pcard--xl .pcard__frame, .pcard__media, .pcard--xl .pcard__media { aspect-ratio: 1; }
  .pcard__media { border-radius: var(--r-sm); }
  .pcard__summary, .pcard__picked, .pcard__actions [data-quick-view] { display: none; }
  .pcard__title, .pcard--md .pcard__title, .pcard--xl .pcard__title { font-size: var(--step-0); line-height: 1.2; }
  .pcard__kicker { font-size: 10px; letter-spacing: 0.08em; }
  .pcard__meta { font-size: 11px; gap: 6px; }
  .pcard__swatches { max-height: 34px; overflow: hidden; gap: 8px; }
  .pcard__actions .btn { width: 100%; min-height: 44px; padding-inline: var(--space-2); font-size: var(--step--2); }
}
/* Touch phones: swatches and the quote button line up at the foot of each row; the button is a quiet outline
   (orange stays for the page's main action). */
@media (max-width: 560px) and (hover: none) {
  .pcard { grid-template-rows: auto 1fr auto; }
  .pcard__actions .btn--accent { --btn-bg: transparent; --btn-fg: var(--indigo-600); box-shadow: inset 0 0 0 1.5px var(--indigo-200); }
  .pcard__actions .btn--accent:active { background: var(--indigo-50); }
}
