/* =====================================================================
   متجر مفارش ولبادات ومراتب ومخدات: تصميم بسيط ونظيف (RTL)
   الفكرة: الأزرق النيلي (لون القطن المصبوغ) + غُرزة اللحاف كعنصر مميز
   الاستخدام: لوحة التحكم ← تصميم المتجر ← إعدادات القالب ← الكود المخصص (CSS)
   لتغيير الهوية عدّل المتغيّرات في القسم (1) فقط.
   ===================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Readex+Pro:wght@300;400;500;600&display=swap");

/* ---------------------------------------------------------------------
   1) المتغيّرات
   --------------------------------------------------------------------- */
:root {
  /* الألوان */
  --indigo:       #2a3558;   /* الأساسي: نيلي القطن */
  --indigo-deep:  #1d2640;
  --indigo-mist:  #e6eaf3;   /* خلفيات خفيفة مرتبطة بالنيلي */
  --rose:         #b5446e;   /* للخصومات والعدّاد فقط */
  --ink:          #1d2230;
  --ink-soft:     #687083;
  --line:         #dde1e7;
  --paper:        #f7f8f9;   /* خلفية الصفحة */
  --white:        #ffffff;
  --mist:         #eceff2;   /* خلفية الصور */

  /* الأشكال: لكل عنصر نصف قطر يناسب حجمه */
  --r-pill:  999px;  /* الأزرار */
  --r-img:   24px;   /* صور المنتجات (شكل المخدة) */
  --r-panel: 16px;   /* اللوحات */
  --r-field: 12px;   /* الحقول */

  /* غُرزة اللحاف */
  --stitch: 1.5px dashed;
  --line-strong: #c3c9d4;

  /* الحركة */
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  /* طريقة عرض الصور: cover تملأ الإطار، contain تعرض المنتج كاملًا */
  --img-fit: cover;

  /* ربط متغيّرات سلة بالهوية */
  --font-main: "Readex Pro", "Tajawal", system-ui, sans-serif;
  --color-primary: var(--indigo);
  --color-primary-dark: var(--indigo-deep);
  --color-primary-light: #44528a;
  --color-primary-reverse: #ffffff;
  --main-text-color: var(--ink);
  --color-grey: var(--paper);
}

/* ---------------------------------------------------------------------
   2) الأساسيات
   --------------------------------------------------------------------- */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-main);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
}

a { transition: color .2s ease; }
::selection { background: var(--indigo); color: #fff; }

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
  border-radius: 6px;
}

img { max-width: 100%; }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------------------------------------------------------------------
   3) الأزرار: شكل حبّة (pill)
   --------------------------------------------------------------------- */
.s-button-element,
.btn,
button.btn {
  font-family: var(--font-main);
  font-weight: 500;
  border-radius: var(--r-pill);
  padding-inline: 1.5rem;
  transition: background-color .2s ease, color .2s ease,
              border-color .2s ease, transform .15s ease;
}

.s-button-primary,
.s-button-solid.s-button-primary,
.btn--primary {
  background: var(--indigo);
  border: 1.5px solid var(--indigo);
  color: #fff;
}

.s-button-primary:hover,
.btn--primary:hover {
  background: var(--indigo-deep);
  border-color: var(--indigo-deep);
}

.s-button-element:active { transform: scale(.98); }

.s-button-outline {
  background: transparent;
  border: 1.5px solid var(--indigo);
  color: var(--indigo);
}

.s-button-outline:hover {
  background: var(--indigo);
  color: #fff;
}

/* ---------------------------------------------------------------------
   4) الهيدر
   --------------------------------------------------------------------- */
.top-navbar {
  background: var(--indigo-mist);
  color: var(--indigo);
  font-size: .85rem;
}

.top-navbar a { color: inherit; }

.store-header,
.main-nav-container {
  background: var(--white);
}

.store-header { border-bottom: 1px solid var(--line); }

.main-menu > li > a {
  font-weight: 400;
  color: var(--ink);
  transition: color .2s ease;
}

.main-menu > li:hover > a,
.main-menu > li.active > a {
  color: var(--indigo);
  font-weight: 500;
}

.sub-menu,
.main-menu .sub-menu {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: .5rem;
}

.sub-menu a {
  border-radius: 10px;
  padding: .45rem .8rem;
}

.sub-menu a:hover {
  background: var(--indigo-mist);
  color: var(--indigo);
}

.s-search-input,
.header-search input {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding-inline: 1.25rem;
}

.s-search-input:focus,
.header-search input:focus {
  background: var(--white);
  border-color: var(--indigo);
  outline: none;
}

