/* Archivo (SIL Open Font License 1.1, assets/vendor/OFL.txt), latin subset, variable width and weight. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("vendor/archivo-latin.woff2") format("woff2");
}

@property --split {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 50%;
}

:root {
  --paper: #ffffff;
  --ink: #151a2d;
  --ink-2: #4a5165;
  --hair: #e3e6ef;
  --tint: #f5f6fa;
  /* Colours carry meaning, as in the paper's figures: crimson only for ScaleSR results, window blue only for the
     method's sliding window (spotlight frames, minimap frame, progress, focus). */
  --accent: #c82c4c;
  --accent-soft: rgba(200, 44, 76, 0.07);
  --window: #4450d4;
  --window-soft: rgba(68, 80, 212, 0.13);
  --veil: rgba(255, 255, 255, 0.88);
  --wide: 88rem;
  --text: 46rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 1.0625rem;
  font-weight: 430;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--window); outline-offset: 3px; border-radius: 4px; }
h1, h2, p, figure, ol, ul { margin: 0; }

/* No word alone on the last line: balanced headings, "pretty" paragraphs (site.js also glues the last two words). */
h2, .title-text, .claim-text { text-wrap: balance; }
p, li, figcaption { text-wrap: pretty; }

/* ---------- reading progress ---------- */

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--window);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 50;
  pointer-events: none;
}

/* ---------- masthead: centred, one column ---------- */

.masthead {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(2rem, 5vh, 3.4rem) var(--gutter) clamp(1.6rem, 4vh, 2.4rem);
  text-align: center;
}

.title { font-weight: inherit; }

.wordmark {
  display: block;
  font-size: clamp(3.2rem, 8vw, 7.4rem);
  font-weight: 820;
  font-stretch: 125%;
  letter-spacing: -0.035em;
  line-height: 0.92;
}

.title-text {
  display: block;
  margin-top: clamp(0.8rem, 2vh, 1.2rem);
  font-size: clamp(1.1rem, 1.8vw, 1.65rem);
  font-weight: 600;
  font-stretch: 106%;
  line-height: 1.3;
}

.authors { margin-top: clamp(1.1rem, 2.4vh, 1.5rem); font-size: 1.05rem; font-weight: 560; line-height: 1.45; }
.affiliations { margin-top: 0.3rem; color: var(--ink-2); font-size: 0.92rem; line-height: 1.5; }
.affiliations sup { margin-left: 0.5em; }
.affiliations sup:first-child { margin-left: 0; }
.contact { margin-top: 0.3rem; color: var(--ink-2); font-size: 0.92rem; line-height: 1.5; }
.contact a { text-decoration-color: var(--hair); text-underline-offset: 0.2em; }
.contact a:hover { color: var(--ink); text-decoration-color: currentColor; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1.3rem; }
.links a {
  padding: 0.55rem 1.15rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 620;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.links a:hover { background: var(--ink); color: var(--paper); }

/* ---------- stages: the zoomable images of the hero and the 10K tour, one full screen each ---------- */

.stage {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
}

.world { position: absolute; top: 0; left: 0; transform-origin: 0 0; --k: 1; }
.world-image { width: 100%; height: 100%; }

.detail { position: absolute; overflow: hidden; --split: 0%; }
.detail img { width: 100%; height: 100%; }
.detail-sr { position: absolute; inset: 0; }
.detail-lq {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--split)) 0 0);
  opacity: 0;
}

.wipe {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--split);
  width: calc(2px / var(--k));
  margin-left: calc(-1px / var(--k));
  background: var(--paper);
  box-shadow: 0 0 calc(10px / var(--k)) rgba(21, 26, 45, 0.35);
  opacity: 0;
}

.detail.is-comparing .detail-lq, .detail.is-comparing .wipe { opacity: 1; }
#hero .detail-lq, #hero .wipe { transition: opacity 0.45s; }
.detail.autoplay { animation: sweep 7s ease-in-out infinite alternate; }

@keyframes sweep {
  from { --split: 12%; }
  to { --split: 88%; }
}

.tag {
  position: absolute;
  top: 1.2rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.85rem;
  font-weight: 620;
  pointer-events: none;
}
.tag-lq { left: 1.2rem; }
.tag-sr { right: 1.2rem; background: var(--accent); color: #fff; }
.tour-stage .tag { opacity: 0; }

/* Where the view is in the whole image, and how many pixels it shows: one widget, centred at the bottom.
   It fades out once the whole image is in view. */
.hud {
  position: absolute;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: opacity 0.4s;
  pointer-events: none;
}
.stage.is-whole .hud { opacity: 0; }

.minimap {
  position: relative;
  width: clamp(6rem, 9vw, 8.5rem);
  aspect-ratio: 1;
  border: 2px solid var(--paper);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 0.4rem 1.6rem rgba(21, 26, 45, 0.28);
  background: var(--tint);
}
.minimap img { width: 100%; height: 100%; }
.minimap-frame {
  position: absolute;
  border: 2px solid var(--window);
  border-radius: 3px;
  background: var(--window-soft);
  box-shadow: 0 0 0 200px rgba(255, 255, 255, 0.35);
}

.readout {
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.94);
  font-size: clamp(0.95rem, 1.25vw, 1.15rem);
  font-weight: 760;
  font-stretch: 118%;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: center;
}
.readout small { display: block; color: var(--ink-2); font-size: 0.66em; font-weight: 560; font-stretch: 100%; }

