/**
 * JagInsights — unified top bar for authenticated app pages.
 * Include after tailwind.css or shared.css.
 */
@import url('./logo-display.css?v=1');

/* ── Light app shell tokens (same canvas + one primary blue everywhere) ───────── */
:root {
  --app-canvas: #e0f2fe;
  --app-border: rgba(59, 130, 246, 0.32);
  /* Emerald, matching the content. These were blue (#2563eb/#3b82f6/#93c5fd), which put
     the ONE component that appears on every single page -- the nav underline and the XP
     bar -- off-brand from every page it sat on, since all nine signed-in pages style their
     content emerald (#059669). Same hue family as the product now. */
  --app-primary: #059669;
  --app-primary-bright: #10b981;
  --app-primary-soft: rgba(5, 150, 105, 0.14);
  --app-on-dark-accent: #6ee7b7;
}

/* ── Dark mode: switch canvas to deep navy ───────────────────────────── */
html[data-theme="dark"] {
  --app-canvas: #0d1219;
}
html[data-theme="dark"] body.dashboard-ready,
html[data-theme="dark"] #app-shell {
  background: var(--app-canvas) !important;
}
html[data-theme="dark"] .app-shell-xp-mobile {
  background: rgba(0, 0, 0, 0.5) !important;
}
html[data-theme="dark"] #auth-loading-screen {
  background: #0d1219 !important;
}

/* ── Upgrade visibility (tier from syncHeaderUpgradeButton) ───────── */
body.tier-pro #upgrade-btn {
  display: none !important;
}

.app-shell-header {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  min-height: var(--shell-h, 68px);
  padding: 0;
  /* Default = dark theme. The navy gradient is wrapped behind the new
     semantic --bg-page token so an html[data-theme="light"] override
     can swap in a clean white surface without losing the dark look. */
  background:
    radial-gradient(80% 180% at 100% 0%, rgba(236,72,153,0.18), transparent 46%),
    radial-gradient(70% 160% at 0% 0%, rgba(59,130,246,0.20), transparent 52%),
    linear-gradient(180deg, rgba(9,16,34,0.97) 0%, rgba(8,14,30,0.95) 100%);
  border-bottom: 1px solid rgba(125, 211, 252, 0.22);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  transition: background-color 150ms ease, background-image 150ms ease, border-color 150ms ease;
}

/* Navbar stays dark on every page — light + dark routes alike.
   The brand logo (logo.png) is intentionally transparent so the
   silver wordmark FILLS in against a darker backdrop. A white
   navbar made it disappear; user feedback was "the background
   needs to be a darker type so the transparent photo pops".
   Dark navy gradient defined above (~lines 36-51) now applies
   universally — no light-theme override needed. */

.app-shell-header__inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
  /* Aligns the logo and nav to the same column the page content uses. */
  max-width: var(--page-max, 1440px);
  margin: 0 auto;
  padding: 0 var(--page-inset, 32px);
  gap: 16px;
}

.app-shell-header__left,
.app-shell-header__right {
  display: flex;
  align-items: stretch;
  gap: clamp(16px, 2.5vw, 40px);
  min-width: 0;
}

