/* ===== Tokens ===== */
:root {
  --echo-dark: #432355;
  --echo-mid: #74509a;
  --echo-light: #8C6AAA;
  --echo-tint: #f6f2fa;
  --echo-tint-2: #faf8fc;
  --echo-border: #e4d9ef;
  --ink: #1a1a2e;
  --text: #363636;
  --muted: #6b7280;
  --surface-soft: #f8f6fb;  /* flat panel fill (TL;DR, notes, code) */
  --rule: #e6e1ec;          /* hairline above ruled columns */
  --nav-h: 52px;
}

/* ===== Base ===== */
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }

body {
  font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: #e8dcf3; }

section[id] { scroll-margin-top: 36px; }

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--echo-light);
  outline-offset: 2px;
  border-radius: 4px;
}

.echo-name { font-weight: 700; }
.echo-name .d { color: var(--echo-dark); }
.echo-name .l { color: var(--echo-light); }

/* ===== Section nav ===== */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid rgba(67, 35, 85, 0.09);
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform 0.28s ease, visibility 0s linear 0.28s;
}
.topnav.is-visible {
  transform: none;
  visibility: visible;
  transition: transform 0.28s ease, visibility 0s;
}
.topnav-inner {
  max-width: 1120px;
  height: var(--nav-h);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topnav-brand {
  flex: none;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.topnav-links {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav-links::-webkit-scrollbar { display: none; }
/* Auto margins centre the row when it fits, and collapse to 0 when it scrolls. */
.topnav-links a:first-child { margin-left: auto; }
.topnav-links a:last-child { margin-right: auto; }
.topnav-links a {
  flex: none;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #5b5366;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.topnav-links a:hover {
  background: var(--echo-tint);
  color: var(--echo-dark);
}
.topnav-links a.is-active {
  background: var(--echo-tint);
  color: var(--echo-dark);
  box-shadow: inset 0 0 0 1px var(--echo-border);
}
.topnav-actions {
  flex: none;
  display: flex;
  gap: 0.2rem;
}
.topnav-actions a {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #4b4453;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.topnav-actions a:hover {
  background: var(--echo-tint);
  color: var(--echo-dark);
}
.topnav-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--echo-light), var(--echo-dark));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ===== Hero ===== */
.hero {
  padding-top: 2.5rem;
  padding-bottom: 0;
  background:
    radial-gradient(900px 380px at 50% -140px, rgba(140, 106, 170, 0.17), rgba(140, 106, 170, 0) 72%),
    #fff;
}

.publication-title {
  font-size: 2.4rem !important;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: 1.2rem;
  color: var(--ink);
  text-wrap: balance;
}

.publication-subtitle {
  font-size: 1.35rem;
  color: #4b5563;
  margin-top: -0.4rem;
  margin-bottom: 1.1rem;
}
.publication-subtitle .echo-name { font-size: 1.12em; }

/* Authors: names in ink (purple on hover), affiliation marks in brand purple. */
.publication-authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.5rem;
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
}
.publication-authors .author-block { white-space: nowrap; }
.publication-authors a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}
.publication-authors a:hover,
.publication-authors a:focus-visible { color: var(--echo-mid); }
.publication-authors sup,
.publication-affiliations sup {
  font-size: 0.6em;
  font-weight: 600;
  line-height: 0;
  color: var(--echo-mid);
  letter-spacing: 0.02em;
}
.publication-authors sup { margin-left: 0.15em; }
.publication-affiliations sup { margin-right: 0.15em; }

.publication-affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15rem 1.25rem;
  font-size: 0.98rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.publication-affiliations .affil-block { white-space: nowrap; }

/* Footnotes: one note per line, set off by a short rule. */
.publication-notes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}
.publication-notes::before {
  content: "";
  width: 2.5rem;
  height: 2px;
  border-radius: 2px;
  background: var(--echo-border);
  margin-bottom: 0.55rem;
}
.publication-notes p { margin: 0; text-wrap: balance; }
.publication-notes .note-mark {
  font-size: 0.9em;
  font-weight: 700;
  color: var(--echo-mid);
  margin-right: 0.2em;
}
.publication-notes .note-icon {
  color: var(--echo-light);
  margin-right: 0.4em;
}
.publication-notes a { color: #6b3f8c; }
.publication-notes a:hover { color: var(--echo-dark); text-decoration: underline; text-underline-offset: 2px; }

/* ===== Link Buttons ===== */
.publication-links {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}
.publication-links .button.is-dark {
  font-size: 0.88rem;
  font-weight: 500;
  padding-left: 1.1em;
  padding-right: 1.2em;
  background: #221c29;
  border: 1px solid #221c29;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.publication-links .button.is-dark:hover {
  background: var(--echo-dark);
  border-color: var(--echo-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(67, 35, 85, 0.22);
}

/* ===== Sections ===== */
.section { padding: 2rem 1.5rem; }

.title.is-3 {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin-bottom: 1.25rem;
  text-wrap: balance;
}

/* Small label above each section title, with a hairline running to the edge */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--echo-mid);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--echo-border);
}

