﻿:root {
  --color-bg: #fcf8fa;
  --color-surface: #ffffff;
  --color-surface-soft: #f6f2f5;
  --color-border: #e3bebb;
  --color-text: #1c1b1d;
  --color-text-soft: #5b403f;
  --color-primary: #98001b;
  --color-primary-strong: #be1e2d;
  --color-primary-on: #ffffff;
  --color-accent: #ffb55a;
  --color-accent-on: #4a2800;
  --color-secondary: #465d95;
  --color-secondary-strong: #364d84;
  --color-secondary-on: #ffffff;
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --topbar-h: 56px;
  --font-en: "Outfit", sans-serif;
  --font-ar: "Zain", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-en);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
}
html[lang="ar"] body { font-family: var(--font-ar); }

.skip-link {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  transform: translateY(-200%);
}
.skip-link:focus {
  inset-inline-start: 16px;
  top: 8px;
  transform: translateY(0);
  z-index: 1200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.topbar {
  position: fixed;
  inset-inline: 0;
  top: 0;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  z-index: 1000;
  transition: transform 180ms ease;
  width: 100%;
  max-width: 100vw;
}
.topbar.is-hidden { transform: translateY(-100%); }

.brand-wrap { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.store-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
}
.store-name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: var(--space-2); }
.icon-btn {
  min-width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.page-main {
  padding: calc(var(--topbar-h) + 52px + var(--space-2)) var(--space-4) 120px;
}
.chips-wrap {
  position: fixed;
  inset-inline: 0;
  top: var(--topbar-h);
  background: var(--color-bg);
  z-index: 900;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  transition: transform 180ms ease, top 180ms ease;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}
.chips-wrap.is-hidden { transform: translateY(-100%); }
.topbar.is-hidden + .page-main .chips-wrap { top: 0; }
.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface-soft);
  color: var(--color-text-soft);
  border-radius: 9999px;
  padding: 7px 14px;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}
.chip[aria-pressed="true"] {
  background: var(--color-primary-strong);
  color: var(--color-primary-on);
  border-color: var(--color-primary-strong);
}

.product-grid {
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.product-media {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--color-surface-soft);
  overflow: hidden;
}
.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-body { padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: var(--space-1); }
.brand { margin: 0; font-size: 0.8rem; color: var(--color-text-soft); }
.name { margin: 0; font-size: 0.95rem; font-weight: 600; min-height: 2.3em; }
.weight { margin: 0; font-size: 0.85rem; color: var(--color-text-soft); }
.product-foot { margin-top: var(--space-1); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.price { margin: 0; font-size: 1rem; font-weight: 700; color: var(--color-primary); }

.add-btn {
  border: 0;
  background: var(--color-secondary);
  color: var(--color-secondary-on);
  border-radius: var(--radius-sm);
  min-height: 32px;
  padding: 0 var(--space-2);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.add-btn:hover { background: var(--color-secondary-strong); }
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  overflow: hidden;
  min-height: 32px;
}
.stepper button {
  border: 0;
  background: var(--color-surface-soft);
  width: 30px;
  height: 32px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }

.empty-state { text-align: center; color: var(--color-text-soft); }

.cart-bar {
  position: fixed;
  bottom: var(--space-4);
  inset-inline: var(--space-4);
  z-index: 950;
  max-width: calc(100vw - (var(--space-4) * 2));
  overflow: hidden;
}
.cart-bar-btn {
  width: 100%;
  border: 1px solid var(--color-primary-strong);
  background: var(--color-primary-strong);
  color: var(--color-primary-on);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font: inherit;
}
.cart-bar-btn small { display: block; font-size: 0.85rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 21, 0.5);
  z-index: 1001;
}
.overlay[hidden],
.cart-drawer[hidden] {
  display: none;
}
.cart-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85dvh;
  background: var(--color-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  z-index: 1002;
  padding: 0 var(--space-4) var(--space-4);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-2);
}
.drawer-handle-wrap { display: flex; justify-content: center; padding: var(--space-2) 0; }
.drawer-handle { width: 48px; height: 6px; border-radius: 9999px; background: var(--color-border); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 0 0 var(--space-2); border-bottom: 1px solid var(--color-border); }
.drawer-head h2 { margin: 0; font-size: 1.2rem; }
.drawer-items { overflow: auto; display: grid; gap: var(--space-2); padding-top: var(--space-2); }
.cart-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  background: var(--color-surface);
}
.cart-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-soft);
  flex: 0 0 64px;
}
.cart-item-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.cart-item h3 { margin: 0; font-size: 0.95rem; }
.cart-item p { margin: 0; color: var(--color-text-soft); font-size: 0.85rem; }
.cart-item-total { font-weight: 700; color: var(--color-primary); }
.subtotal { margin: 0; font-weight: 700; }
.note { margin: 0; font-size: 0.85rem; color: var(--color-text-soft); }
.district-label { font-size: 0.85rem; color: var(--color-text-soft); }
.district-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 var(--space-2);
  font: inherit;
}
.order-btn {
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-primary-strong);
  color: var(--color-primary-on);
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--space-2);
}
.drawer-foot {
  display: grid;
  gap: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}
.summary-box {
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  display: grid;
  gap: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid #465d95;
  outline-offset: 2px;
}

@media (min-width: 700px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-media { aspect-ratio: 1 / 1; }
}
@media (max-width: 700px) {
  .product-foot {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .product-foot [data-controls] {
    width: 100%;
    display: block;
  }
  .product-foot .add-btn,
  .product-foot .stepper {
    width: 100%;
    justify-content: center;
  }
  .cart-item {
    align-items: flex-start;
  }
}
@media (max-width: 360px) {
  .page-main { padding-inline: var(--space-3); }
  .product-grid { gap: var(--space-2); }
  .product-body { padding-inline: var(--space-2); }
  .name { font-size: 0.9rem; }
  .store-name { font-size: 0.92rem; }
}
@media (min-width: 1024px) {
  .page-main { max-width: 1280px; margin: 0 auto; }
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cart-drawer {
    left: 50%;
    right: auto;
    width: min(560px, 92vw);
    transform: translateX(-50%);
    border-radius: var(--radius-lg);
    bottom: var(--space-4);
    border: 1px solid var(--color-border);
  }
}
@media (min-width: 1320px) {
  .product-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
