/* Swiss-style deck: black on white, one grotesk, oversized type, running headers. */
:root {
  --bg: #ffffff;
  --ink: #000000;
  --grey: #6e6e6e;
  --rule: #000000;
  --pad: clamp(20px, 4.4vw, 64px);
  --display: "Inter Tight", "Inter", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.9375rem;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--ink); color: var(--bg); }
a:focus-visible, button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }

/* Language switching */
html[data-lang="en"] .vi,
html[data-lang="vi"] .en { display: none; }

/* Top line, like the deck's "Presented by" strip */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 16px var(--pad);
  background: var(--bg); font-weight: 500;
}
.top nav { display: flex; gap: 24px; margin-left: auto; }
.lang { padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-weight: 500; color: var(--grey); }
.lang span + span::before { content: " / "; color: var(--grey); font-weight: 400; }
html[data-lang="en"] .lang [data-l="en"],
html[data-lang="vi"] .lang [data-l="vi"] { color: var(--ink); }

/* Slides */
.slide { padding: 0 var(--pad) clamp(96px, 13vw, 200px); scroll-margin-top: 48px; }
.run, .meta { display: flex; justify-content: space-between; gap: 24px; font-weight: 500; }
.run { padding: 28px 0 clamp(64px, 9vw, 132px); }
.meta .right { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 40px; }

/* Oversized, edge-to-edge type. Font size is set by script; the vw value is the no-JS fallback. */
.fit {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: 22vw; line-height: 1.02; letter-spacing: -0.03em; white-space: nowrap;
}
.fit > span { display: inline-block; padding: 0 0.03em 0 0.03em; }

