/* Procedura project page. Dark engineering theme, one accent (wordmark blue).
   Radius system: surfaces 16px, media 10px, interactive pills. */

@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/space-grotesk-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --bg: #07090d;
  --bg2: #0a0d13;
  --panel: #0f131b;
  --line: rgba(150, 166, 205, .14);
  --line-strong: rgba(150, 166, 205, .26);
  --text: #e8ebf3;
  --muted: #9aa4ba;
  --accent: #7c98e9;
  --accent-bright: #a9bdf5;
  --accent-dim: rgba(124, 152, 233, .16);
  --plate: #f4f5f8;
  --plate-ink: #2a2f3a;
  --code-bg: #0c1017;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  --r: 16px;
  --rm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: rgba(124, 152, 233, .32); }

img { max-width: 100%; display: block; }
a { color: var(--accent-bright); text-decoration: none; }

h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------ background */

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
  filter: saturate(1.14) contrast(1.03);
}
#scene.ready { opacity: 1; }

.scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(4, 5, 8, .5) 100%),
    linear-gradient(rgba(4, 5, 8, .35), transparent 22%, transparent 72%, rgba(4, 5, 8, .45));
}

.grain {
  position: fixed; inset: -100px; z-index: 60; pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: no-preference) {
  .grain { animation: grain 9s steps(6) infinite; }
  @keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-32px, 12px); }
    40% { transform: translate(18px, -28px); }
    60% { transform: translate(-14px, 24px); }
    80% { transform: translate(26px, -8px); }
  }
}

