/* ================================================================
   Header — Matches Stitch reference
   ================================================================ */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 64px;
  background: rgba(250, 248, 255, 0.9);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.header-inner {
  height: 100%;
  max-width: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ── LEFT: Brand ──────────────────────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  min-width: 240px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--on-surface);
}

/* ── Header brand mark ─────────────────────────────────────── */
.header-brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: block;
}

.header-brand-name {
  font-family: var(--font-display, "Plus Jakarta Sans", sans-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--on-surface, #041748);
  white-space: nowrap;
}

/* Hide the long name on narrow viewports */
@media (max-width: 1100px) {
  .header-brand-name { font-size: 0.95rem; }
}

@media (max-width: 768px) {
  .header-brand-name { display: none; }
  .header-brand-version { display: none; }
}

.header-brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--on-surface);
}

.header-brand-version {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 0.875rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── CENTER: Search ───────────────────────────────────── */
.header-center {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 18px;
  min-height: 40px;
  background: var(--surface-container-low);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
  text-align: left;
}

.header-search:hover {
  background: var(--surface-container);
}

.header-search > i {
  color: var(--outline);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.header-search__text {
  flex: 1;
  font-family: var(--font-editorial);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  font-weight: 300;
  font-style: italic;
  letter-spacing: 0;
  color: var(--outline);
}

.header-search__kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 0.875rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: var(--surface);
  color: var(--on-surface-variant);
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  margin-left: auto;
}

/* ── RIGHT: Actions ───────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Community switcher */
.header-community {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  background: var(--surface-container-low);
  border-radius: var(--radius-lg);
  transition: background var(--duration-fast) var(--ease-out);
}

.header-community:hover { background: var(--surface-container); }

.header-community__select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--on-surface);
  cursor: pointer;
  padding-right: 18px;
}

.header-community__chevron {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--outline);
  font-size: 0.7rem;
  pointer-events: none;
}

/* Icon buttons */
.header-icon-btn {
   width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-container-low);
  color: var(--on-surface-variant);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.header-icon-btn:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}

/* Contribute button */
.header-contribute {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(226, 30, 73, 0.18);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.header-contribute:hover {
  opacity: 0.95;
  color: var(--on-secondary-container);
}

.header-contribute:active {
  transform: scale(0.98);
}

.header-contribute i {
  font-size: 0.85rem;
}

/* Avatar */
.header-brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-container), var(--tertiary-container));
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-container);
  color: var(--on-surface);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.header-avatar:hover {
  transform: scale(1.05);
  color: var(--on-surface);
}

/* Hide mobile toggle on desktop — re-enable in media query */
.mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--surface-container-low);
  color: var(--on-surface);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .header-search__text { display: none; }
  .header-community { display: none; }
}

@media (max-width: 768px) {
  .header-inner { padding: 0 16px; }
  .header-left { min-width: 0; }
  .header-brand-name { font-size: 1rem; }
  .header-brand-version { display: none; }
  .header-contribute span { display: none; }
  .header-contribute { padding: 6px 10px; }
  .header-icon-btn { display: none; }
  .mobile-menu-toggle { display: inline-flex; }
}

/* ── Header avatars ────────────────────────────────────── */
.header-brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-container), var(--tertiary-container));
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-container);
  color: var(--on-surface);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-spring);
  flex-shrink: 0;
}

.header-user-avatar:hover {
  transform: scale(1.05);
  color: var(--on-surface);
}

/* Hide ⌘K hint on touch devices */
@media (hover: none) and (pointer: coarse) {
  .header-search__kbd { display: none; }
}

@media (max-width: 768px) {
  .header-contribute {
    display: none !important; /* The bottom tab bar handles this */
  }
  .header-search__kbd {
    display: none !important; /* Hide ⌘K on touch devices */
  }
}