/* ==========================================================================
   Trajectory demo — Classifier Evaluation Playground
   Palette: validated dataviz reference instance (light + dark), CVD-safe.
   The SVG chart marks use the validated categorical hues untouched; the page
   chrome around them is elevated for a refined product feel.
   ========================================================================== */

.viz-root {
  /* surfaces & ink */
  --surface-1: #ffffff;      /* card / chart surface */
  --surface-2: #fcfcfb;      /* insets */
  --page-plane: #f4f5f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;     /* axis / labels */
  --gridline: #e9e9e4;
  --baseline: #d3d2cb;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.14);
  --success-text: #006300;

  /* categorical series (identity) — validated hues, do not alter */
  --series-1: #2a78d6;       /* blue  — model */
  --series-2: #1baf7a;       /* aqua  — secondary */
  --reference: #a8a7a0;      /* muted — diagonal reference line */

  /* status */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* brand accent (chrome only, never a chart mark) */
  --accent: #2a78d6;
  --accent-2: #4f46e5;
  --grad: linear-gradient(135deg, #2a78d6 0%, #4f46e5 100%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(11,11,11,0.04), 0 1px 3px rgba(11,11,11,0.03);
  --shadow: 0 1px 2px rgba(11,11,11,0.04), 0 10px 30px -12px rgba(11,11,11,0.14);
  --shadow-lg: 0 24px 60px -20px rgba(11,11,11,0.22);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  .viz-root {
    --surface-1: #1e1e1c;
    --surface-2: #191917;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #908e87;
    --gridline: #2c2c2a;
    --baseline: #3a3a37;
    --border: rgba(255,255,255,0.09);
    --border-strong: rgba(255,255,255,0.16);
    --success-text: #0ca30c;
    --series-1: #3987e5;
    --series-2: #199e70;
    --reference: #6f6e68;
    --accent: #3987e5;
    --accent-2: #8b83f0;
    --grad: linear-gradient(135deg, #3987e5 0%, #8b83f0 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px -14px rgba(0,0,0,0.6);
    --shadow-lg: 0 28px 64px -22px rgba(0,0,0,0.75);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text-primary);
  background:
    radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 55%),
    var(--page-plane);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------------- Header / footer ---------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-1) 78%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--grad);
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.brand-name { font-size: 16px; letter-spacing: -0.02em; }
.brand-sep { color: var(--text-muted); font-weight: 400; }
.brand-demo { color: var(--text-secondary); font-weight: 500; }
.header-link {
  color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  transition: all 0.18s var(--ease);
}
.header-link:hover { color: var(--text-primary); border-color: var(--accent); transform: translateY(-1px); }

.site-footer {
  padding: 22px 28px; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; margin-top: 40px;
}
.site-footer code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------------- Layout ---------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 40px 28px 12px; }
.intro { max-width: 820px; margin-bottom: 30px; }
.intro h1 {
  font-size: 40px; line-height: 1.08; letter-spacing: -0.035em; margin: 0 0 14px;
  font-weight: 720;
}
.intro h1 .grad-word {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.lede { color: var(--text-secondary); font-size: 17px; margin: 0; }
.lede strong { color: var(--text-primary); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 26px;
  align-items: start;
}
@media (max-width: 940px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.controls { padding: 22px; position: sticky; top: 84px; }
@media (max-width: 940px) { .controls { position: static; } }

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex; gap: 4px; padding: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 20px;
}
.tab {
  flex: 1; padding: 9px 10px; border: none; background: transparent;
  color: var(--text-secondary); font: inherit; font-weight: 550; font-size: 14px;
  border-radius: 8px; cursor: pointer; transition: all 0.18s var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; animation: fade 0.25s var(--ease); }
.tab-panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- Fields ---------------- */
.field { margin-bottom: 18px; }
.field-group {
  margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--border);
}
.field label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 550; color: var(--text-secondary); margin-bottom: 8px;
}
.field .val {
  font-weight: 650; color: var(--accent);
  font-variant-numeric: tabular-nums; font-size: 13px;
}
.hint { font-size: 12px; color: var(--text-muted); margin: 7px 0 0; line-height: 1.45; }

input[type="range"] {
  width: 100%; height: 6px; border-radius: 999px; appearance: none;
  background: var(--gridline); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-1); border: 2px solid var(--accent);
  box-shadow: 0 2px 6px -1px color-mix(in srgb, var(--accent) 50%, transparent);
  transition: transform 0.14s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent);
  background: var(--surface-1);
}
input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }

select, input[type="number"], textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;
  color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.check {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 13px; color: var(--text-secondary); font-weight: 400; cursor: pointer;
}
.check input { width: auto; accent-color: var(--accent); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.file-btn {
  padding: 9px 15px; font-size: 13px; font-weight: 550; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text-primary); transition: all 0.16s var(--ease);
}
.file-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.link-btn {
  background: none; border: none; color: var(--accent); font: inherit;
  font-size: 13px; cursor: pointer; padding: 8px 4px; font-weight: 550;
}
.link-btn:hover { text-decoration: underline; }

