/* ════════════════════════════════════════════════════════════════
   Penworthy — shop (PLP) bundle
   Listing-specific rules. Ported from design-reference/styles.css.
   ════════════════════════════════════════════════════════════════ */

/* ── Shop list view: drop the middle columns on small screens ── */
@media (max-width: 900px) {
  .shop-lr { grid-template-columns: 72px 1fr auto !important; gap: 14px !important; }
  .shop-lr > div:nth-child(3), .shop-lr > div:nth-child(4) { display: none; }
}

/* — page-specific conversions appended below — */

/* ── Breadcrumb + page head (ProductsPage header) ── */
.pw-plp-crumb { font-size: 14px; color: var(--pw-ink-3); margin-bottom: 8px; }
.pw-plp-crumb a:hover { color: var(--pw-blue); }
.pw-plp-crumb-sep { margin: 0 8px; }
.pw-plp-crumb-here { color: var(--pw-blue); }

.pw-plp-head { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 28px; }
.pw-plp-title { font-size: clamp(34px, 5vw, 48px); color: var(--pw-blue); }
.pw-plp-count { color: var(--pw-ink-2); font-size: 16px; }
.pw-plp-count strong { font-weight: 600; }

/* ── Toolbar — Filters / search / sort / view ── */
.pw-plp-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--pw-bg-2);
  border-radius: var(--pw-r-md);
  position: relative;
  z-index: 40;
}
.pw-plp-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--pw-r);
  background: #fff;
  color: var(--pw-ink-2);
  border: 1px solid var(--pw-line);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.pw-plp-filters:hover { border-color: var(--pw-blue); color: var(--pw-blue); }
.pw-plp-filters.is-active {
  background: var(--pw-blue);
  color: #fff;
  border-color: var(--pw-blue);
}
.pw-plp-filters.is-active:hover { filter: brightness(1.08); }
.pw-plp-filters-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--pw-yellow);
  color: var(--pw-blue);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pw-plp-search {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 10px 16px;
  border-radius: var(--pw-pill);
  border: 1px solid var(--pw-line);
}
.pw-plp-search:focus-within { border-color: var(--pw-blue); }
.pw-plp-search-ic { color: var(--pw-ink-3); flex: 0 0 auto; }
.pw-plp-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  padding: 0;
}
.pw-plp-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Sort dropdown (SortDropdown port; popover reuses .card.pw-menu-pop) */
.pw-sort { position: relative; }
.pw-sort-toggle {
  background: #fff;
  padding: 10px 18px;
  border-radius: var(--pw-r);
  border: 1px solid var(--pw-line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.pw-sort-toggle b { color: var(--pw-blue); }
.pw-sort-menu { display: none; }
.pw-sort-menu.is-open { display: block; }
.pw-sort-menu .pw-menu-pop-item { display: block; }

/* Grid / list segmented control (ViewToggle port) */
.pw-viewtoggle {
  position: relative;
  display: inline-flex;
  padding: 4px;
  background: var(--pw-line-2);
  border-radius: var(--pw-pill);
  box-shadow: inset 0 0 0 1px var(--pw-line);
}
.pw-viewtoggle-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 2);
  background: var(--pw-blue-tint-2);
  border-radius: var(--pw-pill);
  transition: left .24s cubic-bezier(.4, 0, .2, 1);
}
.pw-viewtoggle[data-active="list"] .pw-viewtoggle-thumb { left: calc(4px + (100% - 8px) / 2); }
.pw-viewtoggle-btn {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pw-ink-3);
  transition: color .18s;
}
.pw-viewtoggle-btn.is-active,
.pw-viewtoggle-btn[aria-checked="true"] { color: var(--pw-blue-deep); }

/* ── Active filter chips row ── */
.pw-plp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
}
.pw-plp-chips-label { font-size: 13px; color: var(--pw-ink-3); font-weight: 600; }
.pw-chip { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pw-chip:hover { filter: brightness(.97); }
.pw-chip-x { opacity: .7; }
.pw-plp-chips-clear {
  font-size: 13px;
  color: var(--pw-blue);
  text-decoration: underline;
  font-weight: 600;
}

/* ── Results grid / list ── */
.pw-plp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 20px;
}
.pw-plp-list { display: flex; flex-direction: column; gap: 12px; }