.title.is-5 {
  color: #374151;
  font-weight: 600;
}

/* ===== Content Typography ===== */
.content p {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 0.9rem;
}
.content h4 { margin-top: 1.5rem; }
.content a { color: #6b3f8c; }

/* Two shapes are used for set-off content:
   - Panels: flat soft fill, no border (TL;DR, conclusion, method note, BibTeX).
   - Tiles: small soft-purple cards in a grid, no border
     (headline stats, observation numbers, analysis takeaways). */

/* ===== Panels ===== */
.tldr {
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 1.35rem 1.6rem 1.45rem;
}
.tldr p { line-height: 1.7; color: #374151; }
.tldr p:last-child { margin-bottom: 0; }
.tldr-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--echo-mid) !important;
  margin-bottom: 0.4rem;
}

/* ===== Tiles ===== */
.stat,
.insight-item,
.takeaway {
  position: relative;
  background: var(--echo-tint);
  border-radius: 12px;
  padding: 0.9rem 1rem 0.95rem;
}

/* Big numbers: digits carry the weight; qualifiers and units (>, +, %, x)
   are set smaller and lighter so the value reads first. */
.stat-num,
.insight-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--echo-dark);
  line-height: 1.15;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.num-aff {
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--echo-light);
  margin: 0 0.04em;
}
.num-aff:first-child { margin-left: 0; vertical-align: 0.1em; }
.stat-label,
.insight-text {
  font-size: 0.9rem;
  line-height: 1.45;
  color: #4b5563;
  margin-top: 0.3rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.stat { display: flex; flex-direction: column; }

.insight-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.6rem 0 1.5rem;
}
.insight-item { display: flex; flex-direction: column; }

/* ===== Method steps (vertical stepper) ===== */
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--echo-dark);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}
.content .method-steps { margin: 1.6rem 0 1.3rem; }
.method-step {
  position: relative;
  padding-left: 2.8rem;
  padding-bottom: 1.15rem;
}
.method-step:last-child { padding-bottom: 0; }
.method-step::before {
  content: "";
  position: absolute;
  left: calc(0.85rem - 1px);
  top: 2.15rem;
  bottom: 0.4rem;
  width: 2px;
  border-radius: 2px;
  background: var(--echo-border);
}
.method-step:last-child::before { display: none; }
.method-step .step-num {
  position: absolute;
  left: 0;
  top: 0;
}
.content .method-step h4.title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  line-height: 1.7rem;
}
.content .method-step p:last-child { margin-bottom: 0; }
.content p.method-eq { margin: 0.9rem 0; }

.content p.callout {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-top: 1.4rem;
  padding: 1rem 1.25rem;
  background: var(--surface-soft);
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #3f3a46;
}
.callout-icon {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--echo-dark);
  color: #fff;
  font-size: 0.72rem;
}

/* ===== Takeaways (tiles) ===== */
.takeaway-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0 0.5rem;
  padding: 0;
  list-style: none;
}
.takeaway {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.takeaway-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--echo-mid);
}
.takeaway-title {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.42;
  color: var(--ink);
}
.takeaway-body {
  font-size: 0.9rem;
  line-height: 1.55;
  color: #4b5563;
}

/* ===== Figures ===== */
.result-figure {
  margin: 1.2rem auto;
  max-width: 100%;
}
.result-figure img {
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}
.result-figure.fig-large { max-width: 72%; margin: 1.2rem auto 0; }

