/* ----------------------------------------------------------------------
   BridgeLoRA — paper landing page
   Editorial typography in the spirit of an academic broadsheet:
   Newsreader for headlines, Inter for body. Sharp 0-radius. Single
   archival-ochre accent. Pure black/white otherwise.
   ---------------------------------------------------------------------- */

:root {
  --bg:        #ffffff;
  --fg:        #000000;
  --muted:     #5a5a5a;
  --rule:      #000000;
  --rule-soft: rgba(0, 0, 0, 0.12);
  --paper:     #fafaf7;        /* warm offwhite for figure plates */
  --ink:       #9A6418;         /* archival ochre — the one chromatic note */
  --ink-soft:  rgba(154, 100, 24, 0.10);
  --selection: #000;
  --code-bg:   #f4f3ef;
  --max-w:     68rem;
  --measure:   42rem;
}

:root[data-theme="dark"] {
  --bg:        #0a0a0a;
  --fg:        #f6f5f1;
  --muted:     #a5a5a5;
  --rule:      #f6f5f1;
  --rule-soft: rgba(246, 245, 241, 0.16);
  --paper:     #161512;
  --ink:       #D4A65C;
  --ink-soft:  rgba(212, 166, 92, 0.12);
  --selection: #fff;
  --code-bg:   #141311;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv11";
  transition: background 280ms ease, color 280ms ease;
  overflow-x: hidden;
}

::selection { background: var(--selection); color: var(--bg); }

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

.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rule-soft);
}

.topnav__brand {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
  transition: color 160ms;
}
.topnav__brand:hover { color: var(--ink); }
.topnav__brand .dot { color: var(--ink); }

.topnav__links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.topnav__links a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 160ms, border-color 160ms;
}

.topnav__links a:hover { color: var(--ink); border-color: var(--ink); }

.topnav__right { display: flex; align-items: center; gap: 0.6rem; }

.theme-toggle,
.nav-toggle {
  background: transparent;
  border: 1px solid var(--rule-soft);
  color: var(--fg);
  width: 2.2rem; height: 2.2rem;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 160ms, color 160ms;
  padding: 0;
}
.theme-toggle:hover,
.nav-toggle:hover { border-color: var(--ink); color: var(--ink); }

/* hamburger icon */
.nav-toggle { display: none; flex-direction: column; gap: 4px; }
.nav-toggle span {
  display: block;
  width: 16px; height: 1.5px;
  background: var(--fg);
  transition: transform 220ms, opacity 160ms;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

@media (max-width: 880px) {
  .topnav { padding: 0.85rem 1rem; }
  .topnav__links { gap: 1rem; font-size: 0.75rem; letter-spacing: 0.14em; }
  .topnav__links a:nth-child(2) { display: none; } /* hide Method on tablet */
}

@media (max-width: 600px) {
  .topnav__links { display: none; }
  .nav-toggle { display: inline-flex; }
  .topnav__brand { font-size: 1rem; }
}

/* --- mobile drawer ----------------------------------------------- */

.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 4.5rem 1.5rem 2rem;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 320ms;
  overflow-y: auto;
}
.mobile-drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
}

.drawer-close {
  position: absolute;
  top: 1rem; right: 1.2rem;
  width: 2.2rem; height: 2.2rem;
  background: transparent;
  border: 1px solid var(--rule-soft);
  color: var(--fg);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0 0 0.18rem;
}
.drawer-close:hover { border-color: var(--ink); color: var(--ink); }

.drawer-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.drawer-list {
  list-style: none;
  padding: 0; margin: 0 0 2rem 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--rule-soft);
}
.drawer-list li { border-bottom: 1px solid var(--rule-soft); }
.drawer-list a {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 0;
  text-decoration: none;
  color: var(--fg);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.25rem;
  transition: color 160ms;
}
.drawer-list a:hover,
.drawer-list a.active { color: var(--ink); }
.drawer-list .num {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 1.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.drawer-foot a {
  display: inline-block;
  padding: 0.85rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink);
  text-decoration: none;
  border-top: 1px solid var(--rule-soft);
  width: 100%;
}
.mobile-drawer.open ~ * { /* nothing — keep simple */ }

/* lock body scroll while drawer is open */
body.drawer-open { overflow: hidden; }

