/* ═══════════════════════════════════════════════════════════════
   HiBargh — product detail (product.php)
   "برگه‌ی مشخصات" spec-sheet: two-column document, ruled title block,
   size ledger for pillars, .spec-table datasheet, related grid.
   Loads AFTER spec.css — tokens from spec.css :root only, no new fonts,
   radius ≤ 2px, no shadow/blur/gradient decor. Neutralizes legacy
   style.css bleed on .pdp / .prose / .sticky-cta.
   ═══════════════════════════════════════════════════════════════ */

/* page rhythm — neutralize legacy .pdp padding */
.pdp {
  padding-block: 0;
  margin-block: clamp(1.25rem, 3vw, 2rem) clamp(3rem, 7vw, 5rem);
}

/* ════════════ two-column document ════════════ */
.pdp-doc {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

/* ————— photo column ————— */
.pdp-figure {
  display: grid;
  gap: 0.7rem;
  position: sticky;
  top: calc(var(--header-h) + 1.25rem);
  margin: 0;
}
.pdp-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pdp-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 7%;
}
.pdp-frameEmpty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--jacket);
}
.pdp-frameEmpty svg { inline-size: 40px; block-size: 40px; }

.pdp-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 0.55rem;
}
.pdp-thumb {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 7%;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: border-color 150ms ease-out;
}
.pdp-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pdp-thumb:hover { border-color: var(--muted); }
.pdp-thumb[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 0.5px var(--ink); }

/* ————— info column ————— */
.pdp-buy { min-width: 0; }

.pdp-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin: 0 0 0.95rem;
}
/* brand as a spec-sheet chip — cobalt hairline pill, no full-width rule needed */
.pdp-brand {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0;
  color: var(--cobalt-text);
  text-decoration: none;
  padding: 0.22rem 0.66rem;
  border: var(--hair) solid var(--cobalt);
  border-radius: var(--radius-sm);
  line-height: 1.35;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.pdp-brand:hover { background: var(--cobalt); color: var(--on-dark); text-decoration: none; }
.pdp-sku { color: var(--muted); }
.pdp-kicker .ltr { color: var(--ink); }

.pdp-titleBlock {
  padding-top: 0;
}
.pdp-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  line-height: 1.3;
  margin: 0;
}
.pdp-lede {
  max-width: 46rem;
  color: var(--muted);
  margin: 0.7rem 0 0;
  font-size: 0.98rem;
}

/* stock mark line */
.pdp-stock {
  margin: 1.15rem 0 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
}
.pdp-stock .st { inline-size: 9px; block-size: 9px; }

/* pillar note (size page → parent pillar) as a ruled notice */
.pdp-pillarNote {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.5rem;
  padding: 0.8rem 1rem;
  border: var(--hair) solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--chalk);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.6;
}
.pdp-pillarNote svg { inline-size: 17px; block-size: 17px; flex: none; color: var(--muted); }
.pdp-pillarNote .pdp-noteArrow {
  margin-inline-start: auto;
  transition: transform 150ms ease-out;
}
.pdp-pillarNote:hover .pdp-noteArrow { transform: translateX(-4px); color: var(--cobalt-text); }

