/* PleinScout shop (assets/js/shop.js). Builds on the .card / .product / .btn styles in site.css. */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout: filters down the left, products on the right. Phones get the filters as a sheet. */
.shop-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: clamp(24px, 3vw, 40px); align-items: start; }
.shop-side {
  position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow-y: auto; outline: none;
  overscroll-behavior: contain; scrollbar-width: thin; padding: 2px 6px 8px 2px;
}
.shop-side-head, .shop-side-foot, .shop-side-scrim, .shop-filter-btn { display: none; }
.shop-facet { border: 0; margin: 0 0 22px; padding: 0 0 20px; border-bottom: 1.5px solid var(--line); min-width: 0; }
.shop-facet:last-child { border-bottom: 0; }
.shop-facet legend { padding: 0; margin-bottom: 8px; font-size: 12.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--forest); }
.shop-opt-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px;
  font-size: 15px; line-height: 1.3; color: var(--ink); cursor: pointer;
}
.shop-opt-row:hover { background: var(--paper-2); }
.shop-opt-row input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--forest); }
.shop-opt-row input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.shop-opt-row:has(input[type="radio"]:focus-visible) { outline: 2.5px dashed var(--forest); outline-offset: 1px; }
.shop-opt-row.is-on:has(input[type="radio"]) { background: var(--gold); font-weight: 700; }
.shop-opt-name { flex: 1; min-width: 0; }
.shop-opt-n { font-size: 13px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.shop-opt-row.is-empty:not(.is-on) { opacity: .5; }
.shop-more-brands {
  margin-top: 6px; background: none; border: 0; padding: 4px 0; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 700; color: var(--forest); text-decoration: underline; text-underline-offset: 3px;
}

/* Search, count, sort and currency above the products */
.shop-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-bottom: 14px; }
.shop-search { flex: 1 1 100%; margin: 0; }
.shop-search input {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); padding: 12px 14px 12px 42px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--card) no-repeat 14px 50% / 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234D5F54' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
}
.shop-search input:focus { outline: 2.5px dashed var(--forest); outline-offset: 2px; }
.shop-count-line { flex: 1; margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.shop-select { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.shop-select select {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer;
  padding: 8px 32px 8px 12px; border: 2px solid var(--ink); border-radius: 10px; appearance: none;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23213329' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 11px center / 11px;
}
.shop-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.shop-active[hidden] { display: none; }
.shop-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 12px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--ink);
  background: var(--cream); border: 1.5px solid var(--ink); border-radius: 999px;
}
.shop-chip span { font-size: 17px; line-height: 1; color: var(--ink-soft); }
.shop-chip:hover { background: var(--gold); }
.shop-clear { background: none; border: 0; padding: 0 4px; font: inherit; font-size: 14px; font-weight: 700; color: var(--forest); text-decoration: underline; cursor: pointer; }
.shop-none { padding: 24px 0; display: grid; justify-items: start; gap: 8px; }
.shop-none p { margin: 0; color: var(--ink-soft); }
.shop-share {
  margin-top: 12px; background: none; border: 0; padding: 4px 0; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 700; color: var(--forest); text-decoration: underline; text-underline-offset: 3px;
}

