/* Tokens ---------------------------------------------------------------- */
:root {
  --paper: #ECEFF1;
  --ink: #16212B;
  --muted: #5A6672;
  --rule: #C9D0D6;
  --stage: #1C2228;
  --stage-ink: #E6EAED;
  --accent: #E3A21A;

  /* Method families, as in the paper's figures (validated on both surfaces) */
  --implicit: #0072B2;
  --hybrid: #009E73;
  --explicit: #D55E00;
  --classic: #7F7F7F;   /* the reference baseline, deliberately grey */

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1240px;
  --card-h: clamp(140px, 20vw, 240px);
  --font: "Archivo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1F2429;
    --ink: #E3E7EA;
    --muted: #9AA5AF;
    --rule: #3A434B;
    --stage: #14181C;
  }
}
:root[data-theme="dark"] {
  --paper: #1F2429;
  --ink: #E3E7EA;
  --muted: #9AA5AF;
  --rule: #3A434B;
  --stage: #14181C;
}

/* Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ul, dl, dd, pre, figure { margin: 0; }
ul { padding: 0; list-style: none; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

sup { font-size: 0.65em; line-height: 0; margin-left: 0.1em; }

/* Masthead -------------------------------------------------------------- */
.masthead {
  padding-block: clamp(40px, 8vw, 96px) clamp(32px, 5vw, 56px);
  text-align: center;
}

