/* core/styles/base.css: أساس الشكل. كيستعمل غير tokens ديال theme.css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--f-body); font-size: var(--fs-md); line-height: 1.55;
  color: var(--c-ink); background: var(--c-bg); -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; letter-spacing: -.015em; margin: 0; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- شريط الإعلان (غير Livraison offerte، ولا المتجر مغلق) ---------- */
.announce {
  background: var(--c-ink); color: var(--c-on-ink); text-align: center;
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: .01em; padding: 8px var(--gutter);
}
.announce:empty { display: none; }
.announce--closed { background: var(--c-danger); color: #fff; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
}
.hdr-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: var(--header-h); }
.hdr-left { grid-column: 1; display: flex; align-items: center; margin-left: -10px; min-width: 0; }
.hdr-nav { display: flex; gap: 24px; font-size: var(--fs-sm); margin-left: 14px; }
.hdr-nav a { position: relative; padding: 6px 0; }
.hdr-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.hdr-brand { grid-column: 2; justify-self: center; display: inline-flex; align-items: center; }
.hdr-name { white-space: nowrap; font-family: var(--f-display); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }
.hdr-logo { height: 38px; width: auto; }
.hdr-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 2px; margin-right: -10px; }
.hdr-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: none; border: 0; padding: 0; border-radius: 50%; }
.hdr-icon:hover { background: var(--c-soft); }
.hdr-count {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--c-accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
@media (max-width: 899px) { .hdr-nav { display: none; } .hdr-logo { height: 32px; } }

/* التابات ديال الأصناف الكبار */
.hdr-tabs { border-bottom: 1px solid var(--c-line); background: var(--c-bg); }
.hdr-tabs-in { display: flex; justify-content: space-between; gap: 20px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hdr-tabs-in::-webkit-scrollbar { display: none; }
.hdr-tabs a { position: relative; flex: none; padding: 10px 0 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--c-ink-soft); }
.hdr-tabs a::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--c-accent); transform: scaleX(0); transition: transform var(--t) var(--ease); }
.hdr-tabs a:hover { color: var(--c-ink); }
.hdr-tabs a[aria-current="page"] { color: var(--c-ink); }
.hdr-tabs a[aria-current="page"]::after { transform: scaleX(1); }
@media (min-width: 600px) { .hdr-tabs-in { justify-content: center; gap: 36px; } }
@media (min-width: 900px) { .hdr-tabs-in { gap: 40px; } }

/* ---------- Menu (drawer) بحال Kiabi ---------- */
html.no-scroll, html.no-scroll body { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: var(--z-drawer); }
.drawer[hidden] { display: none; }
.drawer-overlay { position: absolute; inset: 0; background: var(--c-overlay); opacity: 0; transition: opacity var(--t); }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(100vw, 420px); display: flex; flex-direction: column;
  background: var(--c-bg); padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateX(-102%); transition: transform var(--t) var(--ease); }
.drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); padding: 0 var(--gutter); flex: none; border-bottom: 1px solid var(--c-line); }
.drawer-title { font-size: var(--fs-md); font-weight: 600; }
.drawer-close { width: 40px; height: 40px; margin-right: -4px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--c-ink); color: var(--c-on-ink); }
.dm-views { position: relative; flex: 1; overflow: hidden; }
.dm-main, .dm-sub { position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; background: var(--c-bg); transition: transform var(--t) var(--ease); }
.dm-sub { transform: translateX(100%); }
.dm-sub[hidden] { display: none; }
.sub-on .dm-main { transform: translateX(-30%); }
.sub-on .dm-sub { transform: none; }
.dm-banner { position: relative; display: block; margin: 16px var(--gutter) 6px; aspect-ratio: 2.1 / 1; border-radius: var(--radius-lg); overflow: hidden; background: var(--c-ink); flex: none; }
.dm-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dm-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0) 60%); }
.dm-banner-t { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 1; color: #fff; font-size: var(--fs-md); font-weight: 600; }
.dm-list { display: flex; flex-direction: column; padding: 6px var(--gutter) 16px; }
.dm-row { display: grid; grid-template-columns: 52px 1fr 18px; gap: 16px; align-items: center; width: 100%; padding: 9px 0; background: none; border: 0; text-align: left; color: var(--c-ink); }
.dm-row > svg { color: var(--c-muted); }
.dm-row:hover .dm-l { text-decoration: underline; text-underline-offset: 4px; }
.dm-th { width: 52px; height: 52px; border-radius: var(--radius); background: var(--c-soft); overflow: hidden; display: block; }
.dm-th img { width: 100%; height: 100%; object-fit: cover; }
.dm-row[data-all] .dm-th:empty, .dm-row[data-shop] .dm-th { background: var(--c-ink); }
.dm-l { font-size: var(--fs-md); font-weight: 500; }
.dm-subhead { display: flex; align-items: center; gap: 6px; padding: 10px var(--gutter) 0; font-size: var(--fs-lg); font-weight: 600; flex: none; }
.dm-back { width: 40px; height: 40px; margin-left: -10px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: none; }
.dm-back:hover { background: var(--c-soft); }
.dm-empty { color: var(--c-muted); font-size: var(--fs-sm); padding: 8px 0; }
.drawer-contact { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 20px var(--gutter) 24px; font-size: var(--fs-sm); color: var(--c-muted); border-top: 1px solid var(--c-line); }
.drawer-contact a:hover { color: var(--c-ink); }

/* ---------- المحتوى ---------- */
#app { min-height: 70vh; }

/* ---------- Footer ---------- */
.site-footer { visibility: hidden; background: var(--c-bg); color: var(--c-ink); margin-top: 80px; border-top: 1px solid var(--c-line); position: relative; }
.is-ready .site-footer { visibility: visible; }
.ftr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 32px; padding-top: 48px; padding-bottom: 36px; }
.ftr-brand { font-family: var(--f-display); font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.ftr-brand .hdr-logo { height: 36px; margin-left: -4px; }
.ftr-title { font-size: var(--fs-sm); font-weight: 500; margin-bottom: 10px; }
.ftr-col { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-sm); }
.ftr-col p { margin: 0; color: var(--c-muted); max-width: 32ch; }
.ftr-col a, .ftr-col span { color: var(--c-muted); transition: color var(--t-fast); width: fit-content; }
.ftr-col a:hover { color: var(--c-ink); }
.ftr-bottom {
  position: relative; border-top: 1px solid var(--c-line); padding: 18px var(--gutter);
  text-align: center; font-size: var(--fs-xs); color: var(--c-muted);
  display: flex; flex-direction: column; gap: 4px;
}
.footer-devby a { color: var(--c-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--c-line-strong); }
.footer-devby a:hover { text-decoration-color: var(--c-ink); }

