/* ==========================================================================
   ToolUse.1 — design system
   Dark, editorial, one accent. Motion is intentional, not decorative:
   entrance cascade, count-up, bars that grow, sections that reveal.
   ========================================================================== */

:root {
  --ink: #06070a;
  --ink-2: #0a0c10;
  --panel: #111419;
  --panel-2: #14171d;
  --line: #1f242e;
  --line-soft: #171b22;
  --text: #e9ebf0;
  --muted: #8d95a6;
  --dim: #626b7d;
  --accent: #e5484d;
  --accent-soft: #ff7a70;
  --accent-glow: rgba(229, 72, 77, 0.35);
  --good: #4ade80;
  --warn: #ffb454;
  --bronze: #c98a5b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 12px;
  --shadow: 0 18px 50px -28px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--ink);
  background-image:
    radial-gradient(1200px 560px at 10% -14%, rgba(229, 72, 77, 0.16), transparent 60%),
    radial-gradient(980px 500px at 98% 2%, rgba(96, 118, 214, 0.11), transparent 56%),
    radial-gradient(760px 640px at 50% 120%, rgba(229, 72, 77, 0.08), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* fine grain overlay — keeps the large dark fields from banding */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--text); border-bottom: 1px solid var(--line); text-decoration: none; transition: border-color 0.25s var(--ease), color 0.25s var(--ease); }
a:hover { border-bottom-color: var(--accent); color: #fff; }

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; position: relative; z-index: 2; }

/* ------------------------------------------------------------------ nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(6, 7, 10, 0.72);
  border-bottom: 1px solid var(--line-soft);
}
.nav .wrap { display: flex; align-items: center; gap: 1.4rem; height: 58px; }
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--mono); font-weight: 600; font-size: 0.92rem; letter-spacing: 0.02em;
  border: none;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 3px; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.15);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.15); }
  50% { box-shadow: 0 0 0 7px rgba(229, 72, 77, 0.04); }
}
.brand span.mark { color: var(--accent); }
.nav-links { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; }
.nav-links a {
  border: none; font-size: 0.84rem; color: var(--muted); letter-spacing: 0.01em;
  position: relative; padding: 0.2rem 0;
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px; height: 1px;
  background: var(--accent); transition: right 0.3s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after { right: 0; }
.nav-links a[aria-current="page"] { color: var(--text); }
.nav-cta {
  border: 1px solid var(--line) !important; border-radius: 999px; padding: 0.32rem 0.85rem !important;
  color: var(--text) !important;
}
.nav-cta:hover { border-color: var(--accent) !important; }

/* ------------------------------------------------------------- headings */
.eyebrow {
  margin: 0 0 0.9rem; font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim);
}
h1 {
  margin: 0 0 0.7rem; font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.8rem, 9vw, 5rem); line-height: 0.92; letter-spacing: -0.03em;
}
h1 .mark { color: var(--accent); }
.lede { max-width: 58ch; margin: 0 0 1.6rem; font-size: 1.1rem; color: var(--muted); }

h2.section {
  margin: 0 0 1.1rem; font-size: 0.72rem; font-family: var(--mono);
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); font-weight: 500;
}

/* ---------------------------------------------------------------- hero */
header.hero { padding: 4.2rem 0 1.4rem; border-bottom: 1px solid var(--line); position: relative; }

