/* Deep optimization layer — themes, splash, filters, a11y */
:root,
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f1e8;
  --bg-elev: #fffdf9;
  --bg-card: #ffffff;
  --bg-card-hover: #fff8ef;
  --line: rgba(60, 40, 20, 0.1);
  --text: #1a1410;
  --muted: #6e6258;
  --gold: #b8862d;
  --gold-soft: rgba(184, 134, 45, 0.12);
  --gold-glow: rgba(184, 134, 45, 0.22);
}

[data-theme="light"] .ambient {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 168, 83, 0.2), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 30%, rgba(224, 122, 95, 0.08), transparent 50%);
}

[data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #3d2a12 0%, #b8862d 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] .topbar {
  background: rgba(247, 241, 232, 0.88);
}

[data-theme="light"] .cats {
  background: linear-gradient(180deg, rgba(247, 241, 232, 0.96) 60%, transparent);
}

[data-theme="light"] .fab-bar {
  background: linear-gradient(180deg, transparent, rgba(247, 241, 232, 0.94) 28%);
}

[data-theme="light"] body {
  background: #efe6d8;
}

@media (min-width: 520px) {
  [data-theme="light"] body {
    background: #e8dcc8;
  }
}

.icon-moon {
  display: none;
}
[data-theme="light"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: block;
}

/* Splash */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #0c0a09;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.splash.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 3px solid #d4a853;
  position: relative;
  box-shadow: 0 0 0 6px rgba(212, 168, 83, 0.12);
}
.splash-mark::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: #d4a853;
}
.splash-name {
  font-family: var(--display);
  font-size: 1.5rem;
  color: #f5f0e8;
  letter-spacing: 0.04em;
}
.splash-bar {
  width: 96px;
  height: 3px;
  border-radius: 99px;
  background: rgba(245, 230, 200, 0.12);
  overflow: hidden;
}
.splash-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, transparent, #d4a853, transparent);
  animation: splashLoad 0.9s ease infinite;
}
@keyframes splashLoad {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(280%);
  }
}

.net-banner {
  position: sticky;
  top: 0;
  z-index: 45;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 12px;
  background: #3a2a12;
  color: #f0d9a0;
  border-bottom: 1px solid rgba(212, 168, 83, 0.25);
}
[data-theme="light"] .net-banner {
  background: #fff3d6;
  color: #6a4a10;
}

.filters-wrap {
  max-width: 480px;
  margin: 8px auto 0;
  padding: 0 16px;
}
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.filters::-webkit-scrollbar {
  display: none;
}
.filter-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: 600 0.75rem / 1 var(--font);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s;
}
.filter-chip.active {
  color: var(--gold);
  border-color: rgba(212, 168, 83, 0.45);
  background: var(--gold-soft);
}

.item-prep {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--muted);
}
.item-card.in-cart {
  border-color: rgba(212, 168, 83, 0.4);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 83, 0.12);
}

.sheet {
  position: relative;
}
.sheet.sheet,
.sheet.cart-sheet {
  position: fixed;
}
.sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 10, 9, 0.45);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
body.rtl .sheet-close {
  right: auto;
  left: 14px;
}
.sheet-close.inline {
  position: static;
  width: 34px;
  height: 34px;
  background: var(--bg-card);
}
.cart-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sheet-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.pairs {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pairs-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pairs-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pair-chip {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font: 600 0.78rem / 1.2 var(--font);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.15s;
}
.pair-chip:hover {
  border-color: rgba(212, 168, 83, 0.4);
  color: var(--gold);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}
.modal[hidden] {
  display: none !important;
}
.modal-card {
  width: min(100%, 360px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 20px 18px;
  text-align: center;
  animation: modalIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #062814;
  background: linear-gradient(135deg, #3ee07a, #25d366);
}
.modal-card h3 {
  font-family: var(--display);
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.modal-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  line-height: 1.45;
}
.modal-card .btn-primary {
  margin-bottom: 8px;
}
.btn-secondary.sm {
  width: auto;
  display: inline-flex;
  padding: 10px 16px;
  margin-top: 12px;
  border-radius: 12px;
}

.back-top {
  position: fixed;
  right: 16px;
  bottom: calc(var(--fab-h) + var(--safe-b) + 12px);
  z-index: 48;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font: 600 0.75rem / 1 var(--font);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
body.rtl .back-top {
  right: auto;
  left: 16px;
}

.footer-stats {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #7a7064;
}
.footer-tip {
  margin-top: 4px;
  font-size: 0.7rem;
  color: #5c544c;
}
.empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}
.pill.closed {
  color: var(--danger);
  border-color: rgba(224, 122, 95, 0.35);
  background: rgba(224, 122, 95, 0.1);
}

body.rtl {
  font-family: "Noto Sans Arabic", "DM Sans", system-ui, sans-serif;
}
body.rtl .hero-title,
body.rtl .brand-mini,
body.rtl .cat-heading,
body.rtl .sheet-top h2,
body.rtl .cart-head h2,
body.rtl .popular-head h2 {
  font-family: "Noto Sans Arabic", var(--display), sans-serif;
}

.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;
}

@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;
  }
  .splash-bar span {
    animation: none;
    width: 100%;
  }
}

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

