/* ---------------------------------------------------------------------------
   FNODE — academic project page
   Palette: paper #fdfdfb · ink #1d2025 · cardinal #9e1b23 · muted #59616c
            rule #e4e2dc · wash #f6f5f1
   Type:    serif prose (Charter/Cambria/Georgia), sans utility, mono code
--------------------------------------------------------------------------- */

:root {
  --paper: #fdfdfb;
  --ink: #1d2025;
  --cardinal: #9e1b23;
  --cardinal-soft: #f8efee;
  --muted: #59616c;
  --rule: #e4e2dc;
  --wash: #f6f5f1;
  --serif: "Charter", "Bitstream Charter", "Sitka Text", "Cambria", Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --wide: 66rem;
  --prose: 43rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- top navigation ---- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(253, 253, 251, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.site-nav .nav-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-nav .brand {
  font-weight: 700;
  color: var(--cardinal);
  letter-spacing: 0.1em;
  margin-right: auto;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover,
.site-nav a:focus-visible { color: var(--cardinal); }

/* ---- header / masthead ---- */

.masthead {
  max-width: var(--prose);
  margin: 0 auto;
  padding: 2.8rem 1.25rem 0;
  text-align: center;
}
.masthead .journal {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.3rem;
}
.masthead h1 {
  font-size: clamp(1.7rem, 4.4vw, 2.3rem);
  line-height: 1.22;
  font-weight: 700;
  margin: 0 0 1.3rem;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
.masthead .authors { font-size: 1.1rem; margin: 0 0 0.45rem; }
.masthead .authors a { color: var(--ink); text-decoration: none; }
.masthead .authors a:hover { color: var(--cardinal); }
.masthead .authors sup { font-size: 0.68em; color: var(--muted); }
.masthead .affil {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.1rem 0;
}
.masthead .meta {
  font-family: var(--sans);
  font-size: 0.79rem;
  color: var(--muted);
  margin: 1rem 0 0;
}
.masthead .meta a { color: inherit; }
.masthead .meta a:hover { color: var(--cardinal); }

/* ---- action buttons ---- */

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0 0;
  font-family: var(--sans);
}
.actions a {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.42rem 1rem;
  border: 1px solid #c9c5bc;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
.actions a:hover,
.actions a:focus-visible {
  border-color: var(--cardinal);
  color: var(--cardinal);
  background: var(--cardinal-soft);
}
.actions svg { width: 0.95em; height: 0.95em; fill: currentColor; flex: none; }

/* ---- hero: teaser figure + key numbers ---- */

.hero {
  max-width: var(--wide);
  margin: 2.4rem auto 0;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 2rem;
  align-items: center;
}
.hero figure { margin: 0; }
.hero .glance { margin: 0; }

/* ---- article body ---- */

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
}
main > section:first-child { margin-top: 2.6rem; }

section { scroll-margin-top: 4.2rem; }
section + section {
  margin-top: 2.8rem;
  border-top: 1px solid var(--rule);
  padding-top: 2.2rem;
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 1.1rem;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
h2 .secno, h3 .secno { color: var(--cardinal); font-weight: 700; margin-right: 0.2em; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.6rem; text-wrap: balance; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--cardinal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 700; }
var { font-style: italic; font-family: var(--serif); }

.equation {
  margin: 1rem 0;
  text-align: center;
  font-size: 1.02rem;
  overflow-x: auto;
}

/* ---- overview: abstract + contributions rail ---- */

.overview-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 2.4rem;
  align-items: start;
}
.abstract-block { font-size: 0.98rem; color: #33383f; }
.abstract-block .keywords {
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}
.abstract-block .keywords b {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.rail-card {
  border: 1px solid var(--rule);
  background: var(--wash);
  padding: 1.2rem 1.3rem;
}
.rail-card h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cardinal);
  margin: 0 0 0.9rem;
}
ol.contributions {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
ol.contributions li { margin-bottom: 0.7rem; padding-left: 0.15rem; }
ol.contributions li:last-child { margin-bottom: 0; }
ol.contributions li::marker { color: var(--cardinal); font-weight: 700; }

/* ---- method cards ---- */

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}
.method-card {
  border: 1px solid var(--rule);
  padding: 1.15rem 1.3rem 1.25rem;
  background: #fff;
}
.method-card h3 { font-size: 1.02rem; margin-bottom: 0.55rem; }
.method-card p { font-size: 0.93rem; line-height: 1.55; margin-bottom: 0.6rem; }
.method-card .equation { font-size: 0.95rem; margin: 0.7rem 0; }

/* ---- schematics strip ---- */

.schematics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 1.4rem 0 1.8rem;
}
.schematics figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  background: #fff;
  padding: 0.55rem;
}
.schematics figure img {
  flex: 1;
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 7.5rem;
}
.schematics figcaption {
  margin-top: 0.5rem;
  font-size: 0.73rem;
  text-align: left;
}

/* ---- benchmark tabs ---- */

.tabs { border: 1px solid var(--rule); background: #fff; }
.tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--wash);
  font-family: var(--sans);
}
.tablist button {
  appearance: none;
  border: none;
  background: none;
  padding: 0.6rem 0.95rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tablist button:hover { color: var(--cardinal); }
.tablist button[aria-selected="true"] {
  color: var(--cardinal);
  border-bottom-color: var(--cardinal);
  background: #fff;
}
.tab-panel { padding: 1.4rem 1.5rem; }
.panel-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.8rem;
  align-items: start;
}
.panel-grid figure { margin: 0; }
.panel-grid .panel-text h3 { font-size: 1.05rem; }
.panel-grid .panel-text p { font-size: 0.94rem; line-height: 1.55; }

