/* ============================================================
   Butikette by Layal — design system
   Mobile-first. Tokens from AGENTS.md §8.1.
   ============================================================ */

:root {
  --cream: #FAF8F5;
  --sand: #F2ECE4;
  --espresso: #231F20;
  --gold: #B8965A;
  --gold-dark: #9A7C46;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(35,31,32,.08);
  --font-latin: 'Inter', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Cairo', 'Inter', system-ui, sans-serif;
  --max-width: 1080px;
  --header-h: 60px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--espresso);
  font-family: var(--font-latin);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body,
[dir="rtl"] { font-family: var(--font-arabic); }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 8px;
  background: var(--espresso); color: var(--cream);
  padding: 10px 16px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { inset-inline-start: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--cream);
  border-bottom: 1px solid var(--sand);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: .2px;
  white-space: nowrap;
}
.logo .accent { color: var(--gold-dark); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative;
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
}
.icon-btn:hover { background: var(--sand); }
.cart-count {
  position: absolute; top: 2px; inset-inline-end: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--gold); color: #fff;
  border-radius: 999px; font-size: .68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.lang-toggle {
  display: inline-flex; border: 1px solid var(--sand); border-radius: 999px; overflow: hidden;
}
.lang-toggle a {
  padding: 8px 14px; font-size: .85rem; font-weight: 600; min-height: 40px; display: inline-flex; align-items: center;
}
.lang-toggle a[aria-current="true"] { background: var(--espresso); color: var(--cream); }

/* ---------- Promo banner ---------- */
.promo-banner {
  background: var(--espresso); color: var(--cream);
  text-align: center;
  padding: 8px 40px 8px 40px;
  font-size: .82rem;
  position: relative;
}
.promo-banner a { color: var(--gold); text-decoration: underline; }
.promo-close {
  position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--cream); font-size: 1rem; cursor: pointer; min-width: 32px; min-height: 32px;
}

/* ---------- Layout ---------- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }
.section { padding: 28px 0; }
.section-title { font-size: 1.4rem; margin: 0 0 14px; font-weight: 700; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(160deg, var(--sand) 0%, var(--cream) 70%);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  margin: 16px 0;
}
.hero h1 { font-size: 1.9rem; margin: 0 0 10px; line-height: 1.2; }
.hero p { margin: 0 auto 18px; max-width: 420px; opacity: .85; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  border-radius: 12px; border: none; cursor: pointer;
  background: var(--espresso); color: var(--cream);
  font-weight: 600; font-size: .95rem;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { background: #3a3436; transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }
.btn-outline { background: transparent; color: var(--espresso); border: 1px solid var(--espresso); }
.btn-outline:hover { background: var(--sand); }

/* ---------- Category tiles ---------- */
.cat-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; }
.cat-row::-webkit-scrollbar { display: none; }
.cat-tile {
  flex: 0 0 108px;
  background: var(--sand); border-radius: var(--radius);
  padding: 16px 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 108px; justify-content: center;
  border: 1px solid transparent;
}
.cat-tile:hover, .cat-tile[aria-current="true"] { border-color: var(--gold); }
.cat-tile .icon { font-size: 1.7rem; }
.cat-tile .name { font-size: .8rem; font-weight: 600; }

/* ---------- Product grid ---------- */
.product-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1080px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

.product-card {
  background: var(--sand);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--sand);
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-img {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--sand);
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-badge {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: var(--gold); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.card-sale-pct {
  position: absolute; top: 10px; inset-inline-end: 10px;
  background: var(--espresso); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-weight: 700; font-size: .95rem; margin: 0; line-height: 1.3; }
.card-sizes { display: flex; gap: 6px; align-items: center; font-size: .68rem; color: #6b6669; }
.size-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); border: 1px solid var(--cream); box-shadow: 0 0 0 1px var(--sand); }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price-now { font-weight: 700; font-size: 1.05rem; }
.price-now.sale { color: var(--gold-dark); }
.price-was { color: #9b9598; text-decoration: line-through; font-size: .85rem; }
.countdown-pill {
  font-size: .72rem; color: var(--gold-dark); font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.countdown-pill.expired { display: none; }

/* ---------- Filters ---------- */
.filters-bar { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; background: var(--cream); position: sticky; top: var(--header-h); z-index: 40; border-bottom: 1px solid var(--sand); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 38px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--sand); background: var(--sand);
  font-size: .82rem; font-weight: 600; cursor: pointer;
}
.chip[aria-current="true"] { background: var(--espresso); color: var(--cream); border-color: var(--espresso); }
.filters-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.select-wrap select {
  min-height: 42px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--sand); background: var(--sand);
}
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--gold); }
.clear-filters { background: none; border: none; color: var(--gold-dark); font-weight: 600; cursor: pointer; font-size: .82rem; min-height: 38px; padding: 0 4px; }

