/* =========================================================================
   GulfRabit · Catalog module (PLP, PDP, Search)
   Load after shared/css/style.css.
   ========================================================================= */

/* ---- Listing layout (sidebar + grid) --------------------------------- */
.plp { display: grid; gap: var(--space-6); grid-template-columns: 1fr; }
@media (min-width: 1024px) { .plp { grid-template-columns: 260px 1fr; } }

.plp-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.plp-count { color: var(--text-muted); font-size: var(--fs-14); }

/* ---- The toolbar on a phone -------------------------------------------
   Sort used to wrap onto its own line, so a 390px screen spent two rows and
   ~90px on two controls — above a grid the row exists to serve. Both sit on
   one row now, Sort pushed right (see .sort-field in _forms.css, which three
   modules share), matched to the Filters button's height so they read as a
   pair rather than a button and a form field. */
@media (max-width: 767px) {
  /* The category name at 2.25rem was the biggest thing on the page and pushed
     the first row of products most of a screen down. 35% off it — 1.4625rem —
     still reads as the page's title against the 0.875rem blurb under it. */
  .plp-head h1 { font-size: 1.4625rem; line-height: 1.15; letter-spacing: -0.018em; }

  .plp-toolbar { flex-wrap: nowrap; gap: var(--space-2); }
  /* The count is the one thing here that can afford to give up room. */
  .plp-count { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- Filters sidebar -------------------------------------------------- */
/* On mobile the filter controls live in a bottom-sheet (opened via the Filters
   button); the inline sidebar only shows from desktop up. */
.filters { align-self: start; display: none; }
@media (min-width: 1024px) { .filters { display: block; position: sticky; top: calc(var(--header-h) + var(--space-4)); } }
.filter-group { padding: var(--space-4) 0; border-bottom: 1px solid var(--border-hairline); }
.filter-group__title { width: 100%; font-size: var(--fs-14); font-weight: var(--fw-semibold); margin-bottom: var(--space-3); display: flex; justify-content: space-between; align-items: center; background: none; border: 0; color: var(--text-primary); cursor: pointer; text-align: left; padding: 0; }
.filter-group__title:hover { color: var(--link); }
.filter-chevron { transition: transform var(--dur-base) var(--ease-out); flex-shrink: 0; }
.filter-group__title[aria-expanded="false"] { margin-bottom: 0; }
.filter-group__title[aria-expanded="false"] .filter-chevron { transform: rotate(-90deg); }
.filter-count { color: var(--text-muted); font-weight: var(--fw-regular); font-size: var(--fs-12); }
.filter-option { display: flex; align-items: center; gap: var(--space-2); padding: 4px 0; font-size: var(--fs-14); color: var(--text-secondary); cursor: pointer; }
.filter-option input { accent-color: var(--gr-cyan); width: 18px; height: 18px; }
.price-range { display: flex; align-items: center; gap: var(--space-2); }
.price-range input[type="number"] { width: 100%; }

/* Mobile filters bottom-sheet */
.filters-sheet-backdrop { position: fixed; inset: 0; background: var(--scrim); z-index: 1050; opacity: 0; transition: opacity .3s var(--ease-out); }
.filters-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1051;
  max-height: 85vh; overflow-y: auto;
  background: var(--surface-raised); border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
  border-top: 1px solid var(--border-hairline);
  transform: translateY(100%); transition: transform .3s var(--ease-out);
  padding: var(--space-5);
}
.filters-sheet.is-open { transform: translateY(0); }

/* ---- Product Detail (PDP) --------------------------------------------- */
.pdp { display: grid; gap: var(--space-7); grid-template-columns: 1fr; }
@media (min-width: 1024px) { .pdp { grid-template-columns: 1.1fr 1fr; align-items: start; } }

.gallery { display: grid; gap: var(--space-3); }
/* <picture> carries the WebP source only. Both the main image and the thumbs
   are sized width/height 100% against their frame, so an inline picture box
   between them would make each image size to its own ratio instead — the
   third time this exact trap has appeared, after the hero and the cards. */
.gallery__main picture, .gallery__thumb picture { display: contents; }

.gallery__main { position: relative; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border-hairline); background: var(--surface-sunken); aspect-ratio: 1; }
.gallery__main img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease-out); }
/* Zoom only where a pointer exists. On a phone :hover latches on tap, so
   touching the photo left it stuck at 1.6× with no way back — and pinch-zoom
   is the gesture people actually use there. */
@media (hover: hover) {
  .gallery__main.zoomable:hover img { transform: scale(1.6); cursor: zoom-in; }
}

/* A scrolling strip, not a wrapping grid.
   Twelve photos at 72px wrapped to three rows on a 360px screen — 216px of
   thumbnails between the product image and its price, which is the one thing
   the page exists to show. */
.gallery__thumbs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: var(--space-1);
  /* No visible scrollbar on desktop; the row is obviously scrollable from the
     part-visible thumb at the edge. */
  scrollbar-width: thin;
}
.gallery__thumb {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 64px; height: 64px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border-hairline);
  cursor: pointer; padding: 0; background: var(--surface-sunken);
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.gallery__thumb:active { transform: scale(.94); }