.s-cart-summary-count,
.s-cart-summary-wrapper .count {
  background: var(--rose);
  color: #fff;
  font-size: .72rem;
  font-weight: 500;
  min-width: 1.3rem;
  height: 1.3rem;
  line-height: 1.3rem;
  border-radius: var(--r-pill);
  text-align: center;
}

/* ---------------------------------------------------------------------
   5) عناوين الأقسام: خط غُرزة تحت العنوان
   --------------------------------------------------------------------- */
.s-block__title,
.s-slider-block__title {
  position: relative;
  align-items: center;
  margin-block-end: 1.75rem;
  padding-block-end: .9rem;
}

/* الغُرزة: خط متقطع (يتحرك في القسم 15) */
.s-block__title::after,
.s-slider-block__title::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  height: 1.5px;
  background: repeating-linear-gradient(
    to left,
    var(--line-strong) 0 7px,
    transparent 7px 13px
  );
}

.s-block__title h2,
.s-slider-block__title h2 {
  font-size: clamp(1.3rem, 1.05rem + 1vw, 1.8rem);
  font-weight: 500;
}

.s-block__title a,
.s-slider-block__title a {
  color: var(--indigo);
  font-size: .9rem;
  font-weight: 500;
}

/* ---------------------------------------------------------------------
   6) بطاقة المنتج: بلا إطار ولا ظل، الصورة هي البطاقة
   --------------------------------------------------------------------- */
.s-product-card-entry {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  height: 100%;
}

/* إطار الصورة */
.s-product-card-entry .s-product-card-image {
  position: relative;
  background: var(--mist);
  border-radius: var(--r-img);
  overflow: hidden;
}

.s-product-card-entry .s-product-card-image img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: var(--img-fit);
  transition: transform .6s ease;
}

.s-product-card-entry:hover .s-product-card-image img {
  transform: scale(1.04);
}

/* الغُرزة: خط متقطع يظهر داخل الصورة عند التمرير */
.s-product-card-entry .s-product-card-image::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: var(--stitch) rgba(255, 255, 255, .95);
  border-radius: calc(var(--r-img) - 8px);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}

.s-product-card-entry:hover .s-product-card-image::after,
.s-product-card-entry:focus-within .s-product-card-image::after {
  opacity: 1;
}

/* النص تحت الصورة */
.s-product-card-content {
  padding: .9rem .25rem 0;
}

.s-product-card-content-title,
.s-product-card-content-title a {
  font-size: .95rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.s-product-card-content-title a:hover { color: var(--indigo); }

.s-product-card-content-sub {
  color: var(--ink-soft);
  font-size: .82rem;
}

/* الأسعار */
.s-product-card-price,
.s-product-card-sale-price h4,
.s-product-card-sale-price span {
  font-weight: 500;
  font-size: 1rem;
  color: var(--indigo);
}

.s-product-card-sale-price {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}

.s-product-card-sale-price h4 { color: var(--rose); margin: 0; }

.s-product-card-sale-price span {
  color: var(--ink-soft);
  font-weight: 300;
  font-size: .82rem;
  text-decoration: line-through;
}

/* شارة العرض: مطرّزة بغُرزة */
.s-product-card-promotion-title {
  background: var(--white);
  color: var(--rose);
  font-size: .75rem;
  font-weight: 500;
  padding: .15rem .8rem;
  border: var(--stitch) var(--rose);
  border-radius: var(--r-pill);
  inset-block-start: .85rem;
  inset-inline-start: .85rem;
}

/* نفاد الكمية */
.s-product-card-out-of-stock .s-product-card-image img {
  opacity: .5;
  filter: grayscale(.8);
}

/* المفضلة */
.s-product-card-wishlist-btn {
  background: rgba(255, 255, 255, .9);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: color .2s ease;
}

.s-product-card-wishlist-btn:hover,
.s-product-card-wishlist-added { color: var(--rose); }

/* زر الإضافة للسلة */
.s-product-card-content-footer .s-button-element {
  width: 100%;
}

@media (hover: hover) and (min-width: 992px) {
  .s-product-card-entry .s-product-card-content-footer {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .3s ease, opacity .3s ease, margin .3s ease;
  }
  .s-product-card-entry:hover .s-product-card-content-footer,
  .s-product-card-entry:focus-within .s-product-card-content-footer {
    max-height: 4rem;
    opacity: 1;
    margin-top: .75rem;
  }
}

/* ---------------------------------------------------------------------
   7) صفحة المنتج
   --------------------------------------------------------------------- */
.product-single .product-form,
.product-single .main-content {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: clamp(1rem, 2.2vw, 1.75rem);
}

.product-single h1,
.product-single .product-title {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
  font-weight: 500;
}

.product-single .total-price,
.product-single .product-price {
  color: var(--indigo);
  font-size: 1.55rem;
  font-weight: 500;
}

.product-single .before-price,
.product-single .product-regular-price {
  color: var(--ink-soft);
  text-decoration: line-through;
}

.product-single .swiper-slide img,
.product-single .main-image img {
  border-radius: var(--r-img);
  background: var(--mist);
}

/* خيارات المقاس واللون: المحدّد يظهر بإطار غُرزة */
.s-product-options-option-label,
.s-product-options-option-container label {
  font-weight: 500;
}

.s-product-options-option-container input:checked + label,
.s-product-options-thumbnails-wrapper .selected,
.s-product-options-option-container .selected {
  border: var(--stitch) var(--indigo);
  background: var(--indigo-mist);
  color: var(--indigo);
}

.s-quantity-input-input {
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  text-align: center;
  font-weight: 500;
}

/* ---------------------------------------------------------------------
   8) مميزات المتجر والآراء (الصفحة الرئيسية)
   --------------------------------------------------------------------- */
.s-block--features__item {
  background: transparent;
  text-align: center;
}

.s-block--features__item .feature-icon,
.s-block--features__item i {
  display: inline-grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  background: var(--indigo-mist);
  color: var(--indigo);
  border-radius: 50%;
  margin-block-end: .75rem;
}

.s-block--features__item h2,
.s-block--features__item h3 {
  font-size: 1rem;
  font-weight: 500;
}

.s-block--testimonials__item {
  background: var(--white);
  border: var(--stitch) var(--line);
  border-radius: var(--r-panel);
  padding: 1.5rem;
}

/* ---------------------------------------------------------------------
   9) السلة وإتمام الطلب
   --------------------------------------------------------------------- */
.cart-item,
.s-cart-item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 1rem;
  margin-bottom: .75rem;
}

