/**
 * Shared Header Styles (genius.page)
 *
 * Single source of truth for the site-wide navigation header across:
 * index.php, account.php, brief.php, import.php, network/index.php,
 * recreate/intro.php, recreate/upload.php, domains/pages/index.php.
 *
 * Specificity strategy:
 * - Header chrome (`.nav`, `.brand`, `.burger`) uses low-specificity selectors
 *   and must be loaded AFTER the page's inline <style> so cascade order wins.
 * - Button/token-badge rules are scoped to `.nav-actions .*` (specificity 0,2,0)
 *   so they always override page-level `.btn` / `.token-badge` (0,1,0) without
 *   needing `!important`, even if the shared CSS is loaded before page CSS.
 *
 * Visual reference: account.php (the canonical button size).
 *
 * This file intentionally does NOT style body-level `.btn` / `.token-badge`
 * variants (hero CTAs, account "tokens remaining" card, etc.) to avoid
 * breaking per-page layouts.
 */

/* ========== HEADER CHROME ========== */

header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(245, 247, 251, 0.9), rgba(245, 247, 251, 0.75));
  z-index: 2000;
  border-bottom: 1px solid var(--edge, #e5e7eb);
}

header .nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 2100;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 20px;
  text-decoration: none;
  color: var(--text, #0f172a);
}

/* ========== BURGER (mobile toggle) ========== */

.burger {
  display: none;
  width: 42px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--edge, #e5e7eb);
  background: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
  z-index: 2300;
}

.burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text, #0f172a);
  position: relative;
}

.burger span::before,
.burger span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--text, #0f172a);
  transition: transform 160ms ease;
}

.burger span::before { top: -7px; }
.burger span::after { top: 7px; }

/* ========== NAV ACTIONS (desktop) ========== */

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 2200;
}

.nav-actions form {
  margin: 0;
}

.logout-form {
  display: contents;
}

/* ---- Header buttons (higher specificity than page-level .btn) ---- */

.nav-actions .btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: normal;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  transition: transform 150ms ease, box-shadow 150ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-actions .btn-primary {
  background: linear-gradient(135deg, var(--accent, #3575f6), #2f5fd7);
  color: #fff;
  box-shadow: 0 16px 30px rgba(53, 117, 246, 0.2);
}

.nav-actions .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 36px rgba(53, 117, 246, 0.28);
}

.nav-actions .btn-ghost {
  background: rgba(53, 117, 246, 0.08);
  color: var(--accent, #3575f6);
  border: 1px solid rgba(53, 117, 246, 0.2);
}

.nav-actions .btn-ghost:hover {
  background: rgba(53, 117, 246, 0.14);
}

/* ---- Header token badge (compact pill, brief.php-style) ---- */

.nav-actions .token-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(18, 194, 163, 0.15), rgba(53, 117, 246, 0.15));
  border: 1px solid rgba(18, 194, 163, 0.3);
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text, #0f172a);
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.nav-actions .token-badge:hover {
  background: linear-gradient(135deg, rgba(18, 194, 163, 0.25), rgba(53, 117, 246, 0.25));
  border-color: rgba(53, 117, 246, 0.5);
  transform: translateY(-1px);
}

.nav-actions .token-badge .token-icon {
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, var(--accent-2, #12c2a3), var(--accent, #3575f6));
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.nav-actions .token-badge .token-count {
  font-size: 16px;
  color: var(--accent, #3575f6);
}

/* ========== RESPONSIVE (mobile burger menu) ==========
 *
 * Collapsible behavior is scoped to `.burger + .nav-actions` so pages that
 * don't render a burger button (e.g. recreate/intro.php, recreate/upload.php)
 * keep their nav-actions visible as before. Pages WITH a burger get the
 * collapsible drawer.
 */

@media (max-width: 900px) {
  header { position: static; }

  header .nav {
    position: relative;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .burger { display: inline-flex; }

  .burger + .nav-actions {
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--edge, #e5e7eb);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.12);
    width: 100%;
    margin-top: 10px;
    order: 3;
  }

  .burger + .nav-actions.open { display: flex; }

  .burger + .nav-actions .btn,
  .burger + .nav-actions .token-badge {
    width: 100%;
    justify-content: center;
  }

  .burger + .nav-actions form,
  .burger + .nav-actions form .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  header .nav { gap: 8px; padding: 8px 12px; }

  .nav-actions .btn {
    font-size: 14px;
    padding: 10px 14px;
  }

  .nav-actions .token-badge {
    font-size: 13px;
    padding: 7px 12px;
  }
}
