/* ============================================================
   HEADER.CSS — Site Header, Navigation, Search & Drawer
   Redesign spec: docs/superpowers/specs/2026-10-18-site-header-redesign-design.md
   Single owner of every header rule (the header block was removed from
   responsive.css on purpose: two owners invited the old override bugs).
   ============================================================ */

/* ── Row height: drives the sticky offset and the anchor scroll offset ── */
:root                 { --hdr-row-h: 74px; }
:root.is-scrolled     { --hdr-row-h: 56px; }
html                  { scroll-padding-top: calc(var(--hdr-row-h) + 16px); }

/* ── Icons: outline only, one stroke width, never bold ────────────── */
.hdr-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hdr-ic {
  display: block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hdr-ic--14 { width: 14px; height: 14px; }
.hdr-ic--16 { width: 16px; height: 16px; }
.hdr-ic--18 { width: 18px; height: 18px; }
.hdr-ic--20 { width: 20px; height: 20px; }
.hdr-ic--22 { width: 22px; height: 22px; }

/* ── Shell ───────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
  max-width: 100%;
  contain: layout style;
  transition: box-shadow var(--transition-base);
}
:root.is-scrolled .site-header { box-shadow: var(--shadow-md); }

.hdr-row {
  height: var(--hdr-row-h);
  background: var(--surface-raised);
  transition: height var(--transition-base);
}
.hdr-row-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .hdr-row, .hdr-logo-mark, .site-header { transition: none; }
}

/* ── Logo ────────────────────────────────────────────────────────── */
.hdr-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  min-width: 0;
  min-height: 44px; /* the mark stays 34px but the hit area is a full touch target */
  color: inherit;
  text-decoration: none;
}
.hdr-logo-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: 10px;
  color: var(--brand-700);
  transition: width var(--transition-base), height var(--transition-base);
}
:root.is-scrolled .hdr-logo-mark { width: 30px; height: 30px; }
.hdr-logo-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.hdr-logo-name {
  font-size: 15.5px;
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  white-space: nowrap;
}
.hdr-logo-tagline { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
:root.is-scrolled .hdr-logo-tagline { display: none; }

/* ── Nav + «بیشتر» ───────────────────────────────────────────────── */
/* The nav must never be squeezed: if it shrinks, the nowrap labels spill out
   of their boxes and collide. The search field absorbs the pressure instead
   (below 1024px the nav is hidden outright — see the compact block). */
.hdr-nav { display: flex; align-items: center; flex-shrink: 0; }
.hdr-nav-list { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.hdr-nav-list > li { flex-shrink: 0; }
.hdr-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding-inline: var(--space-3);
  border: 0;
  border-radius: 9px;
  background: none;
  font-family: var(--font-family);
  font-size: 13.5px;
  font-weight: var(--font-weight-medium);
  color: var(--neutral-700);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.hdr-nav-link:hover { background: var(--surface-sunken); color: var(--text); }
.hdr-nav-link.active {
  background: var(--brand-100);
  color: var(--brand-700);
  font-weight: var(--font-weight-semibold);
}
.hdr-more { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.hdr-more-btn { padding-inline: var(--space-2) var(--space-3); }
.hdr-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 208px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
}
.hdr-more-menu[hidden] { display: none; }
.hdr-more-link {
  display: flex;
  align-items: center;
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: var(--font-weight-medium);
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.hdr-more-link:hover { background: var(--surface-sunken); color: var(--brand-700); }
.hdr-more-link.active { background: var(--brand-100); color: var(--brand-700); font-weight: var(--font-weight-semibold); }
.hdr-more-btn .hdr-ic {
  transition: transform var(--motion-base) var(--motion-ease-out);
}
.hdr-more-btn[aria-expanded="true"] .hdr-ic { transform: rotate(180deg); }

@keyframes hdr-pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .hdr-more-menu:not([hidden]),
  .hdr-results:not([hidden]) {
    animation: hdr-pop-in var(--motion-fast) var(--motion-ease-out) both;
    transform-origin: top center;
  }
}

/* ── Search ──────────────────────────────────────────────────────── */
.hdr-search { position: relative; flex: 1 1 220px; max-width: 420px; min-width: 0; }
.hdr-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding-inline: var(--space-3);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-muted);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.hdr-field:focus-within {
  border-color: var(--border-focus);
  background: var(--surface-raised);
  box-shadow: var(--shadow-focus);
}
.hdr-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-family);
  font-size: 13.5px;
  color: var(--text);
}
.hdr-input:focus { outline: none; }
.hdr-input::-webkit-search-cancel-button { -webkit-appearance: none; }
/* --text-muted only clears 4.5:1 on white; on the sunken field it lands at 4.0:1,
   so anything sitting on --surface-sunken uses neutral-700 instead. */