.wordmark {
  font-size: clamp(3.25rem, 13vw, 10.5rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.9;
  letter-spacing: -0.02em;
  animation: unfold 1.4s cubic-bezier(0.2, 0.7, 0.1, 1) both;
}

/* The one page-load moment: the wordmark widens from condensed to expanded, like a panorama unrolling. */
@keyframes unfold {
  from { font-stretch: 62%; opacity: 0; }
  30% { opacity: 1; }
  to { font-stretch: 125%; }
}

.paper-title {
  max-width: 34ch;
  margin: clamp(20px, 3vw, 32px) auto 0;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25em 1.25em;
  margin-top: 24px;
  font-size: 1.125rem;
  font-weight: 600;
}

.mail {
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  margin-left: 0.1em;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  color: var(--muted);
}
.mail:hover { color: var(--ink); background: var(--rule); }
.mail svg {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25em 1.5em;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.links-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.venue { font-weight: 700; font-stretch: 110%; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 7px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}
.links a[href]:hover { background: var(--ink); color: var(--paper); }
.links a.pending { border-color: var(--rule); color: var(--muted); cursor: default; }
.soon { font-weight: 400; font-size: 0.85em; }

/* Gallery strip --------------------------------------------------------- */
.gallery { padding-bottom: 20px; }

.gallery-head {
  margin-bottom: 22px;
  text-align: center;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  font-stretch: 110%;
  line-height: 1.2;
}

.tldr h2 {
  font-size: clamp(1.75rem, 4.2vw, 3.25rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.tldr-text {
  max-width: 62ch;
  margin: 14px auto 0;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.5;
}

.hint { color: var(--muted); font-size: 0.95rem; margin-top: 10px; }

/* Arrows sit over the faded ends of the strip, centred on the images */
.strip-wrap { position: relative; }
.icon-btn.strip-arrow {
  position: absolute;
  top: calc(10px + var(--card-h) / 2);
  translate: 0 -50%;
  z-index: 1;
  background: var(--paper);
}
.strip-arrow.prev { left: max(8px, calc(var(--gutter) - 20px)); }
.strip-arrow.next { right: max(8px, calc(var(--gutter) - 20px)); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { border-color: currentColor; }

.strip {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
}
.strip::-webkit-scrollbar { display: none; }

.track {
  display: flex;
  gap: 22px;
  width: max-content;
  padding: 10px 0 6px;
}

.card {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.frame { position: relative; display: block; height: var(--card-h); }

.frame img {
  display: block;
  height: 100%;
  width: auto;
  background: var(--rule);
}

/* Crop marks around the selected image */
.frame::after {
  --m: 16px;
  --t: 2px;
  content: "";
  position: absolute;
  inset: -7px;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) top left / var(--m) var(--t),
    linear-gradient(var(--accent), var(--accent)) top left / var(--t) var(--m),
    linear-gradient(var(--accent), var(--accent)) top right / var(--m) var(--t),
    linear-gradient(var(--accent), var(--accent)) top right / var(--t) var(--m),
    linear-gradient(var(--accent), var(--accent)) bottom left / var(--m) var(--t),
    linear-gradient(var(--accent), var(--accent)) bottom left / var(--t) var(--m),
    linear-gradient(var(--accent), var(--accent)) bottom right / var(--m) var(--t),
    linear-gradient(var(--accent), var(--accent)) bottom right / var(--t) var(--m);
  background-repeat: no-repeat;
}
.card[aria-pressed="true"] .frame::after { opacity: 1; }

.card-name { display: block; margin-top: 12px; font-weight: 600; line-height: 1.25; }
.card-domain { display: block; color: var(--muted); font-size: 0.875rem; }

/* Viewer ---------------------------------------------------------------- */
.explorer { margin-top: 16px; }

.stage {
  position: relative;
  height: min(76vh, 860px);
  min-height: 360px;
  background: var(--stage);
  color: var(--stage-ink);
}
.stage:fullscreen { height: 100%; }

/* OpenSeadragon sets position: relative inline on this element, so size it explicitly. */
.viewer { width: 100%; height: 100%; }

.status, .wheel-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 10px 16px;
  border-radius: 6px;
  background: rgb(20 24 28 / 0.8);
  text-align: center;
  pointer-events: none;
}
.status:empty { display: none; }
.wheel-hint { opacity: 0; transition: opacity 0.25s; }
.wheel-hint.show { opacity: 1; }

.tools {
  position: absolute;
  left: var(--gutter);
  bottom: 20px;
  display: flex;
  gap: 8px;
}
.tools .icon-btn {
  border-color: rgb(230 234 237 / 0.35);
  background: rgb(20 24 28 / 0.82);
}
.tools .icon-btn:hover { border-color: var(--stage-ink); }

.readout {
  position: absolute;
  right: var(--gutter);
  bottom: 20px;
  display: grid;
  justify-items: end;
  padding: 6px 12px;
  border-left: 2px solid var(--accent);
  background: rgb(20 24 28 / 0.82);
  font-size: 0.875rem;
  line-height: 1.4;
  pointer-events: none;
}
#readout-zoom { font-weight: 700; color: var(--accent); }

/* The page shows its own loading and error messages */
.viewer .openseadragon-message { display: none !important; }

/* OpenSeadragon navigator */
.viewer .navigator {
  border: 1px solid rgb(230 234 237 / 0.35) !important;
  background: rgb(20 24 28 / 0.82) !important;
}
.viewer .displayregion { border: 2px solid var(--accent) !important; }

/* Facts under the viewer */
.facts {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 3fr;
  gap: 16px 32px;
  padding-block: 24px 8px;
}
.facts h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-stretch: 120%; }
.facts dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 28px;
}
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { font-weight: 600; overflow-wrap: anywhere; }

/* Results --------------------------------------------------------------- */
.results { padding-top: clamp(56px, 8vw, 104px); }

.section-title {
  text-align: center;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 1.1;
}
.section-lede {
  max-width: 62ch;
  margin: 14px auto 0;
  text-align: center;
  color: var(--muted);
}

.metric-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 28px;
}
.metric-box {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.metric-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}
.metric-box h3 {
  font-size: 1rem;
  font-weight: 700;
  font-stretch: 110%;
}
.metric-box .seg button { display: inline-flex; align-items: center; gap: 2px; }
.better { display: inline-grid; opacity: 0.75; }
.better svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.metric-box .seg { margin-top: 0; padding: 2px; }
.metric-box .seg button { padding: 4px 11px; font-size: 0.82rem; }
.metric-desc { margin-top: 6px; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }

/* Segmented control */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 10px;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.seg button {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:disabled { cursor: default; }
.seg button:not([aria-pressed="true"]):hover { color: var(--ink); }

/* Plot and take-home messages side by side, messages centred on the plot;
   legend and table in the row below the plot. */
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
  grid-template-areas: "switch ." "chart aside" "below aside";
  grid-template-rows: auto auto 1fr;
  column-gap: 32px;
  margin-top: 50px;
}
.view-switch { grid-area: switch; justify-self: start; }
.results-grid.no-switch { grid-template-areas: "chart aside" "below aside"; grid-template-rows: auto 1fr; }
.chart-card { grid-area: chart; margin: 0; }
.chart-below { grid-area: below; }
/* Starts under the view switch, level with the top of the plot */
.takeaways { grid-area: aside; align-self: start; margin-top: 12px; }
.view-switch { margin-top: 0; }
.chart { position: relative; margin-top: 12px; }
.chart-svg { display: block; }
#chart-svg { display: block; touch-action: pan-y; cursor: grab; user-select: none; }
#chart-svg.dragging { cursor: grabbing; }

.chart-svg .grid-lines { stroke: var(--rule); stroke-width: 1; fill: none; }
.chart-svg .grid-minor { stroke: var(--rule); stroke-width: 1; fill: none; opacity: 0.3; }
.chart-svg .edge-lines { stroke: var(--rule); stroke-width: 1; fill: none; }
.chart-svg .axis text { fill: var(--muted); font-size: 12px; }
.chart-svg .axis-title { fill: var(--ink); font-size: 13px; font-weight: 600; }

/* Markers as in the paper's figures: family symbol and colour, thin dark outline */
.chart-svg .pt .mark { stroke: rgb(0 0 0 / 0.75); stroke-width: 0.8; }
.chart-svg .pt .hit { fill: transparent; }
.chart-svg .pt { cursor: pointer; outline: none; transition: opacity 0.2s; }
.chart-svg .pt:hover .mark, .chart-svg .pt:focus-visible .mark { stroke: var(--ink); stroke-width: 2; }
.chart-svg .pt-label { display: none; fill: var(--ink); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.chart-svg.has-highlight .pt.on .pt-label { display: block; }
.chart-svg .fam-implicit { --fam: var(--implicit); }
.chart-svg .fam-hybrid { --fam: var(--hybrid); }
.chart-svg .fam-explicit { --fam: var(--explicit); }
.chart-svg .fam-classic { --fam: var(--classic); }
.chart-svg .pt .mark { fill: var(--fam); }
.chart-svg.has-highlight .pt:not(.on) { opacity: 0.15; }

.chart-tip {
  position: absolute;
  z-index: 2;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 6px 20px rgb(22 33 43 / 0.12);
  font-size: 0.85rem;
  line-height: 1.5;
  pointer-events: none;
}
.chart-tip .tip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--muted); }
.chart-tip strong { color: var(--ink); }
.tip-key { width: 14px; height: 3px; border-radius: 2px; background: var(--fam); }
.tip-key.fam-implicit { --fam: var(--implicit); }
.tip-key.fam-hybrid { --fam: var(--hybrid); }
.tip-key.fam-explicit { --fam: var(--explicit); }
.tip-key.fam-classic { --fam: var(--classic); }
.chart-tip .tip-sub { margin: -2px 0 4px; color: var(--muted); font-size: 0.8rem; }