/* --- hero ---------------------------------------------------------- */

.hero {
  padding: 8rem 1.5rem 4rem;
  border-bottom: 1px solid var(--rule);
}

.hero__inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.hero__kicker {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-bottom: 2rem;
}

.hero__kicker .ink { color: var(--ink); font-weight: 600; }

.hero__kicker .rule {
  flex: 1;
  height: 1px;
  background: var(--rule-soft);
}

.hero__title {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: clamp(2.6rem, 6.8vw, 5.4rem);
  line-height: 0.97;
  letter-spacing: -0.02em;
  max-width: 22ch;
  margin-bottom: 1.6rem;
}

.hero__title em {
  font-style: italic;
  color: var(--ink);
  font-weight: 500;
}

.hero__deck {
  font-family: 'Newsreader', Georgia, serif;
  font-size: clamp(1.2rem, 2.1vw, 1.55rem);
  line-height: 1.4;
  color: var(--fg);
  max-width: 52ch;
  margin-bottom: 3rem;
  font-weight: 400;
}

.hero__authors {
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  padding: 1.4rem 0;
  margin-bottom: 2.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1rem 1.5rem;
}

.hero__authors .author {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.hero__authors .author__name {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.05rem;
}
.hero__authors .author__aff {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  border: 1px solid var(--rule);
  color: var(--fg);
  background: transparent;
  transition: background 160ms, color 160ms, border-color 160ms, transform 160ms;
}
.btn:hover { background: var(--fg); color: var(--bg); transform: translateY(-1px); }
.btn--primary { background: var(--fg); color: var(--bg); }
.btn--primary:hover { background: var(--ink); border-color: var(--ink); }

/* --- the standout "Watch the video" button: the page's one ochre accent --- */
.video-toggle {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 600;
  box-shadow: 0 6px 20px var(--ink-soft);
  animation: video-pulse 2.8s ease-out infinite;
}
.video-toggle:hover { background: var(--ink); color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.video-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.video-toggle__icon { font-size: 0.7em; line-height: 1; transform: translateY(0.5px); }
.video-toggle[aria-expanded="true"] { animation: none; }
@keyframes video-pulse {
  0%   { box-shadow: 0 6px 20px var(--ink-soft), 0 0 0 0 rgba(154, 100, 24, 0.40); }
  70%  { box-shadow: 0 6px 20px var(--ink-soft), 0 0 0 12px rgba(154, 100, 24, 0); }
  100% { box-shadow: 0 6px 20px var(--ink-soft), 0 0 0 0 rgba(154, 100, 24, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .video-toggle { animation: none; }
}

/* --- collapsible video panel below the hero --- */
.video-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 380ms ease, opacity 380ms ease;
  padding: 0 1.5rem;
}
.video-panel.open { max-height: 90vh; opacity: 1; }
.video-panel__inner {
  max-width: 56rem;
  margin: 1.6rem auto 0.4rem;
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  padding: 0.6rem;
}
.video-panel__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.video-panel__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.video-panel__caption {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.6rem 0 0.2rem;
}
@media (prefers-reduced-motion: reduce) {
  .video-panel { transition: none; }
}

/* --- layout: ToC + main ------------------------------------------- */

.layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 4rem;
  }
}

.toc {
  position: relative;
  font-size: 0.85rem;
}

@media (min-width: 1024px) {
  .toc {
    position: sticky;
    top: 5.5rem;
    align-self: start;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
  }
}

.toc__title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.toc__list { list-style: none; }

.toc__list li { margin: 0.45rem 0; }

.toc__list a {
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  border-left: 2px solid transparent;
  padding-left: 0.65rem;
  margin-left: -0.65rem;
  transition: color 160ms, border-color 160ms;
}

.toc__list .num {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 500;
  min-width: 1.4rem;
}

.toc__list a:hover { color: var(--fg); }
.toc__list a.active {
  color: var(--fg);
  border-left-color: var(--ink);
  font-weight: 500;
}

/* --- prose / sections --------------------------------------------- */

.prose section { margin-bottom: 4.5rem; }
.prose section:last-child { margin-bottom: 0; }

.prose h2 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1.8rem;
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
}

