@font-face {
  font-family: "Old Standard TT";
  src: url("../assets/fonts/OldStandardTT-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Old Standard TT";
  src: url("../assets/fonts/OldStandardTT-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Old Standard TT";
  src: url("../assets/fonts/OldStandardTT-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #fffbf0;
  --surface: #f7eedd;
  --ink: #2b241c;
  --muted: #665c50;
  --accent: #a24a14;
  --accent-strong: #7f3a10;
  --accent-tint: #f4e1cc;
  --teal: #2f6a66;
  --rule: #e3d6c1;
  --disabled-ink: #9a9084;
  --disabled-bg: #efe8db;
  --serif: "Old Standard TT", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --text: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 52rem;
  --wide: 68rem;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 1.0625rem/1.65 var(--text);
  -webkit-font-smoothing: antialiased;
}

p, figcaption { text-wrap: pretty; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; }
h2 {
  font-size: 1.85rem;
  margin: 3.5rem 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule);
}
h3 { font-size: 1.3rem; margin: 2rem 0 0.4rem; }

main, footer { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }
#method figure.decomp, #results .compare-grid, .explorer { margin-left: auto; margin-right: auto; }

.masthead {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3.5rem 1.25rem 1rem;
  text-align: center;
}
.masthead-bird {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--rule);
}
.masthead h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); margin: 1rem auto 1rem; max-width: 52rem; }
.proj { color: var(--accent); }

.authors, .affiliations { list-style: none; padding: 0; margin: 0.25rem auto; display: flex; flex-wrap: wrap; justify-content: center; }
.authors { font-size: 1.1rem; gap: 0.2rem 1.2rem; max-width: 50rem; }
.affiliations { color: var(--muted); font-size: 0.95rem; gap: 0.2rem 1.4rem; }
sup { font-size: 0.7em; line-height: 0; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin: 2rem 0 0.5rem; }
.link-card {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  background: var(--bg);
  font-family: var(--serif);
  font-size: 1.1rem;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.link-card svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
a.link-card:hover { background: var(--accent-tint); color: var(--accent-strong); }
.link-card.disabled { color: var(--disabled-ink); border-color: var(--rule); background: var(--disabled-bg); cursor: not-allowed; }

figure { margin: 1.5rem 0; }
figure.decomp { max-width: 58rem; width: calc(100vw - 2.5rem); position: relative; left: 50%; transform: translateX(-50%); }
.stage-wrap { background: var(--surface); border-radius: 12px; overflow: hidden; }
#decomp-stage { display: block; width: 100%; aspect-ratio: 13 / 9; }
.stage-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.75rem; margin-top: 0.8rem; }
.steps { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; background: var(--bg); }
.steps button, .replay {
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
}
.steps button + button { border-left: 1px solid var(--rule); }
.steps button[aria-selected="true"] { background: var(--accent-tint); color: var(--accent-strong); }
.steps button:hover { color: var(--ink); }
.replay { border: 1px solid var(--rule); border-radius: 999px; }
.replay:hover { color: var(--ink); }
#decomp-caption { max-width: var(--measure); margin: 1rem auto 0; color: var(--ink); font-size: 1.2rem; line-height: 1.6; min-height: 6.4em; }

.equation {
  font-family: var(--serif);
  font-size: 1.2rem;
  text-align: center;
  margin: 1.2rem 0;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.6rem 0;
}
.equation .sum { font-size: 1.15em; margin: 0 0.15em; }
.equation .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.2em; font-size: 0.9em; }
.equation .frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 0.2em; }