@media (max-width: 380px) {
  .topbar-inner {
    padding-inline: 8px;
    gap: 4px;
  }

  .topbar-right {
    gap: 4px;
  }

  .brand-mini {
    gap: 4px;
    font-size: 0.95rem;
  }

  .brand-dot {
    width: 6px;
    height: 6px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .topbar-right .lang-btn {
    padding: 10px 8px;
    min-width: 32px;
  }
}

.item-thumb img,
.pop-thumb img,
.cart-thumb img,
.sheet-visual img {
  background: rgba(0, 0, 0, 0.15);
}

/* Fix thumb fallback hidden attr */
.thumb-fallback[hidden] {
  display: none !important;
}
.item-thumb img[style*="display: none"] + .thumb-fallback,
.pop-thumb img[style*="display: none"] + .thumb-fallback {
  display: grid !important;
}
/* High-value: closed banner, sold-out, skins */
.closed-banner {
  position: sticky;
  top: 0;
  z-index: 44;
  display: grid;
  gap: 2px;
  text-align: center;
  font-size: 0.78rem;
  padding: 10px 14px;
  background: linear-gradient(90deg, #3a2210, #5a3018);
  color: #f5e0c0;
  border-bottom: 1px solid rgba(224, 122, 95, 0.35);
}
.closed-banner[hidden] { display: none !important; }
.closed-banner strong { font-weight: 700; display: block; }
.closed-banner span { opacity: 0.9; font-size: 0.72rem; }
[data-theme="light"] .closed-banner {
  background: #fff0e4;
  color: #7a3b12;
}

.skin-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.skin-btn {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--muted);
  font: 600 0.72rem/1 var(--font);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.skin-btn.active {
  color: var(--gold);
  border-color: rgba(212, 168, 83, 0.5);
  background: var(--gold-soft);
}

.item-card.sold-out {
  opacity: 0.72;
  filter: grayscale(0.35);
}
.item-card.sold-out .quick-add {
  color: var(--muted);
  background: transparent;
  cursor: not-allowed;
}
.sold-badge {
  display: inline-block;
  margin-inline-start: 6px;
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(224, 122, 95, 0.18);
  color: var(--danger);
}
.btn-primary.is-disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.footer-tax {
  margin-top: 10px;
  font-size: 0.72rem;
  color: #7a7064;
}
.footer-link.muted {
  display: block;
  margin-top: 6px;
  color: #6b6258;
  font-weight: 500;
}

/* Skin: Ocean */
[data-skin="ocean"] {
  --gold: #3db8c9;
  --gold-soft: rgba(61, 184, 201, 0.14);
  --gold-glow: rgba(61, 184, 201, 0.28);
  --bg: #071018;
  --bg-elev: #0c1822;
  --bg-card: #10202c;
  --bg-card-hover: #152838;
  --line: rgba(180, 220, 230, 0.12);
  --text: #e8f4f8;
  --muted: #8aa8b5;
}
[data-skin="ocean"][data-theme="light"] {
  --bg: #e8f4f8;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0fafc;
  --line: rgba(20, 60, 80, 0.1);
  --text: #0c2430;
  --muted: #5a7a88;
  --gold: #1a8a9a;
  --gold-soft: rgba(26, 138, 154, 0.12);
}
[data-skin="ocean"] .ambient {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(61, 184, 201, 0.2), transparent 55%),
    radial-gradient(ellipse 40% 30% at 0% 80%, rgba(40, 100, 180, 0.12), transparent 50%);
}
[data-skin="ocean"] .hero-title {
  background: linear-gradient(180deg, #e8f8fc 0%, #3db8c9 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-skin="ocean"][data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #0c3040 0%, #1a8a9a 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-skin="ocean"] .cat-btn.active,
[data-skin="ocean"] .fab-cart,
[data-skin="ocean"] .btn-primary {
  background: linear-gradient(135deg, #5ed4e0, #2a9aab);
  color: #041218;
}

/* Skin: Café */
[data-skin="cafe"] {
  --gold: #c4a574;
  --gold-soft: rgba(196, 165, 116, 0.16);
  --gold-glow: rgba(196, 165, 116, 0.28);
  --bg: #140e0a;
  --bg-elev: #1c1410;
  --bg-card: #241a14;
  --bg-card-hover: #2c2018;
  --line: rgba(230, 210, 180, 0.1);
  --text: #f3ebe0;
  --muted: #a89884;
}
[data-skin="cafe"][data-theme="light"] {
  --bg: #f6efe6;
  --bg-elev: #fffaf3;
  --bg-card: #ffffff;
  --bg-card-hover: #fff6ea;
  --line: rgba(80, 50, 20, 0.1);
  --text: #2a1c12;
  --muted: #7a6a58;
  --gold: #8b6914;
  --gold-soft: rgba(139, 105, 20, 0.12);
}
[data-skin="cafe"] .ambient {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(196, 165, 116, 0.18), transparent 55%),
    radial-gradient(ellipse 40% 30% at 100% 60%, rgba(120, 70, 40, 0.12), transparent 50%);
}
[data-skin="cafe"] .hero-title {
  background: linear-gradient(180deg, #fff5e6 0%, #c4a574 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-skin="cafe"][data-theme="light"] .hero-title {
  background: linear-gradient(180deg, #3a2810 0%, #8b6914 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
[data-skin="cafe"] .cat-btn.active,
[data-skin="cafe"] .fab-cart:not(.has-items),
[data-skin="cafe"] .btn-primary:not(.btn-wa) {
  background: linear-gradient(135deg, #dcc09a, #c4a574);
  color: #1a1208;
}

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 1.8rem;
  pointer-events: none;
  z-index: 0;
}
.item-thumb img,
.pop-thumb img,
.cart-thumb img {
  position: relative;
  z-index: 1;
}
