/* trackthe6 — mobile first. Everything is written for a ~380px phone; the media query at the bottom widens it. */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.1);
  --up: #0ca30c;
  --down: #e66767;
  --accent: #3987e5;
  /* Button fills are darker than --accent so white text on them passes 4.5:1 contrast. */
  --accent-btn: #2563c7;
  --accent-btn-hover: #2a6fd6;

  /* Platform colors: the first three slots of a colorblind-checked palette (not brand colors).
     The charts read these same variables (see token() in common.js), so change them here only. */
  --twitch: #3987e5;
  --kick: #d95926;
  --youtube: #199e70;

  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* the hidden attribute always wins, even on flex/grid elements */

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%; /* stops iOS inflating text in landscape */
}

a { color: var(--ink); }
h1, h2 { text-wrap: balance; }

/* One visible keyboard focus ring for every link and button. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Side padding only (so header/footer can set their own top/bottom), and never under a phone notch. */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}

/* Keyboard users can jump past the header. Hidden until it gets focus. */
.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}
.skip:focus { top: 8px; }

/* ---- header ---- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 12px;
  padding-block: 6px;
}
.logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo span { color: var(--muted); font-weight: 600; }
.nav { display: flex; gap: 4px; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* thumb-sized */
  color: var(--ink-2);
  text-decoration: none;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
  transition: background-color 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }

/* ---- page heading (/streams) ---- */
.page-head { margin-bottom: 12px; }
.page-head h1 { margin: 4px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.page-head .updated { margin: 2px 0 0; }

/* ---- banners ---- */
.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #3a2a10;
  color: #fbd38d;
  font-size: 14px;
}

/* ---- cards ---- */
/* minmax(0, 1fr) stops wide content (charts, tables) from stretching the column past the screen. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-bottom: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0; /* lets charts shrink inside grid cells */
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
}
.sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* Every live number uses fixed-width digits, so nothing jiggles sideways when a value refreshes. */
.hero-num, .big, .delta, .chips b, .trailer-stats b { font-variant-numeric: tabular-nums; }

/* ---- hero ---- */
.hero-label { color: var(--ink-2); font-size: 14px; font-weight: 650; margin: 0; }
.hero-num {
  /* 13vw keeps an 8-digit number ("12,345,678") on one line on a 360px phone. */
  font-size: clamp(44px, 13vw, 84px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 4px 0 8px;
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--down);
  margin-right: 6px;
  vertical-align: middle;
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
/* Only look "live" while the data is. common.js sets .is-stale when the snapshot is old or missing. */
.is-stale .live-dot { background: var(--muted); animation: none; }

/* min-height reserves the first line before data arrives, so the page doesn't jump on load. */
.chips { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; min-height: 21px; }
.chips li { color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.chips b { color: var(--ink); font-weight: 650; }
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}
.updated { color: var(--muted); font-size: 13px; margin: 10px 0 0; min-height: 1.5em; }

.peak { color: var(--ink-2); font-size: 14px; margin: 8px 0 0; }
.peak b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---- countdown ---- */
.count {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 2px 0 6px;
  font-size: clamp(30px, 9vw, 48px);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums; /* fixed-width digits: the clock doesn't wobble each second */
}
.count small { font-size: 0.45em; font-weight: 600; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
#countdown .sub { margin-bottom: 0; }

/* ---- card heading with a control on the right (chart range) ---- */
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.card-head h2 { margin: 0; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--page); border: 1px solid var(--ring); }
.seg button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  min-width: 48px;
  min-height: 44px; /* thumb-sized */
  padding: 0 10px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 650; }

/* ---- charts ---- */
.chart { position: relative; height: 240px; }
.chart.small { height: 140px; }

/* ---- stat rows ---- */
.stat { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stat .big { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.delta { font-weight: 650; font-size: 15px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

/* ---- calling-in card ---- */
.sick .big { font-size: 40px; font-weight: 750; letter-spacing: -0.02em; margin: 0; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--accent-btn);
  color: #fff;
  font: inherit;
  font-weight: 650;
  padding: 12px 16px;
  width: 100%;
  margin-top: 12px;
  cursor: pointer;
  min-height: 44px; /* thumb-sized */
  transition: background-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--accent-btn-hover); }
.btn:active:not(:disabled) { transform: scale(0.98); } /* small "pressed" feedback on tap */
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
/* Secondary button: outline only, so it doesn't compete with the main "I'm calling in" button. */
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--axis); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.captcha { margin-top: 12px; min-height: 0; }
.msg { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); min-height: 1.5em; }

/* Top countries: name on the left, count on the right, a thin share bar underneath. */
.mini { margin: 14px 0 8px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.countries { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.countries li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; }
.countries .n { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.countries .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.countries .bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.sick .sub:last-child { margin-bottom: 0; }

/* ---- trailers ---- */
.trailers { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.trailers li { border-top: 1px solid var(--grid); padding-top: 10px; }
.trailers li:first-child { border-top: 0; padding-top: 0; }
.trailers a { font-weight: 600; text-decoration: none; }
.trailers a:hover { text-decoration: underline; }
.trailer-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.trailer-stats b { color: var(--ink); }

/* ---- stream tables (/streams) ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 0 8px 6px 0; }
td { padding: 9px 8px 9px 0; border-top: 1px solid var(--grid); vertical-align: top; }
td.rank { color: var(--muted); width: 1.8em; font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; white-space: nowrap; }
td .channel { font-weight: 600; text-decoration: none; }
td .channel:hover { text-decoration: underline; }
/* Stream titles are written by strangers and can be very long: show two lines at most. */
td .title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ---- footer ---- */
footer {
  border-top: 1px solid var(--grid);
  color: var(--muted);
  font-size: 13px;
  padding-block: 18px max(32px, env(safe-area-inset-bottom));
}
footer p { margin: 4px 0; }
footer a { color: var(--ink-2); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Visitors who ask their device for less motion get none: no pulse, no transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- wider screens ---- */
@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .span-2 { grid-column: span 2; }
  .chart { height: 300px; }
  .btn { width: auto; }
}