.app-shell-header__left {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-shell-header__left::-webkit-scrollbar {
  display: none;
}

.app-shell-header__right {
  flex-shrink: 0;
  align-items: center;
}

/* Brand */
.app-shell-brand {
  display: flex;
  align-items: center;
  font-size: clamp(1.5rem, 2.5vw, 1.875rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #f8fafc;
  text-decoration: none;
  white-space: nowrap;
}
.app-shell-brand img {
  height: 52px !important;
  width: auto !important;
  display: block;
  padding: 0 !important;
  object-fit: contain;
}
.app-shell-brand-accent {
  color: #0891b2;
}

/* Main nav (tablet/desktop) */
.app-shell-nav {
  display: none;
  align-items: stretch;
  gap: clamp(20px, 3vw, 32px);
}
@media (min-width: 768px) {
  .app-shell-nav {
    display: flex;
  }
}

.app-shell-nav-link {
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  color: #94a3b8;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.app-shell-nav-link:hover {
  color: #f8fafc;
}
.app-shell-nav-link.is-active {
  color: var(--app-on-dark-accent, #22d3ee);
  border-bottom-color: var(--app-on-dark-accent, #22d3ee);
}

/* Leaderboard — hide on very small screens; still in Menu dropdown */
.app-shell-nav-link--hide-sm {
  display: none;
}
@media (min-width: 640px) {
  .app-shell-nav-link--hide-sm {
    display: flex;
  }
}

/* Mobile “Menu” control */
.app-shell-nav-more.nav-more-btn {
  display: none;
  align-items: center;
  align-self: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.5);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.app-shell-nav-more.nav-more-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}
@media (max-width: 767px) {
  .app-shell-nav-more.nav-more-btn {
    display: inline-flex;
  }
}

/* Dropdown (sibling of header; wired by account-menu.js) */
#nav-more-menu {
  position: fixed;
  top: calc(var(--shell-h, 68px) + 44px);
  right: clamp(12px, 3vw, 24px);
  min-width: 200px;
  background: rgba(10, 14, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.65);
  padding: 8px;
  z-index: 200;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
#nav-more-menu[hidden] {
  display: none !important;
}
#nav-more-menu a {
  display: block;
  padding: 10px 14px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
#nav-more-menu a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}
#nav-more-menu a.is-active {
  color: var(--app-on-dark-accent, #93c5fd);
}

/* XP cluster */
.app-shell-xp {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
@media (min-width: 768px) {
  .app-shell-xp {
    display: flex;
  }
}

.app-shell-xp-label {
  font-size: 12px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.app-shell-xp-track {
  width: 112px;
  height: 9px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.4);
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.app-shell-xp-track::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
@media (min-width: 1024px) {
  .app-shell-xp-track {
    width: 136px;
    height: 10px;
  }
}

.app-shell-xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--app-primary-bright, #3b82f6), var(--app-primary, #2563eb));
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.45);
  transition: width 0.5s ease;
}

.app-shell-xp-meta {
  font-size: 16px;
  font-weight: 800;
  color: var(--app-on-dark-accent, #93c5fd);
  white-space: nowrap;
  line-height: 1.2;
}
.app-shell-xp-meta .lvl-num {
  font-weight: 900;
  font-size: 16px;
  color: var(--app-on-dark-accent, #93c5fd);
}
.app-shell-xp-meta .lvl-dot {
  color: #64748b;
  font-weight: 600;
}
.app-shell-xp-meta .lvl-tier {
  color: #cbd5e1;
  font-weight: 800;
  font-size: 15px;
}

.app-shell-divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
@media (max-width: 767px) {
  .app-shell-divider {
    display: none;
  }
}

/* Mobile XP strip (below header) */
.app-shell-xp-mobile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  flex-shrink: 0;
  background: rgba(2, 6, 23, 0.75);
  border-bottom: 1px solid rgba(125, 211, 252, 0.22);
}
@media (min-width: 768px) {
  .app-shell-xp-mobile {
    display: none;
  }
}
.app-shell-xp-mobile .app-shell-xp-label {
  flex-shrink: 0;
}
.app-shell-xp-mobile .app-shell-xp-track {
  flex: 1;
  width: auto;
  max-width: none;
  min-width: 0;
}
.app-shell-xp-mobile .app-shell-xp-meta {
  flex-shrink: 0;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
.app-shell-xp-mobile .app-shell-xp-meta .lvl-num {
  font-size: 15px;
}
.app-shell-xp-mobile .app-shell-xp-meta .lvl-tier {
  font-size: 14px;
}

/* Upgrade CTA */
.app-shell-upgrade {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: #fbbf24;
  color: #0f172a !important;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none !important;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.15s;
}
.app-shell-upgrade:hover {
  filter: brightness(1.06);
}

/* Account menu — play-style trigger (works with initAccountMenu) */
.app-shell-header .account-menu {
  position: relative;
  z-index: 101;
}
.app-shell-header [data-account-trigger] {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.app-shell-header [data-account-trigger] .text-right {
  text-align: right;
}
.app-shell-header [data-account-name] {
  font-size: 16px;
  font-weight: 900;
  color: #f8fafc;
}
.app-shell-header [data-account-trigger]:hover [data-account-name] {
  color: var(--app-on-dark-accent, #93c5fd);
}
.app-shell-header #tier-pill {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fbbf24;
  color: #000;
}
.app-shell-header [data-account-avatar] {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.35);
  flex-shrink: 0;
}

.app-shell-header .account-menu-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: rgba(10, 14, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
  padding: 8px;
  z-index: 220;
}
.app-shell-header .account-menu-pop[hidden] {
  display: none !important;
}
.app-shell-header .account-menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}
.app-shell-header .account-menu-name {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
}
.app-shell-header .account-menu-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.app-shell-header .account-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #f8fafc;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.app-shell-header .account-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.app-shell-header .account-menu-item.danger {
  color: #ef4444;
}

/* ═══ Auth boot: spinner only — hide header/main until JS removes #auth-loading-screen ═══ */
body.app-boot > *:not(#auth-loading-screen),
body.play-boot > *:not(#auth-loading-screen) {
  visibility: hidden !important;
}
body.app-ready > *,
body.play-ready > * {
  visibility: visible !important;
}

#auth-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--auth-loading-bg, #e0f2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}
#auth-loading-screen.fade-out {
  animation: jag-auth-fade-out 0.3s ease forwards;
}
@keyframes jag-auth-fade-out {
  to {
    opacity: 0;
    pointer-events: none;
  }
}
.auth-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  animation: jag-auth-spin 0.8s linear infinite;
}
@keyframes jag-auth-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Public display name nudge (email must not be the public handle) ───── */
.jag-pub-name-banner {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), rgba(34, 211, 238, 0.12));
  border-bottom: 1px solid rgba(125, 211, 252, 0.28);
  z-index: 20;
}
.jag-pub-name-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 20px;
  max-width: min(960px, 100%);
}
.jag-pub-name-banner__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
  text-align: center;
}
.jag-pub-name-banner__text strong {
  color: #f8fafc;
}
.jag-pub-name-banner__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.jag-pub-name-banner__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.jag-pub-name-banner__btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}
.jag-pub-name-banner__btn--primary {
  background: #2563eb;
  border-color: rgba(96, 165, 250, 0.5);
  color: #fff;
}
.jag-pub-name-banner__btn--primary:hover {
  filter: brightness(1.08);
}

