/* ==========================================================================
   iWAM project page — clean white academic theme
   (animation widgets: anim.css)
   ========================================================================== */

/* Inter (latin, variable), self-hosted so first paint never waits on a third-party font server.
   One file serves every weight; the five faces mirror Google Fonts (650 renders as 700, 750 as 800).
   Inter © The Inter Project Authors, SIL Open Font License 1.1 (https://openfontlicense.org). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/inter-latin.woff2") format("woff2"); }

:root {
  --bg: #ffffff;
  --bg-light: #f8f9fa;
  --text: #1a1a2e;
  --text-2: #4a4a6a;
  --muted: #6b6b84;           /* captions and notes: lighter than --text-2, 5:1 on white */
  --border: #e5e7eb;
  --link: #2563eb;

  --accent: #a3214f;          /* iWAM crimson (matches the paper's figures) */
  --accent-dark: #861a40;
  --accent-soft: #fbeef3;
  --success: #16a34a;         /* card borders */
  --success-ink: #15803d;     /* green text and badges, 5:1 on white */
  --failure: #dc2626;
  --failure-ink: #c81e1e;     /* red text on the light-red caption bar, 5:1 */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, .10);

  --container: 1100px;
  --text-width: 800px;
  --media-width: 960px;
  --nav-h: 52px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", Consolas, Menlo, monospace;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 8px); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #f5d3df; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

.brand { color: var(--accent); font-weight: 800; letter-spacing: -0.02em; }
.brand i { font-family: Georgia, "Times New Roman", serif; font-weight: 700; padding-right: .03em; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: 8px; background: var(--text); color: #fff; }
.skip-link:focus { top: 12px; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }

/* ---------------------------------------------------------------- Hero */

.hero { padding: 56px 24px 44px; text-align: center; }

.hero-title { margin: 0 auto 18px; max-width: 900px; line-height: 1.2; }
.hero-title .brand { display: block; margin-bottom: 10px; font-size: clamp(2.6rem, 6vw, 3.6rem); line-height: 1; }
.hero-subtitle { display: block; font-size: clamp(1.4rem, 3.2vw, 2.1rem); font-weight: 800; letter-spacing: -0.015em; color: var(--text); text-wrap: balance; }

.hero-authors {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px;
  max-width: 820px; margin: 0 auto 10px;
  font-size: 1.05rem; color: var(--text-2);
}
.hero-authors .author { white-space: nowrap; }
.hero-authors a { color: inherit; }
.hero-affiliations { margin: 0 0 20px; font-size: .92rem; color: var(--muted); }

.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 30px; }
.hero-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 18px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text);
  font-size: .92rem; font-weight: 600;
  transition: border-color .2s, color .2s, background-color .2s;
}
.hero-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.hero-link-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.hero-link-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.hero-link .icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Not public yet (`soon: true` in index.md): a greyed, non-clickable pill. */
.hero-link.is-soon { background: var(--bg-light); border-style: dashed; color: var(--muted); cursor: default; }
.hero-link.is-soon:hover { border-color: var(--border); color: var(--muted); }
.hero-link.is-soon small { font-size: .74rem; font-weight: 600; letter-spacing: .01em; }

