/* ==========================================================================
   Dyna-SAuR project page
   ========================================================================== */

:root {
  --ink: #0f1d17;
  --ink-2: #2b3a33;
  --muted: #5b6b63;
  --line: #e3e9e5;
  --bg: #ffffff;
  --bg-alt: #f5f8f6;
  --card: #ffffff;

  --brand: #1e7a4c;        /* dino green */
  --brand-dark: #135536;
  --brand-soft: #e6f3ec;
  --accent: #12a4b8;       /* "safe and certain" cyan */
  --red: #d62728;
  --orange: #f08a24;
  --blue: #1f77b4;
  --pink: #e377c2;
  --purple: #9467bd;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 29, 23, .05), 0 8px 24px rgba(15, 29, 23, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); font-size: .88em; }
.nowrap, .katex { white-space: nowrap; }
.muted { color: var(--muted); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 38px; object-fit: contain; }
.topnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  color: var(--muted); font-size: 14.5px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.topnav a:hover, .topnav a.active { color: var(--brand-dark); background: var(--brand-soft); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 72px 0 56px;
  text-align: center;
  background:
    radial-gradient(1000px 400px at 15% -10%, rgba(30, 122, 76, .10), transparent 60%),
    radial-gradient(900px 380px at 90% 0%, rgba(18, 164, 184, .10), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.venue {
  display: inline-block;
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand-dark); background: var(--brand-soft);
  border: 1px solid rgba(30, 122, 76, .25);
  padding: 5px 14px; border-radius: 999px; margin-bottom: 22px;
}
.title { margin: 0 auto 26px; max-width: 920px; }
.title-main {
  display: block;
  font-size: clamp(30px, 4.6vw, 50px); font-weight: 800; letter-spacing: -.025em; line-height: 1.12;
  color: var(--ink);
}
.title-sub {
  display: block; margin-top: 10px;
  font-size: clamp(19px, 2.4vw, 26px); font-weight: 500; letter-spacing: -.01em;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.authors {
  list-style: none; padding: 0; margin: 0 0 8px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 26px;
  font-size: 19px; font-weight: 600; color: var(--ink);
}
.authors sup { color: var(--brand); font-weight: 700; margin-left: 1px; line-height: 0; }
.affiliation { margin: 0 0 6px; font-size: 16.5px; color: var(--ink-2); }
.affiliation a { color: inherit; border-bottom: 1px dotted var(--muted); }
.affiliation a:hover { text-decoration: none; color: var(--brand); }
.footnote-line { font-size: 14px; color: var(--muted); margin: 0 0 28px; }
.footnote-line sup { color: var(--brand); line-height: 0; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px;
  font-size: 15.5px; font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(15, 29, 23, .18); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.fill { fill: currentColor; stroke: none; }
.btn-glyph { font-family: "Times New Roman", serif; font-size: 20px; line-height: 1; font-style: italic; width: 18px; text-align: center; }

/* ---------- Sections ---------- */
.section { padding: 80px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--brand); margin: 0 0 8px;
}
.section-title {
  font-size: clamp(26px, 3.2vw, 36px); font-weight: 800; letter-spacing: -.02em;
  margin-bottom: 22px; max-width: 820px;
}
.sub-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 18px;
}
.lead { font-size: 18.5px; color: var(--ink-2); max-width: 860px; margin-bottom: 36px; }
.prose h3 { font-size: 21px; font-weight: 700; margin-bottom: 12px; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.prose .katex-display { margin: .6em 0 1.1em; }
.card .katex-display, .steps .katex-display { margin: .4em 0 .7em; font-size: .9em; }

.split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: center;
  margin: 40px 0;
}
.split-wide { grid-template-columns: 1.15fr 1fr; }
.split > *, .envs > *, .plots > *, .cards3 > *, .steps li > * { min-width: 0; }
.split:first-child { margin-top: 0; }
.split-top { align-items: start; }

/* ---------- Figures ---------- */
.figure { margin: 0; }
.figure img { width: 100%; height: auto; border-radius: 10px; }
.figure figcaption, .video-card figcaption {
  margin-top: 12px; font-size: 14.5px; line-height: 1.55; color: var(--muted);
}
.figure figcaption b { color: var(--ink-2); }
.figure-framed {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.figure-framed img { border-radius: 6px; }
.figure-small { max-width: 440px; margin: 8px auto 0; }
.figure-small figcaption { text-align: center; }
.figure-wide { margin: 36px 0 12px; }

/* ---------- Videos ---------- */
.video-card { margin: 40px 0; }
.video-card video {
  width: 100%; aspect-ratio: 16 / 9; display: block;
  background: #0b0f0d; border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .06), 0 18px 40px rgba(15, 29, 23, .16);
  border: 1px solid var(--line);
}
.video-card figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.video-hero { margin-top: 0; }
.caption-legend { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.caption-legend .sw { margin-right: 4px; }
.chip {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand-dark); background: var(--brand-soft); padding: 2px 9px; border-radius: 999px;
}
.dur {
  margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted);
  background: var(--bg-alt); border: 1px solid var(--line); padding: 1px 8px; border-radius: 6px;
}

/* ---------- TL;DR & stats ---------- */
.tldr {
  display: grid; grid-template-columns: 96px 1fr; gap: 26px; align-items: center;
  margin: 48px 0 28px; padding: 26px 30px;
  background: linear-gradient(135deg, var(--brand-soft), #eaf7f9);
  border: 1px solid rgba(30, 122, 76, .18); border-radius: var(--radius);
}
.tldr img { width: 96px; height: auto; }
.tldr-title { font-size: 15px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-dark); margin-bottom: 6px; }
.tldr p { margin: 0; font-size: 17.5px; color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 56px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 20px 18px; box-shadow: var(--shadow);
}
.stat-num {
  font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-bottom: 6px;
  color: var(--brand);
}
.stat-label { font-size: 14px; line-height: 1.45; color: var(--muted); }

.abstract { max-width: 860px; margin: 0 0 56px; }

/* ---------- Chapters ---------- */
.chapters .eyebrow { margin-bottom: 16px; }
.chapter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.chapter {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  color: var(--ink); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.chapter:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(30, 122, 76, .35); }
.chapter img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-bottom: 1px solid var(--line); }
.chapter-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; font-size: 14px; }
.chapter-meta span { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }

