/*
 * stats.ppq.ai styling, following the ppq.ai design system (PPQdotAI #2935,
 * styles/foundation/*). Token values are copied from theme.css and tokens.css;
 * keep them in sync when the main site changes them.
 * Plotly figures cannot read CSS variables, so their colors live in
 * ppq_theme.py with the same values.
 */

@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-sans: 'Geist', Arial, Helvetica, sans-serif;
  --font-mono: 'Geist Mono', 'SFMono-Regular', Consolas, monospace;
  --space-unit: 0.25rem;
  --text-caption: 0.6875rem;
  --text-xs: 0.75rem;
  --text-label: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-heading: 1.5rem;
  --tracking-tight: -0.015em;
  --tracking-heading: -0.025em;
  --radius: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --duration-fast: 100ms;

  --background: 48 8.772% 88.824%;
  --foreground: 45 4.348% 18.039%;
  --surface: 45 10.526% 85.098%;
  --raised: 48 12.821% 92.353%;
  --card: 50 12.5% 90.588%;
  --muted: 46.667 10.345% 82.941%;
  --muted-foreground: 40 5.882% 30%;
  --border: 45 10.909% 80.784%;
  --border-strong: 44 9.434% 73.333%;
  --ring: 210.619 100% 38.039%;
  --accent: 45 11.321% 79.216%;
  --brand-ink: 11.6 75.758% 34%;
  --success-ink: 142.785 64.228% 23%;
  --destructive-ink: 0 73.709% 37%;
  --bitcoin: 32.579 93.249% 53.529%;
}

.dark {
  color-scheme: dark;
  --background: 0 0% 8.235%;
  --foreground: 0 0% 92.941%;
  --surface: 0 0% 11.373%;
  --raised: 0 0% 14.118%;
  --card: 0 0% 11.373%;
  --muted: 0 0% 16.078%;
  --muted-foreground: 0 0% 73.333%;
  --border: 0 0% 18.039%;
  --border-strong: 0 0% 23.137%;
  --ring: 212.542 100% 76.863%;
  --accent: 0 0% 19.216%;
  --brand-ink: 19.636 78.199% 60%;
  --success-ink: 143.368 58.282% 68.039%;
  --destructive-ink: 0 100% 80.784%;
}

/* Base */

html,
body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: var(--radius);
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  padding: 8px 12px;
  background: hsl(var(--raised));
  border-radius: var(--radius);
}

/* Page shell, matching WorkspacePageShell spacing */

.page {
  max-width: 1184px;
  margin: 0 auto;
  padding: calc(var(--space-unit) * 5) calc(var(--space-unit) * 12) calc(var(--space-unit) * 12);
}

.page-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space-unit) * 4);
  min-height: 40px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  font-size: var(--text-sm);
  min-width: 0;
}
.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--space-unit) * 2);
  min-height: 40px;
  text-decoration: none;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.breadcrumb a.crumb {
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.breadcrumb a.crumb:hover {
  color: hsl(var(--foreground));
}
.breadcrumb img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.breadcrumb .sep {
  color: hsl(var(--muted-foreground));
}

.page-title {
  margin: 2px 0 0;
  font-size: var(--text-heading);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

/* Theme toggle, same placement as the main site */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background var(--duration-fast);
}
.theme-toggle:hover {
  background: hsl(var(--accent));
}
.theme-toggle::before {
  content: '';
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  /* Moon: switch to dark */
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.5 14.08A9.5 9.5 0 0 1 9.92 2.5 9.5 9.5 0 1 0 21.5 14.08Z'/%3E%3C/svg%3E");
}
.dark .theme-toggle::before {
  /* Sun: switch to light */
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Cpath d='M12 2v1.5M12 20.5V22M4.93 4.93l1.06 1.06M18.01 18.01l1.06 1.06M2 12h1.5M20.5 12H22M4.93 19.07l1.06-1.06M18.01 5.99l1.06-1.06'/%3E%3C/svg%3E");
}

/* Intro row, matching the pricing page */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: calc(var(--space-unit) * 8);
  align-items: end;
  padding: calc(var(--space-unit) * 3) 0 calc(var(--space-unit) * 8);
}
.lead {
  margin: calc(var(--space-unit) * 1.5) 0 0;
  font-size: var(--text-base);
  line-height: calc(var(--space-unit) * 6);
}
.explain {
  margin: calc(var(--space-unit) * 2.5) 0 0;
  max-width: 600px;
  font-size: var(--text-label);
  line-height: calc(var(--space-unit) * 5);
  color: hsl(var(--muted-foreground));
}
.explain b {
  font-weight: 500;
  color: hsl(var(--foreground));
}

.facts {
  display: flex;
  margin: 0;
  border: 1px solid hsl(var(--border-strong));
  border-radius: var(--radius-lg);
}
.fact {
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 3);
  min-width: 0;
}
.fact + .fact {
  border-left: 1px solid hsl(var(--border));
}
.fact dt {
  font-size: var(--text-caption);
  line-height: calc(var(--space-unit) * 3.5);
  color: hsl(var(--muted-foreground));
}
.fact dd {
  margin: calc(var(--space-unit) * 0.5) 0 0;
  display: flex;
  align-items: baseline;
  gap: calc(var(--space-unit) * 1);
}
.fact strong {
  font-size: var(--text-lg);
  line-height: calc(var(--space-unit) * 5.5);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}
