/* =========================================
   ONE STEP — nav-menu.css
   القائمة الجانبية (الهامبرغر) — نظام تنقل عام لكل الموقع
   يعتمد بالكامل على متغيرات css/style.css (لا ألوان/خطوط جديدة)
========================================= */

/* ===== HAMBURGER BUTTON (reuses .nav-icon sizing/hover from style.css) ===== */
.menu-toggle { position: relative; }
.hamburger-box {
  position: relative;
  display: inline-block;
  width: 19px;
  height: 13px;
}
.hamburger-line {
  position: absolute;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.3s ease, opacity 0.25s ease, top 0.3s ease;
}
.hamburger-line:nth-child(1) { top: 0; }
.hamburger-line:nth-child(2) { top: 5.5px; }
.hamburger-line:nth-child(3) { top: 11px; }
.menu-toggle.open .hamburger-line:nth-child(1) { top: 5.5px; transform: rotate(45deg); }
.menu-toggle.open .hamburger-line:nth-child(2) { opacity: 0; }
.menu-toggle.open .hamburger-line:nth-child(3) { top: 5.5px; transform: rotate(-45deg); }

/* ===== OVERLAY ===== */
.side-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 23, 62, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 250;
}
.side-menu-overlay.open { opacity: 1; pointer-events: auto; }

/* ===== DRAWER (slides in from the left — same motion language as .cart-drawer) ===== */
.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  max-width: 85vw;
  height: 100%;
  height: 100dvh;
  background: var(--white);
  z-index: 251;
  transform: translateX(-100%);
  /* ⚠️ visibility ليست تجميلاً — هي ما يُخرج المحتوى المغلق من ترتيب التنقل
     بلوحة المفاتيح ومن شجرة الإتاحة. الإزاحة بـtransform وحدها تُبقي كل رابط
     وزرّ داخل القائمة **قابلاً للوصول بـTab** وهو خارج الشاشة تماماً: يختفي
     مؤشّر التركيز من عين المستخدم فيتيه بين عناصر لا يراها. وaria-hidden لا
     يعالج ذلك — بل يجعله مخالفةً صريحة (عنصر قابل للتركيز داخل aria-hidden).
     تُنقَل إلى hidden **بعد** انتهاء الانزلاق (تأخير = مدة الانتقال) كي تبقى
     حركة الإغلاق مرئية كما كانت بالضبط. */
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0.35s;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);
}
/* مفتوحة: تظهر فوراً بلا تأخير (التأخير أعلاه للإغلاق وحده) فينزلق الدرج
   وهو مرئيّ من أول إطار، ويعود محتواه إلى ترتيب التنقل بلوحة المفاتيح. */
.side-menu.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s linear 0s;
}

/* ===== HEADER (identity) ===== */
.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px;
  background: var(--navy);
  flex-shrink: 0;
}
.side-menu-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: #fff;
  flex: 1;
}
.side-menu-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.side-menu-user-text { min-width: 0; }
.side-menu-user-name {
  font-size: 14.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu-user-email {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu-close {
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.side-menu-close:hover { background: rgba(255, 255, 255, 0.26); }

/* ===== BODY / SECTIONS ===== */
.side-menu-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0 10px;
}
.side-menu-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.side-menu-section:last-child { border-bottom: none; }
.side-menu-section-title {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--muted);
  padding: 6px 12px 8px;
}

.side-menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 11px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.side-menu-link:hover { background: var(--gray); color: var(--navy); }
.side-menu-link.active { background: var(--navy); color: #fff; }
.side-menu-link.active .side-menu-icon { color: #fff; }

.side-menu-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
}
.side-menu-icon svg { width: 20px; height: 20px; }

.side-menu-label { flex: 1; min-width: 0; }

.side-menu-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  /* --green-d text on this 14%-tint background measures ~2.5:1 — fails AA
     for this small (10.5px) text. --navy on the same tint measures ~16:1. */
  color: var(--navy);
  background: rgba(120, 199, 103, 0.14);
  padding: 4px 10px;
  border-radius: 14px;
}

/* Logout item reuses the exact destructive-action colors from .account-nav-item.logout */
.side-menu-link.logout-link { color: #c0392b; }
.side-menu-link.logout-link .side-menu-icon { color: #c0392b; }
.side-menu-link.logout-link:hover { background: #fdecec; }

/* ===== FOOTER ===== */
.side-menu-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--muted);
}

/* ===== SCROLL LOCK ===== */
html.side-menu-locked { overflow: hidden; }

/* ===== SMALL SCREENS ===== */
@media (max-width: 380px) {
  .side-menu { width: 88vw; }
  .side-menu-header { padding: 16px; }
}

/* iOS safe area: القائمة الجانبية ملء الشاشة */
.side-menu {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}

/* ===== تقليل الحركة — احترام prefers-reduced-motion (PRODUCT.md §الإتاحة) =====
   المستخدم الذي يطلب تقليل الحركة (نظام التشغيل) تصبح كل الانتقالات/الحركات
   لحظية فعلياً بدل إلغائها — لا تُفقد أي وظيفة، فقط تختفي الحركة. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* ⚠️ القاعدة العامة تُصفّر المدّة لا **التأخير**. بدون هذا السطر يبقى تأخير
     إخفاء القائمة ‎0.35s‎ بينما صار الانزلاق لحظياً: درجٌ مغلق بصرياً وما يزال
     محتواه في شجرة الإتاحة ثلث ثانية. التأخير هنا يتبع المدّة إلى الصفر. */
  .side-menu { transition-delay: 0s !important; }
}