/* ── Legal / privacy strip (end of scroll — compact, all authenticated hubs) ─ */
.jag-legal-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 12px 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 10, 22, 0.94);
}
.jag-legal-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  font-size: 12px;
  line-height: 1.3;
  color: #94a3b8;
}
.jag-legal-footer__row a {
  color: #94a3b8;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.jag-legal-footer__row a:hover {
  color: #94a3b8;
}
.jag-legal-footer__copy {
  color: #8794ab;
  font-weight: 600;
}
html[data-theme="light"] .jag-legal-footer {
  /* Muted strip — avoids a bright “paper” band at the bottom on mostly-dark hubs */
  background: rgba(203, 213, 225, 0.92);
  border-top-color: rgba(15, 23, 42, 0.14);
}
html[data-theme="light"] .jag-legal-footer__row,
html[data-theme="light"] .jag-legal-footer__row a {
  color: #475569;
}
html[data-theme="light"] .jag-legal-footer__row a:hover {
  color: #1e293b;
}
html[data-theme="light"] .jag-legal-footer__copy {
  color: #334155;
}

/* play.html: shell stays navy even when profile theme is light — footer must match */
body.games-hub .jag-legal-footer {
  background: rgba(7, 13, 28, 0.97);
  border-top-color: rgba(255, 255, 255, 0.08);
}
body.games-hub .jag-legal-footer__row,
body.games-hub .jag-legal-footer__row a {
  color: #64748b;
}
body.games-hub .jag-legal-footer__row a:hover {
  color: #94a3b8;
}
body.games-hub .jag-legal-footer__copy {
  color: #475569;
}

/* App shell hubs (dashboard / shop / friends): always match dark strip — not paper white */
#app-shell .jag-legal-footer {
  background: rgba(7, 13, 28, 0.98);
  border-top-color: rgba(255, 255, 255, 0.08);
}
#app-shell .jag-legal-footer__row,
#app-shell .jag-legal-footer__row a {
  color: #64748b;
}
#app-shell .jag-legal-footer__row a:hover {
  color: #94a3b8;
}
#app-shell .jag-legal-footer__copy {
  color: #475569;
}