.s-cart-summary-wrapper,
.cart-summary {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: 1.25rem;
}

.s-cart-summary-total {
  color: var(--indigo);
  font-weight: 600;
  font-size: 1.15rem;
}

/* ---------------------------------------------------------------------
   10) الحقول والنماذج
   --------------------------------------------------------------------- */
.s-form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  font-family: var(--font-main);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.s-form-control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-mist);
  outline: none;
}

/* ---------------------------------------------------------------------
   11) النوافذ والإشعارات
   --------------------------------------------------------------------- */
.s-modal-body,
.s-modal-wrapper .s-modal-body {
  border-radius: var(--r-panel);
  font-family: var(--font-main);
}

.s-toast,
.swal2-popup {
  border-radius: var(--r-panel) !important;
  font-family: var(--font-main) !important;
}

/* ---------------------------------------------------------------------
   12) الفوتر: فاتح وهادئ، يبدأ بخط غُرزة
   --------------------------------------------------------------------- */
.store-footer {
  background: var(--mist);
  color: var(--ink);
  margin-top: 3.5rem;
  border-block-start: var(--stitch) #b9c0cc;
}

.store-footer a { color: var(--ink-soft); }
.store-footer a:hover { color: var(--indigo); }

.store-footer h3,
.store-footer h4,
.store-footer .footer-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.store-footer__inner,
.store-footer .copyright {
  border-block-start: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .85rem;
}

/* ---------------------------------------------------------------------
   13) الجوال
   --------------------------------------------------------------------- */
@media (max-width: 767px) {
  :root { --r-img: 18px; }

  .s-product-card-content-title,
  .s-product-card-content-title a { font-size: .9rem; }

  .s-product-card-entry .s-product-card-image::after { inset: 7px; }

  .store-footer { margin-top: 2.25rem; }
}

/* ---------------------------------------------------------------------
   14) تقليل الحركة
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------------------------------------------------------------------
   15) الحركة
   الفكرة: كل الحركة مستوحاة من الخياطة.
   - لحظة واحدة مميزة: خط الغُرزة تحت عنوان كل قسم "يُخاط" أثناء التمرير.
   - غُرزة صورة المنتج تُخاط عند المرور عليها.
   - الباقي ردود فعل بسيطة على فعل المستخدم (فتح قائمة، إضافة للمفضلة...).
   بدون حركة تلقائية مستمرة، وتُلغى كلها لمن فعّل "تقليل الحركة".
   ملاحظة: الاتجاه هنا لليمين→اليسار (RTL). لو غيّرت الموقع إلى LTR
   بدّل inset(0 0 0 100%) إلى inset(0 100% 0 0).
   --------------------------------------------------------------------- */