/* Skeleton state while an applied filter URL loads (drawer.js adds .is-loading) */
.pw-plp-grid.is-loading > *,
.pw-plp-list.is-loading > * {
  opacity: .45;
  pointer-events: none;
  animation: pw-plp-pulse 1.2s ease-in-out infinite;
}
.pw-plp-grid.is-loading .cover,
.pw-plp-list.is-loading .cover {
  position: relative;
  overflow: hidden;
}
.pw-plp-grid.is-loading .cover::after,
.pw-plp-list.is-loading .cover::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: pw-skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes pw-plp-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  .pw-plp-grid.is-loading > *,
  .pw-plp-list.is-loading > * { animation: none; }
  .pw-plp-grid.is-loading .cover::after,
  .pw-plp-list.is-loading .cover::after { animation: none; }
}

/* ── Grid card (BigBookCard port) ── */
.pw-prod {
  padding: 14px;
  border-radius: var(--pw-r-md);
  border: 1px solid var(--pw-line);
  display: flex;
  flex-direction: column;
  transition: box-shadow .32s cubic-bezier(.22, .61, .36, 1), transform .32s cubic-bezier(.22, .61, .36, 1);
}
.pw-prod:hover { box-shadow: var(--pw-shadow-lg); transform: translateY(-4px); }
@media (prefers-reduced-motion: reduce) {
  .pw-prod:hover { transform: none; }
}
.pw-prod-media { position: relative; }
.pw-cover { display: block; }
.pw-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pw-prod-body { margin-top: 14px; display: flex; flex-direction: column; flex: 1; }
.pw-prod-title {
  font-weight: 700;
  color: var(--pw-ink);
  font-size: 15px;
  line-height: 1.3;
  min-height: 38px;
  display: block;
}
.pw-prod-title:hover { color: var(--pw-blue); }
.pw-prod-sub {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--pw-ink-3);
  margin-top: 2px;
}
.pw-prod-grade { margin-left: auto; font-size: 12px; white-space: nowrap; }
.pw-prod-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  gap: 8px;
}
.pw-prod-price { font-size: 20px; font-weight: 700; color: var(--pw-ink); }
.pw-prod-price .amount { font-size: inherit; font-weight: inherit; color: inherit; }