/* Full leaderboard page (no #app-shell) */
body.page-lb-q .jag-legal-footer {
  background: rgba(7, 13, 28, 0.97);
  border-top-color: rgba(255, 255, 255, 0.08);
}
body.page-lb-q .jag-legal-footer__row,
body.page-lb-q .jag-legal-footer__row a {
  color: #64748b;
}
body.page-lb-q .jag-legal-footer__row a:hover {
  color: #94a3b8;
}
body.page-lb-q .jag-legal-footer__copy {
  color: #475569;
}

/* Billing / settings: column body + flex main → legal strip at viewport bottom */
body.account-page-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.account-page-root > #auth-loading-screen,
body.account-page-root > header,
body.account-page-root > .nav-more-menu,
body.account-page-root > .app-shell-xp-mobile {
  flex-shrink: 0;
}
body.account-page-root > main.account-page-sticky-foot {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}
main.account-page-sticky-foot > .account-layout {
  flex: 1 1 auto;
}
main.account-page-sticky-foot .jag-legal-footer {
  flex-shrink: 0;
  background: rgba(7, 13, 28, 0.98);
  border-top-color: rgba(255, 255, 255, 0.08);
}
main.account-page-sticky-foot .jag-legal-footer__row,
main.account-page-sticky-foot .jag-legal-footer__row a {
  color: #64748b;
}
main.account-page-sticky-foot .jag-legal-footer__row a:hover {
  color: #94a3b8;
}
main.account-page-sticky-foot .jag-legal-footer__copy {
  color: #475569;
}

/* ═══ Bright chrome: Insights + My Stats (html[data-theme="light"]) ═══ */
/* (Older rule that forced the navbar to stay dark on light pages was
   removed — the Step 1 adaptive-navbar block earlier in this file
   now wins. Light pages get a flat var(--bg-surface) navbar.) */
html[data-theme="light"] #nav-more-menu {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] #nav-more-menu a {
  color: #334155;
}
html[data-theme="light"] #nav-more-menu a:hover {
  background: #f1f5f9;
  color: #0f172a;
}
html[data-theme="light"] #nav-more-menu a.is-active {
  color: #0369a1;
}
html[data-theme="light"] .app-shell-divider {
  background: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .app-shell-xp {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] .app-shell-xp-label {
  color: #64748b;
}
html[data-theme="light"] .app-shell-xp-track {
  background: #e2e8f0;
  border-color: rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .app-shell-xp-meta {
  color: #0f172a;
}
html[data-theme="light"] .app-shell-xp-meta .lvl-num {
  color: #0369a1;
}
html[data-theme="light"] .app-shell-xp-meta .lvl-dot {
  color: #94a3b8;
}
html[data-theme="light"] .app-shell-xp-meta .lvl-tier {
  color: #475569;
}
html[data-theme="light"] .app-shell-xp-mobile {
  background: rgba(248, 250, 252, 0.97);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .app-shell-header [data-account-name] {
  color: #0f172a;
}
html[data-theme="light"] .app-shell-header [data-account-trigger]:hover [data-account-name] {
  color: #0369a1;
}
html[data-theme="light"] .app-shell-header .account-menu-pop {
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.12);
}
html[data-theme="light"] .app-shell-header .account-menu-name,
html[data-theme="light"] .app-shell-header .account-menu-item {
  color: #0f172a;
}
html[data-theme="light"] .app-shell-header .account-menu-item:hover {
  background: #f1f5f9;
}
html[data-theme="light"] .app-shell-header .account-menu-sub {
  color: #64748b;
}

/* Dashboard uses #app-shell — don’t force the games-hub dark strip when theme is light */
html[data-theme="light"] #app-shell .jag-legal-footer {
  background: rgba(241, 245, 249, 0.96);
  border-top-color: rgba(15, 23, 42, 0.1);
}
html[data-theme="light"] #app-shell .jag-legal-footer__row,
html[data-theme="light"] #app-shell .jag-legal-footer__row a {
  color: #475569;
}
html[data-theme="light"] #app-shell .jag-legal-footer__row a:hover {
  color: #1e293b;
}
html[data-theme="light"] #app-shell .jag-legal-footer__copy {
  color: #334155;
}
