/**
 * Top bar — single 64px black bar consolidating logo, bucket dropdowns,
 * right-side action cluster (perspective, feedback, dice, profile menu).
 *
 * Replaces the prior three-row stack of eyebrow + masthead + nav.
 * Inspired by D&D Beyond's nav. See docs/4_operations/nav-restructure-plan.md.
 *
 * The bar uses hardcoded dark hex values (not theme tokens) so it stays
 * black even when the user has selected the light theme — DDB's nav has
 * the same theme-independent dark treatment.
 */

/* =============================================================================
   Bar shell
   ============================================================================= */

.top-bar {
  display: flex;
  align-items: stretch;
  height: 64px;
  background: #0a0a0a;
  border-bottom: 2px solid #2a2a2a;
  padding: 0 1.5rem;
  position: relative;
  z-index: 100;
}

.top-bar #header-left { flex: 0 0 auto; display: flex; align-items: center; margin-right: 1.5rem; }
.top-bar #nav         { flex: 1 1 auto; display: flex; align-items: stretch; }
.top-bar #eyebrow     { flex: 0 0 auto; display: flex; align-items: center; }

/* Logo sits inside the 64px bar */
.top-bar .logo-link { display: flex; align-items: center; text-decoration: none; }
.top-bar .site-logo {
  height: 40px;
  width: auto;
  max-width: 220px;
  display: block;
  object-fit: contain;
}

/* =============================================================================
   Bucket dropdowns (center cluster)
   ============================================================================= */

.top-bar-center {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.bucket {
  position: relative;
  display: flex;
  align-items: stretch;
}

.bucket-button {
  height: 64px;
  padding: 0 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #e8e8e8;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.bucket-button:hover { background: #1a1a1a; color: #e8e8e8; }
.bucket-button.active { border-bottom-color: var(--accent-red); }
.bucket-button.open   { background: #1a1a1a; color: #e8e8e8; }

.bucket-panel {
  position: absolute;
  top: 64px;
  left: 0;
  min-width: 220px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-bottom: 2px solid var(--accent-red);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 200;
  padding: 0.25rem 0;
}

.bucket-item {
  display: block;
  padding: 0.7rem 1rem;
  color: #e8e8e8;
  font-family: var(--font-body);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bucket-item:hover {
  background: #242424;
  color: #e8e8e8;
}

.bucket-item.active {
  border-left-color: var(--accent-red);
  color: var(--accent-red);
}

/* =============================================================================
   Right-side cluster
   ============================================================================= */

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 64px;
}

.top-bar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #b0b0b0;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.top-bar-icon-btn:hover {
  background: #1a1a1a;
  color: #e8e8e8;
}

/* The existing .perspective-btn rule sets borders/colors that don't fit the
   compact 64px bar — override the bar instance here. */
.top-bar-right .perspective-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #b0b0b0;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.top-bar-right .perspective-btn:hover {
  background: #1a1a1a;
  color: #e8e8e8;
  border-color: #2a2a2a;
}
.top-bar-right .perspective-btn.perspective-active {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info);
}

/* Login link in the bar (logged-out) */
.top-bar-right .login-link {
  margin-left: 0.5rem;
}

/* =============================================================================
   Profile menu
   ============================================================================= */

.profile {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.profile-button:hover { background: #1a1a1a; }
.profile-button.open  { background: #1a1a1a; }

.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2a2a2a;
  color: #e8e8e8;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0;
  user-select: none;
}

/* Admin red ring around the avatar (only role currently surfaced) */
.profile-button.admin .profile-avatar {
  box-shadow: 0 0 0 2px var(--accent-red);
}

.profile-panel {
  position: absolute;
  top: 64px;
  right: 0;
  min-width: 240px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 200;
  padding: 0.5rem 0;
}

.profile-header {
  padding: 0.6rem 1rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.profile-name {
  color: #e8e8e8;
  font-family: var(--font-body);
  font-weight: 600;
  word-break: break-word;
}

.profile-role-chip {
  align-self: flex-start;
  padding: 0.18rem 0.6rem;
  background: rgba(230, 57, 70, 0.15);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.profile-role-chip:hover {
  background: var(--accent-red);
  color: #fff;
}

.profile-divider {
  height: 1px;
  background: #2a2a2a;
  margin: 0.4rem 0;
}

.profile-item {
  display: block;
  padding: 0.6rem 1rem;
  color: #e8e8e8;
  font-family: var(--font-body);
  text-decoration: none;
  transition: background 0.15s ease;
}
.profile-item:hover { background: #242424; color: #e8e8e8; }

.profile-signout {
  display: block;
  margin: 0.4rem 1rem 0.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid #b0b0b0;
  background: transparent;
  color: #e8e8e8;
  text-decoration: none;
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.profile-signout:hover {
  background: #242424;
  border-color: #e8e8e8;
  color: #e8e8e8;
}

/* =============================================================================
   Banners (impersonation, player view) — sit inline in the bar's right cluster
   ============================================================================= */

.top-bar-right .impersonation-banner,
.top-bar-right .player-view-banner {
  margin-right: 0.4rem;
}

/* =============================================================================
   Mobile (≤ 768px)
   ============================================================================= */

@media (max-width: 768px) {
  .top-bar {
    padding: 0 0.75rem;
  }
  .top-bar #header-left { margin-right: 0.5rem; }
  .top-bar .site-logo { height: 32px; max-width: 160px; }

  /* Center cluster: collapse into a dropdown panel anchored under the bar.
     Toggled by the hamburger in eyebrow (.mobile-nav-toggle). */
  .top-bar-center {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: #1a1a1a;
    border-bottom: 2px solid #2a2a2a;
    height: auto;
    padding: 0.25rem 0;
    z-index: 150;
  }
  .top-bar-center.mobile-open { display: flex; }

  .bucket {
    width: 100%;
    flex-direction: column;
  }
  .bucket-button {
    width: 100%;
    height: auto;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #2a2a2a;
  }
  .bucket-button.active { border-bottom-color: var(--accent-red); }

  .bucket-panel {
    position: relative;
    top: auto;
    width: 100%;
    border-top: none;
    border-left: none;
    border-right: none;
  }

  .bucket-item { padding-left: 2rem; }

  /* Hamburger visible on mobile */
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #e8e8e8;
    cursor: pointer;
    padding: 0.5rem;
  }

  /* Hide the perspective-btn label text on mobile to save room */
  .top-bar-right .desktop-only { display: none; }
}

@media (min-width: 769px) {
  .mobile-nav-toggle { display: none; }
}

/* =============================================================================
   Dice slide-pane — drops down from the top bar; reuses /dice page content.
   The toggle button morphs the dice icon to X while open.
   ============================================================================= */

.dice-pane-toggle {
  /* Inherits .top-bar-icon-btn base; this is just for state-specific tweaks. */
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.dice-pane-toggle.open {
  background: #1a1a1a;
  color: #e8e8e8;
}

.dice-pane-backdrop {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
  z-index: 90;
}

.dice-pane-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.dice-slide-pane {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  transform: translateY(-110%);
  transition: transform 250ms ease-out;
  z-index: 95;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--accent-red);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.dice-slide-pane.open {
  transform: translateY(0);
}

.dice-pane-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

.dice-pane-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dice-pane-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

@media (max-width: 768px) {
  .dice-pane-inner { padding: 1rem; }
  .dice-pane-close { top: 0.5rem; right: 0.5rem; }
}
