/* app/topbar.css — shared header / nav / topbar styling.
 *
 * Loaded by every page that uses the canonical sticky topbar. Used to
 * be duplicated inline in 15+ pages (~25 lines × 15 = ~375 lines of
 * pure repetition). Single source of truth so brand tweaks land in
 * one place.
 *
 * Notes on CSS-var dependencies: this file expects --bg, --text,
 * --muted, --panel-2, --border, --brand-gold, --brand-crimson to be
 * defined in each page's :root block. All current pages already
 * declare those — no change needed.
 */

header.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 18px;
  background: rgba(10,10,14,0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 70;
  backdrop-filter: blur(14px);
}

.hrk-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
}

.hrk-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(217,52,43,0.25);
}

.hrk-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.09em;
  white-space: nowrap;   /* keep the wordmark on one line on narrow desktop widths */
}
.hrk-name .feat { color: var(--brand-crimson); }
.hrk-name .gold { color: var(--brand-gold); }

.topbar nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.topbar nav a:hover,
.topbar nav a:focus-visible {
  background: var(--panel-2);
  color: var(--text);
}
/* P3-M5 audit fix (2026-05-28): keyboard focus needs a visible
 * indicator distinct from hover so Tab navigation is discoverable. */
.topbar nav a:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
}
.topbar nav a.active {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--brand-gold);
  border-radius: 6px 6px 0 0;
}
.topbar nav a#watchlist-nav {
  color: var(--brand-gold);
}
.topbar nav a .badge {
  background: var(--brand-crimson);
  color: white;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
  font-weight: 800;
}

/* ─── Dropdown groups ──────────────────────────────────────────────
 * Hover-open on desktop (≥ 901px); click-toggle on touch via JS that
 * sets .open on the wrapper. Group-level button styled identically to
 * a regular nav link so hover/focus states stay consistent.
 * Active state when the current page lives inside a group: .dropdown.active
 * gives the trigger the same gold inset shadow as a direct active link.
 */
nav[data-nav-version="2"] .dropdown {
  position: relative;
}
nav[data-nav-version="2"] .dropdown-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 10px 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
nav[data-nav-version="2"] .dropdown-btn:hover,
nav[data-nav-version="2"] .dropdown-btn:focus-visible,
nav[data-nav-version="2"] .dropdown:focus-within .dropdown-btn,
nav[data-nav-version="2"] .dropdown:hover .dropdown-btn {
  background: var(--panel-2);
  color: var(--text);
}
nav[data-nav-version="2"] .dropdown-btn:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
}
nav[data-nav-version="2"] .dropdown-btn .caret {
  font-size: 9px;
  opacity: 0.7;
  margin-top: 1px;
}
nav[data-nav-version="2"] .dropdown.active .dropdown-btn {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--brand-gold);
  border-radius: 6px 6px 0 0;
}
nav[data-nav-version="2"] .dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 0 0 1px rgba(245,197,66,0.06);
  display: none;
  flex-direction: column;
  gap: 1px;
}
nav[data-nav-version="2"] .dropdown:hover > .dropdown-menu,
nav[data-nav-version="2"] .dropdown:focus-within > .dropdown-menu,
nav[data-nav-version="2"] .dropdown.open > .dropdown-menu {
  display: flex;
}
nav[data-nav-version="2"] .dropdown-menu a {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 5px;
  white-space: nowrap;
}
nav[data-nav-version="2"] .dropdown-menu a:hover,
nav[data-nav-version="2"] .dropdown-menu a:focus-visible {
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
nav[data-nav-version="2"] .dropdown-menu a.active {
  background: rgba(245,197,66,0.10);
  color: var(--brand-gold);
  box-shadow: none;
  border-radius: 5px;
}
nav[data-nav-version="2"] .dropdown-menu a .badge {
  background: var(--brand-crimson);
  color: white;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 800;
}
nav[data-nav-version="2"] .dropdown-menu .menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}
/* Section labels inside dropdowns (optional grouping aid) */
nav[data-nav-version="2"] .dropdown-menu .menu-label {
  padding: 6px 12px 2px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.discord-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  padding: 6px 13px !important;
  background: #5865F2 !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  text-decoration: none;
  transition: background 0.15s;
  margin-left: 4px;
}
.discord-btn:hover {
  background: #4752c4 !important;
}
.discord-btn svg {
  vertical-align: middle;
  flex-shrink: 0;
}

/* ─── Mobile (≤900px) — collapse v2 nav to hamburger ──────────────
 * Without this, the v2 dropdown nav's flex-wrap layout stacks each
 * item vertically down the right edge of the screen, pushing the
 * logo / search out of place. At phone widths we hide the whole nav
 * and surface a hamburger button (#hrk-mobile-burger) that opens a
 * full-page drawer (#hrk-mobile-drawer). The bottom tab bar still
 * covers the 5 primary destinations; the drawer is the escape hatch
 * for everything else. Markup is injected at runtime by
 * /app/topbar-mobile.js so we don't have to edit 41 HTML pages. */
#hrk-mobile-burger,
#hrk-mobile-drawer { display: none; }

@media (max-width: 900px) {
  /* Hide the v2 dropdown nav inline list entirely. */
  nav[data-nav-version="2"] { display: none !important; }
  /* Hide secondary header items that don't fit on a phone. */
  header.topbar #hrk-search-wrap,
  header.hrk-header #hrk-search-wrap { display: none !important; }
  .hrk-fresh { display: none !important; }

  /* Tighter padding so the logo + burger sit close to the edges. */
  header.topbar,
  header.hrk-header { padding: 9px 12px; gap: 8px; }

  /* Hamburger — gold-tinted round button, top right. */
  #hrk-mobile-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid rgba(245, 197, 66, 0.22);
    color: #F5C542;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
  }
  #hrk-mobile-burger:active {
    background: rgba(245, 197, 66, 0.12);
    border-color: rgba(245, 197, 66, 0.45);
  }

  /* Drawer — slides in from the right, full height, scrollable. */
  #hrk-mobile-drawer {
    display: block;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(82vw, 320px);
    background: #0a0808;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 9000;
    transform: translateX(100%);
    transition: transform 0.22s ease-out;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 calc(env(safe-area-inset-bottom, 0px) + 14px);
    overflow-y: auto;
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.55);
  }
  #hrk-mobile-drawer.open { transform: translateX(0); }

  #hrk-mobile-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 8999;
    opacity: 0;
    transition: opacity 0.22s ease-out;
  }
  #hrk-mobile-drawer-backdrop.open {
    display: block;
    opacity: 1;
  }

  #hrk-mobile-drawer .hrk-drawer-section {
    padding: 6px 0;
  }
  #hrk-mobile-drawer .hrk-drawer-label {
    padding: 10px 18px 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8a8a98;
  }
  #hrk-mobile-drawer a {
    display: block;
    padding: 11px 18px;
    color: #d4cabb;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    -webkit-tap-highlight-color: rgba(245, 197, 66, 0.1);
  }
  #hrk-mobile-drawer a:active {
    background: rgba(245, 197, 66, 0.08);
    color: #F5C542;
  }
  #hrk-mobile-drawer a.active {
    color: #F5C542;
    background: rgba(245, 197, 66, 0.06);
  }
  #hrk-mobile-drawer .hrk-drawer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 18px;
  }
}