/* ————— price block ————— */
.pdp-priceBlock {
  margin-top: 1.5rem;
  padding-top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
}
.pdp-price {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.55rem, 3.2vw, 2.05rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pdp-priceLead { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.pdp-priceWas {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 1rem;
  font-weight: 400;
}
.pdp-priceTo { color: var(--muted); font-size: 1.05rem; font-weight: 500; }
.pdp-discount {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--copper-deep);
  border: 1px solid var(--copper);
  border-radius: var(--radius-sm);
  padding: 0.08rem 0.45rem;
}

/* ————— buy form (simple product) ————— */
.pdp-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1.4rem;
}
.pdp-form .btn-primary { flex: 1; min-width: 12rem; }
.pdp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.9rem;
}
.pdp-actions .btn { flex: 1; min-width: 10rem; }
.pdp-actions .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ════════════ size ledger (pillar) ════════════ */
.pdp-sizes {
  border-top: var(--rule) solid var(--ink);
  margin-top: 1.6rem;
  padding-top: 1rem;
}
.pdp-sizesHead {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.pdp-sizesTitle { font-weight: 700; font-size: 1rem; }
.pdp-sizesCount {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
.pdp-sizeScroll {
  max-height: 21rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--jacket) transparent;
  border-top: 1px solid var(--line);
}
.pdp-sizeScroll::-webkit-scrollbar { width: 6px; }
.pdp-sizeScroll::-webkit-scrollbar-track { background: transparent; }
.pdp-sizeScroll::-webkit-scrollbar-thumb { background: var(--jacket); border-radius: var(--radius-sm); }

.pdp-sizeList { list-style: none; margin: 0; padding: 0; }
.pdp-size {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--line);
  transition: background-color 150ms ease-out;
}
.pdp-size:hover { background: var(--surface); }
.pdp-sizeMain {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.7rem 0.55rem 0.7rem 0.25rem;
  text-decoration: none;
  color: var(--ink);
}
.pdp-sizeLabel {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  direction: ltr;
  text-align: left;
}
.pdp-sizePrice {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  white-space: nowrap;
}
.pdp-sizeWas {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 0.78rem;
  margin-inline-start: 0.4rem;
}
.pdp-sizeBuy { margin: 0; padding-inline-end: 0.4rem; }
.pdp-sizeAdd {
  padding: 0.38rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.pdp-size--oos { opacity: 0.6; }
.pdp-sizeOosTag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding-inline: 0.7rem;
  white-space: nowrap;
}

/* ————— counter facts dl ————— */
.pdp-facts {
  margin: 1.9rem 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.pdp-facts > div {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 0.1rem;
  border-bottom: 1px solid var(--line);
}
.pdp-facts dt {
  flex: none;
  width: 5.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
}
.pdp-facts dd { margin: 0; color: var(--ink); }
.pdp-facts dd .sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ════════════ ruled sections ════════════ */
.pdp-sec { margin-top: clamp(2.5rem, 6vw, 4rem); }

/* datasheet — .spec-table styled in spec.css */
.pdp-specWrap { overflow-x: auto; }

/* spec.css styles .spec-table for column headers; this one is row-headed, so the
   value would be flung to the far edge with a page-wide void between it and its
   label. Keep the pair together in a ledger of its own measure. */
.pdp-specWrap .spec-table { max-width: 52rem; }
.pdp-specWrap .spec-table th[scope="row"] {
  width: 12rem;
  padding: 0.55rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-align: right;
  direction: rtl;
  vertical-align: baseline;
}
.pdp-specWrap .spec-table td {
  text-align: right;
  direction: rtl;
  color: var(--ink);
}

/* ————— description: prose at reading measure, marginalia in the rail ————— */
.pdp-descDoc {
  /* rail fixed, prose flexes — a squeezed rail wraps the note one word per line */
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(1.75rem, 3.5vw, 3.5rem);
  align-items: start;
}

/* description prose — override legacy .prose glass colors */
.pdp-prose { max-width: 46rem; }
.pdp-prose.prose { color: var(--ink); font-family: var(--font-body); line-height: 1.8; }
.pdp-prose.prose > :first-child { margin-top: 0; }
.pdp-prose.prose p { margin-top: 1.1rem; }
.pdp-prose.prose h2, .pdp-prose.prose h3, .pdp-prose.prose h4 {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.4;
  margin-top: 2.2rem;
  padding-top: 1rem;
  border-top: var(--hair) solid var(--line);
}
.pdp-prose.prose h2 { font-size: clamp(1.25rem, 2.2vw, 1.45rem); }
.pdp-prose.prose h3 { font-size: 1.15rem; }
.pdp-prose.prose h4 { font-size: 1.03rem; }
.pdp-prose.prose a { color: var(--cobalt-text); }
.pdp-prose.prose strong { color: var(--ink); }

/* stored lists lose their markers under legacy .prose — give them the
   spec-sheet cobalt tick */
.pdp-prose.prose ul,
.pdp-prose.prose ol { margin-top: 1.05rem; padding-inline-start: 1.4rem; }
.pdp-prose.prose li { margin-top: 0.4rem; }
.pdp-prose.prose ul { list-style: none; padding-inline-start: 0; }
.pdp-prose.prose ul > li { position: relative; padding-inline-start: 1.3rem; }
.pdp-prose.prose ul > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.72em;
  inline-size: 7px; block-size: 7px;
  border-radius: var(--radius-xs);
  background: var(--cobalt);
}
.pdp-prose.prose ol { list-style: decimal; }
.pdp-prose.prose ol li::marker { font-family: var(--font-mono); color: var(--muted); }
.pdp-prose.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.6rem 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  background: var(--bg);
}
.pdp-prose.prose table {
  width: 100%;
  margin-top: 1.4rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.pdp-prose.prose th,
.pdp-prose.prose td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
}
.pdp-prose.prose th { font-weight: 700; color: var(--copper-deep); }

