/* ============================================================
   ویترین فروشگاه — سبک دیجی‌کالا (هدر با جست‌وجو، دایره‌های دسته‌بندی، نوار افقی محصولات،
   کارت محصول تمیز، ناوبری پایین موبایل، فوتر آکاردئونی).
   - فقط از توکن‌های قالب (--ink, --ink-light, --surface, --border, --text, --muted) استفاده می‌کند؛ با همه‌ی قالب‌ها و حالت تیره سازگار است.
   - بعد از storefront-ui.css و dark.css لود می‌شود؛ انتخابگرها با `body.ui[class]` اولویت لازم را دارند.
   ============================================================ */
body.ui[class] {
  /* classic/leather/minimal تعریف‌کننده‌ی --ink‌اند؛ ۱۳ تم دیگر --brand/--brand-dark دارند؛ رنگ برند فروشنده (inline) --ink را بازنویسی می‌کند */
  --dg-pri: var(--ink, var(--brand, #1e3555));
  --dg-pri2: var(--ink-light, var(--brand-dark, var(--dg-pri)));
  --dg-ink: var(--dg-pri);   /* رنگ برند برای متن/حاشیه/آیکن؛ در حالت تیره روشن می‌شود تا روی زمینه‌ی تیره دیده شود (گرادیان‌ها همان --dg-pri می‌مانند) */
  --dg-surf: var(--surface, #fff);
  --dg-line: var(--border, #e3e3e6);
  --dg-soft: var(--surface-alt, #f0f0f2);
  --dg-red: #ef394e;
  --dg-r: var(--ui-radius, 12px);
}
.dg-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- هدر ---------- */
body.ui[class] .shop-header.dg-header { background: var(--dg-surf); background-image: none; color: var(--text); padding: 10px 0 12px; box-shadow: 0 1px 0 var(--dg-line); }
body.ui[class] .shop-header.dg-header .container.dg-hdr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 16px; flex-wrap: nowrap; }
body.ui[class] .dg-hdr > .hdr-regions { grid-column: 1 / -1; }
.dg-brand { display: flex; align-items: center; gap: 10px; color: inherit; min-width: 0; }
body.ui[class] .dg-header .logo-img { height: 40px; width: auto; max-width: 140px; border-radius: 8px; background: transparent; box-shadow: none; }
.dg-name { font-size: 1.05rem; font-weight: 800; color: var(--dg-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
body.ui[class] .dg-header .hdr-name { color: var(--dg-ink); font-weight: 800; }
body.ui[class] .dg-header .hdr-desc, body.ui[class] .dg-header .contact { color: var(--muted); }
.dg-search { position: relative; width: 100%; max-width: 640px; margin: 0 auto; }
.dg-search input { width: 100%; font: inherit; font-size: .92rem; color: var(--text); background: var(--dg-soft); border: 1px solid transparent; border-radius: 12px; padding: 11px 44px 11px 14px; outline: 0; transition: border-color .15s, background .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
.dg-search input::placeholder { color: var(--muted); }
.dg-search input:focus { background: var(--dg-surf); border-color: var(--dg-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dg-ink) 14%, transparent); }
.dg-search-ico { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; pointer-events: none; }
.dg-search-row { padding-top: 10px; }
.dg-actions { display: flex; align-items: center; gap: 4px; }
body.ui[class] .dg-header .cart-link, .dg-act { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: transparent; border: 0; color: var(--text); font-weight: 600; font-size: .86rem; }
body.ui[class] .dg-header .cart-link:hover, .dg-act:hover { background: var(--dg-soft); }
body.ui[class] .dg-header .cart-count { position: absolute; top: 0; inset-inline-start: 2px; min-width: 18px; height: 18px; font-size: .68rem; padding: 0 4px; background: var(--dg-red); color: #fff; }
body.ui[class] .dg-header .cart-count[hidden] { display: none; }

/* ناوبری ثانویه */
body.ui[class] .site-nav { background: var(--dg-surf); }
body.ui[class] .site-nav a { font-size: .86rem; font-weight: 600; }
body.ui[class] .site-nav a.active { color: var(--dg-ink); border-bottom-color: var(--dg-ink); }
body.ui[class] .category-nav { border-radius: 0; }

/* ---------- هیرو ---------- */
.dg-hero { margin: 4px 0 6px; }
body.ui[class] .dg-hero-img { width: 100%; height: auto; aspect-ratio: 16 / 7; max-height: 380px; object-fit: cover; border-radius: var(--dg-r); display: block; }
.dg-hero-card, body.ui[class] .home-hero-fallback.dg-hero-card { background: linear-gradient(135deg, var(--dg-pri), var(--dg-pri2)); color: #fff; border-radius: var(--dg-r); padding: 34px 28px; text-align: start; }
.dg-hero-card h1 { margin: 0 0 8px; font-size: 1.7rem; font-weight: 800; color: inherit; }
.dg-hero-card p { margin: 0 0 18px; opacity: .9; max-width: 560px; }

/* ---------- دسته‌بندی‌ها ---------- */
.dg-cats { margin: 14px 0 4px; }
.dg-cats-track { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; scroll-snap-type: x proximity; }
.dg-cats-track::-webkit-scrollbar { display: none; }
.dg-cat { flex: 0 0 76px; text-align: center; scroll-snap-align: start; color: var(--text); }
.dg-cat-ic { width: 62px; height: 62px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; color: #fff; transition: transform .15s; }
.dg-cat:hover .dg-cat-ic { transform: translateY(-2px); }
.dg-cat-all { background: var(--dg-soft); color: var(--dg-ink); }
.dg-cat-all .dg-ico { width: 26px; height: 26px; }
.dg-c0 { background: linear-gradient(135deg, #14b8a6, #0d9488); } .dg-c1 { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.dg-c2 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); } .dg-c3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.dg-c4 { background: linear-gradient(135deg, #3b82f6, #2563eb); } .dg-c5 { background: linear-gradient(135deg, #22c55e, #16a34a); }
.dg-cat-n { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .76rem; font-weight: 600; line-height: 1.5; }

/* ---------- نوار افقی محصولات ---------- */
.dg-rail { background: linear-gradient(135deg, var(--dg-pri), var(--dg-pri2)); border-radius: calc(var(--dg-r) + 4px); margin: 18px 0; padding: 14px 0 16px; color: #fff; }
.dg-rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 10px; }
.dg-rail-head h2 { margin: 0; font-size: 1.1rem; font-weight: 800; color: #fff; }
.dg-more { display: inline-flex; align-items: center; gap: 2px; font-size: .84rem; font-weight: 600; color: #fff; opacity: .95; }
.dg-more .dg-ico { width: 18px; height: 18px; }
.dg-rail-wrap { position: relative; }
.dg-rail-track { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.dg-rail-track::-webkit-scrollbar { display: none; }
.dg-rail .dg-card { flex: 0 0 168px; scroll-snap-align: start; }
.dg-rail-btn { position: absolute; top: 40%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--dg-surf); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; display: none; place-items: center; }
.dg-rail-btn[hidden] { display: none !important; }
.dg-prev { inset-inline-start: 8px; } .dg-next { inset-inline-end: 8px; }

/* ---------- بلوک‌ها ---------- */
.dg-block-head { display: flex; align-items: center; justify-content: space-between; }
body.ui[class] .section-title { font-size: 1.1rem; font-weight: 800; margin: 24px 0 12px; color: var(--text); position: relative; padding-inline-start: 12px; }
body.ui[class] .section-title::before { content: ""; position: absolute; inset-inline-start: 0; top: 18%; bottom: 18%; width: 4px; border-radius: 4px; background: var(--dg-ink); }
.dg-morewrap { text-align: center; margin: 6px 0 24px; }
.dg-about, body.ui[class] .home-about-teaser { background: var(--dg-surf); border: 1px solid var(--dg-line); border-radius: var(--dg-r); padding: 6px 20px 20px; margin-top: 18px; }

/* ---------- گرید و کارت محصول ---------- */
body.ui[class] .product-grid.dg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-bottom: 28px; }
.dg-card, body.ui[class] .product-card.dg-card { display: flex; flex-direction: column; background: var(--dg-surf); border: 1px solid var(--dg-line); border-radius: var(--dg-r); overflow: hidden; position: relative; transition: box-shadow .15s, border-color .15s; transform: none; }
body.ui[class] .product-card.dg-card:hover { box-shadow: var(--ui-shadow-hover, 0 8px 22px rgba(0,0,0,.12)); border-color: var(--dg-line); transform: none; }
.dg-thumb { aspect-ratio: 1 / 1; background: #fff; display: grid; place-items: center; position: relative; overflow: hidden; }
body.ui[class] .dg-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; background: #fff; }
.dg-thumb .no-image { color: #8a8a93; font-size: .8rem; }
.dg-body, body.ui[class] .product-card .body.dg-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.dg-title, body.ui[class] .product-card .title.dg-title { font-size: .84rem; font-weight: 500; line-height: 1.7; min-height: 2.8em; margin: 0; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dg-priceblock { margin-top: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-height: 2.9em; justify-content: flex-end; }
.dg-struck { font-size: .76rem; color: var(--muted); }
.dg-price { display: inline-flex; align-items: baseline; gap: 4px; }
.dg-amount { font-size: 1rem; font-weight: 800; color: var(--text); }
body.ui[class] .product-card .price .toman { font-size: .7rem; font-weight: 400; color: var(--muted); margin: 0; }
.dg-soldout { font-size: .84rem; font-weight: 700; color: var(--muted); }
body.ui[class] .dg-badge { position: absolute; top: 8px; inset-inline-end: 8px; inset-inline-start: auto; left: auto; font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; z-index: 1; }
.dg-badge-off { background: var(--dg-red); color: #fff; }
body.ui[class] .dg-badge-out { background: #6b6b75; color: #fff; }
body.ui[class] .out-of-stock.dg-card { opacity: 1; pointer-events: auto; }
body.ui[class] .out-of-stock .dg-thumb img { opacity: .45; filter: grayscale(1); }

/* ---------- صفحه‌ی محصولات ---------- */
.dg-listhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dg-listhead .section-title { margin: 6px 0 8px; }
.dg-count { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.dg-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 0 0 14px; padding: 10px 12px; background: var(--dg-surf); border: 1px solid var(--dg-line); border-radius: var(--dg-r); }
.dg-sort { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--muted); }
.dg-sort .dg-ico { width: 18px; height: 18px; }
.dg-sort select { font: inherit; font-size: .84rem; color: var(--text); background: var(--dg-soft); border: 1px solid var(--dg-line); border-radius: 8px; padding: 6px 10px; }
.dg-clear { font-size: .82rem; color: var(--dg-red); font-weight: 600; }

/* ---------- مزیت‌ها و فوتر ---------- */
.dg-trust { background: var(--dg-surf); border-top: 1px solid var(--dg-line); margin-top: 28px; }
.dg-trust-in { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-block: 16px; }
.dg-trust-in div { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: .78rem; color: var(--muted); }
.dg-trust-in .dg-ico { width: 30px; height: 30px; color: var(--dg-ink); }
body.ui[class] .site-footer.dg-footer { background: var(--dg-surf); color: var(--text); border-top: 1px solid var(--dg-line); margin-top: 0; padding: 0 0 8px; }
body.ui[class] .dg-footer a { color: inherit; } body.ui[class] .dg-footer h3 { color: var(--text); }
.dg-totop { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: 14px 0 6px; padding: 10px; border: 1px solid var(--dg-line); border-radius: 10px; background: var(--dg-soft); color: var(--text); font: inherit; font-size: .84rem; cursor: pointer; }
.dg-totop .dg-ico { width: 18px; height: 18px; }
.dg-fsec { border-bottom: 1px solid var(--dg-line); }
.dg-fsec summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; font-weight: 700; cursor: pointer; }
.dg-fsec summary::-webkit-details-marker { display: none; }
.dg-fsec summary::after { content: "›"; font-size: 1.3rem; color: var(--muted); transform: rotate(90deg); transition: transform .15s; line-height: 1; }
.dg-fsec[open] summary::after { transform: rotate(-90deg); }
.dg-fbody { padding: 0 2px 14px; color: var(--muted); font-size: .86rem; }
.dg-fbody p { margin: 0 0 10px; }
.dg-fbody.footer-col-links { display: flex; flex-direction: column; gap: 8px; }
.dg-fmisc { padding: 12px 0 0; }

/* ---------- ناوبری پایین موبایل ---------- */
.dg-bottomnav { display: none; }
@media (max-width: 768px) {
  body.ui[class] { padding-bottom: 66px; }
  body.ui[class] .shop-header.dg-header .container.dg-hdr { grid-template-columns: minmax(0, 1fr) auto; }
  .dg-hdr > .dg-search { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .dg-act span:not(.cart-count), .dg-header .cart-link-label { display: none; }
  .dg-name { max-width: 56vw; }
  .dg-bottomnav { display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 60; background: var(--dg-surf); border-top: 1px solid var(--dg-line); padding-bottom: env(safe-area-inset-bottom, 0); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
  .dg-bottomnav a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; font-size: .68rem; font-weight: 600; color: var(--muted); }
  .dg-bottomnav a.on { color: var(--dg-ink); }
  .dg-bottomnav .cart-count { position: absolute; top: 3px; inset-inline-start: calc(50% + 4px); min-width: 17px; height: 17px; font-size: .64rem; padding: 0 4px; background: var(--dg-red); color: #fff; border-radius: 999px; display: inline-grid; place-items: center; }
  .dg-bottomnav .cart-count[hidden] { display: none; }
  .dg-rail { margin-inline: -20px; border-radius: 0; }
}
@media (min-width: 640px) {
  body.ui[class] .product-grid.dg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .dg-rail .dg-card { flex-basis: 190px; }
}
@media (min-width: 769px) {
  body.ui[class] .shop-header.dg-header .container.dg-hdr { grid-template-columns: auto minmax(280px, 1fr) auto; }
  .dg-rail-btn { display: grid; }
  .dg-rail-track { padding-inline: 20px; }
  .dg-rail .dg-card { flex-basis: 204px; }
  .dg-totop { max-width: 220px; margin-inline: auto; }
  .dg-fcols { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; padding-top: 22px; }
  .dg-fsec { border-bottom: 0; }
  .dg-fsec summary { cursor: default; pointer-events: none; font-size: 1rem; padding-top: 0; }
  .dg-fsec summary::after { display: none; }
  .dg-trust-in { gap: 24px; } .dg-trust-in div { flex-direction: row; justify-content: center; font-size: .9rem; }
}
@media (min-width: 980px) {
  body.ui[class] .product-grid.dg-grid { grid-template-columns: repeat(var(--grid-cols, 4), minmax(0, 1fr)); gap: 16px; }
  body.ui[class] .dg-hero-img { aspect-ratio: 16 / 6; }
}
@media (prefers-reduced-motion: reduce) { .dg-cat-ic, .dg-card { transition: none; } .dg-cat:hover .dg-cat-ic { transform: none; } }

/* ---------- حالت تیره: رنگ برندِ تیره روی زمینه‌ی تیره نامرئی است؛ نسخه‌ی روشن‌شده‌ی همان رنگ برند ---------- */
:root[data-theme="dark"] body.ui[class] { --dg-ink: color-mix(in srgb, var(--dg-pri) 38%, #fff); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.ui[class] { --dg-ink: color-mix(in srgb, var(--dg-pri) 38%, #fff); }
}
:root[data-theme="dark"] body.ui[class] .btn-outline { color: var(--dg-ink); border-color: var(--dg-ink); }
:root[data-theme="dark"] body.ui[class] .btn-outline:hover { background: var(--dg-ink); color: #0f1115; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.ui[class] .btn-outline { color: var(--dg-ink); border-color: var(--dg-ink); }
  :root:not([data-theme="light"]) body.ui[class] .btn-outline:hover { background: var(--dg-ink); color: #0f1115; }
}

/* تم ذاتاً تیره‌ی «شب»: برند (#1e293b) روی زمینه‌ی تیره دیده نمی‌شود؛ از رنگ تاکید خود تم برای متن/آیکن استفاده می‌کنیم */
body.ui.theme-midnight[class] { --dg-ink: var(--accent, #38bdf8); }
