/* product-card.css — shared commerce product tile (MKT-DESIGN-2)
   Tokens only. Zero inline styles. Light + dark via theme.css variables. */

/* ---- Card shell ---- */
.pc {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl, 16px);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
  transition:
    transform var(--duration-fast, .12s) var(--ease, ease),
    box-shadow var(--duration, .15s) var(--ease, ease);
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
  opacity: 0;
  transform: translateY(8px);
}
.pc.pc-seen,
.pc.pc--static {
  opacity: 1;
  transform: none;
  transition:
    opacity .18s var(--ease, ease) var(--pc-stagger, 0ms),
    transform .18s var(--ease, ease) var(--pc-stagger, 0ms),
    box-shadow var(--duration, .15s) var(--ease, ease);
}
.pc:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
}
.pc:active {
  transform: scale(.98);
}
.pc:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pc.is-out .pc-media {
  filter: grayscale(.6);
}
.pc.is-out .pc-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .08);
  pointer-events: none;
}

/* ---- Media 1:1 white stage (owner 30 Sep: the compact square card is the reference) ---- */
.pc-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff;
  overflow: hidden;
}
.pc--rail .pc-media,
.pc--compact .pc-media {
  aspect-ratio: 1 / 1;
}
[data-theme="dark"] .pc-media {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.pc-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8%;
  box-sizing: border-box;
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity .18s var(--ease, ease);
}
.pc-img[src] {
  opacity: 1;
}
.pc-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  opacity: .55;
}
.pc-dots {
  position: absolute;
  inset-inline: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.pc-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(15, 23, 42, .25);
}
.pc-dots span.on {
  background: var(--accent);
}

/* ---- Badges (top-start) ---- */
.pc-badges {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
  pointer-events: none;
}
.pc-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  padding: 3px 7px;
  border-radius: var(--radius-sm, 7px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-subtle);
}
.pc-badge--danger {
  background: var(--danger, #dc2626);
  color: #fff;
}
.pc-badge--new {
  background: var(--accent-soft, rgba(37, 99, 235, .12));
  color: var(--accent);
}
.pc-badge--warn {
  background: #fff4e0;
  color: #9a4b00;
  box-shadow: inset 0 0 0 1px rgba(234, 120, 0, .35);
}
.pc-badge--ok {
  background: #e8f7ee;
  color: #11703a;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, .3);
}
[data-theme="dark"] .pc-badge--warn { background: rgba(245, 158, 11, .18); color: #fbbf24; }
[data-theme="dark"] .pc-badge--ok { background: rgba(34, 197, 94, .16); color: #4ade80; }
.pc-badge--out {
  background: var(--surface2);
  color: var(--muted);
}

/* ---- Quick actions (top-end) ---- */
.pc-actions {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}
.pc-act {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-subtle);
  padding: 0;
  transition:
    background var(--duration-fast, .12s) var(--ease, ease),
    color var(--duration-fast, .12s) var(--ease, ease),
    transform var(--duration-fast, .12s) var(--ease, ease);
}
.pc-act:hover,
.pc-act:focus-visible {
  background: var(--surface2);
  outline: none;
}
.pc-act:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}
.pc-save.is-on {
  color: var(--danger, #dc2626);
}
.pc-save.pc-pop {
  animation: pc-heart-pop .32s var(--ease, ease);
}
@keyframes pc-heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
/* save stays visible (Hicham 30 Sep); only share waits for hover on desktop */
@media (hover: hover) and (pointer: fine) {
  .pc-actions .pc-share {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .15s ease, transform .15s ease;
  }
  .pc:hover .pc-actions .pc-share,
  .pc:focus-within .pc-actions .pc-share {
    opacity: 1;
    transform: none;
  }
}

/* ---- Body ---- */
.pc-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 4px;
  flex: 1;
}
.pc-store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  max-width: 100%;
}
.pc-store:hover {
  color: var(--accent);
}
.pc-store-logo {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.pc-store-logo--ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--muted);
}
.pc-store-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-verified {
  color: var(--accent);
  display: inline-flex;
  flex-shrink: 0;
}
.pc-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
}
.pc-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin-top: auto;
}
.pc-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.pc-price .cur {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-inline-start: 3px;
}
.pc-was {
  font-size: 12px;
  color: var(--muted);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}
.pc-off-chip {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  padding: 2px 7px;
  border-radius: var(--radius-full, 999px);
  line-height: 1.3;
}
.pc-save-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--ok, #16a34a);
  background: color-mix(in srgb, var(--ok, #16a34a) 12%, transparent);
  padding: 2px 6px;
  border-radius: var(--radius-sm, 7px);
}
.pc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.pc-rating {
  color: #ca8a04;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pc-rating-n {
  color: var(--muted);
  font-weight: 500;
}
.pc-meta-sep {
  opacity: 0.45;
}

/* One grid for market and store (owner 30 Sep): compact cards, same size on both pages.
   auto-fill keeps empty tracks, so 3 products stay card-sized instead of stretching. */
.product-grid,
.sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 12px;
}
@media (min-width: 720px) {
  .product-grid,
  .sp-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
  }
}

/* ---- CTA ---- */
.pc-cta {
  display: block;
  width: calc(100% - 24px);
  margin: 8px 12px 12px;
  padding: 10px 12px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-lg, 12px);
  background: var(--accent);
  color: var(--on-accent, #fff);
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast, .12s) var(--ease, ease),
    transform var(--duration-fast, .12s) var(--ease, ease);
}
.pc-cta:hover:not(:disabled) {
  filter: brightness(1.06);
}
.pc-cta:active:not(:disabled) {
  transform: scale(.98);
}
.pc-cta:disabled {
  background: var(--surface2);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}
.pc-cta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Rail / compact variants ---- */
.pc--rail {
  min-width: 148px;
  max-width: 168px;
  flex-shrink: 0;
  scroll-snap-align: start;
}
.pc--compact .pc-cta,
.pc--compact .pc-actions {
  display: none;
}
.pc--compact .pc-body {
  padding: 8px 10px 10px;
}
.pc--compact .pc-title {
  font-size: 12.5px;
}
.pc--compact .pc-price {
  font-size: 15px;
}

/* ---- Contact sheet ---- */
.pc-sheet {
  position: fixed;
  inset: 0;
  z-index: 1200;
}
.pc-sheet[hidden] {
  display: none !important;
}
.pc-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.pc-sheet-panel {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: 85vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
  padding: 12px 16px 24px;
  box-shadow: var(--shadow-modal);
  animation: pc-sheet-up .24s var(--ease, ease);
}
@keyframes pc-sheet-up {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.pc-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  margin: 4px auto 12px;
}
.pc-sheet-x {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.pc-sheet-store {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-inline-end: 40px;
}
.pc-sheet-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.pc-sheet-store-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.pc-sheet-verified {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 2px;
}
.pc-sheet-product {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-lg, 12px);
  margin-bottom: 16px;
}
.pc-sheet-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius, 9px);
  padding: 4px;
}
.pc-sheet-product-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pc-sheet-product-price {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 800;
}
.pc-sheet-actions {
  /* one row per phone: call + WhatsApp side by side; copy spans the row, lighter */
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
}
.pc-sheet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}
.pc-sheet-btn--call {
  background: var(--accent);
  color: var(--on-accent, #fff);
  border-color: transparent;
}
.pc-sheet-btn--wa {
  background: #25d366;
  color: #fff;
  border-color: transparent;
}
.pc-sheet-btn--copy {
  grid-column: 1 / -1;
  min-height: 40px;
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.pc-sheet-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 12px;
}
body.pc-sheet-open {
  overflow: hidden;
}

@media (min-width: 720px) {
  .pc-sheet-panel {
    inset-inline: auto;
    inset-inline-end: 24px;
    bottom: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    border-radius: var(--radius-xl, 16px);
    animation: none;
  }
  .pc-sheet-handle {
    display: none;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .pc,
  .pc.pc-seen,
  .pc-img,
  .pc-sheet-panel,
  .pc-act,
  .pc-cta {
    transition: none !important;
    animation: none !important;
  }
  .pc {
    opacity: 1;
    transform: none;
  }
  .pc:hover {
    transform: none;
  }
}