@media (min-width: 768px) {
  .gallery__thumbs { flex-wrap: wrap; overflow-x: visible; }
  .gallery__thumb { width: 72px; height: 72px; }
}
.gallery__thumb.is-active { border-color: var(--gr-cyan-dark); box-shadow: 0 0 0 2px rgba(27,180,212,.3); }
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }

.pdp-info { align-self: start; }
@media (min-width: 1024px) { .pdp-info { position: sticky; top: calc(var(--header-h) + var(--space-4)); } }
.pdp-price { display: flex; align-items: baseline; gap: var(--space-3); margin: var(--space-4) 0; }
.pdp-price__now { font-family: var(--font-display); font-size: var(--fs-31); }
.pdp-actions { display: flex; gap: var(--space-3); margin: var(--space-5) 0; }

/* ---- "Only 3 left" -----------------------------------------------------
   Amber, not red. Red on a product page means something is wrong — sold out,
   a failed action — and this is the opposite: the thing is available, just
   not for long. Small, weighted, and set close under the stock line so the
   two read as one statement about availability rather than as a warning
   stacked on top of good news.

   No pulse, no countdown, no animation. The urgency has to come from the
   fact being true; a blinking one only tells people it was manufactured. */
.pdp-scarcity {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .35rem;
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: #9A6B08;
}
.pdp-scarcity::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
[data-theme="noor"] .pdp-scarcity,
[data-theme="luxe"] .pdp-scarcity { color: #E8B84B; }

/* ---- Size ladder -------------------------------------------------------
   Sits between the stock line and Add to Cart, which is the order the decision
   is made in: is it here, which size, buy. Each option carries its own price,
   so choosing does not mean clicking to find out what it costs. */
.variant-picker { margin-top: var(--space-5); }
.variant-picker__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.variant-picker__label {
  font-size: var(--fs-12); font-weight: var(--fw-semibold);
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
/* The unit rate. It is the only honest way to compare rungs — 500 g at ৳1,380
   against 1 kg at ৳2,650 is not arithmetic anyone should do in a shop. */
.variant-picker__unit { font-size: var(--fs-12); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.variant-picker__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.variant-opt {
  flex: 1 1 92px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 60px; padding: var(--space-2) var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.variant-opt__label { font-size: var(--fs-14); font-weight: var(--fw-semibold); white-space: nowrap; }
.variant-opt__price { font-size: var(--fs-12); color: var(--text-muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) {
  .variant-opt:hover:not(:disabled) { border-color: var(--gr-cyan-dark); }
}
.variant-opt.is-selected {
  border-color: var(--gr-cyan-dark);
  box-shadow: inset 0 0 0 1px var(--gr-cyan-dark);
  background: rgba(27,180,212,.06);
}
.variant-opt.is-selected .variant-opt__price { color: var(--link-hover); }
.variant-opt:disabled { opacity: .45; cursor: not-allowed; text-decoration: line-through; }

/* ---- Sticky buy bar (phones and small tablets) -------------------------
 *
 * A product page is long: gallery, price, description, specs, FAQ, reviews,
 * related. By the time somebody has read enough to decide, the Add to Cart
 * button is several screens above them, and the decision costs a scroll back.
 * This puts it back within thumb reach the moment the real button leaves the
 * viewport.
 *
 * NOT shown on desktop: the buy column there is already `position: sticky`, so
 * the button never leaves. A second copy would be clutter.
 *
 * It is a DUPLICATE of the real control, not a replacement — pdp-buybar.js
 * forwards its click to the button in the page, so there is one add-to-cart
 * path and one place for its logic to live.
 */
.buybar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  /* Clears the iOS home indicator. Without it the button's lower third is
     under the system gesture area and taps there do nothing. */
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-hairline);
  box-shadow: 0 -2px 16px rgba(16, 19, 20, .07);
  transform: translateY(110%);
  transition: transform 260ms var(--ease-out);
}

.buybar.is-visible { transform: translateY(0); }

.buybar__price { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.buybar__now { font-family: var(--font-display); font-size: var(--fs-20); }
.buybar__was { font-size: var(--fs-12); color: var(--text-muted); text-decoration: line-through; }
.buybar__btn { flex: 1 1 auto; }

@media (min-width: 1024px) { .buybar { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .buybar { transition: none; }
}

/* ---- Tabs ------------------------------------------------------------- */
.tabs { border-bottom: 1px solid var(--border-hairline); display: flex; gap: var(--space-4); overflow-x: auto; }
.tab-btn { padding: var(--space-3) 0; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap; }
.tab-btn.is-active { color: var(--text-primary); border-bottom-color: var(--gr-cyan); }
.tab-panel { padding-top: var(--space-5); }
.tab-panel[hidden] { display: none; }

/* ---- Spec table (industrial/B2B treatment) ---------------------------- */
.spec-table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.spec-table th, .spec-table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-hairline); }
.spec-table th { color: var(--text-muted); font-weight: var(--fw-medium); width: 40%; }
.spec-table td { font-variant-numeric: tabular-nums; }

/* ---- Reviews --------------------------------------------------------- */
.review-card { padding: var(--space-4); border: 1px solid var(--border-hairline); border-radius: var(--radius-lg); background: var(--surface-raised); }
.review-card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); }
.review-card__stars { color: var(--lime-ink); letter-spacing: 2px; }
.review-form { padding: var(--space-5); border: 1px solid var(--border-hairline); border-radius: var(--radius-lg); background: var(--surface-sunken); }
/* Interactive star input */
.star-input { display: inline-flex; gap: 2px; }
.star-input button { background: none; border: 0; cursor: pointer; padding: 2px; line-height: 0; color: var(--border-hairline); transition: color var(--dur-fast) var(--ease-out); }
.star-input button.is-on, .star-input button.is-hover { color: var(--lime-ink); }
.star-input svg { width: 26px; height: 26px; display: block; }
.review-summary { display: flex; align-items: baseline; gap: var(--space-3); }
.review-summary__avg { font-family: var(--font-display); font-size: var(--fs-39); line-height: 1; }

/* ---- Compare table --------------------------------------------------- */
.compare-scroll { overflow-x: auto; }
.compare-table { border-collapse: collapse; width: 100%; min-width: 640px; }
.compare-table th, .compare-table td { padding: var(--space-4); border-bottom: 1px solid var(--border-hairline); text-align: left; vertical-align: top; }
.compare-table thead th { border-bottom: 1px solid var(--border-hairline); }
.compare-table__row-label { color: var(--text-muted); font-weight: var(--fw-medium); font-size: var(--fs-14); white-space: nowrap; width: 160px; position: sticky; left: 0; background: var(--surface-page); }
.compare-col { min-width: 200px; }
.compare-col__media { aspect-ratio: 4/5; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border-hairline); background: var(--surface-sunken); margin-bottom: var(--space-3); position: relative; }
.compare-col__media img { width: 100%; height: 100%; object-fit: cover; }
.compare-col__remove { position: absolute; top: 8px; right: 8px; }
.compare-table .tabular { font-variant-numeric: tabular-nums; }
.compare-best { color: var(--lime-ink); font-weight: var(--fw-semibold); }

