/* ============================================================
   CJ GLOBAL HEADER (Prompt 3) — one component, every public page.
   Modes: .hh-transparent (over hero) / .hh-solid. Sticky via CSS;
   JS toggles .is-scrolled only (rAF). Mobile-first, 44px targets.
   ============================================================ */

.hh {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--cj-header-h);
  transition: background var(--duration-base) var(--ease-out), box-shadow var(--duration-base), border-color var(--duration-base);
}
.hh-solid { background: var(--cj-white); border-bottom: 1px solid var(--cj-border); }
.hh-transparent { background: transparent; border-bottom: 1px solid transparent; }
.hh-transparent.is-scrolled {
  background: rgba(4, 11, 20, 0.88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--cj-border-dark);
  box-shadow: var(--shadow-md);
}

.hh-inner {
  height: var(--cj-header-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding-left: max(var(--space-4), env(safe-area-inset-left));
  padding-right: max(var(--space-4), env(safe-area-inset-right));
}
.hh-logo { flex-shrink: 0; display: inline-flex; border-radius: var(--radius-sm); }
.hh-logo img { height: 44px; width: auto; }

/* ---------- Desktop nav (≥1024) ---------- */
.hh-nav { display: none; }
.hh-nav ul { display: flex; align-items: center; gap: var(--space-1); list-style: none; padding: 0; margin: 0; }
.hh-link {
  position: relative; display: inline-flex; align-items: center; gap: 4px;
  padding: var(--space-2) var(--space-3); min-height: 44px;
  font-weight: 600; font-size: 0.9375rem; border-radius: var(--radius-sm);
  color: var(--cj-text); white-space: nowrap;
  transition: color 220ms var(--ease-out);
}
.hh-transparent .hh-link { color: var(--cj-text-inverse); }
.hh-link svg { width: 16px; height: 16px; transition: transform 220ms var(--ease-out); }
.hh-link::after {
  content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: 6px;
  height: 2px; border-radius: 2px; background: var(--cj-primary);
  transform: scaleX(0); transform-origin: left;
  transition: transform 220ms var(--ease-out);
}
.hh-nav li.is-active > .hh-link, .hh-link:hover { color: var(--cj-primary); }
.hh-nav li.is-active > .hh-link::after, .hh-link:hover::after { transform: scaleX(1); }
.hh-hasdrop:hover .hh-link svg, .hh-hasdrop:focus-within .hh-link svg, .hh-hasdrop.is-open .hh-link svg { transform: rotate(180deg); }

/* ---------- Dropdown panels ---------- */
.hh-hasdrop { position: relative; }
.hh-drop {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 260px;
  background: #fff; border: 1px solid var(--cj-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--space-2);
  opacity: 0; visibility: hidden; transform: translateY(8px) scale(0.98); transform-origin: top left;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 200ms;
}
.hh-hasdrop:hover > .hh-drop, .hh-hasdrop:focus-within > .hh-drop, .hh-hasdrop.is-open > .hh-drop {
  opacity: 1; visibility: visible; transform: none;
}
.hh-dropitem {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); min-height: 48px; border-radius: var(--radius-md);
  font-weight: 600; color: var(--cj-text);
  transition: background 180ms, color 180ms;
}
.hh-dropitem:hover { background: var(--cj-primary-soft); color: var(--cj-primary-hover); }
.hh-dropicon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--radius-md);
  display: grid; place-items: center; background: var(--cj-surface-tint); color: var(--cj-primary);
}
.hh-dropicon svg { width: 20px; height: 20px; }
.hh-dropall {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3); margin-top: var(--space-1);
  border-top: 1px solid var(--cj-border);
  font-weight: 700; font-size: var(--text-sm); color: var(--cj-primary);
}
.hh-dropall svg { width: 16px; height: 16px; }
.hh-dropall:hover svg { transform: translateX(3px); }
.hh-dropall svg { transition: transform var(--duration-fast) var(--ease-out); }

/* ---------- Actions ---------- */
.hh-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.hh-iconbtn { border-color: transparent; background: transparent; }
.hh-transparent .hh-iconbtn { color: #fff; }
.hh-iconbtn { position: relative; color: var(--cj-text); }
.hh-iconbtn:hover { border-color: var(--cj-border); color: var(--cj-primary); }
.hh-badge {
  position: absolute; top: 2px; right: 2px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--cj-primary); color: #fff;
  font-size: 0.6875rem; font-weight: 800; line-height: 20px; text-align: center;
}
.hh-login { display: none; font-weight: 700; padding: var(--space-2) var(--space-3); min-height: 44px; align-items: center; color: var(--cj-text); }
.hh-transparent .hh-login { color: #fff; }
.hh-login:hover { color: var(--cj-primary); }
.hh-cta { display: none; }
.hh-acctbtn {
  display: none; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  padding: 4px; border-radius: var(--radius-pill); min-height: 44px; color: inherit;
}
.hh-acctbtn svg { width: 16px; height: 16px; }
.hh-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 1.0625rem;
  background: var(--cj-primary); color: #fff;
}
.hh-acct, .hh-minicart {
  position: absolute; top: calc(var(--cj-header-h) - 6px); right: max(var(--space-4), env(safe-area-inset-right));
  width: min(320px, calc(100vw - 2rem));
  background: #fff; border: 1px solid var(--cj-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: var(--space-2); z-index: var(--z-header);
}
.hh-acct[hidden], .hh-minicart[hidden] { display: none; }
.hh-acctwho { padding: var(--space-2) var(--space-3); font-weight: 700; }
.hh-acctwho small { display: block; font-weight: 400; color: var(--color-text-muted); font-size: var(--text-sm); }
.hh-acct a, .hh-acct button {
  display: flex; width: 100%; align-items: center; text-align: left;
  padding: var(--space-2) var(--space-3); min-height: 48px; border-radius: var(--radius-md);
  font-weight: 600; color: var(--cj-text); background: none; border: none; cursor: pointer; font-size: inherit;
}
.hh-acct a:hover, .hh-acct button:hover { background: var(--cj-primary-soft); color: var(--cj-primary-hover); }
.hh-miniitems { list-style: none; padding: 0; margin: 0 0 var(--space-2); display: grid; gap: var(--space-2); }
.hh-miniitems li { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2); border-radius: var(--radius-md); background: var(--cj-background); }
.hh-miniitems img { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.hh-miniitems strong { display: block; font-size: var(--text-sm); }
.hh-miniitems small { color: var(--color-text-muted); }
.hh-minisub { padding: var(--space-2) var(--space-3); }
.hh-miniactions { display: flex; gap: var(--space-2); padding: var(--space-2); }
.hh-miniactions .btn { flex: 1; }

/* ---------- Burger ---------- */
.hh-burger {
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  width: 48px; height: 48px; background: none; border: none; cursor: pointer; border-radius: var(--radius-md);
  color: var(--cj-text);
}
.hh-transparent .hh-burger { color: #fff; }
.hh-burger span { display: block; width: 24px; height: 2px; border-radius: 2px; background: currentColor; transition: transform 220ms var(--ease-out), opacity 220ms; }
.hh-burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hh-burger.is-open span:nth-child(2) { opacity: 0; }
.hh-burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Search overlay ---------- */
.hh-search {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  background: rgba(4, 11, 20, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: var(--cj-space-12) var(--space-4) var(--space-4);
  overflow-y: auto;
}
.hh-search[hidden] { display: none; }
.hh-searchbox {
  max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: var(--space-2);
  background: #fff; border-radius: var(--radius-xl); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  box-shadow: var(--shadow-lg);
}
.hh-searchbox svg { width: 24px; height: 24px; color: var(--color-text-muted); flex-shrink: 0; }
.hh-searchbox input {
  flex: 1; border: none; outline: none; font-size: 1.125rem; min-height: 56px; background: transparent; color: var(--cj-text);
}
.hh-searchhint { text-align: center; color: #C7D5E4; margin-top: var(--space-4); font-size: var(--text-sm); }

/* ---------- Mobile menu ---------- */
.hh-mnav {
  position: fixed; inset: var(--cj-header-h) 0 0 0; z-index: var(--z-sheet);
  background: var(--cj-navy-deep); color: var(--cj-text-inverse);
  overflow-y: auto; padding: var(--space-4) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden; transform: translateY(-12px);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out), visibility 240ms;
}
.hh-mnav[hidden] { display: none; }
.hh-mnav.is-open { opacity: 1; visibility: visible; transform: none; }
.hh-mnavlist { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; }
.hh-mnavlist > li { border-bottom: 1px solid var(--cj-border-dark); opacity: 0; transform: translateY(10px); transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out); }
.hh-mnav.is-open .hh-mnavlist > li { opacity: 1; transform: none; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(1) { transition-delay: 30ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(2) { transition-delay: 60ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(3) { transition-delay: 90ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(4) { transition-delay: 120ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(5) { transition-delay: 150ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(6) { transition-delay: 180ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(7) { transition-delay: 210ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(8) { transition-delay: 240ms; }
.hh-mnav.is-open .hh-mnavlist > li:nth-child(n+9) { transition-delay: 270ms; }
.hh-mnavlist a, .hh-mnavacc {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: var(--space-3) var(--space-1); min-height: 52px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem;
  color: #fff; background: none; border: none; cursor: pointer; text-align: left;
}
.hh-mnavlist li.is-active > a { color: var(--cj-primary); }
.hh-mnavacc svg { width: 20px; height: 20px; transition: transform 220ms var(--ease-out); }
.hh-mnavacc[aria-expanded="true"] svg { transform: rotate(180deg); }
.hh-mnavsub { list-style: none; padding: 0 0 var(--space-2); margin: 0; display: grid; }
.hh-mnavsub[hidden] { display: none; }
.hh-mnavsub a { font-size: 0.9375rem; font-weight: 600; color: #C7D5E4; min-height: 48px; font-family: var(--font-sans); }
.hh-mnavall { color: var(--cj-primary) !important; }
.hh-mnavactions { display: grid; gap: var(--space-3); }
.hh-mnavactions .btn-ghost { color: #fff; border-color: var(--cj-border-dark); }

/* ---------- Responsive switch ----------
   The full nav (9 links + language + search + cart + sign in + CTA) needs
   ~1280px; below that it collided with the logo, so 1024–1279 keeps the
   burger menu and only shows Sign in / CTA in the bar. */
@media (min-width: 1024px) {
  .hh-login, .hh-cta, .hh-acctbtn { display: inline-flex; }
}
@media (min-width: 1280px) {
  .hh-nav { display: block; min-width: 0; }
  .hh-burger { display: none; }
  .hh-mnav { display: none; }
}
@media (min-width: 1280px) and (max-width: 1439px) {
  .hh-link { padding: var(--space-2); font-size: 0.875rem; }
  .hh-nav ul { gap: 0; }
  .hh-inner { gap: var(--space-3); }
  .hh-logo img { height: 40px; }
  .hh-login { padding-inline: var(--space-2); }
}
@media (display-mode: standalone) {
  [data-cj-install-trigger] { display: none !important; }
}