/* ------------------------------------------------------------------ nav */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 clamp(18px, 4vw, 44px);
  transition: background .35s ease, border-color .35s ease, backdrop-filter .35s ease;
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  background: rgba(7, 9, 13, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.nav-brand img { height: 20px; width: auto; }
.nav-links { display: flex; gap: clamp(16px, 2.6vw, 34px); }
.nav-links a {
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  transition: color .2s ease;
}
.nav-links a:hover { color: var(--text); }
@media (max-width: 560px) { .nav-links { gap: 14px; } .nav-links a { font-size: .8rem; } }

/* --------------------------------------------------- 3D story panels */

.panel {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: 96px clamp(20px, 6vw, 72px) 48px;
}

.hero-block { max-width: 620px; }
.hero-wordmark { width: min(520px, 82vw); height: auto; }
.hero-sub {
  margin-top: 20px;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  color: var(--text);
  max-width: 34ch;
  line-height: 1.45;
}
.hero-authors {
  margin-top: 18px;
  font-size: .92rem;
  color: var(--muted);
  line-height: 1.7;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 24px;
  border-radius: 999px;
  font-family: var(--body);
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: .01em;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.btn:active { transform: scale(.97); }
.btn-solid { background: var(--accent); color: #0a0d14; }
.btn-solid:hover { background: var(--accent-bright); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }

.panel-right { justify-content: flex-end; }
.story-block { max-width: 520px; }
@media (max-width: 768px) {
  .panel { align-items: flex-start; padding-top: 108px; }
  .story-block {
    background: rgba(6, 8, 14, .5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: var(--r);
    padding: 18px 20px;
  }
}
.story-block h2 { margin-bottom: 16px; }
.story-block p { color: var(--muted); font-size: 1.02rem; max-width: 46ch; }

.part-ticker {
  list-style: none;
  margin-top: 26px;
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--accent-bright);
  display: grid;
  gap: 6px;
}
.part-ticker li {
  opacity: 0;
  transform: translateX(14px);
  transition: opacity .4s ease, transform .4s ease;
}
.part-ticker li.on { opacity: 1; transform: none; }
.part-ticker .ticker-more { color: var(--muted); }

.solve-eq {
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 1.15rem;
  color: var(--accent-bright) !important;
}

.story-exit { position: relative; z-index: 2; height: 30dvh; }

/* --------------------------------------------------------- page body */

.page-body {
  position: relative;
  z-index: 3;
  background:
    linear-gradient(rgba(7, 9, 13, 0), var(--bg) 120px),
    var(--bg);
}

.section { padding: clamp(84px, 11vw, 150px) 0; }
.section + .section { border-top: 1px solid var(--line); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4.5vw, 44px);
}

.lead {
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 68ch;
}

/* reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(22px); }
.in .reveal, .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity .7s ease var(--d, 0s), transform .7s cubic-bezier(.16, 1, .3, 1) var(--d, 0s);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ------------------------------------------------------------- plates */

.plate {
  background: var(--plate);
  border-radius: var(--r);
  padding: clamp(10px, 1.8vw, 20px);
}
.plate img { border-radius: var(--rm); width: 100%; }
figure.plate { margin-top: 40px; }
figcaption {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 14px;
  max-width: 90ch;
}
.plate figcaption { color: #5d6575; padding: 0 4px; }

/* in-flow markers after the sticky stage: they provide the scrub distance */
.build-steps { pointer-events: none; }
.build-step { height: 55dvh; }

/* ------------------------------------------------- code + gates split */

.build-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px);
  margin-top: 56px;
  align-items: start;
}
@media (max-width: 900px) { .build-detail { grid-template-columns: 1fr; } }

.code-panel {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.code-tab {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  padding: 10px 18px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(150, 166, 205, .04);
}
.code-tab + pre { border-bottom: 1px solid var(--line); }
.code-panel pre {
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.65;
  color: #c7cfe2;
}
.code-panel .c { color: #5f6a83; }
.code-panel .k { color: var(--accent-bright); }
.code-panel .f { color: #8fd0c3; }
.code-panel .s { color: #d9b98a; }

.gates h3 { margin-bottom: 18px; }
.gate { padding: 18px 0; border-top: 1px solid var(--line); }
.gate-name {
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--accent-bright);
}
.gate p { margin-top: 6px; font-size: .93rem; color: var(--muted); }

/* ----------------------------------------------------------- materials */

.mat-split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px);
  margin-top: 48px;
  align-items: start;
}
@media (max-width: 900px) { .mat-split { grid-template-columns: 1fr; } }

.mat-media { margin: 0; }
.mat-media .plate { position: relative; }
.mat-ref {
  position: absolute;
  right: clamp(20px, 3vw, 34px);
  bottom: clamp(20px, 3vw, 34px);
  width: clamp(84px, 22%, 150px) !important;
  border: 3px solid #fff;
  border-radius: var(--rm);
  box-shadow: 0 8px 28px rgba(10, 13, 20, .35);
}

.mat-copy .lead { margin-top: 0; }
.mat-copy h3 { margin: 30px 0 16px; }
.palette { display: grid; gap: 9px; }
.swatch {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .84rem;
  color: var(--muted);
  min-width: 0;
}
.swatch i {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .12);
}
.swatch span:not(.sw-pbr) {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swatch .sw-pbr { flex: none; font-family: var(--mono); font-size: .7rem; color: #7d88a0; }

/* -------------------------------------------------------- motion strip */

.strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 40px clamp(20px, 4.5vw, 44px) 8px;
  max-width: 1180px;
  margin: 0 auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.strip figure {
  flex: none;
  width: min(320px, 74vw);
  scroll-snap-align: start;
  margin: 0;
}
.strip img {
  border-radius: var(--rm);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
}
.strip figcaption { margin-top: 8px; font-family: var(--mono); font-size: .74rem; }
.strip video {
  border-radius: var(--rm);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  background: #e8e8ea;
}
.motion-stats { margin-top: 26px; color: var(--muted); font-size: .95rem; max-width: 68ch; }

/* -------------------------------------------------------------- results */

.result-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 44px;
}
@media (max-width: 820px) { .result-tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 26px 24px 22px;
}
.tile-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  color: var(--accent-bright);
  display: block;
}
.tile p { margin-top: 10px; font-size: .88rem; color: var(--muted); }

.tbl-title { margin-top: 64px; }
.tbl-scroll {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: .88rem; }
thead th {
  text-align: left;
  font-family: var(--mono);
  font-weight: 500;
  font-size: .74rem;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
tbody td { padding: 9px 16px; color: var(--muted); white-space: nowrap; }
tbody td:first-child { color: var(--text); }
tbody tr:not(:first-child) td { border-top: 1px solid var(--line); }
tbody b { color: var(--text); }
tr.ours td { background: var(--accent-dim); color: var(--text); }
tr.ours td:first-child { font-weight: 600; }
tr.group td {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #5f6a83;
  padding-top: 14px;
}
.ci { font-size: .74em; color: var(--muted); }
.tbl-note {
  margin-top: 14px;
  font-size: .84rem;
  color: var(--muted);
  max-width: 90ch;
  line-height: 1.6;
}

/* -------------------------------------------------------------- gallery */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  max-width: 1560px;
  margin: 44px auto 0;
  padding: 0 clamp(16px, 3vw, 40px);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color .25s ease, transform .25s ease;
}
.card:hover { border-color: var(--line-strong); transform: translateY(-3px); }
@media (prefers-reduced-motion: reduce) { .card:hover { transform: none; } }
.card-media { position: relative; aspect-ratio: 1; background: #000; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-paint {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .38s ease;
}
.card:hover .card-paint, .card.painted .card-paint { opacity: 1; }
.card-ref {
  position: absolute;
  top: 10px; right: 10px;
  width: 26% !important;
  height: auto !important;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.card-name {
  display: block;
  padding: 11px 14px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.card:hover .card-name { color: var(--text); }

/* --------------------------------------------------------------- bibtex */

.bib-card {
  position: relative;
  margin-top: 32px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.bib-card pre {
  padding: 24px 26px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.7;
  color: #c7cfe2;
}
.bib-copy {
  position: absolute;
  top: 14px; right: 14px;
  font-family: var(--body);
  font-weight: 600;
  font-size: .78rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  transition: border-color .2s ease, transform .15s ease;
}
.bib-copy:hover { border-color: var(--accent); }
.bib-copy:active { transform: scale(.96); }

/* --------------------------------------------------------------- footer */

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px clamp(20px, 4.5vw, 44px) 56px;
  border-top: 1px solid var(--line);
}
.foot-logo { height: 26px; width: auto; opacity: .8; }
.foot-note { font-size: .82rem; color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hero-authors sup { font-size: .68em; color: #7d88a0; }
.hero-affil {
  display: block;
  margin-top: 7px;
  font-size: .8rem;
  color: #7d88a0;
}
.hero-affil sup { margin-right: 1px; }
