/*
 * المكوّنات المشتركة: كارت المنتج، الشارات، سلايدر المنتجات
 *
 * بيتحمّل في كل صفحة، لأن كروت المنتجات بتظهر كمان جوّه لوحة البحث
 * في الهيدر — مش في صفحات المنتجات بس.
 *
 * كل القواعد جوّه @layer components عشان ترتيب الأولويات يفضل
 * زي ما كان: كلاسات Tailwind (layer utilities) تقدر تتغلّب عليها،
 * وده نفس ترتيب نسخة Next بالحرف. ماتشيلش السطر ده.
 *
 * الترتيب نفسه معلَن في tailwind.css، فلازم يتحمّل قبل الملفّ ده —
 * وده مظبوط في كل صفحات HTML.
 */

@layer components {
  /* ===== كارت المنتج =====
     القيم الفعلية من ul.products في الثيمة المرجعية:
       .product-inner        overflow:hidden · transition box-shadow .4s, bg .3s
       .product-inner:hover  bg #fff · box-shadow 0 8px 32px 0 rgba(0,0,0,.1)
       .product-summary      padding:14px 20px · transition transform .4s
       :hover .product-summary  transform: translateY(-40px)
       .buttons              absolute · inset 20px · height 40px · padding-top 15px
                             opacity 0 · translateY(50%) · transition .4s
     الفكرة: صفّ الأزرار قاعد تحت حافّة الكارت ومقصوص بـoverflow:hidden،
     ولمّا الملخّص يطلع 40px بيبان مكانه. ارتفاع الكارت مابيتغيّرش. */
  .product-card { position: relative; }

  .product-inner {
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.4s, background-color 0.3s;
  }
  .product-card:hover .product-inner {
    background-color: var(--color-page);
    box-shadow: 0 8px 32px 0 rgb(0 0 0 / 0.1);
  }
  .product-card:hover .product-inner a { color: var(--color-ink); }

  /* بدون خلفية ولا قصّ — المنتج بيطفو على خلفية الصفحة زي الأصل */
  .product-thumbnail {
    position: relative;
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--color-page);
  }
  .product-thumbnail img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* صور المنتجات متصوّرة على أبيض — multiply بيخلّي الأبيض ياخد لون الصفحة */
    mix-blend-mode: multiply;
  }
  /* تبديل الصورة — القاعدتان من ul.products.hover-other_image:
       :hover .product-thumbnails--hover img        { opacity: 0 }
       :hover .product-thumbnails--hover .hover-image { opacity: 1 }
     لازم الأصلية تختفي، وإلا الاتنين يبانوا فوق بعض لأن الصور شفّافة. */
  .product-thumbnail img { transition: opacity 0.5s ease; }
  .product-thumbnail .hover-image { opacity: 0; }
  .product-card:hover .product-thumbnail img { opacity: 0; }
  .product-card:hover .product-thumbnail .hover-image { opacity: 1; }

  .product-summary {
    position: relative;
    padding: 14px 20px;
    background-color: transparent;
    transition: transform 0.4s, background-color 0.3s;
  }
  .product-card:hover .product-summary {
    transform: translateY(-40px);
    background-color: var(--color-page);
  }

  .woocommerce-loop-product__title {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.55556;
    margin: 0 0 6px;
  }
  .loop-price {
    font-size: 14px;
    font-weight: 500;
    display: block;
  }
  .loop-price del { font-size: 85.7142857143%; color: var(--color-muted); margin-inline-start: 5px; }

  .product-buttons {
    position: absolute;
    inset-inline: 20px;
    /* الصفّ مرفوع 10px عن موضعه الطبيعي — غيّر الرقم ده لو عايزه أعلى أو أنزل */
    top: calc(100% - 10px);
    height: 40px;
    padding-top: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    opacity: 0;
    transform: translateY(50%);
    transition: 0.4s;
  }
  .product-card:hover .product-buttons,
  .product-card:focus-within .product-buttons {
    opacity: 1;
    transform: none;
  }

  .loop-add-to-cart {
    font-size: 14px;
    font-weight: 600;   /* من .buttons .button في الثيمة */
    color: var(--color-ink);
    white-space: nowrap;
    text-underline-offset: 4px;
  }
  .loop-add-to-cart:hover { text-decoration: underline; }

  .loop-icon { color: var(--color-ink); opacity: 0.8; transition: opacity 0.3s; }
  .loop-icon:hover { opacity: 1; }

  /* على اللمس مفيش هوفر — كل حاجة ظاهرة */
  @media (hover: none) {
    .product-summary { transform: none !important; }
    .product-buttons {
      position: static;
      opacity: 1;
      transform: none;
      height: auto;
      padding-top: 14px;
    }
  }


  /* ===== الشارات ===== */
  .badge {
    position: absolute;
    inset-inline-start: 0;
    top: 16px;
    z-index: 2;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 12px;
  }
  .badge--sale { background: var(--color-sale); }
  .badge--new { background: var(--color-new); }
  .badge--featured { background: var(--color-featured); }
  .badge--soldout { background: var(--color-soldout); }


  /* ===== نقاط صفحات السلايدر ===== */
  .product-slider__dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
  }
  .product-slider__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-muted) 45%, transparent);
    transition: background 0.3s;
    cursor: pointer;
  }
  .product-slider__dot.is-active { background: var(--color-ink); }


  /* ===== سلايدر المنتجات — صفّ واحد متحرّك ===== */
  .product-slider { position: relative; }
  .product-slider__track {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
  }
  .product-slider__track::-webkit-scrollbar { display: none; }
  .product-slider__item {
    flex: 0 0 calc(50% - 12px);
    scroll-snap-align: start;
    min-width: 0;
  }
  @media (min-width: 768px) { .product-slider__item { flex-basis: calc(33.333% - 16px); } }
  @media (min-width: 1200px) { .product-slider__item { flex-basis: calc(25% - 18px); } }
  @media (min-width: 1700px) { .product-slider__item { flex-basis: calc(20% - 20px); } }


}