/* ---------- Product detail ---------- */
.product-detail { display: grid; gap: 20px; padding: 16px 0; }
@media (min-width: 768px) { .product-detail { grid-template-columns: 1.1fr 1fr; gap: 32px; } }
.gallery {
  aspect-ratio: 3 / 4; background: var(--sand); border-radius: var(--radius); overflow: hidden; position: relative;
}
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { font-size: 1.6rem; margin: 0 0 6px; }
.detail-price { font-size: 1.4rem; font-weight: 700; margin: 8px 0; display: flex; gap: 10px; align-items: baseline; }
.detail-price .sale { color: var(--gold-dark); }
.detail-desc { color: #4a4548; margin: 0 0 16px; }
.detail-options { display: flex; flex-direction: column; gap: 14px; }
.size-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.size-chip {
  min-height: 44px; min-width: 48px; padding: 10px 16px; border-radius: 12px;
  border: 1.5px solid var(--sand); background: var(--sand); font-weight: 600; cursor: pointer;
}
.size-chip[aria-pressed="true"] { border-color: var(--espresso); background: var(--espresso); color: var(--cream); }
.size-chip:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.color-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.color-chip {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--cream); box-shadow: 0 0 0 1px var(--sand); cursor: pointer;
}
.color-chip[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--espresso); }

/* ---------- Cart drawer (fixed off-canvas: bottom sheet on mobile, right/left side panel on desktop) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(35,31,32,.45); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.cart-drawer {
  position: fixed; z-index: 95;
  background: var(--cream);
  display: flex; flex-direction: column;
  /* Mobile default: bottom sheet, hidden by sliding fully below the viewport */
  bottom: 0;
  inset-inline: 0;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform .3s ease;
  box-shadow: 0 -12px 40px rgba(35,31,32,.18);
}
@media (min-width: 768px) {
  /* Desktop: side panel pinned to the trailing edge (right in LTR, left in RTL),
     hidden by sliding fully out of view on that same edge. */
  .cart-drawer {
    top: 0; bottom: 0;
    height: 100vh; max-height: none;
    inset-inline: auto;
    inset-inline-end: 0;
    width: 420px; max-width: 92vw;
    border-radius: 0;
    transform: translateX(100%);
  }
  [dir="rtl"] .cart-drawer { transform: translateX(-100%); }
}
.cart-drawer.open { transform: translate(0, 0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--sand); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--sand); display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; gap: 12px; align-items: center; position: relative; }
.cart-item-img { width: 64px; height: 84px; border-radius: 10px; background: var(--sand); overflow: hidden; flex-shrink: 0; }
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-info .name { font-weight: 600; font-size: .88rem; }
.cart-item-info .meta { font-size: .75rem; color: #6b6669; }
.cart-item-remove {
  position: absolute; top: -6px; inset-inline-end: -6px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--sand); background: var(--sand); color: var(--espresso);
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.cart-item-remove:hover { background: var(--espresso); color: var(--cream); }
.qty-controls { display: inline-flex; align-items: center; gap: 8px; }
.qty-controls button { min-width: 32px; min-height: 32px; border-radius: 8px; border: 1px solid var(--sand); background: var(--sand); cursor: pointer; }
.empty-cart { text-align: center; padding: 36px 0; opacity: .75; }

/* ---------- Footer ---------- */
.site-footer { background: var(--espresso); color: var(--cream); padding: 28px 16px 36px; margin-top: 32px; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.footer-inner a { color: var(--gold); }
.footer-inner .muted { opacity: .75; font-size: .85rem; }

/* ---------- Forms (checkout + accounts) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .85rem; font-weight: 600; }
.field input, .field select, .field textarea {
  min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--sand); border-radius: 10px;
  background: var(--sand); color: var(--espresso);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--gold); outline-offset: 1px;
}
.checkout-block {
  border: 1px solid var(--sand); border-radius: var(--radius);
  background: var(--cream); padding: 16px; margin: 0 0 16px;
}
.checkout-block legend { font-weight: 700; font-size: 1rem; padding-inline: 6px; }
.checkout-submit { width: 100%; position: sticky; bottom: 12px; }
.pay-option {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--sand); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; cursor: pointer;
  min-height: 44px;
}
.pay-option input { margin-top: 6px; accent-color: var(--gold); }
.pay-option:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.summary-line { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; padding: 4px 0; }
.summary-line.total-row { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--sand); margin-top: 6px; padding-top: 8px; }
.form-error {
  background: rgba(178, 58, 72, .1); color: #8f2934;
  border: 1px solid rgba(178, 58, 72, .35);
  border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px;
}
.form-success {
  background: rgba(62, 95, 74, .1); color: #31493a;
  border: 1px solid rgba(62, 95, 74, .3);
  border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px;
}
.auth-form { display: flex; flex-direction: column; gap: 0; }
.auth-form .field:last-of-type { margin-bottom: 16px; }
.logout-form { display: inline; }
.account-link { position: relative; }
.account-name {
  position: absolute; bottom: 2px; inset-inline-end: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold); color: #fff;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Orders (thank-you + my orders) ---------- */
.order-card {
  background: var(--sand); border: 1px solid var(--sand);
  border-radius: var(--radius); padding: 16px;
}
.order-card.order-row { display: block; margin-bottom: 12px; transition: transform .15s ease, box-shadow .15s ease; }
.order-card.order-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.order-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
.status-chip {
  background: var(--cream); border: 1px solid var(--sand);
  border-radius: 999px; padding: 3px 10px;
  font-size: .72rem; font-weight: 700;
}
.status-chip.status-payment { background: var(--gold); color: #fff; border-color: var(--gold); }
.orders-list { display: flex; flex-direction: column; }

/* ---------- Misc ---------- */
.muted { color: #6b6669; }
.badge-sale { background: var(--gold); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 3px 10px; display: inline-block; }
.badge-out { background: #eee; color: #666; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 3px 10px; display: inline-block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
