/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg:          #111217;
  --surface:     #181b1f;
  --surface-2:   #1e2028;
  --border:      rgba(204, 204, 220, 0.12);
  --text:        #d9d9d9;
  --text-muted:  #666;
  --text-dim:    #999;
  --accent:      #5794f2;

  --pass:        rgb(115, 191, 105);
  --pass-bg:     rgb(77, 172, 73);
  --pass-text:   #f7f8fa;
  --fail:        rgb(242, 73, 92);
  --fail-bg:     rgb(239, 25, 32);
  --fail-text:   #f7f8fa;
  --skip:        rgb(204, 204, 220);
  --skip-bg:     rgb(176, 174, 199);
  --skip-text:   #202226;

  --score-low:   #e83c50;
  --score-mid:   #EB9646;
  --score-high:  #58b86e;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Typography — scale */
  --text-xs:   12px;
  --text-sm:   14px;
  --text-base: 16px;
  --text-lg:   18px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  --font-sans: Inter, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Radius */
  --radius-sm: 2px;
  --radius:    4px;
  --radius-lg: 8px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Widget chrome ────────────────────────────────────────────────────────── */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  overflow: visible;
  margin-bottom: var(--space-6);
}
.widget-header {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.widget-title { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.widget-body  { padding: var(--space-4); }

/* Info popover */
.info-wrap { position: relative; display: flex; align-items: center; }
.info-icon { display: flex; align-items: center; color: var(--text-muted); cursor: help; transition: color 0.15s; }
.info-icon:hover { color: var(--text); }
.info-popover {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-dim);
  line-height: 1.6;
  width: 300px;
  z-index: 200;
  white-space: normal;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
}
.info-wrap:hover .info-popover { visibility: visible; opacity: 1; }

/* Widget badge */
.widget-badge {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
}

/* Placeholder (coming-soon pages) */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
  gap: var(--space-3);
  color: var(--text-muted);
}
.placeholder-icon  { font-size: 2.5rem; margin-bottom: var(--space-2); }
.placeholder-title { font-size: var(--text-xl); font-weight: 600; color: var(--text-dim); }
.placeholder-sub   { font-size: var(--text-base); max-width: 480px; line-height: 1.7; }
.placeholder-badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  margin-top: var(--space-2);
  opacity: 0.7;
}

/* ── Matrix table ─────────────────────────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; }
.matrix {
  border-collapse: collapse;
  white-space: nowrap;
  font-size: var(--text-sm);
}
.col-header {
  min-width: var(--cell-width, 72px);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-dim);
  text-align: center;
  padding: 3px 5px 6px;
}
.row-label {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text);
  text-align: left;
  padding-right: var(--space-4);
  white-space: nowrap;
}
.cell {
  text-align: center;
  padding: 4px 8px;
  min-width: 54px;
  border: 1px solid transparent;
}
.cell-pass    { background: linear-gradient(120deg, var(--pass-bg), var(--pass)); color: var(--pass-text); border-color: rgba(0,0,0,0.3); font-size: var(--text-xs); }
.cell-fail    { background: linear-gradient(120deg, var(--fail-bg), var(--fail)); color: var(--fail-text); border-color: rgba(0,0,0,0.3); font-size: var(--text-xs); }
.cell-skip    { background: linear-gradient(120deg, var(--skip-bg), var(--skip)); color: var(--skip-text); border-color: rgba(0,0,0,0.3); font-size: var(--text-xs); }
.cell-latency { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--text-xs); }

/* ── Collapsible sample block ─────────────────────────────────────────────── */
.sample-details { font-size: var(--text-sm); }
.sample-details summary {
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.sample-details summary::before {
  content: '▶';
  font-size: 0.6em;
  transition: transform 0.15s;
}
.sample-details[open] summary::before { transform: rotate(90deg); }
.sample-details summary::-webkit-details-marker { display: none; }

.sample-body {
  position: relative;
  margin-top: 0.5rem;
}
.sample-body pre {
  margin: 0;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
}
.copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
  cursor: pointer;
  z-index: 1;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-mono   { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-bold   { font-weight: 600; }

.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-1       { gap: var(--space-1); }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }

.tabular     { font-variant-numeric: tabular-nums; }
