/* =============================================================================
   پارسی شو — بازار / Market UI fixes
   Loaded after market-pro.css, product-pro.css, market-gadget-fix.css and
   market-ui-fixes.v2.css so it can safely correct what those files set.
   Scope: body.ph-market only. Nothing outside the market section is touched.
   ============================================================================= */

/* =============================================================================
   1) PRODUCT CARD — title
   The card template uses `line-clamp-2` + `min-h-[2.5rem]` + `leading-relaxed`.
   At >=640px the line-height becomes 20px while the glyph box is 22px, so the
   second line was sliced by 1-2px and long titles lost their ellipsis.
   ============================================================================= */
body.ph-market .mp-card h3 {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  line-height: 1.6 !important;
  min-height: 3.2em !important;
  max-height: 3.2em !important;
  padding-bottom: 0 !important;
  text-overflow: ellipsis !important;
  word-break: break-word !important;
}

/* Short description: one clean line with a real ellipsis instead of a hard cut */
body.ph-market .mp-card p.line-clamp-1,
body.ph-market .mp-card p[class*="line-clamp-1"] {
  display: block !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.7 !important;
  max-height: 1.7em !important;
}

/* =============================================================================
   2) PRODUCT CARD — price row
   ============================================================================= */

/* The discount is already printed on the product photo ("٪۱۹ تخفیف" pill).
   Repeating it next to the buy button made the row look broken and pushed the
   old price into the card border. Keep the photo pill, drop the duplicate. */
body.ph-market main article.mp-card .mt-auto > div:last-child > span.text-success-700,
body.ph-market main article.mp-card .mt-auto > div:last-child > span[class*="text-success"] {
  display: none !important;
}

/* Old (crossed-out) price: was 9.5-10px in neutral-400 — almost invisible */
body.ph-market main article.mp-card .mt-auto > div:first-child > span:nth-child(3) {
  font-size: 11px !important;
  line-height: 1.45 !important;
  color: #7b8797 !important;
  text-decoration-thickness: 1px !important;
}
body.ph-market main article.mp-card .mt-auto > div:first-child > span:nth-child(2) {
  line-height: 1.5 !important;
}
body.ph-market main article.mp-card .mt-auto > div:first-child > span:nth-child(1) {
  line-height: 1.35 !important;
}

/* Keep the buy button aligned with the price block, never overlapping it */
body.ph-market main article.mp-card .mt-auto > div:last-child {
  align-self: flex-end !important;
}

/* price units on the compact card: «… تومان (پارسی)» with پارسی small */
body.ph-market .mp-card .ph-price-unit { font-size: .62em !important; }
body.ph-market .mp-card .ph-parsi-mini { font-size: .54em !important; }

/* Night theme (market has its own night class as well as the site one) */
body.ph-market.mk-night main article.mp-card .mt-auto > div:first-child > span:nth-child(3),
html.ph-night body.ph-market main article.mp-card .mt-auto > div:first-child > span:nth-child(3) {
  color: #8194ab !important;
}

/* =============================================================================
   3) CATEGORY RAIL
   ============================================================================= */
body.ph-market .ph-cat-rail {
  gap: 8px !important;
  padding: 2px 2px 10px !important;
  scroll-snap-type: x proximity;
  scroll-padding-inline-start: 2px;
  scrollbar-width: none;
}
body.ph-market .ph-cat-rail::-webkit-scrollbar { display: none; }

