/*
 * التخطيط: التوب بار، الهيدر، لوحة المنيو، لوحة البحث، الفوتر
 *
 * الأجزاء اللي بتتكرّر في كل صفحة (PH.layout في assets/js/ui/layout.js).
 *
 * كل القواعد جوّه @layer components عشان ترتيب الأولويات يفضل
 * زي ما كان: كلاسات Tailwind (layer utilities) تقدر تتغلّب عليها،
 * وده نفس ترتيب نسخة Next بالحرف. ماتشيلش السطر ده.
 *
 * الترتيب نفسه معلَن في tailwind.css، فلازم يتحمّل قبل الملفّ ده —
 * وده مظبوط في كل صفحات HTML.
 */

@layer components {
  /* ===== التوب بار ===== */
  .topbar {
    height: var(--topbar-h);
    background-color: var(--color-brand-dark);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
  }
  .topbar a { color: #fff; }


  /* ===== الهيدر ===== */
  .site-header {
    background-color: var(--color-brand);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .header-main {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 28px;
  }
  .header-mobile { height: var(--header-mobile-h); }
  .logo img, .logo svg { height: 40px; width: auto; }

  .nav-menu { display: flex; align-items: center; gap: 22px; }
  .nav-menu > li > a {
    font-size: 16px;
    font-weight: 400;
    color: #fff;
    white-space: nowrap;
    position: relative;
    padding-block: 4px;
  }
  .nav-menu > li > a::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: inline-end;
    transition: transform 0.3s ease;
  }
  .nav-menu > li > a:hover::after { transform: scaleX(1); }

  .header-icon { position: relative; display: inline-flex; color: #fff; }
  .counter {
    position: absolute;
    inset-inline-end: -8px;
    top: -6px;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    background: #fff;
    color: var(--color-brand);
    font-size: 10px;
    font-weight: 600;
    display: grid;
    place-items: center;
    padding-inline: 4px;
  }


  /* ===== الفوتر — القيم الفعلية من الثيمة =====
       .widget{margin:0 0 40px}            ← المسافة الكبيرة تحت كل عنوان
       .footer-widgets{font-size:14px}
       .footer-widgets .widget a{line-height:1;display:inline-block;padding-bottom:8px}
       input[type=email]{border:0;border-bottom:2px solid;padding:3px;height:60px}
       .mc4wp-form-fields input{flex:1}
       .mc4wp-form-fields input[type=submit]{color:inherit;background:transparent;flex:0}
       .footer-main{font-size:14px;padding:40px 0 35px}
       h4 = 24px/500 */
  .site-footer {
    background-color: var(--color-brand);
    color: #fff;
  }
  .footer-widgets { font-size: 14px; }

  /* كل عنوان ودجت منفصل بـ40px عن محتواه — ده أوضح فرق بصري */
  .footer-widgets h4 {
    color: #fff;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.55556;
    margin: 0 0 40px;
  }
  .footer-widgets p { margin: 0; line-height: 1.9; }
  .footer-widgets a {
    line-height: 1;
    display: inline-block;
    padding-bottom: 8px;
    color: #fff;
  }
  .footer-widgets a:hover { text-decoration: underline; text-underline-offset: 3px; }

  /* النشرة: حقل بخطّ سفلي فقط، وزرّ نصّي شفّاف جنبه */
  .footer-subscribe {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .footer-subscribe input[type='email'] {
    flex: 1;
    min-width: 0;
    height: 60px;
    border: 0;
    border-bottom: 2px solid #838889;
    border-radius: 0;
    padding: 3px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    transition: border-color 0.4s;
  }
  .footer-subscribe input[type='email']:focus {
    outline: none;
    border-color: #fff;
  }
  .footer-subscribe input[type='email']::placeholder { color: rgb(255 255 255 / 0.5); }
  .footer-subscribe button {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 14px;
    padding-inline: 10px 20px;
    cursor: pointer;
    white-space: nowrap;
  }
  .footer-subscribe button:hover { text-decoration: underline; text-underline-offset: 4px; }

  .site-footer .divider {
    border: 0;
    border-top: 1px solid rgb(255 255 255 / 0.22);
    margin: 0;
  }
  .footer-main {
    font-size: 14px;
    padding: 40px 0 35px;
    /* إزاحة 27px من جهة البداية عشان حقوق النشر تتحاذى مع كلمة اللوجو.
       الرقم ده هو الفراغ الفاضي جوّه صندوق الـSVG بتاع اللوجو بعد التصغير. */
    padding-inline-start: 27px;
  }



  /* ===== زرّ المنيو: شرائط بتتحوّل لعلامة ✕ ===== */
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 15px;
    transition: color 0.3s;
  }
  .menu-toggle__box {
    position: relative;
    display: block;
    width: 22px;
    height: 18px;
    flex: 0 0 auto;
  }
  .menu-toggle__bar {
    position: absolute;
    inset-inline: 0;
    height: 1.5px;
    background: currentColor;
    transition: transform 0.62s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.3s ease;
  }
  .menu-toggle__bar:nth-child(1) { top: 0; }
  .menu-toggle__bar:nth-child(2) { top: 8.25px; }
  .menu-toggle__bar:nth-child(3) { bottom: 0; }

  /* التسمية مطويّة وبتتفرد مع الفتح */
  .menu-toggle__label {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.62s ease, opacity 0.4s ease 0.12s;
  }

  /* مفتوح: الزرّ بيتثبّت مكانه فوق اللوحة ولونه بيبقى داكن */
  .menu-toggle.is-open {
    position: fixed;
    top: calc(28px + env(safe-area-inset-top, 0px));
    inset-inline-start: var(--gutter);
    z-index: 95;
    color: var(--color-ink);
  }
  .menu-toggle.is-open .menu-toggle__bar:nth-child(1) {
    transform: translateY(8.25px) rotate(45deg);
  }
  .menu-toggle.is-open .menu-toggle__bar:nth-child(2) { opacity: 0; }
  .menu-toggle.is-open .menu-toggle__bar:nth-child(3) {
    transform: translateY(-8.25px) rotate(-45deg);
  }
  .menu-toggle.is-open .menu-toggle__label { max-width: 8rem; opacity: 1; }

  /* اللوحة بتبدأ تحت الزرّ عشان ما يغطّيش أول رابط */
  .menu-panel__body { padding-top: 76px; }


  /* ===== لوحة المنيو ===== */
  .menu-panel {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* بتفضل مركّبة وبتختفي بالشفافية عشان الخروج يتحرّك.
       visibility بتتأخّر لآخر الحركة فالمحتوى ما يفضلش قابلًا للنقر. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.62s ease, transform 0.62s cubic-bezier(0.2, 0.8, 0.3, 1),
      visibility 0s linear 0.62s;
  }
  .menu-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.62s ease, transform 0.62s cubic-bezier(0.2, 0.8, 0.3, 1),
      visibility 0s;
  }

  .menu-panel__body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    padding-inline: var(--gutter);
    padding-bottom: 40px;
  }
  @media (min-width: 900px) {
    .menu-panel__body { grid-template-columns: 1fr 1fr; gap: 60px; align-items: start; }
  }

  .menu-panel__nav ul { list-style: none; margin: 0; padding: 0; }
  .menu-panel__nav li { margin-bottom: 26px; }
  .menu-panel__nav a {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    color: var(--color-ink);
    display: inline-block;
    position: relative;   /* مرجع للشَرطة */
  }
  .menu-panel__nav a:hover { color: var(--color-brand); }

  /* شَرطة بتطلع جنب الرابط عند الهوفر — جهة البداية (يمين في RTL).
     بتتمدّ من اليمين ناحية الشمال: العرض ثابت والـscaleX هو اللي بيتحرّك
     من transform-origin على اليمين. */
  .menu-panel__nav a::before {
    content: "";
    position: absolute;
    inset-inline-end: 100%;
    margin-inline-end: 16px;
    top: 50%;
    width: 26px;
    height: 1.5px;
    background: currentColor;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 0.3s ease, opacity 0.2s ease;
  }
  .menu-panel__nav a:hover::before,
  .menu-panel__nav a:focus-visible::before {
    transform: scaleX(1);
    opacity: 1;
  }
  @media (min-width: 900px) {
    .menu-panel__nav { padding-inline-start: 8%; padding-top: 10px; }
    .menu-panel__nav a { font-size: 32px; }
    .menu-panel__nav li { margin-bottom: 34px; }
  }

  .menu-panel__image {
    min-height: 240px;
    background-size: cover;
    background-position: center;
  }
  @media (min-width: 900px) { .menu-panel__image { min-height: calc(100vh - 150px); } }

  /* عمود أيقونات التواصل على الطرف */
  .menu-panel__social {
    list-style: none;
    margin: 0;
    padding: 0 var(--gutter) 30px;
    display: flex;
    gap: 14px;
  }
  .menu-panel__social a {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgb(22 22 25 / 0.25);
    display: grid;
    place-items: center;
    color: var(--color-ink);
    transition: 0.3s;
  }
  .menu-panel__social a:hover {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: #fff;
  }
  @media (min-width: 900px) {
    .menu-panel__social {
      position: absolute;
      inset-inline-start: 18px;
      bottom: 70px;
      flex-direction: column;
      padding: 0;
    }
  }


  /* ===== لوحة البحث ===== */
  .search-panel {
    position: fixed;
    inset: 0;
    z-index: 96;
    background: #fff;
    /* اللوحة بتتركّب جوّه .site-header اللي لونه أبيض —
       من غير السطر ده النصّ بيطلع أبيض على أبيض */
    color: var(--color-ink);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* بتفضل مركّبة وبتختفي بالشفافية — نفس أسلوب لوحة المنيو */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.3, 1),
      visibility 0s linear 0.45s;
  }
  .search-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.3, 1),
      visibility 0s;
  }

  .search-panel__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 28px;
    font-size: 15px;
    font-weight: 500;
  }
  .search-panel__close {
    display: inline-flex;
    color: var(--color-ink);
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.3s;
  }
  .search-panel__close:hover { color: var(--color-brand); }

  /* الحقل في منتصف اللوحة زي الأصل */
  .search-panel__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-block: 40px;
    min-height: 0;
  }
  .search-panel__input {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--color-ink);
    background: transparent;
    padding: 0 0 14px;
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 300;
    color: var(--color-ink);
    outline: none;
  }
  @media (min-width: 900px) { .search-panel__input { font-size: 46px; } }
  .search-panel__input::placeholder { color: #b9bcbd; }
  /* زرّ المسح الأصلي بتاع المتصفّح بيبوّظ الشكل */
  .search-panel__input::-webkit-search-cancel-button { display: none; }

  .search-panel__status {
    margin-top: 18px;
    font-size: 14px;
    color: var(--color-muted);
    min-height: 20px;
  }


  /* ===== نتائج البحث داخل اللوحة — كروت منتجات زي الموقع المرجعي ===== */
  .search__results {
    display: grid;
    /* كروت صغيرة بعرض ثابت بدل ما تتمطّ على عرض اللوحة — عشان الصفّ
       الواحد يبان كله من غير تمرير، زي الموقع المرجعي */
    grid-template-columns: repeat(auto-fill, minmax(140px, 180px));
    justify-content: start;
    gap: 30px 24px;
    margin-top: 30px;
    max-height: 52vh;
    overflow-y: auto;
    padding-bottom: 8px;
  }
  /* الكارت في لوحة البحث مختصر: من غير أزرار ومن غير رفع عند المرور */
  .search__results .woocommerce-loop-product__title { font-size: 14px; }
  .search__results .loop-price { font-size: 14px; }
  .search__results .product-buttons { display: none; }
  .search__results .product-card:hover .product-summary { transform: none; }
  .search__results .product-summary { padding: 12px 0 0; }

  .search__all {
    display: inline-block;
    color: var(--color-ink);
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
    transition: color 0.3s;
  }
  .search__all:hover { color: var(--color-brand); }


  /* ===== الروابط السريعة ===== */
  .search-panel__quick { padding-bottom: 36px; }
  .search-panel__quick h2 {
    font-size: 15px;
    font-weight: 400;
    color: #b9bcbd;
    margin: 0 0 14px;
  }
  .search-panel__quick ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 42px;
  }
  .search-panel__quick a {
    font-size: 15px;
    color: var(--color-ink);
    transition: color 0.3s;
  }
  .search-panel__quick a:hover { color: var(--color-brand); }

}
