/* NavSafe-∞ project page.
   One design system: tokens first, then layout top-to-bottom in page order,
   then motion. Category colours match the paper's figures. */

:root {
  --ink: #0f1b2d;
  --ink-2: #33415a;
  --muted: #5d6b80;
  --line: #e3e8f0;
  --line-2: #d3dbe6;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f1f5fa;
  --accent: #1f6fbf;
  --accent-2: #4f9be8;
  --accent-ink: #0d4a8a;

  --tc: #2e5f9e;
  --tv: #b07a1a;
  --vruc: #b0446b;
  --ti: #1f8380;

  --rank-1: #d6e7f8;
  --rank-2: #d8eedc;
  --rank-3: #f8ebcb;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 1px rgba(15, 27, 45, .04);
  --shadow: 0 10px 30px -12px rgba(15, 27, 45, .22), 0 2px 6px rgba(15, 27, 45, .06);
  --shadow-lg: 0 24px 60px -20px rgba(15, 27, 45, .35);

  --max: 1180px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --text-xs: .78rem;
  --text-sm: .9rem;
  --text-base: 1.02rem;
  --text-lg: 1.15rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 400 17px/1.7 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-ink); }
button, input, select { font: inherit; }
img, video { max-width: 100%; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid #e08a1e; outline-offset: 3px; border-radius: 6px; }

.skip { position: absolute; left: 12px; top: -80px; z-index: 100; padding: 10px 14px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.skip:focus { top: 12px; }

/* ---------- navigation ---------- */
nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px max(24px, calc((100vw - var(--max)) / 2));
  background: rgba(247, 249, 252, .72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, box-shadow .3s, background .3s;
}
nav.scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 24px -18px rgba(15, 27, 45, .4); background: rgba(255, 255, 255, .82); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand img { width: 30px; height: 30px; object-fit: contain; }
nav div { display: flex; gap: 6px; }
nav div a {
  position: relative; padding: 7px 14px; border-radius: 999px;
  color: var(--ink-2); font-size: var(--text-sm); font-weight: 600;
  transition: background .2s, color .2s;
}
nav div a:hover { background: var(--surface-2); color: var(--ink); }
nav div a.active { background: var(--ink); color: #fff; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- hero ---------- */
header { position: relative; padding: 0 24px; }
header::before {
  content: ""; position: absolute; inset: -80px 0 auto 0; height: 760px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(620px 340px at 18% 18%, rgba(79, 155, 232, .20), transparent 70%),
    radial-gradient(560px 320px at 84% 8%, rgba(176, 68, 107, .12), transparent 70%),
    radial-gradient(700px 360px at 55% 62%, rgba(31, 131, 128, .10), transparent 70%);
}
.intro { max-width: 1040px; margin: 64px auto 0; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px 5px 9px; margin: 0 0 22px;
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-ink); background: rgba(31, 111, 191, .08); border: 1px solid rgba(31, 111, 191, .18); border-radius: 999px;
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(31, 111, 191, .18); animation: pulse 2.4s var(--ease) infinite; }
h1 {
  margin: 0 auto 26px; max-width: 980px;
  font-size: clamp(2.1rem, 1.2rem + 3.2vw, 3.6rem); line-height: 1.08; font-weight: 750; letter-spacing: -.035em;
  text-wrap: balance;
}
.project-name {
  white-space: nowrap;
  background: linear-gradient(100deg, var(--accent-ink) 0%, var(--accent) 45%, var(--ti) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.authors { max-width: 900px; margin: 0 auto 8px; color: var(--ink-2); font-size: var(--text-base); line-height: 1.75; }
.au { white-space: nowrap; }
.authors sup, .affil sup, .notes sup { color: var(--accent); font-weight: 600; }
.affil { margin: 4px 0; color: var(--ink-2); font-size: var(--text-sm); }
.notes { margin: 4px 0; color: var(--muted); font-size: var(--text-xs); }

.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 28px 0 0; }
.button {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 44px; padding: 9px 20px;
  font-size: var(--text-sm); font-weight: 600; color: #fff;
  background: var(--ink); border: 1px solid var(--ink); border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s;
}
.button:hover { color: #fff; transform: translateY(-2px); box-shadow: var(--shadow); background: #1d2f4a; }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-2); }
.button.secondary:hover { color: var(--ink); background: var(--surface); border-color: #b7c4d6; }
.button-icon { width: 19px; height: 19px; flex: none; object-fit: contain; }
.button:not(.secondary) .button-icon { filter: invert(1) brightness(2); }

/* five-clip scenario strip */
.strip-wrap { max-width: 1320px; margin: 52px auto 0; }
.strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.strip figure {
  position: relative; margin: 0; overflow: hidden; border-radius: var(--radius);
  background: #0b1320; box-shadow: var(--shadow); isolation: isolate;
  transform: translateZ(0);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
}
.strip figure:hover { transform: translateY(-6px) scale(1.02); box-shadow: var(--shadow-lg); z-index: 2; }
.strip video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; transition: transform 1.2s var(--ease); }
.strip figure:hover video { transform: scale(1.06); }
.strip figure::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 52%, rgba(6, 12, 22, .78));
}
.strip figcaption {
  position: absolute; left: 12px; right: 12px; bottom: 9px; z-index: 1; margin: 0;
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  color: #fff; font-size: var(--text-xs); line-height: 1.35;
}
.strip figcaption b { font-size: .84rem; font-weight: 650; letter-spacing: -.005em; }
.strip figcaption span { display: inline-flex; align-items: center; gap: 6px; opacity: .85; font-weight: 500; letter-spacing: .02em; }
.strip figcaption span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.strip-note { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: var(--text-xs); }

/* headline numbers */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 980px; margin: 44px auto 0; padding: 22px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.stats div { text-align: center; padding: 4px 10px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats strong { display: block; font-size: clamp(1.7rem, 1.1rem + 1.8vw, 2.4rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.stats span { color: var(--muted); font-size: var(--text-sm); }

header > figure { max-width: var(--max); margin: 56px auto 0; }

/* ---------- sections ---------- */
main, footer { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
section { padding: 96px 0 8px; }
.section-heading { max-width: 820px; margin: 0 auto 34px; text-align: center; }
.kicker { display: block; margin-bottom: 10px; color: var(--accent); font-size: var(--text-xs); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.section-heading h2 { margin: 0 0 12px; font-size: clamp(1.8rem, 1.1rem + 2vw, 2.55rem); line-height: 1.12; font-weight: 750; letter-spacing: -.03em; }
.section-heading > p { margin: 0 auto; max-width: 760px; color: var(--muted); font-size: var(--text-lg); line-height: 1.6; }
.measure { max-width: 860px; margin: 18px auto; color: var(--ink-2); font-size: var(--text-base); line-height: 1.8; }
.measure strong { color: var(--ink); font-weight: 650; }
.large { max-width: 860px; margin: 72px auto 14px; font-size: clamp(1.3rem, 1rem + .8vw, 1.6rem); line-height: 1.25; font-weight: 700; letter-spacing: -.02em; text-align: center; }
h3 { margin: 6px 0; font-size: 1.12rem; line-height: 1.35; font-weight: 700; letter-spacing: -.01em; }

/* figures */
figure { margin: 34px auto 10px; }
main figure > a, header > figure > a {
  display: block; overflow: hidden; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); cursor: zoom-in;
  transition: box-shadow .35s var(--ease), transform .35s var(--ease), border-color .35s;
}
main figure > a:hover, header > figure > a:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--line-2); }
figure img { display: block; width: 100%; height: auto; background: #fff; padding: 14px; }
figcaption { max-width: 860px; margin: 14px auto 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.65; text-align: center; }

/* category cards */
.categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 36px 0 8px; }
.categories > div {
  --c: var(--tc);
  position: relative; overflow: hidden; padding: 22px 20px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s;
}
.categories > div::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.categories > div::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: var(--c); opacity: .07; transition: transform .5s var(--ease), opacity .5s; }
.categories > div:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--line-2); }
.categories > div:hover::after { transform: scale(1.5); opacity: .12; }
.categories > div[data-category="TV"] { --c: var(--tv); }
.categories > div[data-category="VRUC"] { --c: var(--vruc); }
.categories > div[data-category="TI"] { --c: var(--ti); }
.categories b {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: .05em;
  color: var(--c); background: color-mix(in srgb, var(--c) 11%, transparent);
}
.categories h3 { margin: 12px 0 6px; }
.categories p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.6; }