/* ---------- Tags / swatches ---------- */
.tag { font-weight: 600; padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.tag-green { color: #2e8b2e; background: #e7f4e7; }
.tag-red { color: #c21f2b; background: #fbe9ea; }
.tag-blue { color: var(--blue); background: #e6f0f8; }
.tag-orange { color: #d1700c; background: #fdf0e2; }

.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .12); flex: none; }
.sw-orange { background: #f4a259; }
.sw-blue { background: #6fa8dc; }
.sw-white { background: #fff; }
.sw-pink { background: var(--pink); }
.sw-purple { background: var(--purple); }
.sw-blueline { background: var(--blue); }
.sw-green { background: #2ca02c; }

/* ---------- Method steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 14px; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
}
.steps h4 { font-size: 16.5px; font-weight: 700; margin-bottom: 4px; }
.steps p { margin: 0; font-size: 15.5px; color: var(--muted); }
.step-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent));
}

/* ---------- Algorithm box ---------- */
.algo {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; font-size: 15.5px;
}
.algo-head { padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg-alt); color: var(--ink); }
.algo-body { padding: 16px 20px 6px; }
.algo-body p { margin: 0 0 8px; }
.algo-body ol { margin: 0 0 10px; padding-left: 26px; counter-reset: none; }
.algo-body li { padding: 3px 0; }
.algo-body li::marker { color: var(--muted); font-size: 13px; }
.algo-body li.i1 { padding-left: 20px; }
.algo-body li.i2 { padding-left: 40px; }
.algo-body b { color: var(--ink); }

/* ---------- Details ---------- */
.more {
  margin-top: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 20px;
}
.more summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--brand-dark); list-style: none; display: flex; align-items: center; gap: 10px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); font-weight: 800; }
.more[open] summary::before { content: "−"; }
.more .figure { padding: 4px 0 20px; }

/* ---------- Callout / cards ---------- */
.callout {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 22px 24px; box-shadow: var(--shadow); align-self: center;
}
.callout h4 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.callout p:last-child { margin-bottom: 0; }

.cards3 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.card h4 { font-size: 16.5px; font-weight: 700; margin-bottom: 8px; }
.card p { margin: 0; font-size: 15.5px; color: var(--muted); }

/* ---------- Interactive demo ---------- */
.demo {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 22px;
}
.plots {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  gap: 12px;
  align-items: center;
}
.plot-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px 4px; background: #fff; }
.plot-head { font-size: 15px; font-weight: 700; color: var(--ink); text-align: center; padding: 2px 0 0; }
.plot { width: 100%; height: 470px; }
.flow-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  user-select: none; color: var(--brand);
}
.flow-arrow-symbol { font-size: 52px; line-height: 1; font-weight: 700; }
.flow-arrow-label { font-size: 30px; line-height: 1; font-style: italic; font-family: "Times New Roman", serif; color: var(--ink); }

.controls {
  margin-top: 18px; padding: 18px 20px; border-radius: 12px; background: var(--bg-alt);
  display: grid; grid-template-columns: 64px 1fr; gap: 12px 16px; align-items: center;
}
.controls label { font-size: 17px; font-weight: 600; color: var(--ink); font-family: "Times New Roman", serif; font-style: italic; }
.controls-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.readout { font-family: var(--mono); font-size: 14px; color: var(--ink-2); }
.controls button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 15px var(--font); color: #fff; background: var(--brand);
  transition: background .15s ease, transform .15s ease;
}
.controls button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.controls button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: #d6e2db; outline: none; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand); cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); cursor: pointer;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(30, 122, 76, .25); }

/* ---------- Results ---------- */
.envs { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: stretch; }
.envs .figure-framed { display: flex; flex-direction: column; justify-content: space-between; }
.envs img { max-height: 320px; object-fit: contain; }
.result-block { margin-top: 64px; }
.result-block .video-card { margin-top: 0; }

.tab-buttons { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 7px 18px; border-radius: 999px; font: 600 14.5px var(--font); color: var(--muted); cursor: pointer; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.findings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.findings li { display: flex; gap: 12px; align-items: flex-start; font-size: 15.5px; }
.findings .sw { margin-top: 5px; }
.findings b { color: var(--ink); }

/* ---------- BibTeX ---------- */
.bibtex { position: relative; }
.bibtex pre {
  margin: 0; padding: 22px 24px; overflow-x: auto;
  background: #0f1d17; color: #d8efe3; border-radius: var(--radius);
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  scrollbar-color: #3b4d44 #0f1d17;
}
.copy {
  position: absolute; top: 12px; right: 12px;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #fff;
  font: 600 13px var(--font); padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.copy:hover { background: rgba(255, 255, 255, .16); }

/* ---------- Footer ---------- */
.footer { padding: 36px 0 44px; border-top: 1px solid var(--line); }
.footer-inner { display: flex; align-items: center; gap: 14px; justify-content: center; color: var(--muted); font-size: 14.5px; }
.footer-inner img { width: 30px; height: auto; }
.footer-inner p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .plots { grid-template-columns: 1fr; }
  .flow-arrow { flex-direction: row; gap: 10px; }
  .flow-arrow-symbol { transform: rotate(90deg); font-size: 44px; }
  .plot { height: 420px; }
  .split, .split-wide { grid-template-columns: 1fr; gap: 28px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .cards3 { grid-template-columns: 1fr; }
  .split > .figure, .split > .tabs, .split > .algo { width: 100%; max-width: 620px; justify-self: center; }
  .plot-card { width: 100%; max-width: 560px; margin: 0 auto; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .container, .topbar-inner { padding: 0 16px; }
  .brand span { display: none; }
  .hero { padding: 48px 0 40px; }
  .section { padding: 56px 0; }
  .envs { grid-template-columns: 1fr; }
  .tldr { grid-template-columns: 1fr; text-align: center; padding: 22px; }
  .tldr img { margin: 0 auto; width: 72px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-num { font-size: 24px; }
  .demo { padding: 12px; }
  .plot { height: 360px; }
  .controls { grid-template-columns: 48px 1fr; padding: 14px; }
  .abstract p { text-align: left; }
  .dur { margin-left: 0; }
  .steps li { grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .step-num { width: 30px; height: 30px; font-size: 14px; }
  .card .katex-display, .steps .katex-display { font-size: .8em; }
  .bibtex pre { padding-top: 52px; font-size: 13px; }
}