@keyframes sew {
  from { clip-path: inset(0 0 0 100%); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes badge-in {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {

  /* 15.1 اللحظة المميزة: الخيط يُخاط مع التمرير
     (المتصفحات التي لا تدعم ذلك تعرض الخط ثابتًا) */
  @supports (animation-timeline: view()) {
    .s-block { view-timeline: --section block; }

    .s-block__title::after,
    .s-slider-block__title::after {
      animation: sew linear both;
      animation-timeline: --section;
      animation-range: entry 0% entry 45%;
    }
  }

  /* 15.2 غُرزة صورة المنتج تُخاط عند المرور */
  .s-product-card-entry .s-product-card-image::after {
    clip-path: inset(0 0 0 100%);
    transition: opacity .2s ease, clip-path .7s var(--ease-out);
  }

  .s-product-card-entry:hover .s-product-card-image::after,
  .s-product-card-entry:focus-within .s-product-card-image::after {
    clip-path: inset(0 0 0 0);
  }

  /* 15.3 المفضلة: نبضة عند الإضافة */
  .s-product-card-wishlist-added i {
    animation: pop .4s var(--ease-out);
  }

  /* 15.4 عدّاد السلة: يظهر بنبضة عند تحديثه */
  .s-cart-summary-count,
  .s-cart-summary-wrapper .count {
    animation: badge-in .35s var(--ease-out);
  }

  /* 15.5 القوائم المنسدلة */
  .main-menu > li:hover > .sub-menu,
  .main-menu > li:focus-within > .sub-menu {
    animation: menu-in .22s var(--ease-out);
  }

  /* 15.6 النوافذ المنبثقة */
  .s-modal-body {
    animation: sheet-in .3s var(--ease-out);
  }

  /* 15.7 اختيار المقاس/اللون: انتقال ناعم للحالة المحددة */
  .s-product-options-option-container label,
  .s-product-options-thumbnails-wrapper label {
    transition: border-color .2s ease, background-color .2s ease, color .2s ease;
  }

  /* 15.8 زر الإضافة: ضغطة محسوسة */
  .s-button-primary:active {
    transform: scale(.97);
    transition-duration: .08s;
  }
}

/* ---------------------------------------------------------------------
   16) إصلاح قصّ الصور في البطاقة الأفقية (عرض القائمة على الجوال)
   المشكلة: الصورة كانت تتمدد لارتفاع البطاقة كاملًا فتُقصّ من الجانبين.
   الحل: الصورة تحافظ على نسبتها ولا تتمدد، والنص يبقى بجانبها.
   --------------------------------------------------------------------- */
.s-product-card-horizontal .s-product-card-image {
  align-self: flex-start;   /* لا تتمدد مع ارتفاع النص */
  height: auto !important;
  flex-shrink: 0;
}

.s-product-card-horizontal .s-product-card-image img {
  height: auto !important;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* إن كانت صورك غير مربعة وتريد عرضها كاملة دون قص، فعّل هذا السطر
   (سيظهر لون فاتح حول الصورة بدل القص):
   :root { --img-fit: contain; }
*/

/* ---------------------------------------------------------------------
   17) ملحقات ملف salla-bedding.js
   الفئات التي يضيفها السكربت: bd-contain / is-bump / bd-sew / is-sewn
   إن لم تستخدم ملف JS فلن يتأثر شيء، فكلها اختيارية.
   --------------------------------------------------------------------- */

/* صورة غير مربعة: تُعرض كاملة بدل القص (الإطار يحتفظ بلون الخلفية) */
.s-product-card-image.bd-contain img {
  object-fit: contain;
}

@keyframes badge-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: no-preference) {

  /* نبضة العدّاد عند إضافة منتج */
  .s-cart-summary-count.is-bump,
  .s-cart-summary-wrapper .count.is-bump {
    animation: badge-bump .4s var(--ease-out);
  }

  /* الخياطة للمتصفحات التي لا تدعم الحركة المرتبطة بالتمرير */
  @supports not (animation-timeline: view()) {
    .bd-sew .s-block__title::after,
    .bd-sew .s-slider-block__title::after {
      clip-path: inset(0 0 0 100%);
      transition: clip-path 1.1s var(--ease-out);
    }

    .bd-sew .s-block__title.is-sewn::after,
    .bd-sew .s-slider-block__title.is-sewn::after {
      clip-path: inset(0 0 0 0);
    }
  }
}

/* أجهزة اللمس: لا يوجد "تمرير"، فالغُرزة تظهر لحظة اللمس فقط
   (حتى لا تبقى ظاهرة بعد الضغط) */
@media (hover: none) {
  .s-product-card-entry:hover .s-product-card-image::after,
  .s-product-card-entry:focus-within .s-product-card-image::after {
    opacity: 0;
  }

  .s-product-card-entry:active .s-product-card-image::after {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
}