.hero-videos {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px;
  max-width: 1040px; margin: 0 auto;
  text-align: left;
}
.hero-video { margin: 0; }
.hero-video .video-frame { border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.hero-video figcaption { margin-top: 10px; font-size: .88rem; line-height: 1.45; color: var(--text-2); }
.hero-video figcaption strong { color: var(--text); font-weight: 700; }
.hero-video figcaption span { font-style: italic; }

.hero-dots { display: none; }
.hero-dot { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 999px; background: #d1d5db; cursor: pointer; transition: width .2s, background-color .2s; }
.hero-dot.active { width: 22px; background: var(--accent); }

.hero-tagline {
  max-width: 800px; margin: 30px auto 0; padding: 16px 22px;
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accent-soft);
  font-size: 1.08rem; line-height: 1.6; text-align: left; color: var(--text-2); text-wrap: pretty;
}
.hero-links + .hero-tagline { margin-top: 0; }
.hero-tagline p { margin: 0; }
.hero-tagline strong { color: var(--accent); letter-spacing: .04em; font-size: .86em; margin-right: 4px; }

/* ------------------------------------------------------- Sticky top nav */

.topnav {
  position: sticky; top: 0; z-index: 30;
  height: var(--nav-h);
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  display: flex; align-items: center; gap: 24px;
  max-width: var(--container); height: 100%; margin: 0 auto; padding: 0 24px;
}
.topnav-brand { flex: none; font-size: 1.15rem; color: var(--accent); font-weight: 800; letter-spacing: -0.02em; }
.topnav-brand:hover { text-decoration: none; }
.topnav-brand i { font-family: Georgia, "Times New Roman", serif; }
.topnav-links {
  display: flex; gap: 4px; align-items: center;
  margin: 0 0 0 auto; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.topnav-links::-webkit-scrollbar { display: none; }
.topnav-links a {
  display: block; padding: 6px 12px; border-radius: 999px;
  font-size: .88rem; font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: color .2s, background-color .2s;
}
.topnav-links a:hover { color: var(--text); background: var(--bg-light); text-decoration: none; }
.topnav-links a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* The link row scrolls sideways, which would clip an outside focus ring: draw it inside the pill. */
.topnav-links a:focus-visible { outline-offset: -2px; border-radius: 999px; }

/* ------------------------------------------------------------ Sections */

.section { padding: 72px 0; }
.section-alt { background: var(--bg-light); }
.section-title {
  max-width: 860px; margin: 0 auto 14px;
  font-size: 1.8rem; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em;
  text-align: center; color: var(--text); text-wrap: balance;
}


.section-body > p, .section-body > ul, .section-body > ol, .section-body > h3, .section-body > h4 {
  max-width: var(--text-width); margin-left: auto; margin-right: auto;
}
.section-body > p { margin-top: 0; margin-bottom: 18px; font-size: 1.02rem; line-height: 1.8; color: var(--text-2); }
.section-body strong { color: var(--text); font-weight: 650; }
.section-body > p.lead, .section-body > .lead { max-width: 740px; margin: 0 auto 36px; font-size: 1.08rem; text-align: center; text-wrap: pretty; }
.section-body > h3 { margin-top: 56px; margin-bottom: 10px; font-size: 1.3rem; font-weight: 750; text-align: center; color: var(--text); }
.section-body > h3 + p { text-align: center; max-width: 740px; text-wrap: pretty; }
/* Method: one row per requirement, its statement on the left and its animation on the right (stacked on phones).
   Compact, so both rows fit one screen. */
.req-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 24px; align-items: center; max-width: 960px; margin: 14px auto; }
.req-row.req-row-text { grid-template-columns: minmax(0, 1fr); margin-top: 28px; margin-bottom: 28px; }
.req-row-text .req-text { max-width: 740px; }
.section-method .lead { margin-bottom: 18px !important; }
.req-text .req { display: block; margin-bottom: 4px; font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.req-text h3 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 750; line-height: 1.25; letter-spacing: -0.01em; color: var(--text); }
.req-text p { margin: 0; font-size: 1rem; line-height: 1.65; color: var(--text-2); text-wrap: pretty; }
.req-row .anim { width: 100%; max-width: 520px; justify-self: center; margin: 0; padding: 6px 10px; }
.req-row .anim-head { display: flex; padding: 8px 4px 0; }
.req-row .anim-captions { display: none; }
.method-animation-note { margin: 4px 4px 8px; font-size: .8rem; line-height: 1.5; color: var(--muted); text-align: center; }
/* The pause button sits inside the picture's bottom-right corner; each diagram leaves that corner empty, not in a row of its own. */
.req-row .anim-controls { position: absolute; right: 10px; bottom: 10px; margin: 0; }
.req-row + .tabs { margin-top: 28px; }
/* The round-trip clips under the requirements: a compact strip. */
#roundtrip { max-width: 620px; }
#roundtrip .video-columns, #roundtrip figcaption { font-size: .8rem; }
/* The training / inference tabs are picked by the reader: no autoplay progress bar on them. */
#anim-pipeline .anim-pill-bar { display: none; }
#anim-pipeline .anim-controls { justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
#anim-pipeline .anim-methods { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#anim-pipeline .anim-pill { box-sizing: border-box; min-height: 40px; margin: 0; }
#anim-pipeline .anim-play { margin-left: auto; }
.training-inference { max-width: 860px; margin: 20px auto 28px; }
.training-inference > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 20px; align-items: baseline; }
.training-inference > div + div { margin-top: 20px; }
.training-inference dt { font-weight: 700; color: var(--text); }
.training-inference dd { margin: 0; font-size: 1.02rem; line-height: 1.7; color: var(--text-2); text-align: left; }
.section-body > :first-child { margin-top: 0; }
.section-body > :last-child { margin-bottom: 0; }
/* A section that opens straight on a card (Results, Citation) gets the same air as one that opens on text. */
.section-body > .chart-card:first-child, .section-body > .citation-box:first-child { margin-top: 24px; }