/* The two halves of one sentence, mirrored on both sides of the whole image, each inside its own margin.
   The hero ends on one (4096), the 10K tour opens and ends on the other. */
.stage-note {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(50% - var(--square, 40vh) / 2);
  padding: 0 clamp(1rem, 2.2vw, 2.4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: clamp(1.1rem, 1.75vw, 2rem);
  font-weight: 560;
  font-stretch: 108%;
  line-height: 1.22;
  white-space: nowrap;
  pointer-events: none;
}
.stage-note strong { font-weight: 800; }
.stage-note-left { left: 0; text-align: right; }
.stage-note-right { right: 0; text-align: left; }
html:not(.motion) #hero .stage-note { display: none; }
.motion .stage-note { opacity: 0; }

/* ---------- key claims ---------- */

/* The hero's whole image on the left with the 512 x 512 fine-tuning patch marked at true scale, three numbers on
   the right. Each number reads with its word at first glance; one short line below gives the detail. */
.claims {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(3.5rem, 10vh, 6rem) var(--gutter) clamp(1rem, 3vh, 2rem);
}

.claims-body {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  align-items: center;
  gap: clamp(3rem, 6vw, 6rem);
  margin-top: clamp(2rem, 5vh, 3rem);
}

.claims-image { position: relative; width: min(66vh, 46vw); aspect-ratio: 1; }
.claims-image img { width: 100%; height: 100%; }

.patch { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.patch rect { fill: rgba(68, 80, 212, 0.16); stroke: #fff; stroke-width: 40; }
.patch rect + rect { fill: none; stroke: var(--window); stroke-width: 17; }
.patch-label {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -0.5rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--window);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 650;
  white-space: nowrap;
}

.claim-list { list-style: none; margin: 0; padding: 0; display: grid; gap: clamp(1.4rem, 3.5vh, 2.4rem); }
.claim-list li { padding-top: 0.9rem; border-top: 2px solid var(--ink); }
.claim-big { font-size: clamp(1.4rem, 2.1vw, 2.1rem); font-weight: 620; font-stretch: 106%; line-height: 1.1; white-space: nowrap; }
.claim-figure {
  margin-right: 0.12em;
  color: var(--accent);
  font-size: 2.1em;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.claim-text { margin-top: 0.45rem; color: var(--ink-2); font-size: 1.02rem; }

/* Inside the hero stage (wide screens): the section lies over the stage, and the stage's own image is its figure. */
.motion .hero-stage .claims { position: absolute; inset: 0; max-width: none; margin: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
.motion .hero-stage .claims-image img { visibility: hidden; }

/* ---------- chapters: centred heading and lede, content on the full column ---------- */

.chapter {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(5rem, 14vh, 9rem) var(--gutter) 0;
}

/* Headings use the full column, so a short one never breaks; a long one breaks into two balanced lines. */
.chapter-head { margin: 0 auto; text-align: center; }

/* Every section opens with the same bold heading. */
.chapter h2, .claims h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 720;
  font-stretch: 108%;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.abstract, .chapter-lede { max-width: var(--text); margin: 1.4rem auto 0; color: var(--ink-2); font-size: 1.15rem; line-height: 1.65; }

/* ---------- spotlight stories over Fig. 1 and Fig. 2 ---------- */

.story { margin-top: clamp(2rem, 5vh, 3rem); }
.story:first-child { margin-top: 0; }

.spot-frame { position: relative; overflow: hidden; border-radius: 0.9rem; }
.spot-world { position: relative; transform-origin: 0 0; --zk: 1; }

/* The spotlight is drawn as the sliding window of Fig. 2; its line keeps its width while the figure zooms. */
.spot {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  border: calc(2.5px / var(--zk)) solid var(--window);
  border-radius: calc(0.8rem / var(--zk));
  box-shadow: 0 0 0 calc(7px / var(--zk)) var(--window-soft), 0 0 0 200vmax var(--veil);
  opacity: 0;
  pointer-events: none;
}

.story-steps {
  max-width: var(--text);
  margin: 1.4rem auto 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1rem;
  text-align: center;
}

.story-steps li, .sequence-text li { font-size: 1.15rem; line-height: 1.55; color: var(--ink-2); }
.story-steps strong, .sequence-text strong { color: var(--ink); font-weight: 680; }

/* ---------- visual comparisons ---------- */

.chapter-wide { max-width: none; padding-left: 0; padding-right: 0; }
.chapter-wide .chapter-head { padding: 0 var(--gutter); }

.gallery { margin-top: clamp(2.5rem, 6vh, 4rem); overflow: hidden; }

.gallery-track {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.shot { position: relative; }
.shot img { width: 100%; border-radius: 0.6rem; }
.gallery figcaption { margin-top: 0.7rem; color: var(--ink-2); font-size: 0.95rem; text-align: center; }

/* The patch of ScaleSR (and the ground truth) light up as a comparison reaches the centre. */
.mark {
  position: absolute;
  border: 2.5px solid var(--window);
  border-radius: 5px;
  box-shadow: 0 0 0 5px var(--window-soft);
  opacity: 0;
  transition: opacity 0.45s;
  pointer-events: none;
}
.is-focus .mark-ours { opacity: 1; }
.is-focus .mark-gt { opacity: 1; transition-delay: 0.6s; }

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

.table-wrap { margin-top: 2.4rem; overflow-x: auto; }

.results {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  white-space: nowrap;
}
.results th, .results td { padding: 0.62rem 0.9rem; text-align: right; border-bottom: 1px solid var(--hair); }
.results thead th { color: var(--ink-2); font-weight: 600; font-size: 0.92rem; border-bottom: 2px solid var(--ink); }
.results th[scope="row"], .results thead th:first-child { text-align: left; font-weight: 560; }
.results .best { font-weight: 760; }
.results .second { text-decoration: underline; text-underline-offset: 0.25em; }
.results tr.ours { background: var(--accent-soft); }
.results tr.ours th { color: var(--accent); font-weight: 780; font-stretch: 112%; }
.results tr.ours th, .results tr.ours td { border-bottom: 2px solid var(--accent); }

/* ---------- sequences (components, beyond 4K): figure or table on the left, the sentences on the right ---------- */

.sequence {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: center;
  margin-top: clamp(2.5rem, 6vh, 4rem);
}

.sequence-stage { display: grid; gap: 2.5rem; }
.sequence-table .table-wrap { margin-top: 0; }
.sequence-text { padding: 0; list-style: none; display: grid; gap: 1.6rem; }

/* ---------- citation and footer ---------- */

#citation .chapter-head h2 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); }
.bibtex { max-width: 60rem; margin: 1.6rem auto 0; text-align: center; }
.bibtex pre {
  margin: 0;
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  background: var(--tint);
  border-radius: 0.8rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: left;
}
.copy {
  margin-top: 1rem;
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 620;
  cursor: pointer;
}
.copy:hover { background: var(--ink); color: var(--paper); }

.footer {
  max-width: var(--wide);
  margin: clamp(5rem, 14vh, 8rem) auto 0;
  padding: 0 var(--gutter) 3rem;
  color: var(--ink-2);
  font-size: 0.92rem;
  text-align: center;
}
.footer p { padding-top: 2rem; border-top: 1px solid var(--hair); }
.footer .visitors { display: inline-block; width: auto; height: 20px; margin-left: 0.6rem; vertical-align: middle; }

/* ---------- motion layout (set by site.js on wide screens without reduced motion) ---------- */

/* One section, one screen: its content is centred in the viewport, and the page settles on section boundaries. */
.motion .scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}

/* The last screen holds the citation and the footer. */
.motion .closing .chapter { width: 100%; padding-top: 0; }
.motion .closing .footer { width: 100%; margin-top: clamp(3rem, 9vh, 5rem); padding-bottom: 0; }

.motion .spot { opacity: 1; }
.motion .story-steps { position: relative; display: block; }
.motion .story-steps li {
  position: absolute;
  inset: 0 0 auto 0;
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity 0.35s, transform 0.35s;
}
.motion .story-steps li.is-active { opacity: 1; transform: none; }

/* The first and the last comparison rest at the centre of the screen. */
.motion .gallery-track {
  flex-direction: row;
  gap: 3vw;
  width: max-content;
  max-width: none;
  margin: 0;
  padding: 0 calc((100vw - min(88vw, 92rem)) / 2);
}
.motion .gallery figure { flex: 0 0 min(88vw, 92rem); }

.motion .results th, .motion .results td { padding-top: 0.5rem; padding-bottom: 0.5rem; }

.motion .sequence-stage {
  position: relative;
  display: block;
  aspect-ratio: var(--aspect, 1400 / 1100);
  max-height: calc(100vh - 13rem);
}
.motion .sequence-item { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; }
.motion .sequence-item img { max-height: 100%; width: auto; }
.motion .sequence-table { justify-items: stretch; }
.motion .sequence-text li { opacity: 0.32; transition: opacity 0.35s; }
.motion .sequence-text li.is-active { opacity: 1; }

/* ---------- small screens ---------- */

@media (max-width: 899px) {
  .claims-body { grid-template-columns: 1fr; justify-items: center; }
  .claims-image { width: min(100%, 32rem); }
  .sequence { grid-template-columns: 1fr; }
  .stage { height: 64vh; }
  .stage-note { display: none; }
}

@media (max-width: 520px) {
  .claim-big { font-size: 1.25rem; }
  .results { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .detail.autoplay { animation: none; --split: 50%; }
  .links a, .copy, .mark, .hud { transition: none; }
}