.run-btn {
  width: 100%; margin-top: 22px; padding: 13px; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 650; color: #fff;
  background: var(--grad); border: none; border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform 0.14s var(--ease), box-shadow 0.14s var(--ease), filter 0.14s var(--ease);
}
.run-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -10px color-mix(in srgb, var(--accent) 75%, transparent); }
.run-btn:active { transform: translateY(0); filter: brightness(0.96); }
.run-btn:disabled { opacity: 0.6; cursor: progress; transform: none; }

.status { font-size: 13px; margin: 13px 0 0; min-height: 18px; font-weight: 500; }
.status.error { color: var(--critical); }
.status.ok { color: var(--success-text); }

/* ---------------- Results ---------------- */
.results { animation: rise 0.4s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.dataset-line {
  color: var(--text-secondary); font-size: 14px; margin-bottom: 18px;
  padding: 11px 15px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-sm);
}
.dataset-line strong { color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 650; }

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 15px; margin-bottom: 22px;
}
.tile {
  position: relative; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.tile::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad); opacity: 0.9;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tile .tile-label { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 8px; }
.tile .tile-value {
  font-size: 34px; font-weight: 720; letter-spacing: -0.03em;
  color: var(--text-primary); line-height: 1; font-variant-numeric: tabular-nums;
}
.tile .tile-sub { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.tile.is-muted::before { background: var(--baseline); opacity: 0.5; }
.tile.is-muted .tile-value { color: var(--text-muted); }

.warnings {
  border: 1px solid var(--border); border-left: 3px solid var(--warning);
  background: var(--surface-1); border-radius: 12px; padding: 13px 16px; margin-bottom: 22px;
  font-size: 13px; color: var(--text-secondary); box-shadow: var(--shadow-sm);
}
.warnings .warn-title { font-weight: 650; color: var(--text-primary); }

.charts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px; margin-bottom: 22px;
}
.chart-card {
  margin: 0; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.chart-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.chart-card figcaption { margin-bottom: 12px; }
.chart-card h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.cap-sub { font-size: 12px; color: var(--text-muted); }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-empty {
  display: flex; align-items: center; justify-content: center; min-height: 230px;
  color: var(--text-muted); font-size: 13px; text-align: center; padding: 0 24px;
  background: var(--surface-2); border-radius: 12px; border: 1px dashed var(--baseline);
}

/* SVG chart elements — validated marks, unchanged */
.axis-line { stroke: var(--baseline); stroke-width: 1; }
.grid-line { stroke: var(--gridline); stroke-width: 1; }
.axis-tick { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }
.axis-title { fill: var(--text-secondary); font-size: 11px; font-weight: 550; font-family: var(--font); }
.series-line { fill: none; stroke: var(--series-1); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.reference-line { fill: none; stroke: var(--reference); stroke-width: 1.5; stroke-dasharray: 3 3; }
.rel-marker { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 1.5; }
.hover-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; pointer-events: none; }
.crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.hit-layer { fill: transparent; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 40;
  background: var(--text-primary); color: var(--surface-1);
  border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 8px 11px; font-size: 12px; opacity: 0; transition: opacity 0.1s;
  font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 550;
}
.tooltip .tt-key { color: color-mix(in srgb, var(--surface-1) 60%, transparent); font-weight: 400; }

/* ---------------- Threshold table ---------------- */
.table-card { padding: 22px; }
.table-card h3 { margin: 0 0 18px; font-size: 15.5px; font-weight: 650; }
.table-card h3 .mono { color: var(--accent); font-weight: 600; }
.threshold-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.metric {
  padding: 13px 15px; background: var(--surface-2); border-radius: 12px;
  border: 1px solid var(--border);
}
.metric .m-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.metric .m-value { font-size: 23px; font-weight: 680; font-variant-numeric: tabular-nums; margin-top: 3px; letter-spacing: -0.02em; }

.confusion { display: grid; grid-template-columns: auto 1fr 1fr; gap: 3px; max-width: 480px; }
.cm-cell {
  padding: 14px; text-align: center; background: var(--surface-2);
  border-radius: 8px; font-variant-numeric: tabular-nums;
}
.cm-head { background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 550; display: flex; align-items: center; justify-content: center; }
.cm-cell .cm-n { font-size: 21px; font-weight: 680; }
.cm-cell .cm-tag { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cm-tp, .cm-tn { background: color-mix(in srgb, var(--good) 13%, var(--surface-1)); }
.cm-fp, .cm-fn { background: color-mix(in srgb, var(--critical) 11%, var(--surface-1)); }

/* ---------------- Empty state ---------------- */
.results-empty {
  border: 1.5px dashed var(--baseline); border-radius: var(--radius);
  min-height: 440px; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--surface-1) 40%, transparent);
}
.empty-inner { text-align: center; color: var(--text-muted); max-width: 320px; }
.empty-inner p { font-size: 14.5px; }
.empty-glyph {
  width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 16px;
  background: var(--grad); opacity: 0.2;
  animation: pulse 3s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 0.16; } 50% { transform: scale(1.08); opacity: 0.28; } }
