/*
 * Compare 1 — اسلایدر قبل و بعد
 *
 * سبکِ این کامپوننت اینجاست، نه در tailwind.css، چون فقط جایی لود می‌شود که
 * خودِ کامپوننت رندر شده باشد (core/class-component.php آن را enqueue می‌کند).
 *
 * بدون جاوااسکریپت: --pos روی ۵۰٪ می‌ماند و هر دو حالت نصف‌نصف دیده می‌شوند.
 * script.js فقط کشیدن را اضافه می‌کند.
 */

.compare-stage {
  --pos: 50%;
  position: relative;
  overflow: hidden;
  inline-size: 100%;
  max-inline-size: 26rem;
  margin-inline: auto;
  aspect-ratio: 9 / 10;
  border-radius: 32px;
  background: var(--raised, #F3E7DA);
  box-shadow: 0 6px 14px rgba(36, 20, 16, .05), 0 40px 76px -34px rgba(36, 20, 16, .34);
  touch-action: pan-y;
}

.compare-stage .compare-img {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* لایهٔ «قبل» از خطِ اسلایدر تا لبهٔ راست دیده می‌شود.
   مختصات فیزیکی است، نه منطقی: خودِ تصویر در RTL آینه نمی‌شود، و در فارسی
   «قبل» طبیعتاً سمت راست می‌نشیند و «بعد» سمت چپ. */
.compare-clip {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--pos));
}

.compare-tag {
  position: absolute;
  inset-block-start: 1rem;
  z-index: 2;
  border-radius: 999px;
  background: rgba(251, 247, 242, .94);
  color: var(--ink, #2E1B12);
  padding: .3rem .85rem;
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.7;
  box-shadow: 0 1px 2px rgba(36, 20, 16, .05), 0 6px 16px -8px rgba(36, 20, 16, .16);
}
.compare-tag-b { right: 1rem; }
.compare-tag-a { left: 1rem; }

/* دستهٔ اسلایدر: خطِ عمودی به‌اضافهٔ یک قرص گرد. */
.compare-handle {
  position: absolute;
  inset-block: 0;
  left: var(--pos);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 0;
  pointer-events: none;
}
.compare-handle::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inline-size: 2px;
  margin-inline-start: -1px;
  background: rgba(251, 247, 242, .95);
  box-shadow: 0 0 0 1px rgba(36, 20, 16, .18);
}
.compare-handle > svg {
  position: relative;
  flex: none;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: .8rem;
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--ink, #2E1B12);
  box-shadow: 0 2px 4px rgba(36, 20, 16, .08), 0 12px 26px -12px rgba(36, 20, 16, .4);
}

/* خودِ input کلِ تصویر را می‌پوشاند تا هدفِ لمسی بزرگ باشد؛ دیده نمی‌شود و
   نمایشِ وضعیت با .compare-handle انجام می‌شود. */
.compare-range {
  position: absolute;
  inset: 0;
  z-index: 4;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  padding: 0;
  direction: ltr;
  cursor: ew-resize;
  background: transparent;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
}
.compare-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 2.75rem;
  block-size: 100%;
  background: transparent;
  cursor: ew-resize;
}
.compare-range::-moz-range-thumb {
  inline-size: 2.75rem;
  block-size: 100%;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}
.compare-range::-moz-range-track { background: transparent; }
.compare-range:focus { outline: none; }
.compare-range:focus-visible ~ .compare-handle > svg {
  outline: 2px solid var(--primary, #B4453F);
  outline-offset: 3px;
}

@media (max-width: 767px) {
  .compare-stage { border-radius: 20px; }
  .compare-handle > svg { inline-size: 2.5rem; block-size: 2.5rem; padding: .7rem; }
}