details {
  max-width: var(--max); margin: 26px auto 0; padding: 4px 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
summary { cursor: pointer; padding: 14px 0; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 10px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--accent); font-weight: 700; transition: transform .3s var(--ease); }
details[open] summary::before { transform: rotate(45deg); }
details figure { margin: 4px 0 20px; }
details figure > a { box-shadow: none; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; max-width: var(--max); margin: 18px auto; }
.metrics p {
  margin: 0; padding: 18px 18px 16px; color: var(--muted); font-size: var(--text-sm); line-height: 1.6;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.metrics strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: var(--text-base); font-weight: 700; }
.note { color: var(--muted); font-size: var(--text-sm); }
#benchmark > .note { text-align: center; }

/* ---------- leaderboard ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin: 30px 0 10px; }
.controls label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.controls select, .controls input {
  height: 44px; min-width: 240px; max-width: 100%; padding: 8px 14px;
  font-size: var(--text-sm); color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.controls select:hover, .controls input:hover { border-color: #b7c4d6; }
.controls select:focus, .controls input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(31, 111, 191, .14); outline: none; }

.table-scroll { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { padding: 13px 14px; text-align: right; border-bottom: 1px solid var(--line); }
tbody tr:last-child > * { border-bottom: 0; }
th:first-child { text-align: left; min-width: 250px; white-space: normal; }
thead th { position: sticky; top: 0; z-index: 2; background: #f6f8fc; color: var(--ink-2); font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
thead th:first-child { left: 0; z-index: 3; }
thead button { padding: 4px 6px; margin: -4px -6px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; letter-spacing: inherit; cursor: pointer; transition: background .2s, color .2s; }
thead button:hover { background: var(--surface-2); color: var(--ink); }
thead [aria-sort=descending] button, thead [aria-sort=ascending] button { color: var(--accent); }
tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); font-weight: 650; }
tbody tr { transition: background .2s; }
tbody tr:hover > * { background: #f5f9ff; }
td small, th small { display: block; color: var(--muted); font-size: var(--text-xs); font-weight: 400; line-height: 1.5; }
td { position: relative; }
td[data-value] {
  background-image: linear-gradient(90deg, rgba(79, 155, 232, .55), rgba(31, 111, 191, .85));
  background-repeat: no-repeat;
  background-size: calc((100% - 28px) * var(--bar-f, 0)) 3px;
  background-position: right 14px bottom 5px;
}
td.rank-1 { background-color: var(--rank-1); font-weight: 700; }
td.rank-2 { background-color: var(--rank-2); }
td.rank-3 { background-color: var(--rank-3); }
tr[data-group="Reference"] > *, tr[data-group="Privileged reference"] > * { background-color: #f3f6fb; }
tr[data-group="Privileged reference"] > * { border-bottom: 2px solid var(--line-2); }
tbody tr.in { animation: row-in .5s var(--ease) both; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0 0; color: var(--muted); font-size: var(--text-xs); }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border-radius: 3px; }

/* ---------- experiments ---------- */
.findings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: var(--max); margin: 22px auto 0; }
.findings article {
  padding: 22px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.findings article:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.findings article > span { display: inline-block; padding: 3px 10px; border-radius: 999px; background: rgba(31, 111, 191, .08); color: var(--accent-ink); font-size: var(--text-xs); font-weight: 700; letter-spacing: .03em; }
.findings h4 { margin: 12px 0 8px; font-size: 1.15rem; line-height: 1.35; font-weight: 700; letter-spacing: -.01em; }
.findings p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.7; }