/* Super-resolution: bars and Elo box plots, styled like the paper's figures */
.chart-svg .bar-grid { stroke: var(--rule); stroke-width: 1; }
.chart-svg .bar-base { stroke: var(--muted); stroke-width: 1; }
.chart-svg .bar-hit { fill: transparent; }
.chart-svg .bar, .chart-svg .box { cursor: pointer; outline: none; transition: opacity 0.2s; }
.chart-svg .bar-fill, .chart-svg .box-fill { fill: var(--fam); stroke: rgb(0 0 0 / 0.75); stroke-width: 0.8; }
.chart-svg .bar:hover .bar-fill, .chart-svg .bar:focus-visible .bar-fill,
.chart-svg .box:hover .box-fill, .chart-svg .box:focus-visible .box-fill { stroke: var(--ink); stroke-width: 2; }
.chart-svg .bar-label { fill: var(--muted); font-size: 11px; }
.chart-svg .bar-value { display: none; fill: var(--ink); font-size: 11px; font-weight: 700; }
.chart-svg.has-highlight .bar.on .bar-value { display: block; }
.chart-svg.has-highlight .bar.on .bar-label { fill: var(--ink); font-weight: 600; }
.chart-svg.has-highlight .bar:not(.on), .chart-svg.has-highlight .box:not(.on) { opacity: 0.2; }
.chart-svg .whisker, .chart-svg .median { stroke: var(--ink); stroke-width: 1; }
.chart-svg .median { stroke-width: 1.6; }
.chart-svg .panel-title { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart-svg .elo-panel.overall .panel-title { font-weight: 800; }

.chart-hint { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }

/* One row per family: the family, then its methods */
.legend { display: grid; gap: 6px; margin-top: 16px; }
.legend-col { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.legend button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.legend .legend-family {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 11.5rem;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 700;
}
.legend-methods { display: flex; flex-wrap: wrap; gap: 4px; }
.legend .legend-method {
  padding: 3px 10px;
  border-radius: 999px;
  border-color: var(--rule);
  font-size: 0.85rem;
}
.legend button:hover { background: var(--rule); }
.legend button[aria-pressed="true"] { border-color: var(--accent); background: rgb(227 162 26 / 0.12); }
.legend-icon { width: 14px; height: 14px; stroke: rgb(0 0 0 / 0.75); stroke-width: 0.8; }
.legend-icon.fam-implicit { fill: var(--implicit); }
.legend-icon.fam-hybrid { fill: var(--hybrid); }
.legend-icon.fam-explicit { fill: var(--explicit); }
.legend-swatch { width: 12px; height: 12px; border: 0.8px solid rgb(0 0 0 / 0.75); background: var(--fam); }
.legend-swatch.fam-implicit { --fam: var(--implicit); }
.legend-swatch.fam-hybrid { --fam: var(--hybrid); }
.legend-swatch.fam-explicit { --fam: var(--explicit); }
.legend-swatch.fam-classic { --fam: var(--classic); }

.numbers { margin-top: 14px; }
.numbers summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
.numbers table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.numbers th, .numbers td { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
.numbers th:nth-child(-n+2), .numbers td:nth-child(-n+2) { text-align: left; }
.numbers th { color: var(--muted); font-weight: 600; }

.takeaways h3 { font-size: 1rem; font-weight: 700; font-stretch: 110%; }
.takeaways ul { display: grid; gap: 10px; margin-top: 12px; }
.takeaways button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.takeaways button:hover { border-left-color: var(--muted); }
.takeaways button[aria-pressed="true"] { border-left-color: var(--accent); background: rgb(227 162 26 / 0.08); }
.tk-figure {
  font-size: 1.6rem;
  font-weight: 800;
  font-stretch: 115%;
  line-height: 1.1;
  font-variant-numeric: proportional-nums;
}
.tk-title { font-weight: 700; }
/* Collapsed by default: the description opens on the selected card */
.tk-text { display: none; margin-top: 4px; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.takeaways button[aria-pressed="true"] .tk-text { display: block; }
.takeaways-hint { margin-top: 10px; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 980px) {
  .results-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "switch" "chart" "below" "aside"; }
  .results-grid.no-switch { grid-template-rows: none; grid-template-areas: "chart" "below" "aside"; }
  .chart-below { margin-bottom: 32px; }
}
@media (max-width: 600px) {
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; justify-self: stretch; border-radius: 18px; }
  .view-switch button { border-radius: 14px; }
}

/* Text sections --------------------------------------------------------- */
.prose, .citation { padding-block: clamp(48px, 7vw, 88px) 0; }
.cite-block + .cite-block { margin-top: 28px; }
.citation-head p { color: var(--muted); }
.prose h2, .citation h2 { margin-bottom: 16px; }
.prose h2 { text-align: center; }
.prose p {
  max-width: 68ch;
  margin-inline: auto;
  text-align: justify;
  hyphens: auto;
}
.prose p + p { margin-top: 1em; }

.citation-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.text-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.text-btn:hover { border-color: currentColor; }

pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer {
  padding-block: clamp(48px, 7vw, 88px) 40px;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer p { max-width: 68ch; }

/* Small screens --------------------------------------------------------- */
@media (max-width: 720px) {
  .stage { height: 64vh; }
  .facts { grid-template-columns: 1fr; }
  .readout { bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark { animation: none; }
  .wheel-hint { transition: none; }
}