.fig-caption {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.55;
  margin-top: 0.8rem;
  margin-bottom: 1rem;
  text-align: left;
}
.fig-caption strong { color: #374151; }

.fig-caption-small {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.4rem;
}

/* Animated figures: break out of the reading column */
.dynamic-figure {
  width: min(1100px, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}
/* Tall diagrams (Figs. 1-2): only slightly wider than the text column,
   so each fits on one laptop screen. */
.dynamic-figure.is-compact { width: min(880px, calc(100vw - 32px)); }

/* Playback controls for animated figures: one soft tray holding
   play/pause, replay, and a segmented speed picker. */
.playback {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #f4f1f7;
  box-shadow: inset 0 0 0 1px #ebe5f1;
}
.playback button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #5a5066;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.playback button:hover { background: rgba(255, 255, 255, 0.75); color: var(--echo-dark); }
.playback button:focus-visible { outline: 2px solid var(--echo-light); outline-offset: 1px; }
.playback .pb-icon { width: 11px; height: 11px; fill: currentColor; flex: none; }
.playback .pb-toggle { min-width: 74px; }           /* no width jump between Play / Pause */
.playback .pb-icon-only { width: 28px; padding: 0; }
.playback .pb-icon-only .pb-icon { width: 13px; height: 13px; }
.pb-sep { width: 1px; height: 16px; margin: 0 3px; background: #ddd5e6; }
.pb-speed { display: inline-flex; gap: 2px; }
.playback .pb-speed-opt {
  min-width: 38px;
  padding: 0 7px;
  color: #8a8095;
  font-variant-numeric: tabular-nums;
}
.playback .pb-speed-opt[aria-pressed="true"] {
  background: #fff;
  color: var(--echo-dark);
  box-shadow: 0 1px 2px rgba(26, 26, 46, 0.12), 0 0 0 1px rgba(67, 35, 85, 0.06);
}
@media (prefers-reduced-motion: reduce) {
  .playback button { transition: none; }
}

/* Results charts draw in on first view (static/figures/reveal.js). */
svg.rv-armed .rv-fade { transition: opacity 0.4s ease; }
svg.rv-armed .rv-pop {
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
svg.rv-armed .rv-fade:not(.rv-in) { opacity: 0; }
svg.rv-armed .rv-pop:not(.rv-in) { opacity: 0; transform: scale(0.2); }

/* ===== Math (KaTeX) ===== */
.katex-display { margin: 0.8rem 0; }

/* ===== BibTeX ===== */
.bibtex-container {
  position: relative;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 1.15rem 1.4rem;
}
.bibtex-container pre {
  background: transparent;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
  color: #3b3542;
}
/* One span per line; a field that wraps hangs under its own text. */
.bibtex-container .bib-line { display: block; }
.bibtex-container .bib-field { padding-left: 4ch; text-indent: -4ch; }
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.75rem !important;
}
.bibtex-container .copy-btn.is-light {
  background: #fff;
  border: none;
  border-radius: 7px;
  color: var(--echo-dark);
  box-shadow: 0 1px 2px rgba(26, 26, 46, 0.08);
}
.bibtex-container .copy-btn.is-light:hover { background: #fff; color: var(--echo-mid); }

/* ===== Acknowledgements ===== */
.acknowledgements { padding-top: 0.5rem; }
.acknowledgements .title.is-6 {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.acknowledgements .content p {
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ===== Footer ===== */
.footer {
  padding: 2rem 1.5rem 2.25rem;
  background: var(--echo-tint-2);
  border-top: 1px solid var(--echo-border);
}
.footer-inner { text-align: center; }
.footer-brand { font-size: 1.15rem; }
.footer-affil {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #6b6474;
}
.footer-credit {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #9a93a3;
}
.footer-credit a {
  color: #7b7286;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.15);
  text-underline-offset: 2px;
}
.footer-credit a:hover { color: var(--echo-dark); }

/* ===== Responsive ===== */
@media screen and (max-width: 768px) {
  .publication-title { font-size: 1.6rem !important; }
  .publication-subtitle { font-size: 1.1rem; }
  .publication-authors { font-size: 1.05rem; gap: 0.3rem 1.1rem; }
  .publication-affiliations { font-size: 0.88rem; gap: 0.1rem 0.9rem; }
  .publication-notes { font-size: 0.78rem; }

  .section { padding: 1.5rem 1rem; }
  .title.is-3 { font-size: 1.45rem; }

  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .takeaway-grid { grid-template-columns: 1fr; }
  .result-figure.fig-large { max-width: 100%; }

  .topnav-inner { gap: 0.5rem; padding: 0 0 0 16px; }
  .topnav-actions { display: none; }
  .topnav-links {
    padding-right: 16px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .topnav-links a { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
}

@media screen and (max-width: 520px) {
  .insight-box { grid-template-columns: 1fr; }
  .bibtex-container { padding: 3rem 1rem 1rem; }
  .bibtex-container pre { font-size: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .topnav, .topnav.is-visible { transition: none; }
  .publication-links .button.is-dark:hover { transform: none; }
}

/* In-plot annotations get a white halo so gridlines and guides never cut through text. */
.fig3 :is(.f3-note, .f3-callout, .f3-callout-sub, .f3-label-echo, .f3-label-plain, .f3-value),
.fig4 :is(.f4-series-label, .f4-width-label, .f4-end-value, .f4-legend-title, .f4-legend-note),
.fig6 :is(.f6-end, .f6-value, .f6-note) {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}