.prose h2 .num {
  font-family: 'Newsreader', Georgia, serif;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 0.55em;
  font-weight: 500;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  padding-top: 0.35em;
}

.prose h3 {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  font-size: 1.35rem;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.005em;
}

.prose h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink);
  margin: 2rem 0 0.7rem;
  font-weight: 600;
}

.prose p {
  max-width: var(--measure);
  margin-bottom: 1.15rem;
  color: var(--fg);
}

.prose p .term { font-style: italic; }
.prose p code, .prose li code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.35em; }

.prose strong { font-weight: 600; }

.prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 160ms, text-decoration-color 160ms;
}
.prose a:hover { color: var(--ink); text-decoration-color: var(--ink); }

.prose ul, .prose ol {
  max-width: var(--measure);
  padding-left: 1.4rem;
  margin-bottom: 1.4rem;
}
.prose ul li, .prose ol li { margin-bottom: 0.45rem; }

/* abstract */
.abstract {
  background: var(--paper);
  border-left: 2px solid var(--ink);
  padding: 2rem 2rem 1.4rem;
  margin-bottom: 4.5rem;
}
.abstract h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--ink);
  margin-bottom: 1rem;
  display: block;
}
.abstract p {
  max-width: 60ch;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.55;
}

.abstract p:first-of-type::first-letter {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 500;
  float: left;
  font-size: 4.4rem;
  line-height: 0.92;
  padding: 0.25rem 0.55rem 0 0;
  color: var(--ink);
}

/* equation block */
.eq {
  display: block;
  margin: 1.6rem auto;
  text-align: center;
  font-size: 1.1rem;
  overflow-x: auto;
}