.fact dd span {
  font-size: var(--text-caption);
  color: hsl(var(--muted-foreground));
}

a.link-fact {
  display: block;
  text-decoration: none;
  border: 1px solid hsl(var(--border-strong));
  border-radius: var(--radius-lg);
  padding: calc(var(--space-unit) * 2) calc(var(--space-unit) * 3);
  transition: background var(--duration-fast);
}
a.link-fact:hover {
  background: hsl(var(--raised));
}
a.link-fact .fact-label {
  display: block;
  font-size: var(--text-caption);
  line-height: calc(var(--space-unit) * 3.5);
  color: hsl(var(--muted-foreground));
}
a.link-fact .fact-value {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  font-weight: 500;
}

.bolt {
  color: hsl(var(--bitcoin));
}

/* Sections */

.section {
  padding-top: calc(var(--space-unit) * 8);
  border-top: 1px solid hsl(var(--border));
  margin-bottom: calc(var(--space-unit) * 8);
}
.section-title {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.section-description {
  margin: calc(var(--space-unit) * 1.5) 0 calc(var(--space-unit) * 4);
  max-width: 720px;
  font-size: var(--text-label);
  line-height: calc(var(--space-unit) * 5);
  color: hsl(var(--muted-foreground));
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.chart-card {
  padding: calc(var(--space-unit) * 2);
}

/* Ranked model lists, styled like the pricing table */

.ranking {
  margin-top: calc(var(--space-unit) * 4);
}
.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: calc(var(--space-unit) * 3) calc(var(--space-unit) * 3);
  background: hsl(var(--surface));
  border-bottom: 1px solid hsl(var(--border));
  font-size: var(--text-label);
  font-weight: 500;
}
.ranking-header span {
  font-size: var(--text-caption);
  font-weight: 400;
  color: hsl(var(--muted-foreground));
}
.ranking-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.ranking-columns ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ranking-columns ol + ol {
  border-left: 1px solid hsl(var(--border));
}
.ranking-row {
  display: grid;
  grid-template-columns: 2.5ch minmax(0, 1fr) auto;
  gap: calc(var(--space-unit) * 3);
  align-items: baseline;
  padding: calc(var(--space-unit) * 2.5) calc(var(--space-unit) * 3);
  border-bottom: 1px solid hsl(var(--border));
}
.ranking-columns ol li:last-child {
  border-bottom: 0;
}
.rank {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}
.model-id {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}
.delta.up {
  color: hsl(var(--success-ink));
}
.delta.down {
  color: hsl(var(--destructive-ink));
}
.empty {
  padding: calc(var(--space-unit) * 4);
  color: hsl(var(--muted-foreground));
}

/* Info cards on the creator payouts page */

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--space-unit) * 4);
}
.info-card {
  padding: calc(var(--space-unit) * 4);
}
.info-card h3 {
  margin: 0 0 calc(var(--space-unit) * 2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.info-card p {
  margin: 0 0 calc(var(--space-unit) * 3);
  font-size: var(--text-label);
  color: hsl(var(--muted-foreground));
}
.info-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.info-card li + li {
  margin-top: calc(var(--space-unit) * 1.5);
}
.text-link {
  font-size: var(--text-label);
  font-weight: 500;
  color: hsl(var(--brand-ink));
  text-decoration: none;
}
.text-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.info-card .contact-line {
  margin: 0;
}
/* The contact link carries legacy inline styles; the theme wins here */
.info-card .contact-line a {
  color: hsl(var(--brand-ink)) !important;
  font-weight: 500 !important;
  text-decoration: none;
}
.info-card .contact-line a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer */

.site-footer {
  padding-top: calc(var(--space-unit) * 6);
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  gap: calc(var(--space-unit) * 4);
  flex-wrap: wrap;
  font-size: var(--text-label);
  color: hsl(var(--muted-foreground));
}
.site-footer a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
}
.site-footer a:hover {
  color: hsl(var(--foreground));
}
.site-footer nav {
  display: flex;
  gap: calc(var(--space-unit) * 4);
}

/* Plotly hover labels should not inherit the page's text cursor */
.js-plotly-plot .plotly .cursor-crosshair {
  cursor: default;
}

/* Narrow viewports */

@media (max-width: 720px) {
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }
  .intro {
    grid-template-columns: minmax(0, 1fr);
    gap: calc(var(--space-unit) * 5);
  }
  .facts {
    width: fit-content;
    max-width: 100%;
  }
  .ranking-columns {
    grid-template-columns: minmax(0, 1fr);
  }
  .ranking-columns ol + ol {
    border-left: 0;
    border-top: 1px solid hsl(var(--border));
  }
  .info-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  a.link-fact {
    transition: none;
  }
}