.cover { padding-top: clamp(20px, 3vw, 44px); padding-bottom: clamp(40px, 6vw, 88px); }
.cover .meta { padding-top: 14px; border-top: 1px solid var(--ink); }
.cover .fit { margin-top: 8px; padding-top: 0.06em; animation: up 0.9s cubic-bezier(.2, .7, .2, 1) both; }
.cover .meta { animation: fade 0.8s ease 0.3s both; }
@keyframes up { from { opacity: 0; transform: translateY(0.12em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.xl {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(2.125rem, 5.4vw, 4.75rem); line-height: 1.02; letter-spacing: -0.04em;
}
.xl b { font-weight: 700; }
.small { max-width: 23rem; }
.small p + p { margin-top: 0.9em; }
.narrow { margin-top: 18px; }
.cv { font-weight: 600; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.cv:hover { text-decoration: none; opacity: 0.6; }

/* Hello */
.hello { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.75fr); gap: clamp(28px, 5vw, 80px); align-items: start; }
.photo { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; object-position: 50% 18%; border-radius: clamp(20px, 3vw, 40px); }
.hello .small { margin-top: clamp(28px, 4vw, 56px); }

/* Scattered keywords */
.cloud {
  display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(20px, 3.4vw, 52px) clamp(32px, 6vw, 96px);
  max-width: 62rem; margin: clamp(56px, 8vw, 120px) auto 0;
  font-family: var(--display); font-weight: 600; font-size: clamp(1.25rem, 2.4vw, 2rem); letter-spacing: -0.02em;
}
.cloud li:nth-child(odd) { transform: translateY(-0.5em); }
.cloud li:nth-child(3n) { transform: translateY(0.45em); }

/* Numbered index, right half of the slide */
.index { width: min(100%, 46%); margin: clamp(40px, 6vw, 88px) 0 0 auto; }
.index li > * {
  display: flex; justify-content: space-between; align-items: baseline; gap: 24px;
  padding: 26px 0 6px; border-bottom: 1px solid var(--rule);
  font-family: var(--display); font-weight: 600; font-size: clamp(1.125rem, 2vw, 1.75rem); letter-spacing: -0.02em;
}
.index i { font-style: normal; flex: none; }
.index a:hover { text-decoration: none; }
@media (hover: hover) { .index a:hover { padding-left: 12px; } }
.index a { transition: padding .2s ease; }
.index.wide { width: min(100%, 70%); }
.index.wide li > * { font-size: clamp(1rem, 1.6vw, 1.375rem); }
.index.wide li span { text-align: right; text-wrap: balance; }

/* Chapter dividers */
.dark { background: var(--ink); color: var(--bg); --rule: #ffffff; --grey: #a3a3a3; }
.dark:not(.end) { display: flex; flex-direction: column; justify-content: space-between; min-height: min(86vh, 60vw); padding-bottom: clamp(20px, 3vw, 44px); }
.dark .run { padding-bottom: 40px; }

/* Case layout: large title, figures, three columns at the foot */
.nums { display: flex; flex-wrap: wrap; gap: 24px clamp(32px, 7vw, 120px); margin-top: clamp(40px, 6vw, 88px); }
.nums b { display: block; font-family: var(--display); font-weight: 700; font-size: clamp(2.5rem, 6.5vw, 5.5rem); line-height: 1; letter-spacing: -0.05em; }
.nums span { display: block; margin-top: 8px; max-width: 13rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: clamp(24px, 5vw, 88px); margin-top: clamp(56px, 9vw, 150px); align-items: start; }
.cols h3 { font-size: inherit; font-weight: 700; }
.cols p + p { margin-top: 0.9em; }
.cols p a { font-weight: 600; border-bottom: 1px solid var(--ink); }
.cols p a:hover { text-decoration: none; opacity: 0.6; }
.cols ul li::before { content: "▸ "; }
.cols ul { white-space: nowrap; }

/* Closing slide */
.end { padding-bottom: 28px; }
.end .lead { font-family: var(--display); font-weight: 500; font-size: clamp(1.5rem, 3.4vw, 3rem); letter-spacing: -0.03em; line-height: 1.05; }
.mail { margin: clamp(40px, 7vw, 110px) 0 clamp(40px, 6vw, 88px); line-height: 1.15; letter-spacing: -0.035em; }
.mail:hover { text-decoration: none; opacity: 0.7; }
.end .meta { flex-direction: row-reverse; align-items: end; color: var(--grey); }
.end .meta a { color: var(--bg); }
.end .meta .right { justify-content: flex-end; }

/* Motion */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .cover .fit, .cover .meta, .js.ready .cover .fit { animation: none; }
}

@media (max-width: 760px) {
  .top nav { display: none; }
  .lang { margin-left: auto; }
  .meta { flex-direction: column; gap: 10px; }
  .meta .right { justify-content: flex-start; gap: 4px 20px; }
  .hello { grid-template-columns: 1fr; }
  .photo { max-width: 220px; }
  .cloud { justify-content: flex-start; gap: 14px 28px; }
  .cloud li:nth-child(n) { transform: none; }
  .index, .index.wide { width: 100%; }
  .index.wide li > * { flex-direction: column; gap: 4px; }
  .index.wide li span { text-align: left; }
  .cols { grid-template-columns: 1fr; }
  .cols ul { white-space: normal; }
  .dark:not(.end) { min-height: 62vh; }
  .end .meta { flex-direction: column; align-items: flex-start; }
}

@media print {
  .top { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---- Layout pass: scannable in a minute ---- */
.slide { padding-bottom: clamp(72px, 9vw, 140px); }
.run { padding-bottom: clamp(44px, 6vw, 88px); }
.dark:not(.end) { min-height: min(56vh, 44vw); }
.xl[id] { scroll-margin-top: 110px; }

/* Cover: the pitch and the CV sit on the first screen */
.cover { padding-bottom: clamp(48px, 6vw, 88px); }
.pitch { display: flex; justify-content: space-between; align-items: end; gap: 32px 64px; flex-wrap: wrap; margin-top: clamp(14px, 2vw, 28px); animation: fade 0.8s ease 0.45s both; }
.pitch p { max-width: 40rem; font-family: var(--display); font-weight: 500; font-size: clamp(1.25rem, 2.2vw, 1.875rem); line-height: 1.15; letter-spacing: -0.025em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-block; padding: 15px 24px; background: var(--ink); color: var(--bg); border: 1px solid var(--ink); font-weight: 600; }
.btn.line { background: none; color: var(--ink); }
.btn:hover { text-decoration: none; background: var(--bg); color: var(--ink); }
.btn.line:hover { background: var(--ink); color: var(--bg); }

/* One-minute summary */
.brief { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: clamp(28px, 5vw, 88px); align-items: start; }
.who .photo { max-width: 300px; }
.who dl { margin: 28px 0 0; }
.who dl div { padding: 10px 0; border-top: 1px solid var(--ink); }
.who dt { color: var(--grey); }
.who dd { margin: 2px 0 0; font-weight: 500; }
.nums.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px clamp(16px, 3vw, 48px); margin-top: clamp(32px, 4.5vw, 64px); }
.nums.four b { font-size: clamp(2.25rem, 4.6vw, 4rem); }
.index.full { width: 100%; margin-top: clamp(20px, 3vw, 40px); }
.index.full li > * { padding-top: 18px; font-size: clamp(1rem, 1.5vw, 1.3125rem); }
.index.full li span { text-align: right; }

/* Logo marquee: two identical lists slide left by exactly one list width */
.marquee {
  display: flex; overflow: hidden; margin: clamp(40px, 6vw, 88px) calc(var(--pad) * -1) 0;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
}
.marquee ul { display: flex; flex: none; align-items: center; animation: slide 32s linear infinite; }
.marquee:hover ul { animation-play-state: paused; }
.marquee li {
  display: flex; align-items: center; gap: 16px; padding: clamp(22px, 3vw, 40px) clamp(28px, 4vw, 60px);
  font-family: var(--display); font-weight: 600; font-size: clamp(1.25rem, 2.4vw, 2rem); letter-spacing: -0.02em; white-space: nowrap;
}
.marquee img { width: clamp(30px, 3.4vw, 46px); height: auto; display: block; }
@keyframes slide { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .pitch { animation: none; }
  .marquee { flex-wrap: wrap; overflow: visible; }
  .marquee ul { animation: none; flex-wrap: wrap; }
  .marquee ul[aria-hidden] { display: none; }
}

@media (max-width: 760px) {
  .brief { grid-template-columns: 1fr; }
  .who .photo { max-width: 160px; }
  .nums.four { grid-template-columns: 1fr 1fr; }
  .index.full li > * { flex-direction: row; }
  .index.full li span { text-align: right; }
  .dark:not(.end) { min-height: 44vh; }
  .btn { padding: 13px 18px; }
}

/* Evidence rows under the tool logos */
.index.use { max-width: 62rem; margin-left: 0; }
.index.use li > * { justify-content: flex-start; gap: clamp(20px, 5vw, 72px); }
.index.use i { width: 5.5em; }
.index.use li span { text-align: left; }
.nums.four b { font-size: clamp(2rem, 4.2vw, 3.75rem); }

/* ---- Timeline rail: a fixed column on the right, a scrolling strip on small screens ---- */
.rail { --p: 0; font-weight: 500; }
.rail-title { color: var(--grey); margin-bottom: 18px; }
.rail a { display: block; color: var(--grey); transition: color .15s; }
.rail a:hover { color: var(--ink); text-decoration: none; }
.rail a.on { color: var(--ink); font-weight: 600; }
.rail a.past { color: var(--ink); }
.rail i { font-style: normal; margin-right: 8px; }

@media (min-width: 1100px) {
  body { padding-right: 216px; }
  .rail {
    position: fixed; top: 0; right: 0; bottom: 0; width: 216px; z-index: 20;
    display: flex; flex-direction: column; justify-content: center;
    padding: 24px 20px 24px 30px; background: var(--bg); border-left: 1px solid var(--ink);
  }
  .rail ol { position: relative; padding-left: 20px; }
  /* the line, and its filled part */
  .rail ol::before, .rail ol::after { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 1px; background: #cfcfcf; }
  .rail ol::after { background: var(--ink); width: 2px; left: -0.5px; transform-origin: top; transform: scaleY(var(--p)); }
  .rail li { position: relative; padding: 7px 0; }
  .rail li.sub { padding: 4px 0 4px 14px; font-size: 0.8125rem; }
  .rail a::before {
    content: ""; position: absolute; left: -24px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px;
    border-radius: 50%; background: var(--bg); border: 1px solid #9a9a9a; z-index: 1; transition: transform .15s, background .15s;
  }
  .rail li.sub a::before { left: -22px; width: 5px; height: 5px; margin-top: -2.5px; }
  .rail a.past::before { background: var(--ink); border-color: var(--ink); }
  .rail a.on::before { background: var(--ink); border-color: var(--ink); transform: scale(1.5); }
}

@media (max-width: 1099.98px) {
  .top { height: 50px; padding-top: 0; padding-bottom: 0; }
  .lang { margin-left: auto; }
  .rail {
    position: sticky; top: 50px; z-index: 9; background: var(--bg);
    border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
    overflow-x: auto; scrollbar-width: none; white-space: nowrap;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-title, .rail li.sub { display: none; }
  .rail ol { display: flex; gap: 22px; padding: 11px var(--pad); width: max-content; }
  .rail a.on { border-bottom: 2px solid var(--ink); padding-bottom: 2px; }
  .slide, .xl[id] { scroll-margin-top: 104px; }
}
@media print { .rail { display: none; } body { padding-right: 0; } }

.top .lang { margin-left: auto; }

/* ---- Polish pass: loading states, touch, every screen size ---- */
:root {
  --skel: linear-gradient(100deg, #ececec 40%, #f7f7f7 50%, #ececec 60%) 0 0 / 200% 100%;
  --pl: max(var(--pad), env(safe-area-inset-left, 0px));
  --pr: max(var(--pad), env(safe-area-inset-right, 0px));
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Notched phones held sideways keep their gutters */
.top, .slide { padding-left: var(--pl); padding-right: var(--pr); }
.marquee { margin-left: calc(var(--pl) * -1); margin-right: calc(var(--pr) * -1); }
.end { padding-bottom: max(28px, env(safe-area-inset-bottom, 0px)); }

/* Very wide screens: the text column stops growing, backgrounds still run edge to edge */
@media (min-width: 1900px) { :root { --pad: calc((100vw - 216px - 1560px) / 2); } }

/* Type that breaks well at any width */
.xl, .pitch p, .end .lead { text-wrap: balance; overflow-wrap: break-word; }
.cols p, .who dd, .nums span, .small { text-wrap: pretty; }
.cols p { max-width: 38rem; }

/* Skip link for keyboard users */
.skip { position: absolute; left: var(--pl); top: -60px; z-index: 30; padding: 12px 16px; background: var(--ink); color: var(--bg); font-weight: 600; }
.skip:focus { top: 8px; }

/* Cover name: a skeleton bar until the fonts arrive, then it rises in at its final size */
.js .cover .fit { animation: none; }
.js:not(.ready) .cover .fit { color: transparent; }
.js:not(.ready) .cover .fit > span { border-radius: 0.06em; background: var(--skel); animation: shimmer 1.3s linear infinite; }
.js.ready .cover .fit { animation: up 0.9s cubic-bezier(.2, .7, .2, 1) both; }

/* Photo: a shimmer placeholder of the same shape until the image is in */
.photo { background: var(--skel); animation: shimmer 1.3s linear infinite; }
.photo.loaded { background: none; animation: none; }

/* Buttons and links give feedback and are easy to hit with a thumb */
.btn { transition: background .15s, color .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.lang { min-height: 44px; padding: 0 6px; margin-right: -6px; }
@media (hover: none) {
  .btn:hover { background: var(--ink); color: var(--bg); }
  .btn.line:hover { background: none; color: var(--ink); }
}

/* Proof: text buttons that open the image in a dialog, nothing shown inline */
.proofs { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 0.3em; }
.proof {
  padding: 11px 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.proof::after { content: " \2197\FE0E"; }
.proof:hover { opacity: 0.6; }
.modal { overflow: hidden; }
.viewer {
  width: min(94vw, 980px); max-width: none; max-height: 92vh; max-height: 92dvh; padding: 14px;
  border: 1px solid var(--ink); background: var(--bg); color: var(--ink); overflow: auto; overscroll-behavior: contain;
}
.viewer[open] { animation: fade .2s ease both; }
.viewer::backdrop { background: rgba(0, 0, 0, 0.72); }
.viewer form { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.viewer .close { border: 1px solid var(--ink); background: var(--ink); color: var(--bg); width: 44px; height: 44px; font: inherit; cursor: pointer; }
/* the frame takes the image's shape before the image exists, so nothing jumps */
.viewer .frame { --r: 1.5; width: 100%; width: min(100%, calc((92dvh - 190px) * var(--r))); aspect-ratio: var(--r); margin: 0 auto; }
.viewer.loading .frame { background: var(--skel); animation: shimmer 1.3s linear infinite; }
.viewer.failed .frame { display: none; }
.viewer img { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity .25s ease; }
.viewer.done img { opacity: 1; }
.viewer .state { margin-top: 12px; font-weight: 500; }
.viewer .state:empty { display: none; }
.viewer .foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; margin-top: 12px; }
.viewer .foot p { color: var(--grey); }
.viewer .full { font-weight: 600; text-decoration: underline; text-underline-offset: 4px; white-space: nowrap; }

/* Desktop rail on a short window: scroll inside the rail instead of clipping */
@media (min-width: 1100px) {
  .rail { justify-content: safe center; overflow-y: auto; }
}

/* Tablets and small laptops */
@media (min-width: 760.02px) and (max-width: 1099.98px) {
  .brief { grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr); }
  .nums.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
  .cols ul { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 24px; white-space: normal; }
}

/* Phones and tablets: the strip is thumb-sized and shows that it scrolls */
@media (max-width: 1099.98px) {
  .rail { scroll-behavior: smooth; }
  .rail ol { padding: 0 var(--pr) 0 var(--pl); gap: 22px; }
  .rail a { padding: 12px 0; }
  .rail a.on { border-bottom: 0; padding-bottom: 12px; box-shadow: inset 0 -2px var(--ink); }
}
@media (max-width: 760px) {
  .slide { padding-bottom: 64px; }
  .cols { gap: 22px; margin-top: 40px; }
  .cols ul { display: flex; flex-wrap: wrap; gap: 4px 20px; }
  .nums { gap: 20px 32px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; text-align: center; }
  .index.full li > * { gap: 16px; }
  .index.use li > * { flex-direction: column; gap: 2px; }
  .index.use i { width: auto; color: var(--grey); font-size: 0.875rem; }
  .viewer { width: 100vw; max-height: 100vh; max-height: 100dvh; border-left: 0; border-right: 0; padding: 12px max(12px, env(safe-area-inset-right, 0px)) 16px max(12px, env(safe-area-inset-left, 0px)); }
}
/* Running headers never break mid-label; big titles leave room for the rail */
.run { gap: 12px; }
.run > span { white-space: nowrap; }
@media (min-width: 1100px) { .xl { font-size: clamp(2.125rem, 4.6vw, 4.75rem); } }
@media (max-width: 760px) { .end .meta .right { justify-content: flex-start; } .end .meta a { padding: 6px 0; } }
/* Company and university logos: a quiet row in the summary, a small mark above each case title */
.brands { display: flex; flex-wrap: wrap; align-items: center; gap: 18px clamp(24px, 4vw, 52px); margin-top: clamp(28px, 4vw, 52px); }
.brands a { display: block; padding: 6px 0; }
.brands a:hover { opacity: 0.6; }
.brands img, .mark { display: block; width: auto; height: clamp(24px, 2.4vw, 32px); }
.brands img.wide, .mark.wide { height: clamp(36px, 3.2vw, 44px); }
.mark { margin-bottom: clamp(18px, 2.4vw, 32px); height: clamp(28px, 2.8vw, 38px); }
.mark.wide { height: clamp(34px, 3.4vw, 46px); }
/* Small phones */
@media (max-width: 380px) {
  .nums.four { gap: 18px 14px; }
  .index.full li > * { font-size: 0.9375rem; }
}
/* Phones held sideways: the two bars stop sticking so the content keeps the screen */
@media (max-width: 1099.98px) and (max-height: 520px) {
  .top, .rail { position: static; }
  .slide, .xl[id] { scroll-margin-top: 12px; }
  .dark:not(.end) { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .photo, .viewer.loading .frame, .js:not(.ready) .cover .fit > span { animation: none; }
  .viewer[open], .viewer img { animation: none; transition: none; }
  .rail { scroll-behavior: auto; }
  .btn:active { transform: none; }
}
@media print {
  .skip, .viewer, .proofs, .actions { display: none; }
  .slide { break-inside: avoid; }
  .marquee ul { animation: none; }
  .marquee ul[aria-hidden] { display: none; }
}
@media (max-width: 380px) { .run { font-size: 0.8125rem; } }

/* ---- Final pass: fixes from the ten-reviewer check ---- */
/* keyboard focus and anchor jumps clear the sticky bars */
html { scroll-padding-top: 60px; }
.mark + .xl[id] { scroll-margin-top: 190px; }
@media (max-width: 1099.98px) {
  html { scroll-padding-top: 104px; }
  .mark + .xl[id] { scroll-margin-top: 170px; }
}
@media (max-width: 1099.98px) and (max-height: 520px) {
  html { scroll-padding-top: 12px; }
  .mark + .xl[id] { scroll-margin-top: 80px; }
}
.rail a:focus-visible { outline-offset: -2px; }

/* figures: language spans inside a number are part of the number, not a caption */
.nums b span { display: inline; margin: 0; max-width: none; }
.nums.four { align-items: start; }
@media (min-width: 1100px) and (max-width: 1499.98px) {
  .nums.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* education has three text columns, no keyword list */
@media (min-width: 1100px) {
  #education .cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* logo strip fills very wide screens and can be paused */
.marquee ul { min-width: 100%; justify-content: space-around; }
.marquee.paused ul { animation-play-state: paused; }
.pause { margin-top: 10px; padding: 10px 0; border: 0; background: none; color: var(--grey); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.pause:hover { color: var(--ink); }
.pause[aria-pressed="true"] { color: var(--ink); }

/* logos of different shapes look the same size */
.brands img[src*="hyperpulse"], .mark[src*="hyperpulse"] { height: clamp(30px, 3vw, 40px); }
.brands img.wide { height: clamp(44px, 4vw, 56px); }

/* headings wrap by balance on phones instead of fixed breaks; the top bar never wraps */
@media (max-width: 760px) { .xl br { display: none; } }
.top > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang { flex: none; white-space: nowrap; }
.index.full li span { text-wrap: balance; }

@media (prefers-reduced-motion: reduce) {
  .js.ready .cover .fit { animation: none; }
  .marquee ul { min-width: 0; }
}
@media print { .pause { display: none; } }

/* ---- Rail line: starts at the first dot, ends at the last, fills up to where the reader is ---- */
@media (min-width: 1100px) {
  .rail ol { --start: 6px; --end: 6px; --fill: 0px; }
  .rail ol::before { top: var(--start); bottom: var(--end); background: #d9d9d9; }
  .rail ol::after {
    top: var(--start); bottom: auto; left: -0.5px; width: 2px; height: var(--fill);
    transform: none; background: var(--ink); transition: height .18s linear;
  }
  .rail a::before { transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease; }
  .rail a.past::before { background: var(--ink); border-color: var(--ink); }
  .rail a.on::before { transform: scale(1.35); box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--ink); }
  .rail li.sub a.on::before { transform: scale(1.6); box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--ink); }
  .rail a { transition: color .2s ease; }
}
@media (prefers-reduced-motion: reduce) { .rail ol::after, .rail a::before { transition: none; } }
/* arrows stay text glyphs on phones instead of turning into emoji */
a, button, .proof::after { font-variant-emoji: text; }

/* ---- Top line: slimmer, and out of the way while reading down ---- */
.top { transition: transform .25s ease; }
@media (min-width: 1100px) { .top { padding-top: 10px; padding-bottom: 10px; } }
.bar-hidden .top { transform: translateY(-100%); }
.bar-hidden .top:focus-within { transform: none; }
@media (max-width: 1099.98px) {
  .rail { transition: top .25s ease; }
  .bar-hidden .rail { top: 0; }
}
@media (prefers-reduced-motion: reduce) { .top, .rail { transition: none; } }

/* ---- Bottom fade: what has not been scrolled to yet dissolves at the foot of the screen ---- */
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  height: clamp(64px, 14vh, 130px); pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.92));
  transition: opacity .25s ease;
}
@media (min-width: 1100px) { body::after { right: 216px; } }
.fade-dark body::after { background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.92)); }
.fade-off body::after { opacity: 0; }
html:not(.js) body::after { display: none; }
@media print { body::after { display: none; } }

/* ---- One slide, one screen: on desktop a case fits the window after a jump from the contents ---- */
@media (min-width: 1100px) {
  .slide { padding-bottom: clamp(48px, 9vh, 104px); }
  .run { padding-top: 22px; padding-bottom: clamp(20px, 4.5vh, 52px); }
  .xl { font-size: clamp(2rem, min(4vw, 8.4vh), 4.5rem); }
  .nums { margin-top: clamp(20px, 4vh, 44px); }
  .nums b { font-size: clamp(2.25rem, min(5vw, 9vh), 4.75rem); }
  .cols { margin-top: clamp(24px, 5vh, 56px); }
  .mark { margin-bottom: clamp(12px, 2vh, 22px); }
  .index { margin-top: clamp(24px, 5vh, 56px); }
  .marquee { margin-top: clamp(24px, 5vh, 56px); }
  .xl[id] { scroll-margin-top: calc(22px + 1.4em * 0.2 + clamp(20px, 4.5vh, 52px) + 28px); }
  .mark + .xl[id] { scroll-margin-top: calc(50px + clamp(20px, 4.5vh, 52px) + clamp(28px, 2.8vw, 38px) + clamp(12px, 2vh, 22px)); }
}

/* Gentle motion for the awards and tools rows only. */
.soft-rows > li { --row-delay: 0ms; }
.soft-rows > li:nth-child(2) { --row-delay: 65ms; }
.soft-rows > li:nth-child(3) { --row-delay: 130ms; }
.soft-rows > li:nth-child(4) { --row-delay: 195ms; }
.js .soft-rows > li {
  opacity: 0; transform: translateY(8px);
  transition: opacity 600ms ease var(--row-delay), transform 600ms cubic-bezier(.2,.7,.2,1) var(--row-delay);
}
.js .soft-rows > li.in { opacity: 1; transform: none; }
.soft-rows li > div {
  border-bottom-color: #b8b8b8;
  transition: background-color 280ms ease, border-color 280ms ease;
}
@media (hover: hover) {
  .soft-rows li:hover > div { background-color: #f5f5f3; border-bottom-color: #777; }
}
@media (prefers-reduced-motion: reduce), print {
  .js .soft-rows > li { opacity: 1; transform: none; transition: none; }
  .soft-rows li > div { transition: none; }
}

/* Hallmark ? alignment pass ? existing Swiss editorial layout retained
 * pre-emit critique: P4 H4 E4 S5 R5 V3 */
:root {
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --color-soft-rule: oklch(80% 0 0);
}
html, body { overflow-x: clip; }
.xl { min-width: 0; overflow-wrap: anywhere; }
.cols > * { min-width: 0; }
.cols h3 { margin-bottom: var(--space-sm); }
.cols p { max-width: none; line-height: 1.5; }
.cols ul { white-space: normal; }
.index.soft-rows { width: 100%; max-width: none; margin-left: 0; }
.index.soft-rows li > div {
  display: grid; grid-template-columns: 7rem minmax(0, 1fr);
  gap: var(--space-lg); align-items: baseline;
  padding: var(--space-md) 0;
}
.index.soft-rows li > div > span { text-align: left; text-wrap: pretty; }
.index.soft-rows i { width: auto; font-variant-numeric: tabular-nums; }
.index.full:not(.soft-rows) li > a { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--space-md); }
.index.full:not(.soft-rows) li > a > span { text-align: left; }
.customer-case { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 1px solid var(--color-soft-rule); }
.small.narrow { max-width: 42rem; line-height: 1.5; }
@media (min-width: 760.02px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-xl); }
  .cols > ul { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); }
  .cols p { text-align: justify; }
  #education .cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nums:not(.four) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-lg); }
  .nums:not(.four) span { max-width: 18rem; }
}
@media (max-width: 760px) {
  .cols { gap: var(--space-lg); }
  .index.soft-rows li > div { grid-template-columns: 1fr; gap: var(--space-sm); }
  .index.soft-rows i { color: var(--grey); font-size: 0.9375rem; }
  .small.narrow { max-width: none; }
  .btn, .rail a { white-space: nowrap; }
}

/* Company names and positions stay on separate lines at every width. */
.case-title .case-brand, .case-title .case-position { display: block; }
.case-title .case-position { margin-top: var(--space-md); font-size: 0.52em; line-height: 1.25; letter-spacing: -0.02em; }
.nums.research-metric { display: block; }
.nums.research-metric span { max-width: 24rem; }

/* Restore the research section's original three-column desktop layout. */
@media (min-width: 1100px) {
  #paper ~ .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: clamp(24px, 4vw, 64px); }
  #paper ~ .cols > ul { grid-column: auto; display: block; }
  #paper ~ .cols > ul li + li { margin-top: 4px; }
}