/* =============================================================================
   4) CATEGORY TILES — classic surface cards
   The SPA shipped one generic grid icon on every tile, a repeated
   "دسته‌بندی" caption and the same photo behind an 85% white wash, so all nine
   tiles looked identical. This is a restrained, classic category chip: tinted
   icon tile, category name, one accent colour per category.
   ============================================================================= */
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] {
  position: relative !important;
  isolation: isolate;
  width: 170px !important;
  min-width: 170px !important;
  height: 66px !important;
  min-height: 66px !important;
  padding: 0 13px !important;
  border-radius: 14px !important;
  border: 1px solid #e3eaf3 !important;
  background: #ffffff !important;
  background-image: none !important;
  color: #22374e !important;
  overflow: hidden !important;
  box-shadow: 0 1px 2px rgba(15, 34, 55, .04) !important;
  scroll-snap-align: start;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease, transform .18s ease;
  text-align: right;
}
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat]:hover {
  border-color: color-mix(in srgb, var(--cat, #2563eb) 42%, #e3eaf3) !important;
  background: color-mix(in srgb, var(--cat, #2563eb) 4%, #ffffff) !important;
  box-shadow: 0 8px 20px -16px rgba(15, 34, 55, .55) !important;
  transform: translateY(-1px);
}
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat]:active { transform: translateY(0); }

/* selected */
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat].ph-cat--active {
  border-color: var(--cat, #2563eb) !important;
  background: color-mix(in srgb, var(--cat, #2563eb) 7%, #ffffff) !important;
  box-shadow: 0 0 0 1px var(--cat, #2563eb) inset, 0 10px 22px -18px rgba(15, 34, 55, .6) !important;
}

/* the app's washed-out photo + flat white overlay are decorative only */
body.ph-market .ph-cat-tile > .ph-cat-bg,
body.ph-market .ph-cat-tile > .ph-cat-wash,
body.ph-market .ph-cat-tile .ph-cat-mark,
body.ph-market .ph-cat-tile .ph-cat-scrim { display: none !important; }

/* content row: icon tile + name */
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative {
  position: static !important;
  inset: auto !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 9px !important;
  width: 100% !important;
  padding: 0 !important;
}

html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative > span:first-child {
  width: 38px !important;
  height: 38px !important;
  flex: 0 0 38px !important;
  border-radius: 12px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background:
    linear-gradient(160deg,
      color-mix(in srgb, var(--cat, #2563eb) 15%, #ffffff) 0%,
      color-mix(in srgb, var(--cat, #2563eb) 5%, #ffffff) 100%) !important;
  border: 1px solid color-mix(in srgb, var(--cat, #2563eb) 24%, #ffffff) !important;
  color: var(--cat, #2563eb) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .95),
    inset 0 -1px 0 color-mix(in srgb, var(--cat, #2563eb) 14%, transparent),
    0 6px 14px -9px color-mix(in srgb, var(--cat, #2563eb) 70%, transparent),
    0 0 16px -6px color-mix(in srgb, var(--cat, #2563eb) 55%, transparent) !important;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative > span:first-child svg {
  width: 18px !important;
  height: 18px !important;
  color: currentColor !important;
}

html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat].ph-cat--active > span.relative > span:first-child {
  background: var(--cat, #2563eb) !important;
  border-color: var(--cat, #2563eb) !important;
  color: #ffffff !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 8px 18px -10px color-mix(in srgb, var(--cat, #2563eb) 90%, transparent),
    0 0 18px -4px color-mix(in srgb, var(--cat, #2563eb) 65%, transparent) !important;
}

/* the redundant "دسته‌بندی" caption on every tile */
body.ph-market .ph-cat-tile .ph-cat-label { display: none !important; }

html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] .ph-cat-name {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  width: auto !important;
  margin: 0 !important;
  color: #22374e !important;
  font-size: 12.5px !important;
  font-weight: 800 !important;
  line-height: 1.4 !important;
  letter-spacing: 0 !important;
  white-space: normal !important;
  text-overflow: ellipsis !important;
  max-height: 2.8em;
  text-shadow: none !important;
}
html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat].ph-cat--active .ph-cat-name {
  color: var(--cat, #2563eb) !important;
}

html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative > span:last-child {
  min-width: 0 !important;
  width: auto !important;
}

/* night theme */
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] {
  background: #13263b !important;
  border-color: #23394f !important;
  color: #e6eef8 !important;
  box-shadow: none !important;
}
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat]:hover {
  background: #162b42 !important;
  border-color: color-mix(in srgb, var(--cat, #2563eb) 55%, #23394f) !important;
}
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] .ph-cat-name {
  color: #e6eef8 !important;
}
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative > span:first-child {
  background: color-mix(in srgb, var(--cat, #2563eb) 26%, #13263b) !important;
  border-color: color-mix(in srgb, var(--cat, #2563eb) 44%, #13263b) !important;
  color: #ffffff !important;
}
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat].ph-cat--active {
  background: color-mix(in srgb, var(--cat, #2563eb) 22%, #13263b) !important;
  border-color: var(--cat, #2563eb) !important;
}
html.ph-night body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat].ph-cat--active .ph-cat-name {
  color: #ffffff !important;
}

@media (max-width: 639.98px) {
  html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] {
    width: 152px !important;
    min-width: 152px !important;
    height: 62px !important;
    min-height: 62px !important;
    padding: 0 11px !important;
    border-radius: 13px !important;
  }
  html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] > span.relative > span:first-child {
    width: 34px !important;
    height: 34px !important;
    flex-basis: 34px !important;
  }
  html body.ph-market .ph-cat-rail > button.ph-cat-tile[data-ph-cat] .ph-cat-name { font-size: 12px !important; }
}

/* =============================================================================
   5) PRODUCT DETAIL — layout + price block
   Below 1024px the two-column product layout collapsed to a single column, so
   the gallery rendered as a ~950px square (it looked like a sheet of A3 paper)
   and pushed the whole buy box below the fold. Keep two columns from 768px.
   ============================================================================= */
@media (min-width: 768px) and (max-width: 1023.98px) {
  body.ph-market .pp-row1 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 20px !important;
    align-items: start !important;
  }
  body.ph-market .mp-stage { max-width: 100% !important; }
  body.ph-market .mp-buybox h1 { font-size: 20px !important; line-height: 1.5 !important; }
}
@media (max-width: 767.98px) {
  body.ph-market .mp-stage { max-width: 520px; margin-inline: auto; }
}

/* The old price is a flex item that can shrink below its text width on narrow
   columns, so it slid under the discount pill. Keep it at its natural width. */
body.ph-market .mp-buybox .line-through {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}
body.ph-market .mp-buybox .flex.items-end {
  row-gap: 6px !important;
}

/* =============================================================================
   6) Reduced motion
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  body.ph-market .ph-cat-tile { transition: none !important; }
  body.ph-market .ph-cat-tile:hover { transform: none; }
}

/* =============================================================================
   9) SHOP SLIDER v2 (phg) — the bundle's own builder
   The enhancer bundle injects its .phg styles at runtime (after every <link>),
   so these overrides carry one extra ancestor to win the cascade:
   - the red action button left the absolute corner and now sits in the footer,
   - name / price are right aligned,
   - price reads «… تومان (پارسی)» with پارسی small.
   ============================================================================= */
body.ph-market .phg-card .phg-name {
  text-align: right !important;
}
body.ph-market .phg-card .phg-foot {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  direction: rtl !important;
  text-align: right !important;
}
body.ph-market .phg-card .phg-cost {
  justify-content: flex-start !important;
  align-items: baseline !important;
  width: auto !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  direction: rtl !important;
  text-align: right !important;
}
body.ph-market .phg-card .phg-go {
  position: static !important;
  inset: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  flex: 0 0 30px !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  background: var(--phg-accent, #d6273c) !important;
  border: 0 !important;
  color: #ffffff !important;
  box-shadow: 0 8px 16px -12px rgba(214, 39, 60, .95) !important;
}
body.ph-market .phg-card .phg-go svg { width: 13px !important; height: 13px !important; }
body.ph-market .phg .phg-cost .ph-parsi-mini {
  display: inline !important;
  font-size: 8px !important;
  font-weight: 600 !important;
  color: #a3aec0 !important;
  margin-inline-start: 2px !important;
  white-space: nowrap !important;
}
body.ph-market .phg-card .phg-cost b { white-space: nowrap !important; }
body.ph-market .phg-card .phg-cost i { white-space: nowrap !important; }

/* =============================================================================
   10) SHOP SLIDER (phg) — a clear frame around the whole block
   The cards, the orange promo and the arrows used to float on the page with no
   container. They now sit inside one bordered panel so the section reads as a
   single, recognisable block.
   ============================================================================= */
body.ph-market .phg {
  background: linear-gradient(180deg, #f7faff 0%, #ffffff 62%) !important;
  border: 1px solid #e6edf6 !important;
  border-radius: 24px !important;
  padding: 16px 16px 12px !important;
  margin: 26px 0 !important;
  box-shadow: 0 26px 52px -46px rgba(15, 34, 55, .55) !important;
  overflow: visible !important;
}
body.ph-market .phg .phg-headrow {
  margin: 0 6px 14px !important;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef3f9;
}
body.ph-market .phg .phg-headrow h2 {
  font-size: 17px !important;
  font-weight: 900 !important;
  color: #16283b !important;
}
body.ph-market .phg .phg-rail {
  padding-inline: 0 !important;
}
body.ph-market .phg .phg-card {
  border: 1px solid #edf2f8 !important;
  box-shadow: 0 12px 26px -24px rgba(15, 34, 55, .55) !important;
}
body.ph-market .phg .phg-card:hover {
  border-color: #dfe8f3 !important;
  box-shadow: 0 20px 36px -26px rgba(15, 34, 55, .6) !important;
}
body.ph-market .phg .phg-ctl {
  position: absolute !important;
  inset-inline-start: 18px !important;
  bottom: 12px !important;
  width: min(340px, 46%) !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* =============================================================================
   7) REMOVED — duplicate search + filter card above the product grid
   The hero already carries the market search, so this whole card (title, count,
   search box and the four selects) is gone on request.
   market-nav.js tags it with .ph-flt-gone; the :has() rule is a CSS-only
   fallback for the moment before the script runs.
   ============================================================================= */
body.ph-market main#products > section:has(select),
body.ph-market main#products > section.ph-flt-gone { display: none !important; }

/* =============================================================================
   8) TRUST STRIP — bottom of the market
   Turns the flat grey box into a premium reassurance panel: gradient hairline,
   soft light, divided columns, elevated icon medallions with a verified tick.
   ============================================================================= */
body.ph-market section.ph-trust {
  position: relative;
  border-radius: 22px !important;
  border: 1px solid #e3eaf3 !important;
  background:
    radial-gradient(58% 120% at 100% 0%, rgba(37, 99, 235, .10), rgba(37, 99, 235, 0) 62%),
    radial-gradient(48% 120% at 62% 0%, rgba(13, 148, 136, .07), rgba(13, 148, 136, 0) 64%),
    radial-gradient(44% 110% at 18% 0%, rgba(245, 158, 11, .08), rgba(245, 158, 11, 0) 66%),
    linear-gradient(180deg, #ffffff 0%, #f6faff 100%) !important;
  box-shadow:
    0 26px 50px -42px rgba(15, 34, 55, .6),
    inset 0 1px 0 #ffffff !important;
  padding: 20px 8px 18px !important;
  overflow: hidden;
}
body.ph-market section.ph-trust::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb 0%, #22d3ee 55%, #f59e0b 100%);
}

body.ph-market .ph-trust-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 2px 0 14px;
  text-align: center;
}
body.ph-market .ph-trust-kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e8f1ff;
  border: 1px solid #d6e6ff;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .3px;
}
body.ph-market .ph-trust-head strong {
  font-size: 14px;
  font-weight: 900;
  color: #16283b;
  line-height: 1.5;
}

body.ph-market .ph-trust-item {
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 10px !important;
  padding: 6px 12px;
  border-radius: 14px;
  transition: background .2s ease;
}
/* one accent per promise */
body.ph-market .ph-trust-item:nth-child(1) { --tc: #2563eb; --tc-2: #60a5fa; }
body.ph-market .ph-trust-item:nth-child(2) { --tc: #d97706; --tc-2: #fbbf24; }
body.ph-market .ph-trust-item:nth-child(3) { --tc: #0d9488; --tc-2: #2dd4bf; }
body.ph-market .ph-trust-item:nth-child(4) { --tc: #7c3aed; --tc-2: #a78bfa; }
body.ph-market .ph-trust-item:hover { background: color-mix(in srgb, var(--tc, #2563eb) 6%, transparent); }
body.ph-market .ph-trust-item + .ph-trust-item::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 14%;
  height: 72%;
  width: 1px;
  background: linear-gradient(180deg, rgba(219, 229, 241, 0), #dbe5f1 20%, #dbe5f1 80%, rgba(219, 229, 241, 0));
}

body.ph-market .ph-trust-ico {
  position: relative;
  width: 52px !important;
  height: 52px !important;
  border-radius: 16px !important;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--tc, #2563eb) 12%, #ffffff) 0%,
    color-mix(in srgb, var(--tc, #2563eb) 26%, #ffffff) 100%) !important;
  border: 1px solid color-mix(in srgb, var(--tc, #2563eb) 30%, #ffffff) !important;
  color: var(--tc, #1d4ed8) !important;
  box-shadow:
    0 10px 22px -14px color-mix(in srgb, var(--tc, #2563eb) 85%, transparent),
    0 0 18px -8px color-mix(in srgb, var(--tc, #2563eb) 60%, transparent),
    inset 0 1px 0 #ffffff !important;
  transition: transform .22s ease, box-shadow .22s ease;
}
body.ph-market .ph-trust-ico svg { width: 23px !important; height: 23px !important; }
body.ph-market .ph-trust-item:hover .ph-trust-ico {
  transform: translateY(-2px);
  box-shadow:
    0 16px 28px -12px color-mix(in srgb, var(--tc, #2563eb) 95%, transparent),
    0 0 22px -6px color-mix(in srgb, var(--tc, #2563eb) 70%, transparent),
    inset 0 1px 0 #ffffff !important;
}
/* verified tick */
body.ph-market .ph-trust-ico::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #16a34a url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>") center / 11px 11px no-repeat;
  box-shadow: 0 4px 10px -6px rgba(22, 163, 74, .9);
}

body.ph-market .ph-trust-item p:first-of-type {
  font-size: 13.5px !important;
  font-weight: 800 !important;
  color: #16283b !important;
  line-height: 1.5 !important;
}
body.ph-market .ph-trust-item p:last-of-type {
  font-size: 11.5px !important;
  color: #6b7c90 !important;
  line-height: 1.75 !important;
  margin-top: 3px !important;
}

@media (max-width: 1023.98px) {
  body.ph-market .ph-trust-item + .ph-trust-item::before { display: none; }
  body.ph-market .ph-trust-item:nth-child(2n)::before { display: block; }
  body.ph-market .ph-trust-item { padding: 8px 6px; }
}

/* night theme */
html.ph-night body.ph-market section.ph-trust {
  background: linear-gradient(180deg, #101f2f 0%, #0d1a28 100%) !important;
  border-color: #23394f !important;
  box-shadow: none !important;
}
html.ph-night body.ph-market .ph-trust-head strong { color: #e6eef8; }
html.ph-night body.ph-market .ph-trust-kicker {
  background: rgba(37, 99, 235, .18);
  border-color: rgba(37, 99, 235, .38);
  color: #93c5fd;
}
html.ph-night body.ph-market .ph-trust-ico {
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--tc, #2563eb) 26%, #132338) 0%,
    color-mix(in srgb, var(--tc, #2563eb) 12%, #132338) 100%) !important;
  border-color: color-mix(in srgb, var(--tc, #2563eb) 42%, #294158) !important;
  color: color-mix(in srgb, var(--tc, #2563eb) 45%, #ffffff) !important;
  box-shadow: none !important;
}
html.ph-night body.ph-market .ph-trust-ico::after { border-color: #0d1a28; }
html.ph-night body.ph-market .ph-trust-item p:first-of-type { color: #e6eef8 !important; }
html.ph-night body.ph-market .ph-trust-item p:last-of-type { color: #9fb3c8 !important; }
html.ph-night body.ph-market .ph-trust-item + .ph-trust-item::before {
  background: linear-gradient(180deg, rgba(36, 56, 77, 0), #24384d 20%, #24384d 80%, rgba(36, 56, 77, 0));
}