.eq .label {
  float: right;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* figures */
figure {
  margin: 2.4rem 0;
  max-width: 100%;
}
.fig-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
figure img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 1px solid var(--rule-soft);
}
:root[data-theme="dark"] figure img {
  filter: invert(0.92) hue-rotate(180deg);
}
figcaption {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: var(--measure);
}
figcaption .figlabel {
  font-weight: 600;
  color: var(--fg);
  margin-right: 0.5rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

/* tables */
.tbl-wrap {
  margin: 2rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* visual cue that this region scrolls */
  background:
    linear-gradient(to right, var(--bg) 30%, transparent),
    linear-gradient(to right, transparent, var(--bg) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, var(--rule-soft), transparent),
    radial-gradient(farthest-side at 100% 50%, var(--rule-soft), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.tbl-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.tbl-wrap caption {
  caption-side: top;
  text-align: left;
  margin-bottom: 0.8rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: var(--measure);
}
.tbl-wrap caption .figlabel {
  font-weight: 600;
  color: var(--fg);
  margin-right: 0.5rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}
.tbl-wrap th, .tbl-wrap td {
  text-align: left;
  padding: 0.6rem 1rem 0.6rem 0;
  border: none;
}
.tbl-wrap thead th {
  border-top: 1.5px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}
.tbl-wrap tbody tr:last-child td {
  border-bottom: 1.5px solid var(--rule);
}
.tbl-wrap tbody tr td {
  border-bottom: 1px solid var(--rule-soft);
}
.tbl-wrap .num { text-align: right; padding-right: 0; }
.tbl-wrap .best { font-weight: 600; }
.tbl-wrap .group td {
  font-weight: 500;
  color: var(--ink);
  font-style: italic;
  padding-top: 1rem;
  border-bottom: none;
  font-size: 0.85rem;
}
.tbl-wrap tfoot td {
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 0.5rem;
  border-bottom: none;
}

/* algorithm block */
.algo {
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  padding: 1.5rem 1.6rem;
  margin: 2rem 0;
}
.algo .algo__head {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--fg);
  margin-bottom: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 0.6rem;
}
.algo .algo__head .num {
  color: var(--ink);
  margin-right: 0.6rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.algo__body {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.algo__body .line {
  white-space: pre;
  padding-left: 0;
}
.algo__body .line.i1 { padding-left: 1.4rem; }
.algo__body .line.i2 { padding-left: 2.8rem; }
.algo__body .kw { color: var(--ink); font-weight: 600; }
.algo__body .cm { color: var(--muted); font-style: italic; }

/* pull quote — key results */
.results {
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--ink);
  padding: 1.5rem 1.8rem;
  margin: 2.4rem 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 760px) {
  .results { grid-template-columns: repeat(2, 1fr); }
}
.results .item .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink);
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.results .item .val {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.results .item .note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* footer / citation */
.endmatter {
  border-top: 1px solid var(--rule);
  padding: 4rem 1.5rem;
}
.endmatter__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}
.endmatter__inner > * { min-width: 0; }
@media (min-width: 860px) {
  .endmatter__inner { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
}
.endmatter h3 {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.4rem;
  margin-bottom: 1rem;
  font-weight: 500;
}
.endmatter pre {
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre;
}
.endmatter pre code { display: block; }

/* On phones, soft-wrap the BibTeX so it stays readable without horizontal
   scroll. Indent wrapped lines slightly so the structure is preserved. */
@media (max-width: 600px) {
  .endmatter pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    padding: 1rem 1.1rem;
    font-size: 0.78rem;
  }
  .endmatter pre code { display: block; padding-left: 1.5em; text-indent: -1.5em; }
}
.endmatter .links { display: flex; flex-direction: column; gap: 0.6rem; }
.endmatter .links a {
  color: var(--fg);
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: color 160ms;
}
.endmatter .links a:hover { color: var(--ink); }
.endmatter .links a .arr {
  color: var(--ink);
  font-weight: 500;
}

.footer-bar {
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.footer-bar .ink { color: var(--ink); }

/* fade-in on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 700ms ease, transform 700ms cubic-bezier(0.22, 1, 0.36, 1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* KaTeX size tuning */
.katex { font-size: 1.05em !important; }
.katex-display { margin: 1.4em 0 !important; }

/* ---- inline citations ---- */
sup.cite {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  margin-left: 1px;
}
sup.cite a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  padding: 0 0.1em;
  transition: color 140ms, background 140ms;
}
sup.cite a:hover {
  color: var(--bg);
  background: var(--ink);
}
sup.cite a:target,
li.ref-list-item:target { background: var(--ink-soft); }

/* ---- references list ---- */
.references {
  border-top: 1px solid var(--rule-soft);
  padding-top: 2.5rem;
}
.ref-list {
  list-style: none;
  counter-reset: ref;
  padding-left: 0;
  max-width: var(--measure);
  font-size: 0.9rem;
  line-height: 1.5;
}
.ref-list li {
  counter-increment: ref;
  padding: 0.55rem 0 0.55rem 2.6rem;
  position: relative;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--fg);
  transition: background 280ms;
}
.ref-list li:last-child { border-bottom: none; }
.ref-list li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0;
  top: 0.55rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.86rem;
}
.ref-list li:target {
  background: var(--ink-soft);
  padding-left: 2.9rem;
  padding-right: 0.6rem;
}
.ref-list .ref-authors {
  font-weight: 500;
  color: var(--fg);
}
.ref-list em {
  color: var(--muted);
  font-style: italic;
}

/* Small print at section boundaries */
.kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

/* ---- small-screen content scaling -------------------------------- */
@media (max-width: 760px) {
  /* Tables don't shrink — they scroll horizontally so numbers stay legible */
  .tbl-wrap table {
    width: max-content;
    min-width: 100%;
    white-space: nowrap;
  }
  .tbl-wrap th, .tbl-wrap td { padding-right: 1.4rem; }

  /* Figures: image gets a min width so detail is preserved; figure scrolls
     horizontally if the image is wider than the viewport. */
  figure { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 0.2rem; }
  figure img { min-width: 560px; width: 100%; max-width: none; }
  figcaption { min-width: 100%; }

  /* Algorithm block: keep pseudocode horizontally scrollable on phones;
     white-space:pre stays on the per-line elements only, not the wrapper
     (otherwise the source newlines between <div>s become blank rows). */
  .algo { padding: 1.1rem 1.2rem; }
  .algo__body { font-size: 0.74rem; }

  /* Equations: scroll instead of forcing tiny font */
  .eq { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Results pull-quote stacks fully on phone */
  .results { padding: 1.2rem 1.3rem; }
}

/* Endmatter grid collapses on phone, no horizontal bleed */
@media (max-width: 600px) {
  .endmatter { padding: 3rem 1.2rem; }
  .endmatter__inner { gap: 2rem; }
}