/* Branded placeholder cover (BookCover fallback port) */
.pw-cover-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.pw-cover-ph-blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.pw-cover-ph-blob.is-tr { right: -22%; top: -14%; width: 70%; aspect-ratio: 1; background: rgba(255,255,255,.30); }
.pw-cover-ph-blob.is-bl { left: -18%; bottom: -16%; width: 55%; aspect-ratio: 1; background: rgba(255,255,255,.18); }
.pw-cover-ph-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  text-align: center;
  gap: 9px;
}
.pw-cover-ph-ic { opacity: .92; filter: drop-shadow(0 2px 6px rgba(0,0,0,.10)); }
.pw-cover-ph-title {
  font-family: var(--pw-display);
  font-weight: 700;
  line-height: 1.12;
  font-size: 14.5px;
  text-wrap: balance;
}
.pw-cover-ph-cat {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.pw-cover-ph-foot {
  position: relative;
  text-align: center;
  padding: 6px 0;
  font-family: var(--pw-script);
  opacity: .55;
  font-size: 13px;
}

/* Save heart — filled when saved (app.js only toggles .is-saved) */
.pw-save svg { fill: none; stroke-width: 2px; }
.pw-save.is-saved svg { fill: currentColor; stroke-width: 0; }

/* Highlight pills on list rows (ItemTags port) */
.pw-tag-new { background: var(--pw-coral-light); color: var(--pw-coral); font-size: 11px; font-weight: 700; padding: 2px 8px; }
.pw-tag-popular { background: var(--pw-yellow-light); color: #A07000; font-size: 11px; font-weight: 700; padding: 2px 8px; }

/* ── List row (ListRow port; ≤900px collapse lives above the marker) ── */
.shop-lr {
  display: grid;
  grid-template-columns: 80px 1fr 140px 120px 140px;
  gap: 20px;
  padding: 16px;
  align-items: center;
}
.shop-lr-media { width: 80px; position: relative; }
.shop-lr-main { min-width: 0; }
.shop-lr-main .tag-icons { margin-bottom: 6px; }
.shop-lr-title { font-weight: 700; color: var(--pw-ink); font-size: 16px; display: block; }
.shop-lr-title:hover { color: var(--pw-blue); }
.shop-lr-sub { font-size: 13px; color: var(--pw-ink-3); margin-top: 2px; }
.shop-lr-meta { font-size: 13px; color: var(--pw-ink-2); }
.shop-lr-mute { color: var(--pw-ink-3); }
.shop-lr-lang {
  font-size: 13px;
  color: var(--pw-ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.shop-lr-buy { text-align: right; }
.shop-lr-price { font-size: 22px; font-weight: 700; color: var(--pw-ink); }
.shop-lr-price .amount { font-size: inherit; font-weight: inherit; color: inherit; }
.shop-lr-add { margin-top: 8px; display: flex; justify-content: flex-end; }

/* ── Pagination — number buttons per the design ── */
.pw-plp-pages {
  margin-top: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.pw-plp-pages .page-numbers {
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: var(--pw-r);
  background: #fff;
  color: var(--pw-ink-2);
  border: 1px solid var(--pw-line);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pw-plp-pages a.page-numbers:hover { border-color: var(--pw-blue); color: var(--pw-blue); }
.pw-plp-pages .page-numbers.current {
  background: var(--pw-blue);
  color: #fff;
  border-color: var(--pw-blue);
}
.pw-plp-pages .page-numbers.prev,
.pw-plp-pages .page-numbers.next {
  padding: 0 16px;
  color: var(--pw-blue);
  white-space: nowrap;
}
.pw-plp-pages .page-numbers.dots { border: none; background: transparent; }

/* ── Zero-results state (BUILD-NOTES flow gap #1) ── */
.pw-plp-empty {
  padding: 56px 20px 72px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.pw-plp-empty-art { min-height: 0; margin-bottom: 18px; }
.pw-plp-empty-art:empty { display: none; }
.pw-plp-empty-title { font-size: clamp(24px, 3.4vw, 32px); color: var(--pw-blue); }
.pw-plp-empty-text {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--pw-ink-2);
  max-width: 460px;
  line-height: 1.55;
}
.pw-plp-empty-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  max-width: 560px;
}
.pw-plp-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
}

/* ── Refine drawer (FilterDrawer port) ──
   Default (no JS): an inline refine panel below the results, so the GET form
   stays usable. html.pw-js (set by drawer.php) switches it off-canvas. */
.pw-drawer-overlay {
  position: fixed;
  inset: var(--pw-drawer-top, 82px) 0 0 0; /* measured by drawer.js — tracks admin bar + announcement banner */
  background: rgba(0,0,0,.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s, visibility .25s;
  z-index: 80;
}
.pw-drawer-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

.pw-drawer {
  background: #fff;
  display: flex;
  flex-direction: column;
}
html:not(.pw-js) .pw-drawer {
  max-width: 720px;
  margin: 8px auto 64px;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-r-md);
}
html:not(.pw-js) .pw-drawer-close { display: none; }
html.pw-js .pw-drawer {
  position: fixed;
  top: var(--pw-drawer-top, 82px); /* measured by drawer.js */
  left: 0;
  bottom: 0;
  width: min(440px, 92vw);
  box-shadow: 4px 0 30px rgba(0,0,0,.18);
  z-index: 81;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
html.pw-js .pw-drawer.is-open { transform: translateX(0); }
/* Logged-in preview: track the header under the WP admin bar */
@media (min-width: 861px) {
  body.admin-bar .pw-drawer-overlay { top: var(--pw-drawer-top, 114px); }
  html.pw-js body.admin-bar .pw-drawer { top: var(--pw-drawer-top, 114px); }
}

/* ≤860px: the drawer presents as a bottom sheet (client request, 2026-07-11 —
   slides up from below like the reference site instead of from the side). */
@media (max-width: 860px) {
  .pw-drawer-overlay { inset: 0; }
  html.pw-js .pw-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 90vh;
    height: 90dvh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,.22);
    transform: translateY(103%);
  }
  html.pw-js .pw-drawer.is-open { transform: translateY(0); }
  /* Sheet grabber */
  html.pw-js .pw-drawer::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--pw-line);
  }
}
@media (prefers-reduced-motion: reduce) {
  html.pw-js .pw-drawer { transition: none; }
  .pw-drawer-overlay { transition: none; }
  .pw-viewtoggle-thumb { transition: none; }
}

.pw-drawer-head {
  padding: 24px 28px;
  border-bottom: 1px solid var(--pw-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}
.pw-drawer-head-left { display: flex; align-items: center; gap: 10px; }
.pw-drawer-head-ic { color: var(--pw-blue); display: inline-flex; }
.pw-drawer-title { font-size: 22px; }
.pw-drawer-active {
  background: var(--pw-yellow-light);
  color: var(--pw-blue);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pw-drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--pw-line-2);
  color: var(--pw-ink-2);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.pw-drawer-close:hover { background: var(--pw-line); color: var(--pw-ink); }

.pw-drawer-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* minHeight:0 lets the body shrink so it scrolls instead of pushing the footer off-screen */
.pw-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 28px 24px;
}
.pw-drawer-group {
  padding: 18px 0;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--pw-line);
}
.pw-drawer-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.pw-drawer-group-title { font-size: 15px; font-weight: 700; color: var(--pw-ink); }
.pw-drawer-pickone { font-size: 11px; font-weight: 600; color: var(--pw-ink-3); }
.pw-drawer-help {
  font-size: 12.5px;
  color: var(--pw-ink-3);
  margin: -8px 0 12px;
  line-height: 1.4;
}