/* ---- Chips (active filters) ------------------------------------------ */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--border-hairline); font-size: var(--fs-12); }
.chip button { background: none; border: 0; color: var(--text-muted); cursor: pointer; }

/* ---- Order channels (WhatsApp / Messenger) ---------------------------
   Sit under the wishlist button. flex-basis is set so the pair wraps to a
   stacked full-width layout once the buy column drops under ~400px. */
.order-channels { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
.order-channel { flex: 1 1 190px; }
.order-channel__icon { flex-shrink: 0; }

/* ---- Spec tab section headings + barcode ------------------------------ */
.spec-heading { margin: var(--space-6) 0 var(--space-3); font-family: var(--font-body); font-size: var(--fs-12); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.spec-heading:first-child { margin-top: 0; }
/* Loosened tracking so a 13-digit code can be read off the screen and checked
   against the physical pack — the whole point of publishing it. */
.barcode-value { font-variant-numeric: tabular-nums; letter-spacing: .1em; }

/* ---- Product FAQ ------------------------------------------------------
   Native <details> rather than a JS accordion: it is keyboard-accessible for
   free and the browser's find-in-page can reach closed answers. */
.faq-list { max-width: 70ch; }
.faq-item { border-bottom: 1px solid var(--border-hairline); }
.faq-item__q {
  padding: var(--space-4) 0;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.faq-item__q::-webkit-details-marker { display: none; }
/* Own marker so the affordance survives the list-style reset above. */
.faq-item__q::after {
  content: "";
  width: 9px; height: 9px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--dur-base) var(--ease-out);
  flex-shrink: 0;
}
.faq-item[open] .faq-item__q::after { transform: rotate(-135deg); }
.faq-item__q:hover { color: var(--link); }
.faq-item__a {
  padding-bottom: var(--space-4);
  color: var(--text-secondary);
  line-height: var(--lh-normal);
}


/* ---- The phone buy bar (see the fragment for why) --------------------- */
.pdp-buybar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 990;                             /* same layer as the tab bar it replaces */
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4) calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-top: 1px solid var(--border-hairline);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pdp-buybar { background: rgba(255, 255, 255, .99); }
}
.pdp-buybar__price { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pdp-buybar__price .price { font-size: var(--fs-20); }
.pdp-buybar__price .caption { color: var(--text-muted); }
.pdp-buybar .btn-gr { flex: 1 1 auto; min-width: 0; justify-content: center; }
@media (max-width: 991.98px) {
  .pdp-buybar:not([hidden]) { display: flex; }
  body.has-pdp-buybar { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
