/* pingrank.gg — BBS/ANSI brand direction "1d"
   Tokens from design/README.md; brand elements are hard-edged (radius 0),
   outer content panels may use 6px. */

:root {
  --bg: #05080f;
  --bg-panel: #080c16;
  --bg-inset: #070b15;
  --bg-slab-top: #0a1428;
  --surface-box: #080f22;
  --border: #16233f;
  --blue-900: #1e40e0;
  --blue-700: #2f5cff;
  --blue-500: #3a68ff;
  --blue-400: #4d7bff;
  --blue-300: #5f86ff;
  --blue-200: #7aa0ff;
  --blue-100: #a8c0ff;
  --text: #eaf0ff;
  --text-dim: #93a5cc;
  --text-dim-2: #7d90ba;
  --text-faint: #66799f;
  --text-shade: #1e3a7a;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  /* shared page column: 1200px centered on desktop, gutter padding below that.
     Backgrounds stay full-bleed; only the content is inset. */
  --gutter: max(26px, calc((100% - 1200px) / 2));
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-300); text-decoration: none; }
a:hover { color: var(--blue-100); }

/* ---- cross-document view transitions ---- */

@view-transition { navigation: auto; }

.site-header { view-transition-name: site-header; }
.site-footer { view-transition-name: site-footer; }
main { view-transition-name: main-content; }

@keyframes vt-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
::view-transition-old(main-content) { animation: 140ms ease both vt-fade-out; }
::view-transition-new(main-content) { animation: 220ms ease both vt-slide-in; }

/* htmx fragment swaps (globalViewTransitions) get a tighter treatment */
::view-transition-old(lb-panel),
::view-transition-old(games-grid),
::view-transition-old(stats-strip) { animation: 100ms ease both vt-fade-out; }
::view-transition-new(lb-panel),
::view-transition-new(games-grid),
::view-transition-new(stats-strip) { animation: 180ms ease both vt-slide-in; }

#lb-panel { view-transition-name: lb-panel; }
#games-grid { view-transition-name: games-grid; }
#stats-strip { view-transition-name: stats-strip; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---- scanline slab ---- */

.slab {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-slab-top) 0%, var(--bg-inset) 100%);
}
.slab::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(120,150,255,0.05) 0 1px, transparent 1px 4px);
  pointer-events: none;
}
.slab > * { position: relative; z-index: 1; }

/* ---- ping-meter mark ---- */

.mark {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 2px solid var(--blue-700);
  background: var(--surface-box);
  flex: none;
}
.mark span { display: block; }
.mark span:nth-child(1) { height: 26%;  background: var(--blue-900); }
.mark span:nth-child(2) { height: 50%;  background: var(--blue-500); }
.mark span:nth-child(3) { height: 74%;  background: var(--blue-300); }
.mark span:nth-child(4) { height: 100%; background: var(--blue-100); }

.mark--40  { width: 40px;  height: 40px;  gap: 3px; padding: 6px 0; }
.mark--40 span { width: 5px; }
.mark--104 { width: 104px; height: 104px; gap: 6px; padding: 14px 0; }
.mark--104 span { width: 12px; }

/* ---- site header (spec lockup) ---- */

.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px var(--gutter);
  background: linear-gradient(180deg, var(--bg-slab-top) 0%, var(--bg-inset) 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(120,150,255,0.05) 0 1px, transparent 1px 4px);
  pointer-events: none;
}
.site-header > * { position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
}
.brand:hover { color: var(--text); }

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.wordmark b {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--text);
}
.wordmark b i { font-style: normal; color: var(--blue-400); }
.wordmark small {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--blue-700);
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 22px;
  font-size: 14px;
  letter-spacing: 1px;
}
.site-nav a { color: var(--text-dim); }
.site-nav a:hover { color: var(--blue-200); }
.site-nav a.active { color: var(--blue-400); }

/* ---- layout ---- */

main {
  padding: 36px var(--gutter) 72px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px var(--gutter);
  color: var(--text-dim-2);
  font-size: 13px;
}
.site-footer .shade-rule { margin-bottom: 14px; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { color: var(--text-dim); }

.shade-rule {
  font-size: 14px;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--text-shade);
  white-space: nowrap;
  overflow: hidden;
}

/* ---- hero (direction 1d) ---- */

