/* ── HEADER — Fallout Bright ── */
header {
  background: rgba(20, 18, 16, 0.95);
  backdrop-filter: blur(12px);
  color: var(--primary);
  padding: 0 14px;
  border-bottom: 1px solid var(--primary);
  box-shadow: none;
  position: relative;
  z-index: 15;
  height: var(--header-height);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  transition: height .18s ease, box-shadow .18s ease, border-color .18s ease;
}

header h1 {
  font-size: 1.2rem;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-align: left !important;
  margin: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  color: var(--primary);
  text-shadow: 0 0 8px var(--primary-glow);
}

h1 a {
  color: var(--primary) !important;
}

.header-left { display: flex; align-items: center; min-width: 0; gap: 10px; }
.brand-logo { width: 28px; height: 28px; margin-right: .5rem; filter: drop-shadow(0 0 6px var(--primary-glow)); }
.header-center { display: flex; justify-content: center; align-items: center; gap: 20px; }
.header-right {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

/* Header stat display */
.header-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.header-stat .val {
  color: var(--primary);
  font-weight: 500;
}

.header-stat .mdi {
  color: var(--secondary);
  font-size: 14px;
}

/* Header buttons — unified style */
.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.15s;
}

.header-btn:hover {
  color: var(--primary);
  background: var(--primary-dim);
}

/* Search button */
.open-search-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s ease;
}
.open-search-btn:hover, .open-search-btn:focus-visible {
  color: var(--primary);
  background: var(--primary-dim);
}
.open-search-btn .mdi { font-size: 18px; }

/* Create Feature Area Button */
.create-feature-area-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s ease;
}
.create-feature-area-btn:hover, .create-feature-area-btn:focus-visible {
  color: var(--primary);
  background: var(--primary-dim);
}
.create-feature-area-btn .mdi { font-size: 18px; }

/* Buy RadiaLog button */
.buy-radialog-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-display);
  white-space: nowrap;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .15s ease;
}
.buy-radialog-btn:hover, .buy-radialog-btn:focus-visible {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}
.buy-radialog-btn .mdi { font-size: 16px; }

/* Header stats - responsive marquee system */
.header-stats-inline {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  position: relative;
  overflow: hidden;
  height: var(--header-height);
}

.header-stats-inline .stat-text {
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
}

.header-stats-inline .stat-sep {
  color: var(--text-tertiary);
}

/* Marquee container */
.marquee-container {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  min-width: 0;
}

.marquee-items {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.marquee-item {
  position: absolute;
  top: 0; right: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  padding-right: 2px;
}

.marquee-item.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Marquee title */
.marquee-title {
  font-size: 1.25rem !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1;
  color: var(--primary);
  white-space: nowrap;
  display: block !important;
  font-family: var(--font-display);
}

/* Static display (desktop) */
.header-stats-static {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.header-stats-static .stat-text {
  color: var(--green);
  font-weight: 600;
}

.header-stats-static .stat-sep {
  color: var(--text-tertiary);
}

/* Overlay for search */
.header-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 14;
}
.header-search-overlay.hidden { display: none; }

/* Responsive breakpoints */
@media (min-width: 1200px) {
  .header-stats-inline {
    width: auto;
    min-width: 300px;
  }
  .marquee-container {
    display: none !important;
  }
  .header-stats-static {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    white-space: nowrap;
  }
  .header-right {
    gap: 1rem;
  }
}

@media (max-width: 1199px) and (min-width: 800px) {
  .header-stats-static {
    display: none !important;
  }
  .marquee-container {
    display: flex !important;
    width: 280px;
    min-width: 220px;
  }
  .header-left h1 {
    display: flex !important;
    font-size: 1.1rem;
  }
  .header-right {
    gap: 0.75rem;
  }
}

/* Tablet: hide RadiaLog text label */
@media (max-width: 899px) and (min-width: 480px) {
  .buy-radialog-btn {
    font-size: 0;
    padding: 4px 8px;
  }
  .buy-radialog-btn .mdi {
    font-size: 18px;
  }
}

/* Mobile */
@media (max-width: 799px) and (min-width: 480px) {
  header {
    grid-template-columns: auto 1fr auto;
    padding: 0 0.75rem;
  }
  .open-search-btn, .create-feature-area-btn {
    width: 40px;
    height: 40px;
  }
}

/* Ultra-narrow */
@media (max-width: 479px) {
  header {
    grid-template-columns: auto 1fr auto;
    padding: 0 0.5rem;
  }
  .brand-logo { width: 32px; height: 32px; margin-right: 0; }
  .header-right .open-search-btn,
  .header-right .create-feature-area-btn,
  .header-right .contribute-wrapper,
  .header-right .heatmap-export-trigger-btn,
  .header-right .buy-radialog-btn {
    display: none !important;
  }
}

/* Minimal header mode */
:root.minimal-header {
  --header-height: 40px;
}
:root.minimal-header header { box-shadow: none; border-bottom-color: var(--border-medium); }
:root.minimal-header header h1 { display: flex !important; }
:root.minimal-header .brand-logo { width: 22px; height: 22px; margin-right: .25rem; filter: drop-shadow(0 0 1px var(--primary-glow)); }
:root.minimal-header .header-left { gap: 0; }
:root.minimal-header .header-stats-inline { display: none !important; }
:root.minimal-header .open-search-btn { width: 32px; height: 32px; }
:root.minimal-header .create-feature-area-btn { width: 32px; height: 32px; }
:root.minimal-header .menu-toggle-btn {
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  border-radius: var(--radius-sm);
  border-width: 1.5px;
}

/* When using glitch effect on header title, disable flicker */
header h1.glitch { animation: none; }

@media (prefers-reduced-motion: reduce) {
  header h1.glitch { animation: none !important; }
}

header h1 .glitch-text { line-height: 1; transform-origin: center left; }

/* Contribute (+) dropdown */
.contribute-wrapper { display: inline-block; }
.contribute-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated), var(--shadow-glow);
  padding: 4px;
  min-width: 230px; max-width: 280px;
  backdrop-filter: blur(12px);
  opacity: 0; transform: translateY(-4px) scale(.96);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
  z-index: 25; transform-origin: top right;
}
.contribute-menu.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.contribute-menu:focus { outline: none; }
.contribute-item {
  display: flex; width: 100%; background: transparent; border: 0;
  color: var(--text-secondary); font: inherit;
  padding: 10px 12px; text-align: left;
  border-radius: var(--radius-sm); cursor: pointer;
  gap: .55rem; align-items: center; position: relative; white-space: nowrap;
  font-size: 13px;
}
.contribute-item .mdi { font-size: 18px; color: var(--primary); width: 20px; text-align: center; }
.contribute-item .label { flex: 1; min-width: 0; }

@media (max-width: 480px) {
  .contribute-menu { min-width: 200px; max-width: 240px; }
  .contribute-item { white-space: normal; }
}
.contribute-item:hover, .contribute-item:focus-visible { background: var(--bg-hover); color: var(--text-primary); }
.contribute-item:active { background: var(--primary-dim); }

body .header-stats-inline, body .header-stats-static, body .marquee-container { display: none !important; }

/* Header bar avatar / login button */
#header-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

#header-profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#header-profile-btn.hidden,
#header-login-btn.hidden {
  display: none !important;
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-medium);
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.header-avatar:hover {
  border-color: var(--primary);
}

#header-avatar-initials {
  font-size: 0.8rem;
  line-height: 1;
  color: var(--primary);
  font-family: var(--font-display);
}

#header-avatar-initials.hidden {
  display: none !important;
}

#header-avatar-img.hidden {
  display: none !important;
}
