/**
 * Fixed site header: logo + hamburger (left), primary nav (center), status + auth (right).
 * Use: <div class="header__inner header__inner--site"> … </div>
 * Load after style.css (or any sheet that defines --space-*, --color-*, --radius-*).
 */

:root {
  --site-header-height: 4.5rem;
}

body:has(#header.header) {
  padding-top: var(--site-header-height);
}

/* Full strip styling here so the bar stays visible even when style.css / page CSS omits .header background. */
#header.header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 200 !important;
  min-height: var(--site-header-height);
  box-sizing: border-box;
  background: rgba(8, 11, 20, 0.92);
  border-bottom: 1px solid var(--color-border-subtle, rgba(140, 170, 220, 0.07));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#header.header .header__inner {
  position: relative;
  min-height: var(--site-header-height);
  box-sizing: border-box;
}

/* ── 3-column layout: logo | centered nav | utilities ── */
#header.header .header__inner.header__inner--site {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4, 1rem);
  max-width: var(--content-wide, 1200px);
  margin: 0 auto;
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
}

.header__inner--site .header__left {
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  justify-self: start;
  min-width: 0;
  z-index: 2;
  flex: unset;
}

/* #header scope: wins over generic .header__inner flex from other sheets (e.g. style.css). */
#header.header .header__inner--site .header__right {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: var(--space-2, 0.5rem);
  min-width: 0;
  z-index: 2;
  flex: unset;
}

.header__nav.header__nav--site {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  z-index: 2;
}

.header__nav--site > a {
  font-size: var(--text-sm, 0.875rem);
  color: var(--color-text-muted, #8a92a8);
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  position: relative;
  padding: var(--space-1, 0.25rem) 0;
  white-space: nowrap;
}

.header__nav--site > a:not(.header__nav-play)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-gold, #c9a032);
  transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.header__nav--site > a:not(.header__nav-play):hover {
  color: var(--color-text, #e4e8f0);
}

.header__nav--site > a:not(.header__nav-play):hover::after {
  width: 100%;
}

/* Lit primary CTA — first item in centered nav */
.header__nav-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-md, 0.5rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-sm, 0.875rem);
  color: #0a0c14 !important;
  text-decoration: none !important;
  background: linear-gradient(145deg, #f0d878 0%, var(--color-gold, #c9a032) 45%, var(--color-gold-active, #a8851e) 100%);
  border: 1px solid rgba(255, 236, 160, 0.55);
  box-shadow:
    0 0 0 1px rgba(201, 160, 50, 0.35),
    0 0 28px rgba(201, 160, 50, 0.55),
    0 0 48px rgba(240, 200, 90, 0.2),
    0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 180ms cubic-bezier(0.16, 1, 0.3, 1), filter 180ms;
}

.header__nav-play:hover {
  color: #0a0c14 !important;
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow:
    0 0 0 1px rgba(255, 240, 180, 0.65),
    0 0 36px rgba(201, 160, 50, 0.65),
    0 0 64px rgba(240, 210, 120, 0.28),
    0 6px 20px rgba(0, 0, 0, 0.4);
}

.header__nav-play:active {
  transform: translateY(0);
}

.header__nav-play::after {
  display: none !important;
}

/* Top-right utility strip */
#header.header .header__nav-end {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem;
  margin-left: 0;
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  background: rgba(17, 22, 40, 0.92);
  border: 1px solid var(--color-border-subtle, rgba(140, 170, 220, 0.07));
  border-radius: var(--radius-md, 0.5rem);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  color: var(--color-text, #e4e8f0);
  white-space: nowrap;
}

.header-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4caf7d;
  box-shadow: 0 0 0 2px rgba(76, 175, 125, 0.25), 0 0 10px rgba(76, 175, 125, 0.45);
  flex-shrink: 0;
}