.stats { display: flex; flex-wrap: wrap; gap: 1.3rem 2.4rem; margin: 2rem 0 0.6rem; padding: 0; list-style: none; }
.stats li { display: flex; flex-direction: column; gap: 0.14rem; }
.stats b {
  font-family: var(--mono); font-size: 1.55rem; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fff, #aab2c2);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stats span { font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }

/* ---------------------------------------------------------------- layout */
main { padding: 2.8rem 0 4rem; display: grid; gap: 3.4rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.2rem; align-items: start; }

.card {
  padding: 1.4rem 1.5rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  transition: transform 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: #2b3240; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 0.5rem; font-family: var(--serif); font-size: 1.2rem; font-weight: 400; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.card .k { font-family: var(--mono); font-size: 0.7rem; color: var(--accent-soft); letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------------------------------------------------------- leaderboard */
.board { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; box-shadow: var(--shadow); }
.board-head {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.board-head h2 { margin: 0; font-size: 0.92rem; font-family: var(--mono); letter-spacing: 0.06em; }
.stamp { margin: 0; font-family: var(--mono); font-size: 0.7rem; color: var(--dim); }
.board-tools { display: flex; gap: 0.4rem; align-items: center; }
.chip {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.24rem 0.7rem;
  background: transparent; cursor: pointer; transition: all 0.25s var(--ease);
}
.chip:hover { color: var(--text); border-color: #2b3240; }
.chip[aria-pressed="true"] { color: #fff; border-color: var(--accent); background: rgba(229, 72, 77, 0.12); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  padding: 0.7rem 0.9rem; text-align: left; font-family: var(--mono); font-size: 0.64rem;
  font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
th.sortable { cursor: pointer; transition: color 0.2s var(--ease); }
th.sortable:hover { color: var(--text); }
th .arrow { opacity: 0.35; margin-left: 0.25rem; }
th[aria-sort] .arrow { opacity: 1; color: var(--accent); }
td { padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.25s var(--ease); }
.js tbody tr { opacity: 0; transform: translateY(8px); }
.js tbody tr.in { opacity: 1; transform: none; }
tbody tr:hover { background: var(--panel-2); }

.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-rank { width: 2.6rem; color: var(--dim); font-family: var(--mono); }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 1.55rem; height: 1.55rem;
  border-radius: 999px; font-size: 0.72rem; border: 1px solid var(--line); color: var(--muted);
}
.rank-1 { border-color: #d8b25a; color: #f3d489; background: rgba(216, 178, 90, 0.1); box-shadow: 0 0 16px -4px rgba(216, 178, 90, 0.5); }
.rank-2 { border-color: #9aa3b2; color: #c8ced8; background: rgba(154, 163, 178, 0.1); }
.rank-3 { border-color: var(--bronze); color: #e0ad83; background: rgba(201, 138, 91, 0.1); }
.col-model { min-width: 15rem; }
.model-name { font-weight: 500; }
.model-sub { display: block; margin-top: 0.16rem; font-family: var(--mono); font-size: 0.67rem; color: var(--dim); }

.score-cell { display: flex; align-items: center; gap: 0.55rem; justify-content: flex-end; }
.bar { position: relative; width: 96px; height: 5px; border-radius: 3px; background: #1b1f27; overflow: hidden; flex: none; }
.bar > i {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  border-radius: 3px; box-shadow: 0 0 14px -2px var(--accent-glow);
  transition: width 1.1s var(--ease);
}
.score-value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.6rem; text-align: right; }
.ci { font-family: var(--mono); font-size: 0.66rem; color: var(--dim); }
.spurious-high { color: var(--accent); }
.spurious-mid { color: var(--warn); }

.tag {
  display: inline-block; margin-right: 0.35rem; padding: 0.14rem 0.42rem; border: 1px solid var(--line);
  border-radius: 999px; font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--warn); white-space: nowrap;
}
.empty { margin: 0; padding: 1.2rem 1.25rem; color: var(--dim); font-style: italic; }
.col-notes { max-width: 22rem; font-size: 0.76rem; color: var(--muted); }

/* per-protocol mini bars in leaderboard */
.proto-mini { display: flex; gap: 0.55rem; }
.proto-mini > div { display: flex; flex-direction: column; gap: 0.22rem; min-width: 3.1rem; }
.proto-mini .pl { font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.proto-mini .pb { height: 3px; border-radius: 2px; background: #1b1f27; overflow: hidden; }
.proto-mini .pb > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5b6ee0, #8f7bff); transition: width 1.1s var(--ease); }
.proto-mini .pv { font-family: var(--mono); font-size: 0.64rem; color: var(--muted); }

/* ---------------------------------------------------------- submit block */
.submit {
  border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--ink-2), #0b0d11);
  padding: 1.7rem; position: relative; overflow: hidden;
}
.submit::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent);
}
.submit h2 { margin-top: 0; }
.steps { margin: 1rem 0 0; padding-left: 1.3rem; color: var(--muted); display: grid; gap: 0.7rem; max-width: 62ch; }
.steps b { color: var(--text); }
code {
  font-family: var(--mono); font-size: 0.84em; background: #0a0c10; border: 1px solid var(--line);
  border-radius: 5px; padding: 0.06em 0.36em; color: #cdd3de;
}
pre {
  margin: 1.1rem 0; padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-radius: 10px;
  background: #08090c; overflow-x: auto; font-size: 0.82rem; line-height: 1.62;
}
pre code { background: none; border: none; padding: 0; }

/* -------------------------------------------------------------- metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.metric {
  padding: 1.3rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  position: relative; overflow: hidden;
}
.metric::after {
  content: ""; position: absolute; left: 1.3rem; right: 1.3rem; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent); opacity: 0.5;
}
.metric .label { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); margin-bottom: 0.4rem; }
.metric .value { font-family: var(--mono); font-size: 1.7rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.metric .note { margin-top: 0.35rem; font-size: 0.78rem; color: var(--dim); }
.metric .note code { font-size: 0.78em; }
.metric-leader { grid-column: 1 / -1; margin: 0.2rem 0 0; color: var(--dim); font-size: 0.8rem; }
.metric-leader b { color: var(--text); font-weight: 500; }

/* ------------------------------------------------------------------ footer */
footer { border-top: 1px solid var(--line); padding: 2rem 0 3rem; color: var(--dim); font-size: 0.78rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1.4rem; align-items: center; }
footer .license { margin-left: auto; font-family: var(--mono); font-size: 0.7rem; }
footer a { color: var(--muted); }

/* ------------------------------------------------------------- reveal */
.reveal { opacity: 1; transform: none; }
.js .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); will-change: opacity, transform; }
.js .reveal.in { opacity: 1; transform: none; }
.js .hero .anim { opacity: 0; transform: translateY(16px); animation: rise 0.8s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .stats { gap: 0 1.3rem; }
  .metrics { grid-template-columns: 1fr; }
  .board th, .board td { padding: 0.6rem 0.55rem; font-size: 0.82rem; }
  .bar { display: none; }
  .nav-links a:not(.nav-cta):not([aria-current]) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal, .js .reveal { opacity: 1 !important; transform: none !important; }
  .hero .anim, .js .hero .anim { opacity: 1 !important; transform: none !important; }
  tbody tr, .js tbody tr { opacity: 1 !important; transform: none !important; }
}
