/* ============================================================
   AutoIndex — project page styles
   Palette derived from the paper's crimson/black figures.
   ============================================================ */

:root {
  --accent:        #d81e28;
  --accent-soft:   #fbe9ea;
  --accent-ink:    #b3161f;
  --ink:           #16171a;
  --ink-2:         #45474d;
  --muted:         #74777e;
  --line:          #e7e8ea;
  --bg:            #ffffff;
  --bg-tint:       #f7f7f8;
  --card:          #ffffff;
  --card-line:     #e7e8ea;
  --pos:           #128a52;
  --bar2:          #5c6d92;
  --shadow:        0 1px 2px rgba(20,22,26,.04), 0 8px 28px rgba(20,22,26,.06);
  --radius:        16px;
  --maxw:          1080px;
  --readw:         720px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark mode is opt-in only (toggle). Light is the default regardless of OS. */
:root[data-theme="dark"] {
  --accent:#ff5a52; --accent-soft:#2a1517; --accent-ink:#ff7b74;
  --ink:#ecedef; --ink-2:#c3c5ca; --muted:#8b8e96; --line:#26282d;
  --bg:#0d0e11; --bg-tint:#141519; --card:#16181c; --card-line:#26282d;
  --pos:#4ecb8b; --bar2:#8fa1c8; --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --accent:#d81e28; --accent-soft:#fbe9ea; --accent-ink:#b3161f;
  --ink:#16171a; --ink-2:#45474d; --muted:#74777e; --line:#e7e8ea;
  --bg:#ffffff; --bg-tint:#f7f7f8; --card:#ffffff; --card-line:#e7e8ea;
  --pos:#128a52; --bar2:#5c6d92; --shadow:0 1px 2px rgba(20,22,26,.04), 0 8px 28px rgba(20,22,26,.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.read { max-width: var(--readw); margin-left: auto; margin-right: auto; }
section { padding: 62px 0; border-top: 1px solid var(--line); }
section.plain { border-top: none; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
  font-weight: 600;
}
h2.section-title {
  font-size: clamp(26px, 3.4vw, 34px);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 10px;
  font-weight: 750;
}
.section-lead { color: var(--ink-2); font-size: 18px; margin: 0 0 34px; max-width: 700px; }
p { color: var(--ink-2); }
.read p { color: var(--ink-2); }
strong { color: var(--ink); font-weight: 650; }

/* ---------- top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.nav-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.nav-brand:hover { text-decoration: none; }
.brand-dot { width: 11px; height: 11px; border-radius: 3px; background: var(--accent); display: inline-block; }
.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links a { color: var(--ink-2); font-size: 14.5px; font-weight: 500; }
.nav-links a:hover { color: var(--accent-ink); text-decoration: none; }
.theme-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: border-color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 720px){ .nav-links .nav-hide { display: none; } }

/* ---------- hero ---------- */
.hero { padding: 66px 0 40px; text-align: center; }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .04em;
  color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 22px;
}
h1.title {
  font-size: clamp(34px, 6.2vw, 62px);
  line-height: 1.04; letter-spacing: -.035em; font-weight: 800;
  margin: 0 auto 8px; max-width: 15ch;
}
.title .accent { color: var(--accent); }
.subtitle { font-size: clamp(17px, 2.4vw, 21px); color: var(--ink-2); max-width: 46ch; margin: 0 auto 30px; }

.authors { max-width: 760px; margin: 0 auto 6px; font-size: 17px; line-height: 2; }
.authors a { color: var(--ink); font-weight: 550; }
.authors .sep { color: var(--muted); }
.affil { color: var(--muted); font-size: 15px; margin: 6px auto 4px; }
.affil sup { color: var(--accent); font-weight: 700; }
.eq { color: var(--muted); font-size: 13.5px; font-style: italic; margin-bottom: 30px; }

/* buttons */
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 20px; border-radius: 11px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn svg { width: 17px; height: 17px; }
.btn .tag { font-family: var(--mono); font-size: 11px; opacity: .7; }

/* ---------- stat cards ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-top: 46px;
}
.stat {
  background: var(--card); border: 1px solid var(--card-line);
  border-radius: var(--radius); padding: 22px 20px; text-align: left;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content:""; position:absolute; left:0; top:0; bottom:0; width:3px; background: var(--accent); }
.stat .num { font-size: clamp(28px, 3.6vw, 38px); font-weight: 800; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .num .pm { color: var(--accent); }
.stat .lbl { font-size: 13.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
@media (max-width: 860px){ .stats { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 440px){ .stats { grid-template-columns: 1fr; } }

/* ---------- figure ---------- */
figure { margin: 0; }
.fig {
  background: var(--card); border: 1px solid var(--card-line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.fig.tight { padding: 18px; }
.fig img { margin: 0 auto; border-radius: 6px; }
figcaption { color: var(--muted); font-size: 14.5px; margin-top: 16px; line-height: 1.55; }
figcaption b { color: var(--ink-2); }

/* ---------- steps / how it works ---------- */
.steps { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-top: 8px; }
.step {
  background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.step .k { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.step h4 { margin: 8px 0 6px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.step p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
@media (max-width: 820px){ .steps { grid-template-columns: 1fr; } }

/* ---------- chart ---------- */
.chart-card { background: var(--card); border:1px solid var(--card-line); border-radius: var(--radius); padding: 26px 22px 18px; box-shadow: var(--shadow); }
.legend { display:flex; gap:20px; justify-content:center; margin-bottom: 6px; flex-wrap: wrap; }
.legend span { display:inline-flex; align-items:center; gap:8px; font-size: 14px; color: var(--ink-2); }
.legend i { width: 13px; height: 13px; border-radius: 3px; display:inline-block; }
.chart-scroll { overflow-x: auto; position: relative; }

/* interactive chart */
.chart-scroll svg .bar { transition: opacity .12s ease; }
.chart-scroll svg.dim .bar:not(.hot) { opacity: .32; }
.chart-scroll svg .bar.hot { opacity: 1; }
.chart-scroll svg .hit { cursor: pointer; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--bg);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0,0,0,.22); opacity: 0; transform: translate(-50%, -8px);
  transition: opacity .12s ease; white-space: nowrap; min-width: 150px;
}
.chart-tip.show { opacity: 1; }
.chart-tip .tt-split { font-weight: 700; margin-bottom: 3px; }
.chart-tip .tt-row { display:flex; justify-content: space-between; gap: 16px; color: color-mix(in srgb, var(--bg) 72%, var(--muted)); }
.chart-tip .tt-row b { color: var(--bg); font-variant-numeric: tabular-nums; }
.chart-tip .tt-model { display:flex; align-items:center; gap:6px; font-size:12px; margin-bottom:5px; color: color-mix(in srgb, var(--bg) 65%, var(--muted)); }
.chart-tip .tt-model i { width:9px; height:9px; border-radius:2px; display:inline-block; }

/* ---------- case-study flow ---------- */
.flow { display: grid; grid-template-columns: repeat(4, 1fr) ; gap: 0; align-items: stretch; }
.flow-item { position: relative; display: flex; }
.flow-card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius);
  padding: 18px 16px; box-shadow: var(--shadow); width: 100%; display: flex; flex-direction: column;
}
.flow-card .fc-head { font-size: 12px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.flow-card .fc-body { flex: 1; font-size: 13.5px; color: var(--ink-2); }
.flow-card .fc-body code, .flow-card pre { font-family: var(--mono); }
.flow-card pre { margin: 0; font-size: 12px; line-height: 1.6; white-space: pre-wrap; color: var(--ink-2); }
.flow-card .lx { color: var(--accent); }
.flow-card .strip { color: var(--accent); font-weight: 700; }
.flow-tag {
  margin-top: 12px; align-self: flex-start; font-size: 11.5px; font-weight: 600;
  color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 4px 9px; border-radius: 999px; font-style: italic;
}
.flow-rank { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13px; }
.flow-rank li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.flow-rank .no { color: var(--muted); width: 14px; }
.flow-rank .x { color: var(--muted); }
.flow-rank .ok { color: var(--pos); font-weight: 700; }
.flow-metrics { border-top: 1px solid var(--line); padding-top: 10px; font-family: var(--mono); font-size: 12.5px; }
.flow-metrics .m { display:flex; justify-content: space-between; gap: 10px; }
.flow-metrics .up { color: var(--accent); font-weight: 700; }
.flow-arrow {
  position: absolute; right: -13px; top: 50%; transform: translateY(-50%);
  z-index: 2; color: var(--accent); width: 26px; height: 26px; display: grid; place-items: center;
}
.flow-item:last-child .flow-arrow { display: none; }
.flow-item { padding: 0 12px; }
.flow-item:first-child { padding-left: 0; } .flow-item:last-child { padding-right: 0; }

/* staggered reveal for flow */
.flow-item { opacity: 0; transform: translateX(-22px); transition: opacity .5s ease, transform .5s ease; }
.flow.in .flow-item { opacity: 1; transform: none; }
.flow.in .flow-item:nth-child(1){ transition-delay: 0s; }
.flow.in .flow-item:nth-child(2){ transition-delay: .18s; }
.flow.in .flow-item:nth-child(3){ transition-delay: .36s; }
.flow.in .flow-item:nth-child(4){ transition-delay: .54s; }
@media (max-width: 860px){
  .flow { grid-template-columns: 1fr; gap: 30px; }
  .flow-item { padding: 0; transform: translateY(-16px); }
  .flow.in .flow-item { transform: none; }
  .flow-arrow { right: 50%; top: auto; bottom: -28px; transform: translateX(50%) rotate(90deg); }
}
@media (prefers-reduced-motion: reduce){ .flow-item { opacity:1; transform:none; transition:none; } }

/* ---------- table ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.results { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--card); }
table.results th, table.results td { padding: 12px 14px; text-align: right; white-space: nowrap; }
table.results th:first-child, table.results td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); font-weight: 600; }
table.results thead th { font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--card-line); }
table.results tbody tr + tr td { border-top: 1px solid var(--line); }
table.results td { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.delta { color: var(--pos); font-weight: 650; }
.delta.big { color: var(--accent); }
.delta.neg { color: var(--muted); font-weight: 500; }
.row-avg td { font-weight: 700; color: var(--ink); background: var(--bg-tint); }
.row-avg td:first-child { background: var(--bg-tint); }
.tblnote { color: var(--muted); font-size: 13.5px; margin-top: 14px; }

/* ---------- takeaways ---------- */
.takeaways { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.take {
  background: var(--card); border:1px solid var(--card-line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); display:flex; gap:16px;
}
.take .ic { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent-ink); display:grid; place-items:center; font-size:19px; }
.take h4 { margin: 2px 0 6px; font-size: 16.5px; font-weight: 700; }
.take p { margin: 0; font-size: 14.5px; }
@media (max-width: 720px){ .takeaways { grid-template-columns: 1fr; } }

/* ---------- callout / example ---------- */
.callout {
  border-left: 3px solid var(--accent); background: var(--bg-tint);
  padding: 18px 22px; border-radius: 0 12px 12px 0; margin: 22px 0; font-size: 15.5px; color: var(--ink-2);
}
.callout b { color: var(--ink); }

/* ---------- bibtex ---------- */
.bibtex {
  background: #0e0f12; color: #d6d8de; border-radius: var(--radius);
  padding: 22px 22px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
  border: 1px solid #26282d;
}
:root[data-theme="light"] .bibtex, .bibtex { }
.bibtex .k { color: #ff8a83; }
.bibtex .v { color: #9ecbff; }
.copy-btn {
  float: right; border:1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; font-family: var(--sans);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- footer ---------- */
footer.site { border-top: 1px solid var(--line); padding: 40px 0 60px; color: var(--muted); font-size: 14px; }
footer.site a { color: var(--ink-2); }
footer.site .foot-grid { display:flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* fade-in */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce){ .reveal { opacity:1; transform:none; transition:none; } html{scroll-behavior:auto;} }
