/* Header only: keep the storefront, offer cards and section tiles untouched. */
:root { --header-height: 130px; }

.store-header {
  height: var(--header-height);
  padding: 0 24px;
  overflow: visible;
  background: #0c0912;
  border-bottom: 1px solid #282131;
  box-shadow: 0 3px 18px #08051114;
  backdrop-filter: none;
  color: #f7f5fb;
  z-index: 1400;
}

.store-header .header-container {
  height: 78px;
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) auto;
  gap: 28px;
  direction: ltr;
}

.store-header .logo {
  position: static;
  transform: none;
  width: auto;
  height: auto;
  max-width: none;
  gap: 10px;
  overflow: visible;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff;
}

.store-header .logo-img { display: block; }
.store-header .logo-text { width: auto; overflow: visible; }
.store-header .brand-ar { font-size: 1.25rem; }
.store-header .brand-en { font-size: 1.05rem; }

.store-search { position: relative; width: 100%; min-width: 0; }
.store-search-field {
  display: flex;
  align-items: stretch;
  height: 46px;
  background: #fff;
  border-radius: 999px;
  border: 2px solid transparent;
  transition: border-color .15s ease;
}
.store-search-field:focus-within { border-color: #b493f4; }
.store-search input {
  width: 100%;
  min-width: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 999px 0 0 999px;
  background: transparent;
  color: #21192d;
  font: inherit;
  font-size: .86rem;
  outline: none;
}
.store-search input::placeholder { color: #79727f; opacity: 1; }
.store-search-submit {
  flex: 0 0 50px;
  margin: -2px;
  margin-left: 0;
  border: 0;
  border-radius: 0 999px 999px 0;
  background: #6d28d9;
  color: #fff;
  cursor: pointer;
  font-size: 1.05rem;
}
.store-search-submit:hover { background: #7c3aed; }
.store-header .header-actions {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr;
}
.store-header :is(.header-favorites, .cart-btn, .theme-toggle, .back-to-home) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: #211b29;
  color: #f7f5fb;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease;
}
.store-header :is(.header-favorites, .cart-btn, .theme-toggle, .back-to-home):hover { background: #342343; transform: none; }
.store-header .cart-count { top: -5px; left: auto; right: -3px; background: #6d28d9; color: #fff; }
.store-header .auth-nav { direction: rtl; }
.store-header :is(.auth-login-btn, .auth-user-btn) {
  display: flex;
  height: 42px;
  min-height: 42px;
  max-width: 160px;
  padding: 0 13px;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #211b29;
  color: #f7f5fb;
  font-size: .78rem;
  white-space: nowrap;
}
.store-header :is(.auth-login-btn, .auth-user-btn):hover { background: #342343; transform: none; }
.store-header .auth-login-btn i { color: inherit; font-size: 1rem; }
.store-header .auth-user-btn > span:not(.auth-avatar-fallback) { overflow: hidden; text-overflow: ellipsis; }
.store-header .auth-dropdown { inset-inline-start: 0; }
.store-header :is(a, button):focus-visible { outline: 2px solid #c4a5ff; outline-offset: 3px; }

/* Main sections: solid buttons in the logo purple. White text stays above 4.5:1 in every state. */
.header-sections {
  --section-bg: #531f8a;        /* Sampled from the logo text (median of its purple pixels); white text 10.9:1. */
  --section-bg-hover: #6426a6;  /* Lighter shade; white text 8.9:1. */
  --section-bg-active: #41196c; /* Darker shade for pressed/current; white text 13.5:1. */
  height: 52px;
  padding-block: 6px;
  direction: ltr; /* Same as the row order, so a scrolled row starts at the first section. */
}
.header-sections-inner {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: var(--container-width);
  height: 100%;
  margin: 0 auto;
}
.header-sections a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 6px;
  background-color: var(--section-bg);
  color: #fff;
  text-decoration: none;
  font-size: .86rem;
  font-weight: 700;
  line-height: 20px;
  white-space: nowrap;
  direction: rtl;
  transition: background-color 200ms ease;
}
.header-sections a[aria-current] { background-color: var(--section-bg-active); box-shadow: inset 0 -3px 0 #c4a5ff; }
@media (hover: hover) { .header-sections a:hover { background-color: var(--section-bg-hover); } }
.header-sections a:active { background-color: var(--section-bg-active); }
/* Inset ring: stays visible when the mobile row scrolls (an outer ring is clipped at the scroller edge). */
.header-sections a:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.header-sections i { font-size: 1rem; }
@media (forced-colors: active) { .header-sections a[aria-current] { text-decoration: underline; text-underline-offset: 6px; } }

.store-search-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  padding: 8px;
  max-height: min(520px, calc(100dvh - var(--header-height) - 18px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 16px 40px #0003;
  direction: rtl;
  z-index: 1015;
}
.store-search-panel[hidden] { display: none; }
.store-search-status { margin: 0; padding: 8px 10px; color: var(--text-secondary); font-size: .78rem; }
.store-search-group { padding: 8px 10px 4px; color: var(--primary-color); font-size: .75rem; font-weight: 700; }
.store-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  min-height: 62px;
  border-radius: 10px;
  color: var(--text-primary);
  text-decoration: none;
}
.store-search-result:hover, .store-search-result[aria-selected="true"] { background: var(--bg-secondary); }
.store-search-result img, .store-search-result > i { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 8px; object-fit: contain; background: var(--bg-secondary); }
.store-search-result > i { display: grid; place-items: center; color: var(--primary-color); }
.store-search-result > span { display: grid; gap: 2px; min-width: 0; }
.store-search-result strong { font-size: .84rem; line-height: 1.5; overflow-wrap: anywhere; }
.store-search-result small { color: var(--text-secondary); font-size: .74rem; }
.store-search-retry { margin: 6px 10px; border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 8px; background: var(--bg-secondary); color: var(--text-primary); font: inherit; font-size: .78rem; cursor: pointer; }
.shipping-route { min-height: 60vh; padding-top: var(--header-height); }

@media (max-width: 1100px) and (min-width: 769px) {
  .store-header { padding-inline: 20px; }
  .store-header .header-container { gap: 18px; }
  .store-header .logo-img { width: 36px; height: 36px; }
  .store-header .brand-ar { font-size: 1.05rem; }
  .store-header .brand-en { font-size: .85rem; }
  .store-header :is(.auth-login-btn, .auth-user-btn) { padding-inline: 10px; }
  .store-header .auth-login-btn span { display: none; }
  .store-header .header-actions { gap: 5px; }
  .store-header :is(.header-favorites, .cart-btn, .theme-toggle, .back-to-home) { flex-basis: 38px; width: 38px; height: 38px; }
}

@media (max-width: 768px) {
  :root { --header-height: 170px; }
  .store-header { padding: 0 12px; overflow: visible; }
  .store-header .header-container { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 62px 56px; gap: 0 10px; height: 118px; width: 100%; }
  .store-header .logo { gap: 7px; width: max-content; max-width: 100%; padding: 4px 6px; direction: rtl; }
  .store-header .logo-img { width: 32px; height: 32px; box-shadow: none; }
  .store-header .brand-ar { font-size: 1rem; }
  .store-header .brand-en { font-size: .8rem; }
  .store-header .header-actions { gap: 5px; }
  .store-header :is(.header-favorites, .cart-btn, .theme-toggle, .back-to-home) { flex-basis: 34px; width: 34px; height: 34px; font-size: .94rem; }
  .store-header :is(.auth-login-btn, .auth-user-btn) { width: 34px; height: 34px; min-height: 34px; padding: 0; justify-content: center; }
  .store-header .auth-login-btn span, .store-header .auth-user-btn > span:not(.auth-avatar-fallback), .store-header .auth-user-btn > i { display: none; }
  .store-search { grid-column: 1 / -1; grid-row: 2; align-self: start; padding-top: 2px; }
  .store-search-field { height: 44px; }
  .store-search input { font-size: .8rem; padding-inline: 14px; }
  .header-sections { margin-inline: -12px; padding-inline: 12px; scroll-padding-inline: 12px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .header-sections::-webkit-scrollbar { display: none; }
  .header-sections-inner { gap: 8px; width: max-content; min-width: 100%; }
  .header-sections a { gap: 6px; font-size: .78rem; }
  .header-sections i { font-size: .9rem; }
  .store-search-panel { max-height: calc(100dvh - var(--header-height) - 12px); }
}

@media (max-width: 370px) {
  .store-header .logo-img { width: 25px; height: 25px; }
  .store-header .brand-ar { font-size: .83rem; }
  .store-header .brand-en { font-size: .67rem; }
  .store-header .header-actions { gap: 3px; }
  .store-header :is(.header-favorites, .cart-btn, .theme-toggle, .back-to-home), .store-header :is(.auth-login-btn, .auth-user-btn) { width: 30px; height: 32px; min-height: 32px; flex-basis: 30px; }
}

/* Mobile section row: fade only the edge that hides more sections. Unsupported browsers keep the plain scrolling row. */
@property --sections-fade-start { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --sections-fade-end { syntax: '<length>'; inherits: false; initial-value: 0px; }
@keyframes header-sections-fade {
  from { --sections-fade-start: 0px; --sections-fade-end: 28px; }
  to { --sections-fade-start: 28px; --sections-fade-end: 0px; }
}
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .header-sections {
      mask-image: linear-gradient(to right, transparent, #000 var(--sections-fade-start), #000 calc(100% - var(--sections-fade-end)), transparent);
      animation: header-sections-fade auto linear both;
      animation-timeline: scroll(self inline);
    }
  }
}

@media (prefers-reduced-motion: reduce) { .store-header * { transition: none; } }