/* the margin note — a filed reference block, not a second buy box */
.pdp-descNote {
  position: sticky;
  top: 5.5rem;
  border: var(--hair) solid var(--ink);
  border-radius: var(--radius-md);
  padding: 0.35rem 1.1rem 1rem;
}
.pdp-facts--note { margin-top: 0; border-top: none; }
.pdp-facts--note > div:last-child { border-bottom: none; }
.pdp-facts--note dt { width: 4.5rem; }
.pdp-facts--note dd a { color: var(--ink); text-decoration: none; }
.pdp-facts--note dd a:hover { color: var(--cobalt-text); }
.pdp-noteAsk {
  display: block;
  margin-top: 0.9rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--cobalt-text);
  text-decoration: none;
}
.pdp-noteAsk:hover { color: var(--cobalt-hover); }

/* related grid — auto-fit with a capped track, centred: a short row stays
   symmetric instead of hanging on the RTL edge, and cards never balloon */
.pdp-relGrid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 18rem));
  justify-content: center;
  gap: 1rem;
}
/* auto-fit counts repetitions off the track's max, so below ~2×18rem it drops
   to a single narrow card — pin it to the shop grid's two-up instead */
@media (max-width: 680px) {
  .pdp-relGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ════════════ sticky mobile CTA — ink-ruled white bar ════════════ */
.sticky-cta {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  border-top: var(--hair) solid var(--ink);
  padding: 0.55rem clamp(1rem, 4vw, 1.5rem);
  align-items: center;
  gap: 1rem;
}
.sticky-cta__price {
  flex: 1;
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.sticky-cta__price-old {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 400;
  line-height: 1;
}
.sticky-cta__actions { display: flex; gap: 0.5rem; }
.sticky-cta__actions form { margin: 0; }
.sticky-cta .btn { padding-block: 0.55rem; }
.sticky-cta .btn-ghost { padding-inline: 0.85rem; }

/* ════════════ responsive ════════════ */
@media (max-width: 900px) {
  .pdp-doc { grid-template-columns: 1fr; }
  .pdp-figure { position: static; max-width: 30rem; margin-inline: auto; width: 100%; }
  .pdp-descDoc { grid-template-columns: 1fr; gap: 1.75rem; }
  .pdp-descNote { position: static; }
  .pdp-specWrap .spec-table th[scope="row"] { width: 9rem; }
}
@media (max-width: 560px) {
  .pdp-specWrap .spec-table th[scope="row"] { width: 7.5rem; }
}
@media (max-width: 700px) {
  .sticky-cta { display: flex; }
  main#main-content { padding-bottom: 4.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pdp-pillarNote:hover .pdp-noteArrow { transform: none; }
}
