/* css/global.css — Global Rankings (public leaderboard).
   Mobile-first, app-like. Uses base.css tokens.
   3D hero: .gl-scene hosts the WebGL globe canvas (js/global-3d.js);
   every layer here must survive without it (no-WebGL / reduced motion). */

.gl-wrap {
  /* width:100% is LOAD-BEARING: .app-content is a flex column, so with
     margin:0 auto alone this box shrink-to-fits and GROWS to its content's
     min-content width (the nowrap tabs/rows) — the old mobile overflow.
     A definite width keeps it viewport-capped and lets ellipsis work. */
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--page-px) 120px;
  -webkit-tap-highlight-color: transparent;
  /* hard overflow guard — clip (NOT hidden: hidden would turn this into a
     scroll container and break the sticky tabs) */
  overflow-x: clip;
}

/* ── 3D hero ──────────────────────────────────────────────────
   Full-bleed band: gradient backdrop always, globe canvas when WebGL
   is available. Content (header + stat tiles) floats above it. */
.gl-hero {
  position: relative;
  margin: 0 calc(-1 * var(--page-px));
  padding: 18px var(--page-px) 4px;
  overflow: hidden;                       /* nothing 3D may leak sideways */
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-glow-2), transparent 60%),
    linear-gradient(to bottom, var(--bg-1), transparent 85%);
}
.gl-scene {
  position: absolute; inset: 0;
  pointer-events: none;                   /* never fight scroll gestures */
  /* fade the globe out toward the bottom so it dissolves into the page */
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 96%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 96%);
}
.gl-scene::before {                       /* soft core glow behind the globe */
  content: '';
  position: absolute; left: 50%; top: 24%;
  width: min(78vw, 340px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
  filter: blur(6px);
}
.gl-scene canvas { display: block; width: 100%; height: 100%; }
.gl-hero-inner { position: relative; z-index: 1; }

/* header — over the globe, so it needs a touch of lift for legibility */
.gl-head { padding-top: 78px; margin-bottom: 4px; text-align: center; }
.gl-eyebrow { font: 600 10px/1 var(--font-data); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 7px; }
.gl-title { font: 700 clamp(23px, 7vw, 28px)/1.1 var(--font-ui); color: var(--text-1); margin: 0 0 5px; letter-spacing: -.01em; text-shadow: 0 2px 18px rgba(0,0,0,.45); }
:root[data-theme="light"] .gl-title { text-shadow: none; }
.gl-sub { font: 400 12.5px/1.5 var(--font-ui); color: var(--text-2); margin: 0 auto; max-width: 52ch; }

/* stat tiles — 2×2 glass over the globe (backdrop blur picks it up) */
.gl-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0 10px; }
.gl-tile {
  min-width: 0;
  border: 1px solid var(--glass-border); background: var(--glass-bg);
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  border-radius: 16px; padding: 13px 14px;
}
.gl-tile .n { font: 700 clamp(17px, 5.6vw, 22px)/1 var(--font-data); color: var(--text-1); letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-tile .l { font: 600 10px/1 var(--font-data); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* sticky segmented tabs — full-bleed scroller under the 56px app-bar,
   with edge fades instead of a hard clip */
.gl-tabs {
  position: sticky; top: 56px; z-index: 100;
  display: flex; gap: 6px; overflow-x: auto;
  margin: 6px calc(-1 * var(--page-px)) 12px;
  padding: 12px var(--page-px) 10px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--page-px), #000 calc(100% - var(--page-px)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--page-px), #000 calc(100% - var(--page-px)), transparent);
}
.gl-tabs::-webkit-scrollbar { display: none; }
.gl-tab {
  flex: 0 0 auto; scroll-snap-align: start;
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--border-1); background: var(--bg-2);
  color: var(--text-2); font: 600 13px/1 var(--font-ui);
  cursor: pointer; white-space: nowrap; transition: all .15s var(--ease);
}
.gl-tab:active { transform: scale(.96); }
.gl-tab.active { background: var(--accent); border-color: var(--accent); color: #04140b; }

/* list */
.gl-metric-label { font: 600 10px/1 var(--font-data); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); text-align: right; margin: 0 2px 8px 0; }
.gl-list { display: flex; flex-direction: column; gap: 7px; }

.gl-row {
  position: relative; display: flex; align-items: center; gap: 11px;
  max-width: 100%;
  padding: 11px 13px; border: 1px solid var(--border-1); border-radius: 14px;
  background: var(--bg-1); overflow: hidden;
  transition: transform .1s var(--ease);
}
.gl-row:active { transform: scale(.988); }
/* player rows (Players/Kills/Heroes) open the shared player modal */
.gl-row.pm-clickable { cursor: pointer; }
.gl-row.pm-clickable:hover { border-color: var(--accent-border); }
.gl-row.pm-clickable:hover .gl-primary { color: var(--accent); }
.gl-row.pm-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* magnitude bar (single-hue, sequential) behind the content */
.gl-row .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-glow); border-right: 2px solid var(--accent-border); border-radius: 0 3px 3px 0; z-index: 0; pointer-events: none; }
.gl-row > * { position: relative; z-index: 1; }

.gl-rank { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 12px/1 var(--font-data); color: var(--text-3); background: var(--bg-3); }
.gl-row.top1 .gl-rank { background: linear-gradient(150deg, #f6d873, #d4a017); color: #3a2c00; }
.gl-row.top2 .gl-rank { background: linear-gradient(150deg, #e4e8ee, #b6bdc9); color: #2a2f36; }
.gl-row.top3 .gl-rank { background: linear-gradient(150deg, #e6ad72, #bf7a3c); color: #3a2100; }

.gl-main { flex: 1 1 auto; min-width: 0; }
.gl-primary { font: 600 14.5px/1.25 var(--font-ui); color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-primary .ab { color: var(--accent); font-family: var(--font-data); font-size: 13px; }
.gl-secondary { font: 500 11.5px/1.3 var(--font-data); color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-secondary .ab { color: var(--accent); }

/* value may shrink (with ellipsis) rather than push the row wide */
.gl-value { flex: 0 1 auto; min-width: 0; max-width: 36vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 800 15px/1 var(--font-data); color: var(--text-1); text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.gl-center { text-align: center; padding: 64px 0; color: var(--text-3); font: 400 14px/1.5 var(--font-ui); }
.gl-foot { margin-top: 18px; text-align: center; font: 400 11.5px/1.5 var(--font-ui); color: var(--text-3); }

/* wider screens: roomier hero, 4-across tiles, tabs pin to top
   (desktop has no mobile app-bar — sidebar instead) */
@media (min-width: 700px) {
  .gl-hero { padding-top: 26px; border-radius: 0 0 24px 24px; }
  .gl-head { padding-top: 96px; }
  .gl-sub { font-size: 13px; }
  .gl-scene::before { width: 420px; }
  .gl-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
  .gl-tile { padding: 16px; }
  .gl-tile .n { font-size: 24px; }
  .gl-primary { font-size: 15px; }
  .gl-secondary { font-size: 12px; }
  .gl-value { font-size: 16px; max-width: none; }
}
@media (min-width: 769px) {
  .gl-tabs { top: 0; }
}
