/* Analytics page: range picker, chart chrome, heatmap and tooltips.
   The charts themselves are drawn by analytics.js; the colours it uses are
   the brand tokens from tailwind.config.js, listed again at the top of that
   file. Everything sits on the card surface (#171A22) - the site has no
   light theme. */

/* ---- Range picker ------------------------------------------------------- */
.rd-range {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid #33394B;
  border-radius: 6px;
  background: #171A22;
}
.rd-range button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 4px;
  color: #8890A5;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: color .15s, background-color .15s;
}
@media (min-width: 640px) {
  .rd-range button { min-height: 36px; padding: 0 14px; }
}
.rd-range button:hover { color: #FFFFFF; background: #1F232F; }
.rd-range button[aria-pressed="true"] { color: #FFFFFF; background: #E24D66; }
.rd-range button:focus-visible { outline: 2px solid #FA7D92; outline-offset: 2px; }

/* ---- Chart frames --------------------------------------------------------
   Reserve the drawn height up front, so the page doesn't jump when the
   script paints. The height includes the x-axis band. */
.rd-chart { position: relative; min-height: 240px; }
.rd-chart[data-chart^="growth"] { min-height: 200px; }
.rd-chart svg { display: block; overflow: visible; }
.rd-chart svg:focus { outline: none; }
.rd-chart svg:focus-visible,
.rd-heat-grid:focus-visible { outline: 2px solid #FA7D92; outline-offset: 4px; border-radius: 4px; }
.rd-chart text,
.rd-spark text {
  font-family: inherit;
  font-size: 12px;
  fill: #8890A5;
  font-variant-numeric: tabular-nums;
}
.rd-chart .rd-viz-end { fill: #FFFFFF; font-weight: 700; font-size: 13px; }
.rd-chart .rd-viz-peak { fill: #D3DBEF; font-weight: 700; }

.rd-viz-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 24px;
  border-radius: 6px;
  background: #0C0F14;
  color: #8890A5;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}
.rd-viz-note { margin-top: 8px; color: #8890A5; font-size: 13px; }

/* Summary figures above each chart. */
.rd-viz-sum dt { color: #8890A5; font-size: 13px; font-weight: 600; }
.rd-viz-sum dd { color: #FFFFFF; font-size: 20px; font-weight: 800; line-height: 1.3; }

/* Sparklines in the stat tiles. */
.rd-spark { height: 52px; }
.rd-spark svg { display: block; overflow: visible; }
[data-spark="players"] { height: 72px; }

/* ---- Tooltip ------------------------------------------------------------ */
.rd-viz-tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid #33394B;
  border-radius: 6px;
  background: #0C0F14;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
}
.rd-viz-tip[hidden] { display: none; }
.rd-viz-tip .t { margin-bottom: 2px; color: #8890A5; font-size: 12px; }
.rd-viz-tip .r { display: flex; align-items: center; gap: 6px; }
.rd-viz-tip .k { display: inline-block; width: 12px; height: 2px; border-radius: 1px; background: #E24D66; }
.rd-viz-tip .v { color: #FFFFFF; font-size: 15px; font-weight: 800; }
.rd-viz-tip .l { color: #AEB6CB; }

/* ---- Heatmap -------------------------------------------------------------- */
.rd-heat { position: relative; }
.rd-heat-grid {
  display: grid;
  grid-template-columns: 34px repeat(24, minmax(0, 1fr));
  gap: 2px;
}
.rd-heat-hour { color: #8890A5; font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
.rd-heat-day { color: #8890A5; font-size: 12px; font-weight: 600; line-height: 1; align-self: center; }
.rd-heat-cell { aspect-ratio: 1 / 1; min-height: 10px; border-radius: 2px; }
@media (min-width: 640px) { .rd-heat-cell { border-radius: 3px; } }
.rd-heat-cell.is-on { box-shadow: 0 0 0 2px #FFFFFF; position: relative; z-index: 1; }
.rd-heat-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #8890A5; font-size: 12px; }
.rd-heat-legend span.sw { display: inline-block; width: 18px; height: 10px; border-radius: 2px; }
.rd-heat-legend .sws { display: inline-flex; gap: 2px; }

/* ---- Table views ----------------------------------------------------------- */
.rd-viz-table > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: #8890A5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.rd-viz-table > summary::-webkit-details-marker { display: none; }
.rd-viz-table > summary::before {
  content: "\f0ce";               /* Font Awesome table icon */
  font: var(--fa-font-solid);
  font-size: 12px;
}
.rd-viz-table > summary:hover { color: #FFFFFF; }
.rd-viz-table > summary:focus-visible { outline: 2px solid #FA7D92; outline-offset: 2px; border-radius: 4px; }
.rd-viz-table > div { max-height: 320px; margin-top: 8px; overflow: auto; border: 1px solid #232731; border-radius: 6px; }
.rd-viz-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rd-viz-table th,
.rd-viz-table td { padding: 6px 12px; border-bottom: 1px solid #232731; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rd-viz-table th:first-child,
.rd-viz-table td:first-child { text-align: left; }
.rd-viz-table thead th { position: sticky; top: 0; background: #1F232F; color: #AEB6CB; font-weight: 700; }
.rd-viz-table td { color: #D3DBEF; }

/* ---- Bar lists (rendered in PHP) ------------------------------------------- */
.rd-bars { table-layout: fixed; }

/* ---- Live dot -------------------------------------------------------------- */
.rd-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #46DF31;
  box-shadow: 0 0 0 0 rgba(70, 223, 49, .6);
  animation: rd-live 2s infinite;
}
@keyframes rd-live {
  0%   { box-shadow: 0 0 0 0 rgba(70, 223, 49, .55); }
  70%  { box-shadow: 0 0 0 6px rgba(70, 223, 49, 0); }
  100% { box-shadow: 0 0 0 0 rgba(70, 223, 49, 0); }
}
@media (prefers-reduced-motion: reduce) { .rd-live-dot { animation: none; } }

/* Server-rendered pie and monthly interest table remain useful without JS. */
.rd-version-pie { margin-top: 20px; }
.rd-version-pie > svg { display: block; width: min(100%, 220px); height: auto; margin: 0 auto 16px; }
.rd-insight-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rd-insight-table th, .rd-insight-table td { padding: 9px 0; border-bottom: 1px solid #232731; }
.rd-insight-table th { text-align: left; font-weight: 600; color: #D3DBEF; }
.rd-insight-table td { text-align: right; color: #D3DBEF; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rd-insight-table thead th { font-size: 12px; color: #AEB6CB; }
.rd-insight-table thead th:not(:first-child) { text-align: right; }
.rd-pie-key { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; }
.rd-trends-scroll { margin-top: 12px; overflow-x: auto; color-scheme: dark; }
.rd-trends-scroll:focus-visible, .rd-trend-method summary:focus-visible { outline: 2px solid #FA7D92; outline-offset: 3px; }
.rd-trends-table { min-width: 520px; font-size: 14px; }
.rd-trends-table th, .rd-trends-table td { padding: 12px 16px; }
.rd-trends-table th:first-child { padding-left: 0; overflow-wrap: anywhere; }
.rd-trends-table td:last-child { padding-right: 0; font-weight: 600; }
.rd-trends-table .rd-trend-up { color: #46DF31; }
.rd-trends-table .rd-trend-down { color: #FA7D92; }
.rd-trends-table .rd-trend-flat { color: #AEB6CB; }
.rd-trend-notice { margin-top: 20px; padding: 18px; border: 1px solid #33394B; border-radius: 6px; color: #AEB6CB; background: #1F232F; line-height: 1.6; }
.rd-trend-notice strong { display: block; margin-bottom: 4px; color: #FFFFFF; }
.rd-trend-method { margin-top: 20px; color: #AEB6CB; font-size: 13px; line-height: 1.6; }
.rd-trend-method summary { cursor: pointer; font-weight: 600; }
.rd-trend-method p { margin-top: 10px; max-width: 80ch; }
