/* App Shell — shared header styling (K10).
 * Ported verbatim from the .topnav family already pixel-verified against
 * the Dictation reference navbar (visual-parity pass, prior sprint):
 * fixed position, transparent until scrolled, 22px logo with no icon
 * badge, 1200px content width, 10px icon gap, 40px icon buttons, and a
 * header-scoped .btn recipe (padding/line-height) matching Dictation's
 * Đăng nhập/Đăng ký buttons exactly. Used identically by every migrated
 * page — logo/spacing/color changes here now apply everywhere at once.
 */

.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding: 20px 0; border-bottom: 1px solid transparent;
  transition: background .3s, backdrop-filter .3s, border-color .3s;
  /* K10 visual-QA fix — the header must render identically regardless of
   * what line-height a page sets on its own <body> (Home/Dictation set
   * 1.7 for prose; the Hanzi Studio pages set none, i.e. UA default
   * ~normal). Left unset, that page-level value cascades into every text
   * node in the injected header (.logo, .nav-link, etc.), inflating their
   * line box and shifting them a few px within the flex-centered row —
   * a real cross-page inconsistency caught by visual inspection (logo
   * sat 5px lower on Radical Explorer's un-set-line-height pages than on
   * Home/Dictation's 1.7 pages). Resetting it here insulates the whole
   * shared header from every page's own typography.
   */
  line-height: 1;
}
.topnav.scrolled {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-color: var(--border);
}
.topnav-inner { display: flex; align-items: center; gap: 28px; }

.logo { display: inline-flex; align-items: center; gap: 9px; font-size: 22px; font-weight: 800; letter-spacing: -.5px; white-space: nowrap; }
.logo .go { color: var(--brand-red); }

.nav-links { display: none; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 10px 12px; font-size: var(--hs-text-sm); font-weight: 550;
  color: var(--text2); background: none; border: none; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color .2s, border-color .2s; cursor: pointer;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 700; border-bottom-color: var(--green); }
.nav-badge-new {
  font-size: var(--hs-text-metadata-min); font-weight: 800; letter-spacing: .4px; color: var(--bg);
  background: var(--coral); padding: 2px 6px; border-radius: 999px;
}

.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-cta { display: none; align-items: center; }
/* Header auth CTA — matches Dictation's exact button recipe, scoped to
 * .nav-cta only so it never touches .btn-primary/.btn-outline's many
 * other in-page uses across each workspace. */
.nav-cta .btn { min-height: 0; padding: 13px 26px; font-size: 15px; font-weight: 600; line-height: 1.7; box-shadow: none; }
.nav-cta .btn-primary { background: var(--brand-red); color: #fff; }
.nav-cta .btn-primary:hover { background: #d43f2a; }
.nav-cta .btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border2); }
.nav-cta .btn-outline:hover { border-color: var(--text2); }

/* Honest empty-state notification popover — no real notification system
 * exists anywhere in ChineseGo yet, so this never claims otherwise.
 * Auth-state-aware (K10): auth.js shows this only for authenticated
 * users (see app/auth.js renderGuest()/renderUser()); guests see only
 * Login/Register in .nav-cta. */
.notif-wrap { position: relative; display: inline-flex; }
.notif-popover {
  display: none; position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 14px;
  padding: 14px 16px; min-width: 220px; max-width: min(280px, calc(100vw - 24px));
  z-index: 200; box-shadow: var(--shadow-md);
}
.notif-popover.open { display: block; }
.notif-popover h4 { font-size: var(--hs-text-sm); font-weight: 700; color: var(--text); margin-bottom: 4px; }
.notif-popover p { font-size: var(--hs-text-sm); color: var(--text2); line-height: var(--hs-line-normal); }

.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border2);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  color: var(--text2); transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--border2); background: var(--surface2); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 999px; background: var(--coral); border: 1.5px solid var(--surface); }

.avatar-btn { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; padding: 0; cursor: pointer; }
.avatar { width: 38px; height: 38px; border-radius: 999px; background: var(--green-tint); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.avatar-caret { color: var(--text3); display: flex; }

.menu-toggle { display: flex; }
.mobile-nav { display: none; flex-direction: column; gap: 2px; padding: 12px 20px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.mobile-nav.open { display: flex; }
.mobile-nav .nav-link { width: 100%; justify-content: flex-start; height: auto; padding: 11px 14px; border-bottom: none; border-radius: 12px; }
.mobile-nav .nav-link.active { background: var(--green-tint); }

@media (min-width: 1280px) {
  .menu-toggle { display: none; }
  .mobile-nav.open { display: none; }
  .nav-links { display: flex; }
  .nav-cta { display: flex; }
}
