/* Shared Header Navigation */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 15px;
  gap: 12px;
}

body { padding-top: 56px; }
body.nav-open { overflow: hidden; }

.site-logo {
  font-weight: bold;
  font-size: 1.1em;
  color: #222;
  text-decoration: none;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}
.site-logo:hover { background: #f5f5f5; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-link {
  color: #555;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: nowrap;
  transition: background 0.15s;
}
.nav-link:hover { background: #f5f5f5; color: #222; }
.nav-link.active { background: #222; color: #fff; }

.nav-dropdown { position: relative; }
.nav-dropdown > .nav-link::after { content: ' ▾'; }
.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 1001;
  padding: 5px 0;
}
.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown:focus-within .nav-dropdown-content { display: block; }
.nav-dropdown-content a {
  display: block;
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  font-size: 0.9em;
}
.nav-dropdown-content a:hover { background: #f5f5f5; }

/* Search bar */
.game-toggle {
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
  transition: background 0.15s;
}
.game-toggle:hover { background: #e8e8e8; }
.game-toggle img { display: block; }
.game-arrow { font-size: 0.6em; color: #888; }
.game-picker { position: relative; flex-shrink: 0; display: flex; height: 100%; }
.game-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1001;
  padding: 4px 0;
  min-width: 140px;
}
.game-dropdown.show { display: block; }
.game-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85em;
  color: #333;
  text-align: left;
}
.game-dropdown button:hover { background: #f5f5f5; }
.game-dropdown button.active { font-weight: 600; background: #f0f0f0; }
.header-search {
  position: relative;   /* anchors the suggestion list (#212) */
  flex: 1;
  max-width: 320px;
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border-radius: 8px;
  height: 38px;
}
.header-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 8px;
  font-size: 0.9em;
  outline: none;
  min-width: 0;
}
.header-search button {
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9em;
  color: #666;
  flex-shrink: 0;
}
.header-search button:hover { color: #222; }

/* User section */
.header-user {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.login-btn {
  background: #222;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.8em;
  cursor: pointer;
  white-space: nowrap;
}
.login-btn:hover { background: #444; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}
.user-dropdown { position: relative; }
.user-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 150px;
  z-index: 1001;
  padding: 5px 0;
}
.user-dropdown:hover .user-dropdown-content,
.user-dropdown:focus-within .user-dropdown-content { display: block; }
.user-dropdown-content a, .user-dropdown-content button {
  display: block;
  width: 100%;
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  font-size: 0.9em;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.user-dropdown-content a:hover, .user-dropdown-content button:hover { background: #f5f5f5; }

/* Burger menu - hidden on desktop */
.burger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  color: #333;
  flex-shrink: 0;
}

/* Mobile nav - slide from left */
.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: #fff;
  z-index: 1002;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}
.mobile-nav.open { transform: translateX(0); }

.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1001;
}
.mobile-nav-overlay.open { display: block; }

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  font-size: 1.1em;
}
.mobile-nav-header button {
  background: none;
  border: none;
  font-size: 1.3em;
  cursor: pointer;
  padding: 5px;
  color: #666;
}

.mobile-nav-section {
  padding: 12px 20px 6px;
  font-size: 0.75em;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mobile-nav-divider {
  height: 1px;
  background: #eee;
  margin: 10px 0;
}

.mobile-nav a {
  display: block;
  padding: 14px 20px;
  color: #222;
  text-decoration: none;
  font-size: 1em;
}
.mobile-nav a:active { background: #f5f5f5; }
.mobile-nav .sub { padding-left: 35px; color: #555; }

.mobile-nav-login {
  padding: 20px;
  margin-top: auto;
}
.mobile-nav-login button {
  width: 100%;
  padding: 12px;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
}

/* ===== MOBILE ===== */
/* #174: burger left, a fixed search bar (with the game picker) in the middle,
   Sign In / avatar right. Same 56px height as desktop so nothing shifts. */
@media (max-width: 768px) {
  .site-header-inner { padding: 0 8px; gap: 6px; }

  .burger-btn { display: block; padding: 10px 8px; }
  .nav-links { display: none; }

  .site-logo { display: none; } /* Home is in the bottom bar (#198) — the search gets the room */

  .header-search { display: flex; max-width: none; min-width: 0; height: 38px; }
  .header-search .game-toggle { padding: 4px 4px 4px 8px; }
  .header-search input { font-size: 16px; padding: 8px 4px; width: 100%; } /* 16px: stops iOS zoom-on-focus */
  .header-search button[type="submit"] { padding: 8px 10px; }

  /* Reserve the slot so Sign In / avatar fades in without moving the search bar */
  .header-user { display: flex; justify-content: flex-end; min-width: 58px; }
  .login-btn { padding: 8px 10px; }

  .mobile-search-btn, .mobile-avatar-wrap { display: none; }
}
@media (min-width: 769px) {
  .mobile-search-btn { display: none; }
  .bottom-nav, .me-sheet, .me-overlay { display: none !important; }
}

/* ===== BOTTOM NAV (mobile, #198, #202) =====
   Home · Cards · (Scan) · Collection · Me (Cards = search, with Cards · Sealed · Sets tabs). Scan = the one primary action: a small raised round button in
   the centre, mobile only (no camera on desktop). Icons: Lucide line icons (inline SVG, see header.js).
   Account lives in "Me"; the ☰ drawer keeps the extras. Pages lift their own fixed
   bottom elements with var(--bnav-h). */
:root { --bnav-h: 0px; }
.bottom-nav { display: none; }
@media (max-width: 768px) {
  :root { --bnav-h: calc(52px + env(safe-area-inset-bottom)); }   /* slimmer, like Collectr */
  body { padding-bottom: var(--bnav-h); }
  .header-user { display: none; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 993;
    height: var(--bnav-h); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box;
    background: #fff; border-top: 1px solid #e0e0e0; box-shadow: 0 -1px 3px rgba(0,0,0,.06);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 44px; background: none; border: none; font: inherit; font-size: .65em; font-weight: 600;
    color: #666; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav .bn-ico { width: 20px; height: 20px; display: block; }
  .bottom-nav .active { color: #D81111; }
  .bottom-nav .bn-cam { width: 42px; height: 42px; margin-top: -14px; border-radius: 50%; background: #D81111; color: #fff;
    display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.22); box-sizing: border-box; }
  .bottom-nav .bn-cam .bn-ico { width: 20px; height: 20px; }
  .bottom-nav .bn-scan.active .bn-cam { background: #A30D0D; }
  .bottom-nav a:focus-visible, .bottom-nav button:focus-visible { outline: 2px solid #4A90D9; outline-offset: -3px; }
  .bottom-nav .me-icon img { width: 20px; height: 20px; border-radius: 50%; display: block; }

  .me-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 991; }
  .me-overlay.open { display: block; }
  .me-sheet {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--bnav-h) + 8px); z-index: 992;
    background: #fff; border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.2); padding: 8px 16px 12px;
    transform: translateY(12px); opacity: 0; visibility: hidden; transition: transform .18s, opacity .18s, visibility .18s;
  }
  .me-sheet.open { transform: none; opacity: 1; visibility: visible; }
  .me-sheet a { display: block; padding: 12px 0; color: #222; text-decoration: none; border-bottom: 1px solid #eee; }
  .me-sheet a.admin { color: #d32f2f; }
  .me-user { display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; border-bottom: 1px solid #eee; font-weight: 600; }
  .me-user img { width: 36px; height: 36px; border-radius: 50%; }
  .me-signin, .me-signout { width: 100%; min-height: 44px; margin: 8px 0 4px; border: 1px solid #222; border-radius: 8px; background: #222; color: #fff; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; } /* = .ui-btn.primary */
  .me-signout { background: #fff; border-color: #DDDDDD; color: #222; } /* = .ui-btn */
  .me-note { margin: 2px 0 6px; font-size: .8em; color: #666; }
}

/* Search overlay (mobile) */
.search-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1100;
  padding: 20px;
  align-items: flex-start;
  justify-content: center;
}
.search-overlay.active { display: flex; }
.search-overlay-inner {
  width: 100%;
  max-width: 500px;
  margin-top: 60px;
}
.search-overlay-close {
  position: absolute;
  top: 15px; right: 15px;
  background: none; border: none; color: #fff; font-size: 1.5em; cursor: pointer;
}
.search-overlay form {
  display: flex;
  align-items: stretch;
  background: #fff;
  border-radius: 10px;
  height: 48px;
}
.search-overlay .game-toggle {
  background: #fff;
  border: none;
  border-right: 1px solid #eee;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  border-radius: 10px 0 0 10px;
  height: 100%;
}
.search-overlay .game-arrow { font-size: 0.6em; color: #888; }
.search-overlay input {
  flex: 1;
  border: none;
  padding: 0 12px;
  font-size: 1em;
  outline: none;
  min-width: 0;
}
.search-overlay button[type="submit"] {
  background: #D81111;
  color: #fff;
  border: none;
  padding: 0 18px;
  cursor: pointer;
  font-size: 1em;
  border-radius: 0 10px 10px 0;
}

/* Print */
@media print {
  .site-header, .mobile-nav, .mobile-nav-overlay { display: none !important; }
  body { padding-top: 0; }
}