.hdr-input::placeholder { color: var(--neutral-700); }

/* ── Results panel ───────────────────────────────────────────────── */
.hdr-results {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  max-height: min(420px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
}
.hdr-results[hidden] { display: none; }
.hdr-res-group {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
}
.hdr-res {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
}
.hdr-res:hover, .hdr-res[aria-selected="true"] { background: var(--brand-50); }
.hdr-res-ic { color: var(--brand-700); }
.hdr-res-body { flex: 1 1 auto; min-width: 0; }
.hdr-res-title {
  font-size: 13.5px;
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-res-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-res-price { font-size: 12.5px; font-weight: var(--font-weight-semibold); white-space: nowrap; }
.hdr-res-chip {
  flex-shrink: 0;
  padding: 2px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  font-size: 10.5px;
  font-weight: var(--font-weight-medium);
  color: var(--neutral-700); /* on --surface-sunken; -muted would be 4.0:1 */
}
.hdr-res-empty { padding: var(--space-5) var(--space-3); text-align: center; font-size: 13px; color: var(--text-muted); }
.hdr-res-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* The shared .demo-badge ships at 3.2:1 (warning amber on warning-bg), which misses
   AA for 12px text. Only the instances this header introduces are darkened here, so
   every other badge on the site is left exactly as it was. */
.hdr-results .demo-badge,
.mobile-nav .demo-badge {
  color: #8a5300;
  border-color: rgba(138, 83, 0, 0.25);
}

/* ── Actions ─────────────────────────────────────────────────────── */
.hdr-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-inline-start: auto;
}
.hdr-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding-inline: 14px;
  border: 1px solid var(--brand-200);
  border-radius: 10px;
  background: var(--brand-50);
  font-size: 13.5px;
  font-weight: var(--font-weight-semibold);
  color: var(--brand-700);
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.hdr-cta:hover { background: var(--brand-100); border-color: var(--brand-300); color: var(--brand-800); }
.hdr-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--neutral-700);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.hdr-icon-btn:hover { background: var(--surface-sunken); border-color: var(--border); color: var(--text); }
.hdr-icon-btn:focus-visible, .hdr-cta:focus-visible, .hdr-nav-link:focus-visible, .hdr-more-link:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.hdr-badge {
  position: absolute;
  top: -3px;
  inset-inline-start: -3px;
  min-width: 18px;
  height: 18px;
  padding-inline: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface-raised);
  border-radius: var(--radius-full);
  background: var(--brand-600);
  color: #fff;
  font-size: 10.5px;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
}
.hdr-badge[hidden] { display: none; }
.hdr-search-toggle { display: none; }

/* ── Compact search row (below the main row) ─────────────────────── */
.hdr-row--search {
  height: auto;
  padding-block: var(--space-2);
  border-top: 1px solid var(--border);
}
.hdr-row--search[hidden] { display: none; }
.hdr-search--mobile { flex: 1 1 auto; max-width: none; }

@keyframes hdr-search-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .hdr-row--search:not([hidden]) {
    animation: hdr-search-in var(--motion-base) var(--motion-ease-out) both;
  }
}

/* ── Hamburger ───────────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              transform var(--motion-fast) var(--motion-ease-out);
}
.nav-toggle:hover { background: var(--surface-sunken); border-color: var(--border); }
.nav-toggle:active { transform: scale(0.94); }
.nav-toggle:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.nav-toggle-icon {
  width: 22px;
  height: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.nav-toggle-icon span {
  display: block;
  height: 1.6px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon span:nth-child(1) { transform: translateY(7.2px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon span:nth-child(3) { transform: translateY(-7.2px) rotate(-45deg); }

/* ── Mobile drawer ───────────────────────────────────────────────── */
.mobile-nav {
  display: block;
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  visibility: hidden;
  pointer-events: none;
  /* Keep the layer alive while the drawer slides out, then hide it from
     painting and the accessibility tree. */
  transition: visibility 0s linear var(--motion-slow);
}
.mobile-nav.open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  background: rgba(35, 31, 24, 0.45);
  opacity: 0;
  transition: opacity var(--motion-slow) var(--motion-ease-out);
}
.mobile-nav.open .mobile-nav-overlay { opacity: 1; }
.mobile-nav-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(340px, 86vw);
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  transition: transform var(--motion-slow) var(--motion-spring);
  will-change: transform;
  backface-visibility: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav.open .mobile-nav-drawer { transform: translateX(0); }