.header-status--offline .header-status__dot {
  background: var(--color-text-faint, #4a5270);
  box-shadow: none;
}

.header-status__count {
  font-weight: 700;
  color: var(--color-text, #e4e8f0);
  font-variant-numeric: tabular-nums;
}

.header-status__label {
  font-weight: 600;
  color: var(--color-text-muted, #8a92a8);
}

/* Same footprint as the old header mascot (no icon/image) — keeps “Online | Login” spacing */
.header-mascot-spacer {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.1rem;
  pointer-events: none;
}

.header-status__divider {
  color: rgba(124, 197, 232, 0.35);
  font-weight: 300;
  user-select: none;
  margin: 0 0.15rem;
  font-size: var(--text-sm, 0.875rem);
}

.header-auth-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 1rem;
}

.header-auth-links a {
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  text-transform: none !important;
  letter-spacing: 0.02em !important;
  padding: 0.15rem 0;
  text-decoration: none;
  position: relative;
}

.header-auth-links a::after {
  display: none !important;
}

.header-auth-links__login {
  color: var(--color-crystal, #7cc5e8) !important;
}

.header-auth-links__login:hover {
  color: var(--color-primary-hover, #6498da) !important;
  text-shadow: 0 0 20px var(--color-primary-glow, rgba(74, 126, 194, 0.2));
}

.header-auth-links__register {
  color: var(--color-gold, #c9a032) !important;
}

.header-auth-links__register:hover {
  color: #e0c04e !important;
  text-shadow: 0 0 18px rgba(201, 160, 50, 0.35);
}

/* Logged-in: portrait + account name (replaces Login | Register), same pill as status strip */
.header-auth-links--user {
  gap: 0;
  max-width: min(280px, 58vw);
  min-width: 0;
  flex-shrink: 1;
  align-items: center;
}

.header-user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  text-decoration: none !important;
  color: var(--color-text, #e4e8f0) !important;
  padding: 0;
  font-weight: 700;
}

.header-user-chip:hover {
  color: var(--color-crystal, #7cc5e8) !important;
}

/* Sized to sit flush inside .header__nav-end next to “N Online” */
.header-user-chip__avatar {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(201, 160, 50, 0.45);
  box-shadow: 0 0 10px rgba(201, 160, 50, 0.12);
  background: var(--color-surface-3, #161c32);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user-chip__img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center top;
  display: block;
  flex-shrink: 0;
}

.header-user-chip__fallback {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--color-text-muted, #8a92a8);
  line-height: 1;
}

.header-user-chip__name {
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text, #e4e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.header__nav-end--signed-in .header-mascot-spacer {
  display: none;
  width: 0;
  min-width: 0;
  height: 0;
}

@media (max-width: 900px) {
  :root {
    --site-header-height: 4.25rem;
  }

  #header.header .header__inner.header__inner--site {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-2, 0.5rem);
  }

  .header__inner--site .header__nav.header__nav--site {
    position: fixed;
    top: var(--site-header-height);
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: var(--space-6, 1.5rem) var(--space-4, 1rem);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4, 1rem);
    background: rgba(10, 12, 20, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border, rgba(140, 170, 220, 0.15));
    transform: translateY(-120%);
    transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 199;
    box-sizing: border-box;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .header__inner--site .header__nav.header__nav--site.open {
    transform: translateY(0);
  }

  .header__inner--site .header__nav--site > a {
    width: 100%;
    max-width: 100%;
    white-space: normal;
  }

  #header.header .header__nav-end {
    padding: 0.35rem 0.55rem;
    flex-wrap: nowrap;
    gap: 0.35rem;
    max-width: none;
    justify-content: flex-end;
  }

  .header-mascot-spacer {
    width: 0.5rem;
    min-width: 0.5rem;
    height: 1.25rem;
  }

  .header-auth-links {
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .header-auth-links--user {
    max-width: min(200px, 52vw);
  }

  .header-user-chip__avatar {
    width: 1.875rem;
    height: 1.875rem;
  }
}