.seg { border: 0; padding: 0; margin: 0; }
.seg { text-align: center; }
.seg legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin: 0 auto 0.3rem; letter-spacing: 0.02em; }
.seg label { position: relative; display: inline-block; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--rule);
  margin-right: -1px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.95rem;
}
.seg label:first-of-type span { border-radius: 999px 0 0 999px; padding-left: 1rem; }
.seg label:last-of-type span { border-radius: 0 999px 999px 0; padding-right: 1rem; }
.seg input:checked + span { background: var(--accent-tint); color: var(--accent-strong); border-color: #dcbf9f; position: relative; }
.seg input:hover + span { color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 1px; position: relative; z-index: 1; }

.explorer { max-width: var(--wide); width: calc(100vw - 2.5rem); position: relative; left: 50%; transform: translateX(-50%); margin-top: 1rem; }
.explorer-views { display: flex; gap: 1rem; justify-content: center; }
.explorer-views figure { margin: 0; text-align: center; flex: 0 1 19rem; }
.explorer-views canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; background: var(--surface); }
.explorer-views figcaption { font-family: var(--serif); font-size: 1.05rem; margin-top: 0.35rem; }
.explorer-controls { display: flex; flex-wrap: wrap; gap: 0.9rem 1.75rem; justify-content: center; margin-top: 1rem; }

.fps { margin: 1rem 0 1.25rem; text-align: center; }
.compare-grid {
  max-width: var(--wide);
  width: calc(100vw - 2.5rem);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 2rem;
}
.compare-card { margin: 0; }
.compare-card figcaption { text-align: right; margin-top: 0.35rem; }
.compare-card .expand { font: inherit; font-size: 0.95rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 0.15em; }
.compare-card .expand:hover { color: var(--accent-strong); }

.slider { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px; background: var(--surface); user-select: none; touch-action: pan-y; --pos: 50%; }
.slider img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.slider img.after { clip-path: inset(0 0 0 var(--pos)); }
.slider .divider { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: var(--bg); box-shadow: 0 0 0 1px rgba(43, 36, 28, 0.35); pointer-events: none; }
.slider .knob {
  position: absolute; top: 50%; left: var(--pos);
  width: 2.25rem; height: 2.25rem; margin: -1.125rem 0 0 -1.125rem;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--teal);
  display: grid; place-items: center; pointer-events: none; color: var(--teal);
  box-shadow: 0 1px 4px rgba(43, 36, 28, 0.3);
}
.slider .knob svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slider .tag {
  position: absolute; top: 0.6rem; padding: 0.15rem 0.6rem; border-radius: 999px;
  background: rgba(255, 251, 240, 0.9); color: var(--ink); font-family: var(--serif); font-size: 0.95rem; pointer-events: none;
}
.slider .tag.left { left: 0.6rem; }
.slider .tag.right { right: 0.6rem; }
.slider input[type="range"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize;
  -webkit-appearance: none; appearance: none;
}
.slider input[type="range"]:focus-visible ~ .knob { outline: 2px solid var(--teal); outline-offset: 3px; }

dialog.compare-dialog {
  width: min(96vw, 1920px);
  max-height: 96vh;
  padding: 0.75rem;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
}
dialog.compare-dialog::backdrop { background: rgba(43, 36, 28, 0.75); }
dialog.compare-dialog .dialog-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; font-family: var(--serif); font-size: 1.15rem; }
dialog.compare-dialog .slider { max-height: calc(96vh - 4rem); margin: 0 auto; }
dialog.compare-dialog button.close { font: inherit; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 0.2rem 0.8rem; cursor: pointer; color: var(--muted); }
dialog.compare-dialog button.close:hover { color: var(--ink); }

.bibtex { position: relative; }
.bibtex pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font: 0.8rem/1.55 var(--mono);
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22rem;
  overflow: auto;
}
.bibtex .copy {
  position: absolute; top: 0.5rem; right: 0.5rem;
  font: inherit; font-size: 0.85rem; color: var(--accent); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 999px; padding: 0.15rem 0.75rem; cursor: pointer;
}
.bibtex .copy:hover { color: var(--accent-strong); border-color: var(--accent); }

footer { margin-top: 4rem; padding-bottom: 3rem; color: var(--muted); font-size: 0.92rem; }
footer h2 { font-size: 1.35rem; color: var(--ink); }
footer ul { padding-left: 1.2rem; }
footer li { margin: 0.3rem 0; }

@media (max-width: 720px) {
  .steps button { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
  .explorer-views { gap: 0.5rem; }
  .explorer-views figcaption { font-size: 0.9rem; }
  #decomp-caption { font-size: 1.05rem; min-height: 9em; }
  h2 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