/* Closing should feel decisive, not springy. */
.mobile-nav:not(.open) .mobile-nav-drawer {
  transition-timing-function: var(--motion-ease-in-out);
}
@media (prefers-reduced-motion: reduce) {
  .mobile-nav, .mobile-nav-drawer, .mobile-nav-overlay { transition: none; }
}

@keyframes mnav-item-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .mobile-nav.open .mobile-nav-search {
    animation: mnav-item-in 240ms var(--motion-ease-out) both;
  }
  .mobile-nav.open .mobile-nav-list > li {
    animation: mnav-item-in 260ms var(--motion-ease-out) both;
  }
  .mobile-nav.open .mobile-nav-list > li:nth-child(2)  { animation-delay: 18ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(3)  { animation-delay: 36ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(4)  { animation-delay: 54ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(5)  { animation-delay: 72ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(6)  { animation-delay: 90ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(7)  { animation-delay: 108ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(8)  { animation-delay: 126ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(9)  { animation-delay: 144ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(10) { animation-delay: 162ms; }
  .mobile-nav.open .mobile-nav-list > li:nth-child(11) { animation-delay: 180ms; }
  .mobile-nav.open .mobile-nav-footer {
    animation: mnav-item-in 260ms var(--motion-ease-out) 80ms both;
  }
}
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.mobile-nav-brand { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.mobile-nav-close {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-sunken);
  color: var(--neutral-700); /* graphics only need 3:1, but crisp beats faded */
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.mobile-nav-close:hover { background: var(--neutral-200); color: var(--text); }
.mobile-nav-body { flex: 1 1 auto; min-width: 0; padding: var(--space-4); }
.mobile-nav-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 44px;
  margin-bottom: var(--space-3);
  padding-inline: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-sunken);
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--neutral-700); /* on --surface-sunken; -muted would be 4.0:1 */
  text-align: start;
  cursor: pointer;
}
.mobile-nav-search:hover { border-color: var(--brand-300); color: var(--text); }
.mobile-nav-list { display: flex; flex-direction: column; gap: 2px; }
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.mobile-nav-link span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-nav-link .hdr-ic:first-child { color: var(--text-muted); }
.mobile-nav-chevron { color: var(--text-faint); }
.mobile-nav-link:hover { background: var(--surface-sunken); }
.mobile-nav-link:hover .hdr-ic:first-child { color: var(--brand-700); }
.mobile-nav-link.active { background: var(--brand-100); color: var(--brand-700); font-weight: var(--font-weight-semibold); }
.mobile-nav-link.active .hdr-ic { color: var(--brand-700); }
.mobile-nav-link:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.mobile-nav-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}
.mobile-nav-contact { display: flex; flex-direction: column; gap: var(--space-1); }
.mobile-nav-contact a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.mobile-nav-contact a:hover { color: var(--brand-700); }
.mobile-nav-demo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ══ Compact layout: one row, hamburger + drawer ═══════════════════ */
@media (max-width: 1023px) {
  :root, :root.is-scrolled { --hdr-row-h: 56px; }
  .hdr-nav { display: none; }
  .hdr-search--desktop { display: none; }
  .hdr-search-toggle { display: inline-flex; }
  .hdr-logo-tagline { display: none; }
  .hdr-row-inner { gap: var(--space-2); }
  .hdr-cta .hdr-cta-text { display: none; }
  .hdr-cta { padding-inline: var(--space-3); }
  .nav-toggle { display: flex; }
  /* Touch tiers: every control in the row becomes a 44px target. */
  .hdr-cta { height: 44px; }
  .hdr-icon-btn { width: 44px; height: 44px; }
}

/* ≤480px: the CTA lives in the drawer; the account icon stays in the header */
@media (max-width: 480px) {
  .hdr-cta { display: none; }
}

/* ≤360px: keep the row from overflowing on the narrowest phones */
@media (max-width: 360px) {
  .hdr-logo-text, .hdr-search-toggle { display: none; }
}

/* Brand image */
.hdr-logo-img{width:100%;height:100%;object-fit:cover;border-radius:inherit;display:block}

/* Logo-only brand marks (no baked-in image background) */
.hdr-logo-mark{background:transparent;border-color:transparent;border-radius:0}
.hdr-logo-img{object-fit:contain}