/* ---------- Skeleton ---------- */
#skeleton > [data-sk] { display: none; }
html[data-route="home"] #skeleton > [data-sk="home"],
html[data-route="shop"] #skeleton > [data-sk="shop"],
html[data-route="product"] #skeleton > [data-sk="product"],
html[data-route="cart"] #skeleton > [data-sk="form"],
html[data-route="checkout"] #skeleton > [data-sk="form"],
html[data-route="order"] #skeleton > [data-sk="text"],
html[data-route="page"] #skeleton > [data-sk="text"],
html[data-route="notfound"] #skeleton > [data-sk="notfound"] { display: block; }

.sk {
  background: linear-gradient(90deg, var(--sk-base) 25%, var(--sk-shine) 50%, var(--sk-base) 75%);
  background-size: 200% 100%; animation: sk-shine 1.3s linear infinite; border-radius: var(--radius);
}
@keyframes sk-shine { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

.sk-section { padding-top: 32px; }
.sk-narrow { max-width: 640px; }
.sk-hero { height: clamp(320px, 62vh, 620px); border-radius: 0; }
.sk-title { height: 30px; width: 55%; margin-bottom: 20px; }
.sk-bar { height: 44px; margin-bottom: 14px; }
.sk-btn { height: 52px; margin-top: 20px; }
.sk-line { height: 14px; margin: 10px 0 0; }
.sk-line.short { width: 40%; }
.sk-img { aspect-ratio: 3 / 4; }
.sk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 2px; margin-top: 16px; }
@media (min-width: 768px) { .sk-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .sk-grid { grid-template-columns: repeat(4, 1fr); } }
.sk-hm { height: clamp(150px, 22vw, 240px); border-radius: var(--radius-lg); margin-top: 16px; }
.sk-bento { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: clamp(110px, 30vw, 200px); gap: 10px; margin-top: 28px; }
.sk-bento .sk:first-child { grid-row: span 2; }
@media (min-width: 900px) { .sk-bento { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 280px; } .sk-bento .sk:first-child { grid-row: auto; } }
.sk-circs { display: flex; gap: 14px; margin-bottom: 26px; overflow: hidden; }
.sk-circs .sk { flex: none; width: 64px; height: 64px; border-radius: 50%; }
.sk-chips { display: flex; gap: 8px; margin-top: 18px; }
.sk-chip { height: 38px; width: 84px; border-radius: 999px; }
.sk-product { display: grid; gap: 28px; }
@media (min-width: 768px) { .sk-product { grid-template-columns: 1.1fr 1fr; gap: 48px; } }
.nf h1 { font-size: var(--fs-xl); margin-bottom: 12px; }
.nf a { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Router ---------- */
#skeleton.is-hidden { display: none; }
#view[hidden] { display: none; }
.page-msg { padding-top: 64px; padding-bottom: 32px; text-align: center; }
.page-msg h1 { font-size: var(--fs-xl); margin-bottom: 12px; }
.page-msg p { color: var(--c-muted); }
.page-msg a { text-decoration: underline; text-underline-offset: 4px; color: var(--c-ink); }
.btn { font: 500 var(--fs-sm) var(--f-body); letter-spacing: .01em; padding: 15px 30px; border: 1px solid var(--c-ink); background: var(--c-ink); color: var(--c-on-ink); border-radius: var(--radius-btn); transition: background var(--t) var(--ease), color var(--t) var(--ease), opacity var(--t); }
.btn:hover { background: transparent; color: var(--c-ink); }

/* ---------- Debug ---------- */
.dbg {
  position: fixed; left: 8px; bottom: 8px; z-index: var(--z-toast); padding: 10px 12px;
  background: var(--glass-bg-dark); color: var(--c-on-ink); font: 12px/1.5 monospace;
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
}

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--c-ink); color: var(--c-on-ink); padding: 12px 22px; border-radius: 999px; font-size: var(--fs-sm); z-index: var(--z-toast); max-width: 90vw; text-align: center;
  transition: opacity var(--t), transform var(--t); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 767px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
.btn-ghost { background: transparent; color: var(--c-ink); }
.btn-ghost:hover { background: var(--c-ink); color: var(--c-on-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }