/* SURGE — header
   Sticky white header with logo, linklist nav, action icons, mobile drawer. */

.sg-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow var(--transition-fast);
}
.sg-header.is-stuck {
  box-shadow: 0 1px 0 rgba(15,15,15,0.04), 0 4px 12px rgba(15,15,15,0.04);
}

.sg-header__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  height: 72px;
  gap: var(--space-5);
  padding: 0 var(--container-pad-desktop);
}

/* ── Logo ────────────────────────────────────────────────────────────── */
.sg-header__logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.sg-header__logo img { display: block; width: auto; height: auto; max-height: 32px; object-fit: contain; }
.sg-header__wordmark {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: inherit;
}

/* ── Burger (mobile only) ────────────────────────────────────────────── */
.sg-header__burger {
  display: none;
  width: 36px; height: 36px;
  border: 0; background: transparent; cursor: pointer;
  flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  padding: 0;
}
.sg-header__burger span {
  width: 18px; height: 1.5px; background: currentColor; display: block; border-radius: 1px;
  transition: transform var(--transition-fast);
}

/* ── Desktop nav ─────────────────────────────────────────────────────── */
.sg-header__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}
.sg-header__nav-link {
  position: relative;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: inherit;
  text-decoration: none;
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition-fast);
}
.sg-header__nav-link:hover { color: var(--color-accent); }
.sg-header__nav-link--highlight { font-weight: 600; }
.sg-header__nav-badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-xs);
  line-height: 1.4;
}

/* Nested-menu dropdown — shown on hover/focus of a nav item that has
   children (link.links from the platform menu loader). Anchored to the
   nav item via .sg-header__nav-item position:relative. */
.sg-header__nav-item {
  position: relative;
}
.sg-header__nav-caret {
  opacity: 0.6;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}
.sg-header__nav-item.has-dropdown:hover .sg-header__nav-caret,
.sg-header__nav-item.has-dropdown:focus-within .sg-header__nav-caret {
  opacity: 1;
  transform: rotate(180deg);
}
.sg-header__dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 200px;
  background: var(--color-bg, #FFFFFF);
  border: 1px solid var(--color-border, rgba(0,0,0,0.08));
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: var(--space-2) 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.sg-header__nav-item.has-dropdown:hover .sg-header__dropdown,
.sg-header__nav-item.has-dropdown:focus-within .sg-header__dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
/* Invisible bridge so the dropdown doesn't dismiss when the cursor crosses
   the gap between nav link and panel. */
.sg-header__dropdown::before {
  content: '';
  position: absolute;
  top: -8px; left: 0; right: 0;
  height: 8px;
}
.sg-header__dropdown-link {
  display: block;
  padding: 8px var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text, inherit);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.sg-header__dropdown-link:hover {
  background: var(--color-ink-25, rgba(0,0,0,0.04));
}

/* ── Action icons + inline search ─────────────────────────────────────── */
.sg-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

/* Inline search pill — Surge replaces the search-icon link with a visible
   input (260px wide on desktop, light grey bg). Hidden on mobile; the
   mobile drawer carries its own search row. */
.sg-header__search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  width: 260px;
  padding: 0 12px;
  background: var(--color-surface-2, #F4F4F5);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.sg-header__search:focus-within {
  border-color: var(--color-border);
  background: var(--color-bg);
}
.sg-header__search svg {
  flex: 0 0 16px;
  color: var(--color-text-muted);
}
.sg-header__search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.sg-header__search-input::placeholder {
  color: var(--color-text-muted);
}
@media (max-width: 960px) {
  .sg-header__search { display: none; }
}
.sg-header__icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 28px; height: 28px;
  color: inherit;
  background: transparent; border: 0; padding: 0;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
.sg-header__icon:hover { opacity: 0.7; }
.sg-header__cart-badge {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--color-accent);
  color: #FFF;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ── Mobile drawer ───────────────────────────────────────────────────── */
.sg-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
}
.sg-drawer__backdrop {
  position: absolute; inset: 0;
  background: rgba(15,15,15,0.45);
  opacity: 0;
  transition: opacity 240ms ease;
}
.sg-drawer__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 320px; max-width: 86vw;
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: -16px 0 32px rgba(15,15,15,0.16);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
  display: flex; flex-direction: column;
}
.sg-drawer.is-open .sg-drawer__backdrop { opacity: 1; }
.sg-drawer.is-open .sg-drawer__panel    { transform: translateX(0); }

.sg-drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border);
}
.sg-drawer__title {
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sg-drawer__close {
  width: 32px; height: 32px;
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: inherit;
}

.sg-drawer__nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sg-drawer__link {
  display: block;
  padding: 14px 22px;
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border-soft);
}
.sg-drawer__link:hover { background: var(--color-surface); }
.sg-drawer__sublist {
  padding: 0 22px 8px 38px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-soft);
}
.sg-drawer__sublink {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
}
.sg-drawer__sublink:hover { color: var(--color-text); }

.sg-drawer__actions {
  display: flex; gap: var(--space-3);
  padding: 18px 22px;
  border-top: 1px solid var(--color-border);
}
.sg-drawer__action {
  flex: 1;
  padding: 10px 14px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
  color: var(--color-text);
  text-decoration: none;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sg-header__inner {
    grid-template-columns: auto 1fr auto;
    height: var(--header-height-mobile);
    gap: var(--space-3);
    padding: 0 var(--container-pad-mobile);
  }
  .sg-header__burger { display: inline-flex; }
  .sg-header__nav    { display: none; }
  .sg-header__logo   { justify-self: center; }
  .sg-header__actions { gap: var(--space-3); }
  .sg-header__wordmark { font-size: 18px; }
}

@media (max-width: 480px) {
  .sg-header__actions .sg-header__icon:not(.sg-header__cart) { display: none; }
  /* Keep search if you want — toggle via setting if needed. */
}
