/* esfbot — design tokens (analytics theme, light + dark) */
:root,
[data-style="analytics"][data-mode="dark"] {
  --background: 222 30% 9%;
  --surface: 222 26% 12%;
  --surface-2: 222 22% 16%;
  --foreground: 210 30% 96%;
  --muted: 222 20% 18%;
  --muted-foreground: 215 16% 66%;
  --border: 222 20% 20%;
  --border-strong: 222 20% 28%;
  --primary: 198 90% 58%;
  --primary-foreground: 222 40% 8%;
  --positive: 158 70% 48%;
  --positive-soft: 158 50% 18%;
  --negative: 348 84% 62%;
  --negative-soft: 348 60% 22%;
  --warning: 42 96% 60%;
  --ring: 198 90% 58%;
  --radius: 1rem;
  --shadow-card:
    0 8px 24px -12px hsl(222 60% 4% / 0.6), 0 1px 0 hsl(0 0% 100% / 0.04) inset;
}

[data-style="analytics"][data-mode="light"] {
  --background: 220 30% 98%;
  --surface: 0 0% 100%;
  --surface-2: 220 30% 96%;
  --foreground: 222 47% 11%;
  --muted: 220 24% 95%;
  --muted-foreground: 215 16% 42%;
  --border: 220 18% 90%;
  --border-strong: 220 18% 82%;
  --primary: 222 76% 48%;
  --primary-foreground: 0 0% 100%;
  --positive: 158 70% 32%;
  --positive-soft: 158 64% 92%;
  --negative: 348 78% 48%;
  --negative-soft: 348 80% 95%;
  --warning: 32 90% 46%;
  --ring: 222 76% 48%;
  --shadow-card:
    0 6px 20px -10px hsl(222 40% 30% / 0.18), 0 1px 0 hsl(220 30% 20% / 0.03);
}

* {
  border-color: hsl(var(--border));
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  font-feature-settings: "ss01", "cv11";
}

.num {
  font-variant-numeric: tabular-nums;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.font-display {
  font-family: "Inter", system-ui, sans-serif;
}
.border-strong {
  border-color: hsl(var(--border-strong));
}

[data-mode="dark"] .dark-only {
  display: inline-flex;
}
[data-mode="light"] .light-only {
  display: inline-flex;
}

.range-tab,
.actual-window-tab {
  color: hsl(var(--muted-foreground));
}
.range-tab:hover,
.actual-window-tab:hover {
  color: hsl(var(--foreground));
}
.range-tab[aria-selected="true"],
.actual-window-tab[aria-selected="true"] {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.pulse-dot {
  position: relative;
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 9999px;
  background-color: hsl(var(--positive));
  opacity: 0.5;
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  80%,
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.animate-fade-in {
  animation: fade-in 0.4s ease-out both;
}
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.th-sortable {
  cursor: pointer;
  user-select: none;
}
.th-sortable:hover {
  color: hsl(var(--foreground));
}

/* ---------- Loading skeletons + spinner ---------- */
@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.85;
  }
}
.skeleton-card {
  height: 88px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: linear-gradient(
    100deg,
    hsl(var(--surface)) 30%,
    hsl(var(--surface-2)) 50%,
    hsl(var(--surface)) 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-table {
  height: 220px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: linear-gradient(
    100deg,
    hsl(var(--surface)) 30%,
    hsl(var(--surface-2)) 50%,
    hsl(var(--surface)) 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: linear-gradient(
    100deg,
    hsl(var(--surface)) 30%,
    hsl(var(--surface-2)) 50%,
    hsl(var(--surface)) 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  transition: opacity 0.25s ease;
}
[data-loading="false"] .loading-overlay {
  opacity: 0;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid hsl(var(--border-strong));
  border-top-color: hsl(var(--primary));
  animation: spinner-rot 0.7s linear infinite;
}
@keyframes spinner-rot {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Player detail dialog ---------- */
dialog.player-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(720px, 96vw);
  width: 100%;
  color: inherit;
  border-radius: 14px;
  overflow: hidden;
}
dialog.player-dialog::backdrop {
  background: transparent;
}
.player-dialog-card {
  background: hsl(var(--surface));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px hsl(0 0% 0% / 0.45);
  overflow: hidden;
  max-height: min(85vh, 800px);
  display: flex;
  flex-direction: column;
}
.player-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.player-dialog-body {
  padding: 1.25rem;
  overflow-y: auto;
}
.player-dialog-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.player-dialog-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.player-dialog-meta .stat {
  background: hsl(var(--surface-2));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
}
.player-dialog-meta .stat .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground));
}
.player-dialog-meta .stat .value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.95rem;
}
.player-dialog-news {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--surface-2));
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.player-dialog-chart {
  height: 140px;
  margin-bottom: 1rem;
}
.player-dialog-history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.player-dialog-history th,
.player-dialog-history td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-top: 1px solid hsl(var(--border));
}
.player-dialog-history th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground));
  border-top: none;
}
.player-dialog-history .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
@media (max-width: 640px) {
  dialog.player-dialog {
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }
  .player-dialog-card {
    border-radius: 0;
    height: 100dvh;
    max-height: 100dvh;
  }
}
