@font-face {
  font-family: "Libre Franklin";
  src: url("fonts/LibreFranklin.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #fcfcfd;
  --wash: #f1f3f6;
  --ink: #1e293b;
  --soft: #475569;
  --rule: #d8dee6;
  --zi: #00693e;
  --zj: #d9591f;
  --neutral: #7c8a99;
  --gutter: clamp(16px, 4vw, 64px);
  --label: 15rem;
  --bar: 3rem;
  --logo-filter: none;
}

:root[data-theme="dark"] {
  --paper: #12161c;
  --wash: #1c222b;
  --ink: #e9edf2;
  --soft: #aab4c0;
  --rule: #333c48;
  --zi: #4fc08d;
  --zj: #ff8a5c;
  --neutral: #a3aebb;
  --logo-filter: brightness(0) invert(1);
}

* { box-sizing: border-box; }

html {
  font-size: clamp(17px, 1.05vw + 12px, 22px);
  scroll-behavior: smooth;
  scroll-padding-top: var(--bar);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Libre Franklin", -apple-system, "Helvetica Neue", sans-serif;
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 200; }
h2 { font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1.12; letter-spacing: -0.01em; }
h3 { font-size: 1.3rem; font-weight: 300; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
ul { margin: 0; padding: 0; list-style: none; }
.katex { font-size: 1.08em; }
:focus-visible { outline: 2px solid var(--zj); outline-offset: 2px; }

section { padding: clamp(3.5rem, 7vw, 6.5rem) var(--gutter); }

/* Bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar);
  padding: 0 var(--gutter);
  background: var(--paper);
  box-shadow: 0 2px 6px rgb(30 41 59 / 0.16), 0 6px 20px rgb(30 41 59 / 0.16);
  font-size: 0.82rem;
}
.brand { font-weight: 500; text-decoration: none; }
.bar-links { display: flex; align-items: center; gap: clamp(0.8rem, 2vw, 1.6rem); }
.bar-links a { text-decoration: none; }
.bar-links a:hover { text-decoration: underline; }
#theme-btn {
  padding: 0.15rem 0.7rem;
  border: 0;
  border-radius: 1rem;
  background: var(--wash);
  color: var(--soft);
  font: inherit;
  cursor: pointer;
}

/* Hero */
.hero { padding: clamp(2rem, 4vw, 3.5rem) 0 clamp(3.5rem, 6vw, 5.5rem); }
h1 {
  padding: 0 var(--gutter);
  max-width: 17em;
  font-size: clamp(2.4rem, 5.4vw, 5rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.venue { margin-top: 1rem; padding: 0 var(--gutter); font-size: 1.5rem; font-weight: 300; color: var(--soft); }
.authors {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem clamp(2.5rem, 5vw, 4.5rem);
  margin-top: 2rem;
  padding: 0 var(--gutter);
}
.authors li { display: grid; gap: 0.45rem; align-content: start; }
.authors .tum { --aff-color: #3070b3; }
.authors .mit { --aff-color: #a31f34; }
.authors .dartmouth { --aff-color: #00693e; }
.names { display: flex; flex-wrap: wrap; gap: 0 1.3rem; padding-bottom: 0.3rem; border-bottom: 3px solid var(--aff-color); font-size: 1.15rem; }
.star { margin-left: 0.05em; color: var(--soft); font-size: 0.6em; font-weight: 300; opacity: 0.75; }
.logo { display: block; justify-self: start; height: 1.5rem; width: auto; filter: var(--logo-filter); }
.aff { color: var(--soft); font-size: 0.82rem; }
.star-note { margin-top: 0.7rem; padding: 0 var(--gutter); color: var(--soft); font-size: 0.72rem; opacity: 0.8; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.8rem;
  padding: 0 var(--gutter);
}
.action {
  padding: 0.6rem 1.3rem;
  border-radius: 2rem;
  background: var(--wash);
  font-size: 1.05rem;
  text-decoration: none;
  transition: background 120ms linear, color 120ms linear;
}
.action.primary { background: var(--ink); color: var(--paper); font-weight: 400; }
.action:hover { background: var(--zj); color: #fff; }
.action.unavailable, .action.unavailable:hover { background: var(--wash); color: var(--soft); opacity: 0.6; }
.foot a.unavailable { opacity: 0.45; }

.fork { position: relative; margin: 1.5rem 0; }
#fork { display: block; width: 100%; height: auto; }
.fork-label {
  position: absolute;
  right: var(--gutter);
  font-size: clamp(1rem, 1.9vw, 1.6rem);
  font-weight: 200;
}
.fork-label.zi { top: 3%; }
.fork-label.zj { bottom: 1%; }
.fork-label.zi .katex { color: var(--zi); }
.fork-label.zj .katex { color: var(--zj); }

.abstract {
  max-width: 46em;
  padding: 0 var(--gutter);
  box-sizing: content-box;
  font-size: 1.15rem;
  line-height: 1.5;
}

/* Examples: always dark, so the spectrograms sit in their own light */
.band {
  --paper: #1a212b;
  --ink: #e9edf2;
  --soft: #aab4c0;
  --rule: #333c48;
  --zi: #4fc08d;
  --zj: #ff8a5c;
  background: var(--paper);
  color: var(--ink);
}

.picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem clamp(1.5rem, 4vw, 3rem);
  margin-top: 2rem;
}
.picker h3 { margin-bottom: 0.4rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); }
.picker button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  cursor: pointer;
}
.picker button small { display: block; color: var(--soft); font-size: 0.82rem; }
.picker button:hover { background: rgb(255 255 255 / 0.05); }
.picker button[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 400; }
.picker button[aria-pressed="true"] small { color: #475569; }

.transport {
  position: sticky;
  top: var(--bar);
  z-index: 3;
  display: grid;
  grid-template-columns: 3rem 4.2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.9rem;
  margin-top: 2rem;
  padding: 0.7rem 0;
  background: var(--paper);
}
#play {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}
#clock { font-variant-numeric: tabular-nums; color: var(--soft); }
#now { font-size: 1.35rem; font-weight: 200; line-height: 1.25; }
#now small { color: var(--soft); font-size: 0.78em; }

.score { position: relative; margin-top: 0.8rem; }
.system { position: relative; padding: 0.5rem 0; }
.system + .system { margin-top: 1.6rem; }

/* Score bracket: a heavy spine with curled horns at both ends */
.bracket {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: calc(var(--label) + 0.6rem);
  width: 4px;
  background: var(--ink);
  pointer-events: none;
}
.bracket::before,
.bracket::after {
  content: "";
  position: absolute;
  left: 0;
  width: 1.05rem;
  height: 0.72rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 14' preserveAspectRatio='none'%3E%3Cpath d='M0 14V9C8 8 15 5 20 0C18 6 11 12 4 14Z' fill='%23e9edf2'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.bracket::before { bottom: 100%; }
.bracket::after { top: 100%; transform: scaleY(-1); }

.staff {
  display: grid;
  grid-template-columns: var(--label) minmax(0, 1fr);
  column-gap: 1.5rem;
  align-items: stretch;
  margin: 0.3rem 0;
}
.staff-name {
  justify-self: end;
  align-self: center;
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--soft);
  font: inherit;
  line-height: 1.25;
  text-align: right;
  cursor: pointer;
}
.staff-name strong { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; font-size: 1.1rem; font-weight: 300; color: var(--ink); }
.staff-name small { display: block; font-size: 0.85rem; }
.staff.zi .staff-name strong { color: var(--zi); }
.staff.zj .staff-name strong { color: var(--zj); }

.staff-spec {
  display: block;
  height: clamp(3.8rem, 6.4vw, 5.8rem);
  padding: 0;
  border: 0;
  background: none;
  cursor: crosshair;
  opacity: 0.42;
  transition: opacity 120ms linear;
}
.staff-spec img { display: block; width: 100%; height: 100%; object-fit: fill; }
.staff-spec:hover { opacity: 0.75; }

/* The current staff: inverted name, full color, outlined */
.staff.active .staff-spec { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; }
.staff.active .staff-name { background: var(--ink); color: #475569; }
.staff.active .staff-name strong { color: var(--paper); font-weight: 500; }

.meter { display: none; align-items: flex-end; gap: 2px; height: 0.9em; }
.staff.active .meter { display: inline-flex; }
.meter i { width: 3px; height: 40%; background: currentColor; }
.score.playing .meter i { animation: meter 700ms ease-in-out infinite alternate; }
.score.playing .meter i:nth-child(2) { animation-delay: -250ms; }
.score.playing .meter i:nth-child(3) { animation-delay: -480ms; }
@keyframes meter { from { height: 25%; } to { height: 100%; } }

.timeline {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 1.5rem;
  left: calc(var(--label) + 1.5rem);
  pointer-events: none;
  background-image: repeating-linear-gradient(to right, rgb(255 255 255 / 0.22) 0 1px, transparent 1px 10%);
}
#playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 6px rgb(255 255 255 / 0.6);
}
.ruler {
  display: flex;
  justify-content: space-between;
  margin: 0.3rem 0 0 calc(var(--label) + 1.5rem);
  color: var(--soft);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* Method */
.diagram { margin: 2.5rem 0 0; }
.diagram-scroll { overflow-x: auto; }
#diagram { display: block; width: 100%; min-width: 880px; height: auto; }
#diagram foreignObject div { color: var(--ink); font-size: 18px; line-height: 1.2; }
#diagram foreignObject div.big { font-size: 21px; }
#diagram foreignObject div.small { color: var(--soft); font-size: 15px; }
#diagram foreignObject div.on { color: #fff; font-size: 19px; }
#diagram foreignObject div.on-ink { color: var(--paper); font-size: 19px; }
#diagram foreignObject div.pair { display: flex; align-items: center; height: 36px; }
#diagram foreignObject div.tiny { font-size: 15px; line-height: 20px; }
#diagram foreignObject div.formula { font-size: 13px; color: var(--soft); white-space: nowrap; }
figcaption { max-width: 52em; margin-top: 1.5rem; color: var(--soft); font-size: 0.95rem; }

/* Results */
.results { background: var(--wash); padding-bottom: 3rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; margin-top: 2rem; font-size: 0.95rem; }
.legend > span { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend > span > svg { width: 16px; height: 16px; overflow: visible; }
.legend em { font-style: normal; }
.plots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
  margin-top: 1.5rem;
}
.plot { margin: 0; display: flex; flex-direction: column; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot text { font-family: inherit; font-weight: 300; font-size: 15px; fill: var(--soft); }
.plot figcaption { margin-top: 0.7rem; font-size: 0.9rem; }
.grid { stroke: var(--rule); stroke-width: 1; }
.tick { stroke: var(--ink); stroke-width: 1; }
.chance { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chance-band { fill: var(--ink); opacity: 0.35; }
.bar-zi { fill: var(--zi); }
.bar-zj { fill: var(--zj); }
.bar-sae { fill: var(--neutral); }
.bar-ref { fill: var(--neutral); opacity: 0.45; }

/* Feature explorer */
.features { padding-top: 3rem; }
.explore {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 2rem;
}
.explore h3 { grid-column: 1 / -1; margin-top: 1.2rem; }
.explore h3:first-child { margin-top: 0; }
.tile {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 1.3rem 3.2rem 1.3rem 1.4rem;
  border-radius: 0.6rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  transition: background 120ms linear;
}
.tile strong { font-size: 1.6rem; font-weight: 200; line-height: 1.15; }
.tile::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1.3rem;
  width: 0.7rem;
  height: 0.7rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}
.tile:hover { background: var(--zj); color: #fff; }

/* Footer */
.foot {
  padding: clamp(3rem, 5vw, 4.5rem) var(--gutter) 2.5rem;
  border-top: 1px solid #333c48;
  background: #11161d;
  color: #cdd4dd;
  font-size: 0.92rem;
}
.foot-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 2rem clamp(2rem, 5vw, 5rem);
}
.foot h3 { margin-bottom: 0.7rem; color: #fff; font-size: 1.1rem; }
.foot li { margin-bottom: 0.35rem; }
#copy-bib {
  margin-top: 1rem;
  padding: 0.35rem 1rem;
  border: 0;
  border-radius: 2rem;
  background: #2a323d;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
#copy-bib:hover { background: #cdd4dd; color: #11161d; }
.foot-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem clamp(2rem, 4vw, 3.5rem);
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid #333c48;
}
.foot-logos img { height: 1.6rem; width: auto; filter: brightness(0) invert(1); opacity: 0.85; }
.foot-logos img:last-child { height: 2.8rem; }

@media (max-width: 900px) {
  :root { --label: 0rem; --bar: 2.6rem; }
  .bar-links a:not([href="#features"]) { display: none; }
  .picker, .plots, .explore, .foot-grid { grid-template-columns: minmax(0, 1fr); }
  .fork-label { position: static; padding: 0 var(--gutter); }
  .staff { display: block; margin-bottom: 0.7rem; padding-left: 1.2rem; }
  .staff-name { display: inline-block; margin-bottom: 0.25rem; text-align: left; }
  .staff-name strong { justify-content: flex-start; }
  .staff-spec { width: 100%; }
  .bracket { left: 0; }
  .timeline { display: none; }
  .ruler { margin-left: 1.2rem; }
  #now { grid-column: 1 / -1; font-size: 1.05rem; }
  .transport { grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0.4rem 0.7rem; }
  #play { width: 2.6rem; height: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