.hero {
  padding: clamp(28px, 5vw, 44px) clamp(22px, 4vw, 40px) clamp(32px, 5vw, 48px);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 36px;
}
.hero-lockup {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-word {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-word b {
  font-weight: 700;
  font-size: clamp(34px, 6.4vw, 52px);
  line-height: 0.95;
  letter-spacing: -1px;
  color: var(--text);
  text-shadow: 0 0 18px rgba(47,92,255,0.55);
}
.hero-word b i { font-style: normal; color: var(--blue-400); }
.hero-word small {
  font-size: 17px;
  letter-spacing: 8px;
  color: var(--blue-700);
}
.hero .shade-rule { margin-top: 26px; }
.hero-sub {
  margin: 22px 0 0;
  max-width: 62ch;
  color: var(--text-dim);
  font-size: 15px;
}
.hero-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

/* ---- buttons ---- */

.btn {
  display: inline-block;
  border: 1px solid var(--blue-700);
  background: var(--surface-box);
  color: var(--blue-200);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 1px;
  padding: 10px 18px;
  cursor: pointer;
}
.btn:hover {
  color: var(--text);
  box-shadow: 0 0 10px rgba(47,92,255,0.45), inset 0 0 8px rgba(47,92,255,0.18);
}
.btn--ghost { border-color: var(--border); color: var(--text-dim); }
.btn--ghost:hover { border-color: var(--blue-700); color: var(--blue-200); }

/* ---- panels / sections ---- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 28px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: #0b1424;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
  flex-wrap: wrap;
}
.panel-head .tag {
  background: var(--blue-900);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 3px;
}
.panel-body { padding: 18px 16px; }

h1, h2, h3 { font-family: var(--mono); font-weight: 700; letter-spacing: 1px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 17px; color: var(--blue-200); margin: 0 0 12px; }
.page-intro { color: var(--text-dim); font-size: 15px; margin: 0 0 26px; max-width: 70ch; }

/* ---- stat strip ---- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 36px;
}
.stat {
  background: var(--bg-panel);
  padding: 16px 18px;
}
.stat b {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--blue-100);
  line-height: 1.15;
}
.stat span {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim-2);
  text-transform: uppercase;
}

/* ---- filters ---- */

.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}
.filters label { letter-spacing: 1px; }
select, input[type="search"], input[type="text"] {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-box);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: 0;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--blue-700);
  box-shadow: 0 0 8px rgba(47,92,255,0.35);
}

/* ---- tables ---- */