.full-abstract { max-width: var(--text-width); margin: 4px auto 0; text-align: center; }
.full-abstract > summary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text-2); font-size: .88rem; font-weight: 600;
  cursor: pointer; list-style: none; transition: border-color .2s, color .2s;
}
.full-abstract > summary::-webkit-details-marker { display: none; }
.full-abstract > summary::after { content: "+"; font-weight: 700; }
.full-abstract[open] > summary::after { content: "−"; }
.full-abstract > summary:hover { border-color: var(--accent); color: var(--accent); }
.full-abstract > p { margin: 18px 0 0; text-align: left; font-size: .98rem; line-height: 1.8; color: var(--text-2); }

/* ------------------------------------------------------------- Figures */

.figure { max-width: var(--media-width); margin: 0 auto 36px; text-align: center; }
.figure-media { display: block; cursor: zoom-in; }
.figure img { width: 100%; margin: 0 auto; border-radius: 8px; }
.figure figcaption, .video figcaption {
  max-width: 760px; margin: 12px auto 0;
  font-size: .88rem; line-height: 1.55; color: var(--muted); text-align: center;
}
.figure figcaption strong, .video figcaption strong { color: var(--text-2); }

/* -------------------------------------------------------------- Videos */

.video { max-width: var(--media-width); margin: 0 auto 36px; }
.video .video-frame { background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.video .video-frame video { background: #fff; }
.video-columns { display: grid; gap: 8px; margin: 0 auto 8px; text-align: center; font-size: .9rem; font-weight: 650; color: var(--text); }
.video-columns .col-ok { color: var(--success-ink); }
.video-columns .col-bad { color: var(--failure); }
.video-frame { position: relative; overflow: hidden; border-radius: 10px; background: #0b0d10; }
.video-frame video { width: 100%; height: auto; background: #0b0d10; }
/* A frame with a set aspect ratio keeps its shape before the clip's size is known (poster only). */
.video-frame[style*="aspect-ratio"] > video { position: absolute; inset: 0; height: 100%; object-fit: contain; }
/* .video-frame clips its overflow, so a keyboard focus ring on a video is drawn inside it. */
.video-frame video:focus-visible { outline: 2px solid var(--link); outline-offset: -3px; border-radius: inherit; }
.video-badge {
  position: absolute; top: 8px; right: 8px;
  padding: 1px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: .72rem; font-weight: 600; pointer-events: none;
}

/* Pause / play / replay button that main.js adds to videos without browser controls
   (bottom-right, with a visible label and a larger touch target). */
/* Icon-only, the same round button as on the animations (.anim-play). */
.video-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: var(--text-2);
  cursor: pointer; opacity: 1; transition: border-color .2s, color .2s;
}
.video-toggle:hover { border-color: var(--accent); color: var(--accent); }
.video-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.video-control-label { display: none; }
.video-toggle svg { width: 14px; height: 14px; fill: currentColor; }
.video-toggle .i-play, .video-toggle.is-paused .i-pause { display: none; }
.video-toggle.is-paused .i-play { display: block; }
.video-frame:hover .video-toggle, .video-toggle:focus-visible, .video-toggle.is-user-paused { opacity: 1; }
@media (hover: none) { .video-toggle { opacity: .85; } }
.video-end-state { position: absolute; top: 10px; left: 10px; z-index: 2; padding: 7px 10px; border-radius: 6px; background: rgba(20, 22, 32, .85); color: #fff; font-size: .875rem; font-weight: 600; pointer-events: none; }
.video-end-state[hidden] { display: none; }

/* Video cards, as on BPP: the clip on top, a slim tinted caption bar below; border, caption and badge are green for
   a success and red for a failure. Shared by the Problem cards (video-cards.html) and the comparison rows
   (compare-rows.html). */
.video-cards {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
  margin: 0 auto 36px;
}
.video-card {
  display: flex; flex-direction: column;
  margin: 0; overflow: hidden;
  border: 2px solid var(--border); border-radius: 10px; background: #fff;
  transition: transform .2s ease;
}
.video-card:hover { transform: translateY(-3px); }
.video-card.is-success { border-color: var(--success); }
.video-card.is-failure { border-color: var(--failure); }
.video-card .video-frame { border-radius: 0; }
.video-card video { aspect-ratio: 16 / 9; object-fit: cover; }
.video-card figcaption { flex: 1; padding: 8px 12px; text-align: center; color: var(--text); }
.video-card.is-success figcaption { background: #f0fdf4; color: var(--success-ink); }
.video-card.is-failure figcaption { background: #fef2f2; color: var(--failure-ink); }
.card-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-size: .85rem; font-weight: 600; }
.card-caption { display: block; margin-top: 2px; font-size: .82rem; line-height: 1.45; color: var(--text-2); }
.status { padding: 2px 6px; border-radius: 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--muted); }
.status-success { background: var(--success-ink); }
.status-failure { background: var(--failure); }

/* iWAM vs. FastWAM (compare-rows.html), laid out like BPP's comparisons: per task, a heading with a blue bar and
   one row of equal-width cards. Two columns while a card is at least 250px wide, then stacked; a card is never
   wider than the 640px clips. */
/* "Real robot | Simulation" buttons under the lead (the charts' view buttons): one setting is shown at a time.
   Without JavaScript there is no switch, and every setting is shown, each under its name. */
.view-switch { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: -12px 0 32px; }
.compare-set-name { display: none; }
html:not(.js) .view-switch { display: none; }
html:not(.js) .compare-set[hidden] { display: block; margin-top: 56px; }
html:not(.js) .compare-set-name { display: block; margin: 0 0 20px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: center; color: var(--muted); }
/* Compact: each task block is at most ~700px wide (two ~340px cards), so all three tasks fit about one screen. */
.compare-task { max-width: 700px; margin: 0 auto 30px; }
.compare-task:last-child { margin-bottom: 0; }
/* Task name, then the instruction; on narrow screens the instruction moves under the name as a whole. */
.compare-title {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px;
  margin: 0 0 12px; padding-left: 12px;
  border-left: 4px solid var(--link);
  font-size: 1.08rem; font-weight: 700; line-height: 1.6; color: var(--text);
}
.compare-instruction { font-size: .9rem; font-weight: 400; font-style: italic; line-height: 1.5; color: var(--muted); }
.compare-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 14px; }
.compare-row > .video-card { width: 100%; max-width: 640px; justify-self: center; }

/* One selected imagination example, with camera columns and rollout/future rows. */
.imagine-viewer { margin: 0 auto; }
.imagine-viewer .showcase-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.imagine-panel[hidden] { display: none; }
.imagine-panel { max-width: 812px; margin: 24px auto 0; overflow-x: auto; padding-bottom: 8px; }
html:not(.js) .imagine-panel[hidden] { display: block; margin-top: 28px; }
.imagine { --row-label-width: 110px; --comparison-gap: 16px; width: calc(var(--imagine-video-width) + var(--row-label-width) + var(--comparison-gap) + 42px); margin: 0; padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.imagine-cameras { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 10px calc(var(--row-label-width) + var(--comparison-gap)); text-align: center; font-size: .875rem; font-weight: 600; color: var(--muted); }
.imagine-comparison { display: grid; grid-template-columns: var(--row-label-width) var(--imagine-video-width); gap: var(--comparison-gap); align-items: stretch; }
.imagine-row-labels { display: grid; grid-template-rows: 1fr 1fr; font-size: .9375rem; font-weight: 600; color: var(--text); }
.imagine-row-labels span { display: flex; align-items: center; padding-right: 10px; }
.imagine-row-labels span:last-child { color: var(--accent); }
.imagine .video-frame { border-radius: 8px; }
.imagine .video-end-state { top: auto; bottom: 10px; }
.imagine-tag {
  display: none;
  position: absolute; left: 8px;
  padding: 1px 7px; border-radius: 4px;
  background: rgba(0, 0, 0, .6); color: #fff;
  font-size: .875rem; font-weight: 500; line-height: 1.6; pointer-events: none;
}
.imagine-tag.is-top { top: 8px; }
.imagine-tag.is-bottom { top: calc(50.62% + 8px); }   /* the bottom row starts at pixel row 164 of 324 */

/* --------------------------------------- Overview: chart + takeaways */

/* The success-vs-latency plot on the left, the takeaways beside it; stacked below 900px. */
.overview { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 28px; align-items: stretch; margin: 28px 0; }
.overview-chart { display: flex; }
.overview-chart .chart-card { display: flex; flex-direction: column; width: 100%; max-width: none; margin: 0; padding: 20px 16px 14px; }
.overview-chart .chart-canvas { flex: 1; min-height: 320px; aspect-ratio: auto; }
.overview-chart .chart-note { font-size: .78rem; }
.takeaways { display: grid; gap: 16px; }
/* With an animation beside the chart, the takeaways sit in a row below both. */
.overview.has-anim { margin-bottom: 18px; }
.overview-anim { display: flex; }
.overview-anim .anim { position: relative; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: none; margin: 0; padding: 14px 14px 10px; }
.overview-anim .anim-controls { position: absolute; right: 10px; bottom: 10px; margin: 0; }
.takeaways-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 28px; }
.takeaway-card { display: flex; flex-direction: column; justify-content: center; padding: 22px 26px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; background: #fff; box-shadow: var(--shadow-sm); }
.takeaway-eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.takeaway-card h3 { margin: 6px 0 8px; font-size: 1.12rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; color: var(--text); text-wrap: pretty; }
.takeaway-card p { margin: 0; font-size: .98rem; line-height: 1.65; color: var(--text-2); text-wrap: pretty; }
.takeaway-card strong { color: var(--text); font-weight: 650; }

/* ------------------------------------------------- Rollout showcase */

/* showcase.html: per setting, a name, a row of numbered tabs (underlined; the open one dark), and the open task:
   its story on the left, the video cards on the right. */
.showcase { margin-top: 28px; }
.showcase-views { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: fit-content; max-width: 100%; margin: 0 auto 24px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-light); }
.showcase-views [role="tab"] { min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-2); font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; }
.showcase-views [role="tab"][aria-selected="true"] { background: #fff; color: var(--accent); border-color: var(--border); box-shadow: var(--shadow-sm); }
.showcase-views [role="tab"]:hover { color: var(--accent); }
.showcase-view[hidden] { display: none; }
.js .showcase-view .showcase-top, .js .showcase-view-heading { display: none; }
.imagination-intro { max-width: 740px; margin: 24px auto 0; font-size: 1rem; line-height: 1.7; color: var(--text-2); text-align: center; }
html:not(.js) .showcase-views { display: none; }
html:not(.js) .showcase-view[hidden] { display: block; margin-top: 48px; }
.showcase-group + .showcase-group { margin-top: 64px; }
.showcase-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.showcase-name { margin: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; color: var(--text); }
.showcase-name span { font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.text-button { padding: 4px 0 4px 8px; border: 0; background: none; color: var(--link); font: inherit; font-size: .9rem; white-space: nowrap; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.showcase-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.showcase-tabs [role="tab"] {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 10px; align-items: baseline;
  min-width: 0; padding: 12px 12px 13px;
  border: 0; border-bottom: 3px solid var(--border); border-radius: 0; background: none;
  font: inherit; text-align: left; color: var(--text-2); cursor: pointer;
  transition: border-color .2s, color .2s;
}
.showcase-tabs [role="tab"]:hover { border-color: #b9bdcb; color: var(--text); }
.showcase-tabs [role="tab"][aria-selected="true"] { border-color: var(--text); color: var(--text); }
.st-num { grid-row: 1 / 3; font-size: .82rem; font-weight: 600; color: var(--muted); }
.st-title { font-size: 1.15rem; font-weight: 400; line-height: 1.35; }
[aria-selected="true"] > .st-title { font-weight: 700; }
.st-action { grid-column: 2; font-size: .8rem; color: var(--muted); }
[aria-selected="true"] > .st-num, [aria-selected="true"] > .st-action { color: var(--text); }
[aria-selected="true"] .st-off, [aria-selected="false"] .st-on { display: none; }

.showcase-panel { display: grid; grid-template-columns: minmax(0, .78fr) minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; margin-top: 28px; }
.showcase-panel[hidden] { display: none; }
.showcase-story { padding-right: 8px; }
.story-num { display: block; margin-bottom: 12px; font-size: 2.4rem; font-weight: 400; line-height: 1; letter-spacing: -0.03em; color: #c3c8d6; }
.showcase-story h4 { margin: 0; font-size: 1.8rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; color: var(--text); }
.story-instruction { margin: 12px 0 0; font-size: .98rem; font-style: italic; line-height: 1.5; color: var(--text-2); }
.story-outcomes { margin: 16px 0 0; padding: 0; list-style: none; font-size: .92rem; line-height: 1.5; color: var(--text-2); }
.story-outcomes li { padding-left: 12px; border-left: 3px solid var(--border); }
.story-outcomes li + li { margin-top: 8px; }
.story-outcomes .is-failure { border-color: var(--failure); }
.story-outcomes .is-success { border-color: var(--success); }
.story-outcomes strong { color: var(--text); font-weight: 650; }
.showcase-note { margin: 44px 0 0; font-size: .9rem; text-align: center; color: var(--muted); }
.showcase-note strong { color: var(--text-2); }
.showcase + .takeaway { margin-top: 32px; }
/* Without JavaScript the tabs cannot switch: list every task instead. */
html:not(.js) .showcase-tabs { display: none; }
html:not(.js) .showcase-panel[hidden] { display: grid; }

/* ---------------------------------------------------------------- Tabs */

.tabs { max-width: var(--media-width); margin: 0 auto 36px; }
.tab-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; }
.tab-list [role="tab"], .chart-views button, .view-switch button {
  appearance: none;
  padding: 6px 16px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text-2);
  font: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}
.tab-list [role="tab"]:hover, .chart-views button:hover, .view-switch button:hover { border-color: var(--accent); color: var(--accent); }
.tab-list [role="tab"][aria-selected="true"], .chart-views button[aria-pressed="true"], .view-switch button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.tab-list [role="tab"]:focus-visible, .chart-views button:focus-visible, .view-switch button:focus-visible { border-radius: 999px; }
.tab-panel > .video { margin: 0; }
.key-idea + .tabs, .anim + .tabs { margin-top: 36px; }

/* ---------------------------------------------------------- Takeaway */

.takeaway {
  max-width: 800px; margin: 32px auto 0;
  padding: 18px 24px;
  background: #e8f0fe;
  border-left: 4px solid var(--link);
  border-radius: 0 10px 10px 0;
}
.takeaway p { margin: 0; font-size: 1.04rem; line-height: 1.65; color: var(--text-2); text-wrap: pretty; }
.takeaway p strong { color: var(--text); font-weight: 700; }

/* -------------------------------------------------------------- Charts */

.chart-card {
  max-width: var(--media-width); margin: 0 auto 28px;
  padding: 22px 22px 16px;
  background: #f9f8f3;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.section-alt .chart-card { background: #fff; }
.chart-title { margin-bottom: 10px; font-size: 1.05rem; font-weight: 750; text-align: center; color: var(--text); }
.chart-views { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.chart-views[hidden] { display: none; }
.chart-views button { padding: 4px 14px; font-size: .82rem; }
.chart-canvas { position: relative; width: 100%; aspect-ratio: 2.25; }
.chart-canvas canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.chart-note { max-width: 760px; margin: 10px auto 0; font-size: .82rem; line-height: 1.5; color: var(--muted); text-align: center; }
.chart-details summary { cursor: pointer; font-size: .875rem; }
.chart-details p { margin: 8px 0 0; text-align: left; }

/* Plain tables that charts.js shows instead when Chart.js cannot load. */
.chart-canvas.is-fallback { aspect-ratio: auto; overflow-x: auto; }
.chart-fallback { width: 100%; margin: 8px 0 14px; border-collapse: collapse; font-size: .86rem; color: var(--text-2); text-align: center; }
.chart-fallback caption { margin-bottom: 4px; font-weight: 700; color: var(--text); }
.chart-fallback th, .chart-fallback td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.chart-fallback thead th { font-weight: 600; color: var(--text); }
.chart-fallback tbody th { text-align: left; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ------------------------------------------------------------ Citation */

.citation-box {
  position: relative;
  max-width: var(--media-width); margin: 0 auto;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
}
.citation-box pre, .citation-box .highlight { margin: 0; padding: 0; background: none; border: 0; }
/* Long fields wrap inside the box instead of being cut off at its edge. */
.citation-box pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.citation-box code { font-family: var(--mono); font-size: .82rem; line-height: 1.6; color: var(--text-2); background: none; }
.citation-box .highlight span { color: inherit !important; font-weight: inherit !important; }
.copy-btn {
  position: absolute; top: 12px; right: 12px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text-2);
  font: inherit; font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.copy-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --------------------------------------------------- Lightbox / footer */

.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(14, 16, 20, .86); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 96vw; max-height: 92vh; background: #fff; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
.lightbox-close { position: absolute; top: 14px; right: 18px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 26px; line-height: 40px; cursor: pointer; }

.footer { padding: 32px 24px; border-top: 1px solid var(--border); text-align: center; }
.footer p { margin: 2px 0; font-size: .85rem; color: var(--muted); }

/* ------------------------------------------------------------- Fade-in */

.js .fade-in { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .fade-in.visible { opacity: 1; transform: none; }

/* ---------------------------------------------------------- Responsive */

@media (max-width: 900px) {
  .req-row { grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 28px auto; }
  .overview { grid-template-columns: minmax(0, 1fr); }
  .takeaways-row { grid-template-columns: minmax(0, 1fr); }
  .overview-anim .anim { max-width: 520px; margin: 0 auto; }
  .overview-chart .chart-canvas { min-height: 0; aspect-ratio: 1.3; flex: none; }
  .showcase-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; }
  .showcase-story { grid-column: 1 / -1; padding: 0; }
  .story-num { display: none; }
  .showcase-story h4 { font-size: 1.5rem; }
}

@media (max-width: 768px) {
  .hero { padding: 44px 16px 36px; }
  .hero-tagline { padding: 14px 16px; }
  .showcase-tabs { gap: 8px; }
  .showcase-tabs [role="tab"] { grid-template-columns: minmax(0, 1fr); padding: 8px 4px 10px; }
  .st-num, .st-action { display: none; }
  .st-title { font-size: .95rem; }
  .takeaway-card { padding: 18px 20px; }

  .hero-videos {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 82%;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin: 0 -16px; padding: 0 16px 6px;
  }
  .hero-videos::-webkit-scrollbar { display: none; }
  .hero-video { scroll-snap-align: center; }
  .hero-dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
  .hero-tagline { font-size: 1.02rem; }
  .topnav-brand { display: none; }
  .topnav-inner { padding: 0 8px; }
  .topnav-links { margin-left: 0; }
  .section { padding: 50px 0; }
  .container { padding: 0 16px; }
  .section-title { font-size: 1.4rem; }
  .section-body > p.lead { font-size: 1rem; }
  /* One card per row, no wider than the 640px clips (BPP stacks its cards the same way). */
  .video-cards { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
  .chart-card { padding: 16px 10px 12px; }
  .chart-canvas { aspect-ratio: 1.3; }
  .takeaway { padding: 16px 18px; }
  .takeaway p { font-size: 1rem; }
}

@media (max-width: 640px) {
  .training-inference > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  /* Multi-panel strips (round-trip): swipe across readable panels; labels stay aligned. */
  .video-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 8px; scrollbar-width: thin; }
  .video-scroll > * { min-width: 720px; }
  .copy-btn { top: 8px; right: 8px; padding: 4px 10px; }
  .showcase-panel { grid-template-columns: minmax(0, 1fr); }
  /* Number tables shown when Chart.js cannot load: fit the card without sideways scrolling. */
  .chart-fallback { font-size: .76rem; }
  .chart-fallback th, .chart-fallback td { padding: 5px 3px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .fade-in { opacity: 1; transform: none; transition: none; }
  .video-card, .video-card:hover { transition: none; transform: none; }
}

@media print {
  .topnav, .hero-videos, .hero-dots, .lightbox, .video-toggle, .copy-btn, .text-button { display: none !important; }
  /* Content below the fold may never have scrolled into view: print it fully visible. */
  .js .fade-in { opacity: 1 !important; transform: none !important; transition: none !important; }
  /* Keep each figure on one page. */
  .anim, .chart-card, .video-card, .video, .tabs, .takeaway, .takeaway-card, .citation-box, .figure, .compare-task, .imagine { break-inside: avoid; }
  .section-title, h3 { break-inside: avoid; break-after: avoid; }
}