/* Product grid: flat, even cards (no taped-in tilt here) */
.shop-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.shop-grid > .card { rotate: 0deg; box-shadow: var(--hard-sm); }
.shop-grid > .card:hover { translate: 0 -3px; box-shadow: 5px 6px 0 var(--ink); }
@media (max-width: 1100px) { .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.shop-card { display: flex; flex-direction: column; }
.shop-card .product-body { display: flex; flex-direction: column; flex: 1; padding: 14px 16px 16px; }
.shop-art { background: #fff; }
.shop-art img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.shop-art-btn { position: relative; }
.shop-art-alt { position: absolute; inset: 0; opacity: 0; transition: opacity .3s var(--ease); background: #fff; }
@media (hover: hover) { .shop-card:hover .shop-art-alt { opacity: 1; } }
.shop-card .product-art .tag { font-size: 11px; padding: 4px 8px; }
.shop-brand { margin: 0 0 2px; font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--moss); }
.shop-card .product-body h3 { font-size: 16.5px; line-height: 1.3; margin: 0; }
.shop-title { all: unset; cursor: pointer; }
a.shop-title { color: inherit; }
.shop-title:hover { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.shop-title:focus-visible { outline: 2.5px dashed var(--forest); outline-offset: 2px; }
.shop-blurb { margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; }
.shop-from { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

/* Phones and small tablets: one column, filters in a sheet from the left */
@media (max-width: 900px) {
  .shop-layout { grid-template-columns: 1fr; }
  .shop-filter-btn { display: inline-flex; min-height: 42px; padding: 0 16px; font-size: 15px; }
  .shop-fcount:empty { display: none; }
  .shop-count-line { flex: 1 1 auto; order: 5; flex-basis: 100%; font-size: 14px; }
  .shop-side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 95; width: min(360px, 88vw); max-height: none;
    background: var(--paper); border-right: 2px solid var(--ink); padding: 0;
    display: flex; flex-direction: column; overflow: hidden;
    transform: translateX(-102%); visibility: hidden; transition: transform .28s var(--ease), visibility 0s .28s;
  }
  .side-open .shop-side { transform: none; visibility: visible; transition: transform .28s var(--ease); }
  .side-open .shop-side-scrim { display: block; position: fixed; inset: 0; z-index: 94; }
  .shop-side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 2px solid var(--line); }
  .shop-side-head h2 { font-size: 22px; margin: 0; }
  .shop-side-body { flex: 1; overflow-y: auto; padding: 18px 20px 4px; overscroll-behavior: contain; }
  .shop-side-foot { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 2px solid var(--line); }
  .shop-side-foot .btn { min-height: 46px; padding: 0 16px; }
  .shop-opt-row { padding: 9px 8px; font-size: 16px; }
}
@media (max-width: 560px) {
  .shop-grid { gap: 14px; }
  .shop-card .product-body { padding: 10px 11px 12px; }
  .shop-card .product-body h3 { font-size: 14.5px; }
  .shop-brand { font-size: 10.5px; }
  .shop-card .shop-price { font-size: 16.5px; margin-top: 8px; }
  .shop-card .shop-stock { font-size: 12.5px; }
  .shop-card .shop-add { min-height: 42px; padding: 0 8px; font-size: 14px; margin-top: 10px; white-space: normal; text-align: center; line-height: 1.15; }
  .shop-blurb { display: none; }
  .shop-select span { display: none; }
  .shop-select select { font-size: 14px; padding: 7px 28px 7px 10px; }
}
@media (prefers-reduced-motion: reduce) { .shop-side, .side-open .shop-side { transition: none; } }

.shop-opt { display: grid; gap: 4px; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.shop-opt select {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
  padding: 9px 10px; border: 2px solid var(--ink); border-radius: 8px; background: var(--card); width: 100%;
}
.shop-price { margin-top: 12px; font-size: 19px; color: var(--ink); }
.shop-price s { font-size: 15px; margin-left: 6px; }
.shop-stock { margin: 4px 0 0; font-size: 13.5px; font-weight: 700; }
.shop-stock-in { color: var(--moss); }
.shop-stock-low { color: #9A5B12; }
.shop-stock-out { color: var(--ink-soft); }
.shop-add { margin-top: auto; width: 100%; justify-content: center; }
.product-body .shop-add { margin-top: 14px; }
.shop-add[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--hard-sm); }
.shop-details { margin-top: 12px; font-size: 14px; }
.shop-details summary { cursor: pointer; font-weight: 700; color: var(--forest); }
.shop-desc { margin-top: 8px; color: var(--ink-soft); }
.shop-desc p { margin: 0 0 8px; }

/* Floating cart + account bar */
.shop-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; align-items: center; gap: 12px;
}
.shop-account {
  font-size: 14px; font-weight: 700; color: var(--forest); text-decoration: none;
  background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 8px 14px; box-shadow: var(--hard-sm);
}
.shop-count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--cream); color: var(--forest); font-size: 13px;
}
.shop-bar.has-items .shop-count { background: var(--gold); color: var(--ink); }