.table-scroll { overflow-x: auto; }
table.lb {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}
table.lb th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 9px;
  border-bottom: 1px solid var(--border);
}
table.lb td {
  padding: 10px 9px;
  border-bottom: 1px solid #0d1526;
  color: var(--text-dim);
}
table.lb td.net {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.lb tr:hover td { background: #0b1424; }
table.lb td.rank { color: var(--text-faint); width: 1%; }
table.lb td.region { color: var(--text); width: 1%; }
table.lb tr:nth-child(-n+3) td.rank { color: var(--blue-200); font-weight: 700; }
table.lb td .game-link { color: var(--text); }
table.lb td .game-link:hover { color: var(--blue-200); }
table.lb td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lb td.p50 { color: var(--blue-100); font-weight: 700; }
table.lb td.p95 { color: var(--blue-300); }
th.num { text-align: right !important; }
.empty-row td { color: var(--text-faint); padding: 26px 12px; text-align: center; }

/* in-cell signal meter */
.sig {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
}
.sig span { width: 3px; background: #152444; display: block; }
.sig span:nth-child(1) { height: 26%; }
.sig span:nth-child(2) { height: 50%; }
.sig span:nth-child(3) { height: 74%; }
.sig span:nth-child(4) { height: 100%; }
.sig[data-bars="1"] span:nth-child(-n+1),
.sig[data-bars="2"] span:nth-child(-n+2),
.sig[data-bars="3"] span:nth-child(-n+3),
.sig[data-bars="4"] span:nth-child(-n+4) { background: var(--blue-300); }
.sig[data-bars="4"] span:nth-child(4) { background: var(--blue-100); }

.cgnat-chip {
  font-size: 12px;
  letter-spacing: 1px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.cgnat-chip[data-c="confirmed"] { border-color: var(--blue-700); color: var(--blue-200); }
.cgnat-chip[data-c="likely"] { border-color: #22407e; color: var(--blue-300); }

/* ---- header tooltip (the "?" beside the access column) ----
   The trigger is a real link to the FAQ explainer; the popover is a
   hover/focus-only summary. Positioned below the header so it stays inside
   .table-scroll instead of being clipped at the panel edge. */

.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
.tip:hover, .tip:focus-visible {
  border-color: var(--blue-700);
  color: var(--blue-200);
  box-shadow: 0 0 8px rgba(47,92,255,0.35);
}
/* invisible outer hit area so the 15px trigger doesn't demand precision */
.tip::before {
  content: "";
  position: absolute;
  inset: -6px;
}
/* word variant: the header label itself is the trigger — no badge box, just
   a dotted underline signalling "hover me" */
.tip-word {
  width: auto;
  height: auto;
  margin-left: 0;
  border: none;
  border-bottom: 1px dotted var(--text-dim-2);
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  vertical-align: baseline;
}
.tip-word:hover, .tip-word:focus-visible {
  border: none;
  border-bottom: 1px dotted var(--blue-200);
  color: var(--blue-200);
  box-shadow: none;
}
.tip-pop {
  visibility: hidden;
  opacity: 0;
  /* fixed so the box escapes .table-scroll's overflow clipping (which would
     cut it off on short tables); left/top are set by the layout script */
  position: fixed;
  z-index: 5;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: var(--surface-box);
  border: 1px solid var(--blue-700);
  box-shadow: 0 0 12px rgba(47,92,255,0.3);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: normal;
  color: var(--text-dim);
  /* grace period: linger ~300ms after hover leaves so the pointer can come
     back without the tooltip vanishing underneath it */
  transition: opacity 120ms ease 200ms, visibility 0s linear 320ms;
}
/* safe triangle: an invisible collar bridging the gap up to the trigger,
   clipped to the path a cursor takes from the trigger apex to the popover's
   top corners — diagonal travel toward the popover never drops :hover
   (the popover is a DOM child of .tip, so hovering it keeps .tip:hover) */
.tip-pop::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 12px;
  clip-path: polygon(var(--tip-apex, 50%) 0, 0 100%, 100% 100%);
}
.tip-pop b { color: var(--blue-200); font-weight: 600; }
.tip:hover .tip-pop, .tip:focus-visible .tip-pop {
  visibility: visible;
  opacity: 1;
  transition: opacity 120ms ease, visibility 0s;
}

/* ---- games grid ---- */

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.game-card {
  display: block;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 16px;
  color: var(--text);
}
.game-card:hover {
  border-color: var(--blue-700);
  color: var(--text);
  box-shadow: 0 0 12px rgba(47,92,255,0.25);
}
.game-card h3 { margin: 0 0 8px; font-size: 15px; letter-spacing: 0; }
.game-card .meta { font-size: 13px; color: var(--text-dim-2); }
.game-card .meta b { color: var(--blue-200); font-weight: 600; }
.game-card.nodata { opacity: 0.55; }
.game-card.nodata:hover { opacity: 0.85; }

/* ---- CLI banner lockup (spec: CSS borders, never box-drawing chars) ---- */

.cli-banner {
  border: 1px solid var(--blue-700);
  box-shadow: inset 0 0 0 3px var(--bg-inset), inset 0 0 0 4px rgba(47,92,255,0.35);
  background: var(--surface-box);
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--blue-400);
  overflow-x: auto;
}
.cli-banner .t { color: var(--text); font-weight: 700; letter-spacing: 2px; }
.cli-banner .d { color: var(--text-dim-2); }
.cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--blue-400);
  vertical-align: -2px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

pre.code {
  background: var(--surface-box);
  border: 1px solid var(--border);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--blue-200);
  overflow-x: auto;
  margin: 0;
}
pre.code .c { color: var(--text-dim-2); }
code {
  color: var(--blue-200);
  overflow-wrap: anywhere;
}

/* ---- how it works ---- */

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}
.step {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 18px;
}
.step .n {
  font-size: 12px;
  color: var(--blue-700);
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.step h3 { margin: 0 0 8px; font-size: 15px; color: var(--blue-100); }
.step p { margin: 0; font-size: 14px; color: var(--text-dim); }

/* ---- definition lists (agent page) ---- */

dl.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; font-size: 14px; }
dl.kv dt { color: var(--text-dim-2); letter-spacing: 1px; text-transform: uppercase; font-size: 12px; padding-top: 2px; }
dl.kv dd { margin: 0; color: var(--text); }
dl.kv dd ul { margin: 0; padding-left: 18px; }

.note { font-size: 13px; color: var(--text-dim-2); max-width: 76ch; }

/* ---- faq ---- */

.faq-a p, .faq-a ul { font-size: 15px; color: var(--text-dim); max-width: 76ch; margin: 0 0 12px; }
.faq-a p:last-child, .faq-a ul:last-child { margin-bottom: 0; }
.faq-a ul { padding-left: 20px; }
.faq-a li { margin-bottom: 4px; }
.faq-a b { color: var(--blue-100); font-weight: 600; }
.faq-a dl.kv dd { color: var(--text-dim); }

/* deep links (e.g. the leaderboard tooltip → #access-detection) land with
   breathing room and light the target panel up */
.panel[id] { scroll-margin-top: 18px; }
.panel:target {
  border-color: var(--blue-700);
  box-shadow: 0 0 14px rgba(47,92,255,0.3);
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .site-nav { margin-left: 0; width: 100%; }
  main { padding-top: 24px; padding-bottom: 56px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 10px; }
}