.stat-table {
  margin-top: 0.9rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
  width: 100%;
}
.stat-table th, .stat-table td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  white-space: nowrap;
}
.stat-table th { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
.stat-table tr:last-child td { border-bottom: 2px solid var(--ink); }
.stat-table td.num, .stat-table th.num { text-align: right; }
.stat-table .lead td { background: var(--cardinal-soft); font-weight: 700; }

/* ---- figures ---- */

figure { margin: 1.6rem 0; }
figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
}
img.zoomable { cursor: zoom-in; }
figcaption {
  margin: 0.65rem auto 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}
figcaption .figno { color: var(--ink); font-weight: 700; }

/* ---- lightbox ---- */

dialog.lightbox {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(94vw, 75rem);
  width: auto;
}
dialog.lightbox::backdrop { background: rgba(29, 32, 37, 0.78); }
dialog.lightbox figure {
  position: relative;
  margin: 0;
  background: #fff;
  padding: 1rem 1rem 0.9rem;
  border: 1px solid var(--rule);
}
dialog.lightbox img { max-height: 82vh; width: auto; max-width: 100%; }
dialog.lightbox .lightbox-close {
  position: absolute;
  top: 0.4rem;
  right: 0.55rem;
  border: none;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: 1.9rem;
  height: 1.9rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
}
dialog.lightbox .lightbox-close:hover { color: var(--cardinal); border-color: var(--cardinal); }

/* ---- tables ---- */

.table-scroll { overflow-x: auto; }
.twoup {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  align-items: start;
  margin: 1.6rem 0;
}
.twoup table { font-size: 0.78rem; width: 100%; }
.twoup th, .twoup td { padding: 0.34rem 0.55rem; }
.twoup th:first-child, .twoup td:first-child { white-space: normal; }
table {
  border-collapse: collapse;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
caption {
  caption-side: top;
  text-align: left;
  font-size: 0.81rem;
  color: var(--muted);
  padding-bottom: 0.5rem;
}
caption .figno { color: var(--ink); font-weight: 700; }
th, td {
  padding: 0.4rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
thead th { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); font-weight: 700; }
tbody tr:last-child td { border-bottom: 2px solid var(--ink); }
td.num, th.num { text-align: right; }
.fnode-col { background: var(--cardinal-soft); font-weight: 700; }

/* ---- efficiency figure/text row ---- */

.split {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 2rem;
  align-items: center;
  margin: 1.6rem 0 0;
}
.split figure { margin: 0; }

/* ---- key results tiles ---- */

.glance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.glance > div { background: var(--paper); padding: 0.9rem 1rem; }
.glance .stat {
  font-family: var(--sans);
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--cardinal);
  font-variant-numeric: tabular-nums;
}
.glance .label {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 0.25rem;
}

/* ---- details / collapsible ---- */

details {
  margin: 1.1rem 0 0;
  border: 1px solid var(--rule);
  background: var(--wash);
  padding: 0.7rem 1rem;
}
details summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}
details summary:hover { color: var(--cardinal); }
details[open] summary { margin-bottom: 0.8rem; }
details p { font-size: 0.92rem; }

/* ---- code ---- */

pre {
  background: var(--wash);
  border: 1px solid var(--rule);
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
  margin: 1rem 0;
}
code { font-family: var(--mono); font-size: 0.86em; }
p code, li code {
  background: var(--wash);
  border: 1px solid var(--rule);
  padding: 0.05em 0.35em;
  border-radius: 3px;
}
pre code { background: none; border: none; padding: 0; font-size: 1em; }

/* ---- citation ---- */

.cite-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  align-items: start;
}
.bibtex-wrap { position: relative; }
.bibtex-wrap pre { margin: 0; }
.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.75rem;
  border: 1px solid #c9c5bc;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}
.copy-btn:hover, .copy-btn:focus-visible { color: var(--cardinal); border-color: var(--cardinal); }

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

footer { border-top: 1px solid var(--rule); margin-top: 1rem; }
footer .foot-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.8rem 1.25rem 2.6rem;
  font-family: var(--sans);
  font-size: 0.79rem;
  color: var(--muted);
  line-height: 1.6;
}
footer a { color: inherit; }
footer a:hover { color: var(--cardinal); }

/* ---- focus visibility ---- */

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--cardinal);
  outline-offset: 2px;
}

/* ---- responsive ---- */

@media (max-width: 900px) {
  .hero, .overview-grid, .panel-grid, .twoup, .split, .cite-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .method-grid { grid-template-columns: minmax(0, 1fr); }
  .schematics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .masthead { padding-top: 2rem; }
  th, td { padding: 0.38rem 0.6rem; }
  .tab-panel { padding: 1.1rem 1rem; }
}

@media (max-width: 520px) {
  .glance { grid-template-columns: minmax(0, 1fr); }
  .schematics { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 380px) {
  section { scroll-margin-top: 6.5rem; }
}

/* ---- print: expose all tab panels ---- */

@media print {
  .tab-panel[hidden] { display: block !important; }
  .tablist { display: none; }
  .site-nav { position: static; }
}