.comparison { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; max-width: var(--max); margin: 26px auto 0; }
.comparison p {
  margin: 0; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--text-sm);
}
.comparison strong { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 700; }
.delta { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 700; }
.delta.up { color: #157347; background: #e3f4ea; }
.delta.down { color: #b02a37; background: #fbe7e9; }

/* ---------- citation ---------- */
footer { padding-top: 96px; padding-bottom: 72px; color: var(--muted); }
.citation-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.citation-heading h2 { margin: 0; color: var(--ink); font-size: clamp(1.6rem, 1.1rem + 1.4vw, 2.1rem); font-weight: 750; letter-spacing: -.03em; }
.cite-actions { display: flex; gap: 8px; }
.cite-actions a, .cite-actions button {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: border-color .2s, color .2s;
}
.cite-actions a:hover, .cite-actions button:hover { border-color: var(--accent); color: var(--accent); }
#citation > p { font-size: var(--text-base); }
#citation pre {
  margin: 0; padding: 24px 26px; overflow: auto;
  background: #0f1b2d; color: #dbe6f5; border-radius: var(--radius); box-shadow: var(--shadow);
  font: .86rem/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- motion ---------- */
/* `html` raises specificity above component transitions while the entrance
   runs; site.js drops both classes afterwards so hover effects take over. */
html .reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s var(--ease) var(--d, 0s), transform .9s var(--ease) var(--d, 0s); }
html .reveal.in { opacity: 1; transform: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(31, 111, 191, .35); } 50% { box-shadow: 0 0 0 6px rgba(31, 111, 191, 0); } }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .categories, .metrics, .comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .strip-wrap { margin-left: -24px; margin-right: -24px; }
  .strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 24px 14px; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  .strip figure { flex: 0 0 72%; scroll-snap-align: center; }
  .strip figure:hover { transform: none; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  nav { flex-wrap: wrap; justify-content: center; gap: 6px 12px; padding: 10px 14px; }
  nav div a { padding: 6px 11px; }
  .intro { margin-top: 40px; }
  h1 br { display: none; }
  .eyebrow { font-size: .66rem; letter-spacing: .04em; white-space: nowrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
  .stats div:nth-child(3) { border-left: 0; }
  section { padding-top: 72px; }
  .findings { grid-template-columns: 1fr; }
  .categories, .metrics, .comparison { grid-template-columns: 1fr; }
  .controls label, .controls select, .controls input { width: 100%; min-width: 0; }
  th:first-child { min-width: 180px; }
  figure img { padding: 6px; }
}