/* Facet chips — label > hidden checkbox + pill body (:checked styles the pill) */
.pw-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pw-fchip { position: relative; display: inline-flex; }
.pw-fchip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
.pw-fchip-body {
  padding: 8px 14px;
  border-radius: var(--pw-pill);
  background: #fff;
  color: var(--pw-ink-2);
  border: 1.5px solid var(--pw-line);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.pw-fchip-body.has-media { padding: 6px 14px 6px 8px; }
.pw-fchip-kit { color: var(--pw-blue-deep); display: inline-flex; }
.pw-fchip-ic { color: var(--pw-blue); display: inline-flex; }
.pw-fchip:hover .pw-fchip-body { border-color: var(--pw-blue-deep); }
.pw-fchip input:checked + .pw-fchip-body {
  background: var(--pw-blue-tint-2);
  color: var(--pw-blue-deep);
  border-color: var(--pw-blue-deep);
}
.pw-fchip input:checked + .pw-fchip-body .pw-fchip-ic { color: var(--pw-blue-deep); }
.pw-fchip input:focus-visible + .pw-fchip-body {
  outline: 2px solid var(--pw-blue);
  outline-offset: 2px;
}

/* Price range (PriceRangeSlider port) */
.pw-price-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--pw-ink);
}
.pw-price-val {
  padding: 6px 14px;
  background: var(--pw-blue-tint);
  color: var(--pw-blue);
  font-weight: 700;
  border-radius: var(--pw-r-sm);
  font-variant-numeric: tabular-nums;
}
.pw-price-to { color: var(--pw-ink-3); align-self: center; }
.pw-slider-track {
  position: relative;
  height: 6px;
  margin: 12px 12px;
  background: var(--pw-line);
  border-radius: 3px;
}
.pw-slider-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--pw-blue);
  border-radius: 3px;
}
.pw-slider-handle {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  background: #fff;
  border: 2.5px solid var(--pw-blue);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  cursor: grab;
  touch-action: none;
}
.pw-slider-handle.is-dragging { cursor: grabbing; }
.pw-slider-handle:focus-visible { outline: 2px solid var(--pw-blue); outline-offset: 2px; }
.pw-slider-stops {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 11px;
  color: var(--pw-ink-3);
  padding: 0 4px;
}

.pw-drawer-foot {
  padding: 18px 28px;
  border-top: 1px solid var(--pw-line);
  display: flex;
  gap: 12px;
  background: #fff;
  flex: 0 0 auto;
}
.pw-drawer-reset { flex: 0 0 auto; }
.pw-drawer-apply { flex: 1; }
.pw-drawer-apply.is-counting { opacity: .75; }
.pw-drawer-apply.is-loading { opacity: .6; pointer-events: none; }

/* ── Small screens — toolbar wraps; search takes the full row ── */
@media (max-width: 640px) {
  .pw-plp-search { order: 5; flex-basis: 100%; }
  .pw-plp-toolbar { padding: 12px 14px; }
  .pw-plp-head { margin-bottom: 20px; }
}