/* Drawer */
html.shop-locked { overflow: hidden; }
.shop-drawer { position: fixed; inset: 0; z-index: 100; }
.shop-drawer[hidden] { display: none; }
.shop-scrim { position: absolute; inset: 0; background: rgba(29, 44, 36, .45); }
.shop-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--paper); border-left: 2px solid var(--ink);
  display: flex; flex-direction: column; outline: none;
  animation: shop-in .28s var(--ease);
}
@keyframes shop-in { from { transform: translateX(40px); opacity: 0; } }
.shop-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 2px solid var(--line); }
.shop-panel-head h2 { font-size: 24px; }
.shop-x { font-size: 30px; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 4px 8px; }
.shop-lines { flex: 1; overflow-y: auto; padding: 8px 22px; }
.shop-lines ul { list-style: none; margin: 0; padding: 0; }
.shop-lines li { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.shop-lines img, .shop-noimg { width: 64px; height: 64px; object-fit: contain; background: #fff; border: 1.5px solid var(--line-strong); border-radius: 8px; }
.shop-line-info { display: grid; gap: 2px; font-size: 15px; }
.shop-line-total { font-weight: 700; font-size: 15px; }
.shop-qty { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; }
.shop-qty button {
  width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 8px; background: var(--card);
  font-size: 17px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.shop-empty { padding: 24px 0; }
.shop-panel-foot { padding: 18px 22px 24px; border-top: 2px solid var(--line); display: grid; gap: 10px; }
.shop-subtotal { display: flex; justify-content: space-between; font-size: 18px; }
.shop-checkout { justify-content: center; }
.shop-account-link { justify-self: center; }

.shop-toast {
  position: fixed; left: 50%; bottom: 84px; translate: -50% 0; z-index: 120;
  background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 10px; font-size: 14.5px;
  max-width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .shop-bar { left: 16px; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  .shop-panel { animation: none; }
}

/* Card photos: tap the photo or "See details" for the full gallery */
.shop-art-btn { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.shop-link-card .shop-art-btn { cursor: pointer; }
.shop-art-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.shop-thumbs { display: flex; gap: 6px; margin-bottom: 12px; }
.shop-thumbs button, .shop-m-thumbs button {
  padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden;
}
.shop-thumbs button { width: 48px; height: 48px; }
.shop-thumbs img, .shop-m-thumbs img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shop-thumbs button[aria-pressed="true"], .shop-m-thumbs button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 2px 2px 0 var(--gold); }
.shop-tubes { margin: 2px 0 0; }
.shop-more {
  margin-top: 10px; align-self: center; background: none; border: 0; cursor: pointer; padding: 4px 2px 6px;
  font: inherit; font-size: 14.5px; font-weight: 700; color: var(--forest);
  background: var(--squiggle) repeat-x 0 100% / 30px 6px;
}

/* Details view */
.shop-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
.shop-modal[hidden] { display: none; }
.shop-sheet {
  position: relative; width: min(1040px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; outline: none;
  background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-lg); box-shadow: var(--hard);
  display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(20px, 3vw, 36px); padding: clamp(18px, 3vw, 32px);
  animation: shop-pop .25s var(--ease);
}
@keyframes shop-pop { from { transform: translateY(14px); opacity: 0; } }
.shop-m-x { position: absolute; top: 8px; right: 10px; z-index: 2; }
.shop-m-main { position: relative; aspect-ratio: 1; background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; }
.shop-m-main img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.shop-m-main .tag { position: absolute; top: 12px; left: 12px; rotate: -4deg; }
.shop-m-count { margin: 10px 0 6px; }
.shop-m-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.shop-m-thumbs button { aspect-ratio: 1; }
.shop-m-info h2 { font-size: clamp(24px, 3vw, 32px); padding-right: 36px; }
.shop-m-info .shop-add { width: 100%; justify-content: center; margin-top: 14px; }
.shop-contents { margin-top: 22px; padding-top: 18px; border-top: 2px solid var(--line); }
.shop-contents h3 { font-size: 18px; margin-bottom: 6px; }
.shop-contents p { margin: 0 0 8px; color: var(--ink-soft); }
.shop-colors { list-style: none; margin: 10px 0 12px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.shop-colors li { position: relative; padding-left: 20px; font-size: 15px; font-weight: 600; color: var(--ink); }
.shop-colors li::before { content: ""; position: absolute; left: 0; top: .42em; width: 11px; height: 11px; border-radius: 50%; background: var(--sage); border: 1.5px solid var(--ink); }
.shop-m-info .shop-desc { margin-top: 18px; padding-top: 16px; border-top: 2px solid var(--line); font-size: 15px; }

@media (max-width: 760px) {
  .shop-modal { padding: 0; place-items: end stretch; }
  .shop-sheet { grid-template-columns: 1fr; max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  /* Keep the × on screen while the sheet scrolls (browser bars can cover the top on phones) */
  .shop-m-x { position: sticky; top: 0; justify-self: end; margin: -6px -8px -48px 0; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
}
@media (prefers-reduced-motion: reduce) { .shop-sheet { animation: none; } }
html.shop-locked .shop-bar { visibility: hidden; }

/* Line up prices and buttons along the bottom of each row of cards */
.shop-card .shop-price { margin-top: auto; padding-top: 10px; }
.shop-art .tag { z-index: 1; }

/* Shorter page header on the shop, so products show sooner */
.shop-hero { padding: clamp(40px, 6vw, 72px) 0 clamp(24px, 3vw, 36px); }
.shop-hero h1 { font-size: clamp(38px, 5vw, 64px); max-width: 18ch; }
.shop-hero .lede { margin-top: 16px; }
.shop-hero .hero-note { margin-top: 16px; }
.shop-hero .hero-note { align-items: flex-start; }
.shop-hero .hero-note .dot { margin-top: 6px; }
@media (max-width: 900px) {
  .shop-select:has(#shop-sort) { flex: 1 1 0; min-width: 0; }
  .shop-select select { width: 100%; }
}

/* Every photo sits in the same square, however tall or wide the original is */
.shop-grid > .card.product { padding: 0; }
.shop-card .product-art { aspect-ratio: 1; overflow: hidden; background: #fff; }
.shop-card .shop-art-btn { position: absolute; inset: 0; }
.shop-card .shop-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.shop-m-main img { position: absolute; inset: 0; }

/* Free-shipping nudge in the cart (shop.js freeShipNote) */
.shop-freeship { margin: 10px 0 4px; font-size: 14.5px; }
.shop-freeship.done { color: var(--forest); }
.shop-freeship-bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-bottom: 8px; }
.shop-freeship-bar span { display: block; height: 100%; background: var(--gold); border-radius: 99px; }

/* "Lowest price" badge (products tagged lowest-price, e.g. M. Graham at MAP) */
.shop-lowest { margin: 6px 0 0; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }
.shop-lowest-badge { display: inline-block; padding: 2px 8px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--gold); color: var(--ink); font-weight: 700; font-size: 12px; letter-spacing: .02em; white-space: nowrap; }
.shop-m-info .shop-lowest { font-size: 14px; margin-top: 8px; }
