/* =====================================================
   UniLab — project page styles
   Aesthetic: light, minimal, academic. Inspired by
   gsplayground.github.io: white bg, dark text, blue
   accent, generous whitespace, ~1200px content width.
   ===================================================== */

/* ---------- tokens (dark theme) ---------- */
:root {
  /* surfaces */
  --bg:            #06091a;   /* deep navy page background */
  --bg-alt:        #0a0f24;   /* one step elevated — used for section--alt */
  --bg-soft:       #0a0f24;
  --bg-card:       #0d1330;   /* cards, tables, code blocks */
  --bg-elevated:   #11183b;
  --bg-deep:       #04061a;   /* footer / extra-recessed surfaces */

  /* borders */
  --border:        #1c2348;
  --border-strong: #2a3270;

  /* text */
  --text:          #e6e8f3;
  --text-muted:    #a8aed0;
  --text-soft:     #7c83a8;

  /* accents */
  --accent-cyan:    #22d3ee;
  --accent-blue:    #38bdf8;
  --accent-indigo:  #818cf8;
  --accent-magenta: #ec4899;
  --accent-mint:    #34d399;
  --accent-amber:   #fbbf24;
  --accent:         var(--accent-cyan);
  --accent-hover:   #5eead4;
  --accent-soft:    rgba(34, 211, 238, 0.10);
  --accent-gradient: linear-gradient(135deg, #5eead4 0%, #38bdf8 50%, #818cf8 100%);

  /* semantic marks */
  --yes:           #34d399;
  --no:            #3b4170;
  --partial:       #fbbf24;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
  --shadow:    0 8px 32px rgba(0,0,0,.40);
  --glow-cyan: 0 0 24px rgba(34, 211, 238, 0.18);

  --container:    1440px;
  --container-sm: 880px;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --space-7: 48px; --space-8: 64px; --space-9: 96px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
               Consolas, "Liberation Mono", monospace;
}

@supports (font-variation-settings: normal) {
  :root { --font-sans: "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI",
                       Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; color-scheme: dark; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
/* faint full-page teaser backdrop — fixed behind all content, kept very low
   opacity so charts and figures stay perfectly legible. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/assets/teaser/teaser.png") center top / cover no-repeat;
  opacity: 0.15;
  pointer-events: none;
}
::selection { background: rgba(34,211,238,0.32); color: #fff; }
::-webkit-scrollbar       { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: rgba(34,211,238,0.45); }
img, video, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: var(--accent-cyan); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
button { font: inherit; }

/* ---------- layout ---------- */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.container--narrow { max-width: var(--container-sm); }

.section { padding: var(--space-9) 0; }
.section--alt { background: rgba(255, 255, 255, 0.02); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: var(--space-3);
  font-weight: 700;
}
.section-title {
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  white-space: nowrap;
  margin-bottom: var(--space-5);
}
.section-lede {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 70ch;
  margin-bottom: var(--space-7);
}
.section-note {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 70ch;
  margin-top: var(--space-6);
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(6, 9, 26, 0.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.nav__brand:hover { text-decoration: none; }
.nav__logo { color: var(--accent-cyan); display: inline-flex; }
.nav__name { font-size: 16px; color: var(--text); }

.nav__links {
  display: flex;
  gap: var(--space-5);
  margin-left: var(--space-4);
  flex: 1;
  flex-wrap: wrap;
}
.nav__links a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav__links a:hover { color: var(--text); text-decoration: none; }
.nav__links a.is-active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }

.nav__cta { display: flex; gap: var(--space-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .05s;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn--solid       { background: var(--accent-cyan); color: #06091a; box-shadow: 0 0 0 1px rgba(34,211,238,0.50), var(--glow-cyan); }
.btn--solid:hover { background: var(--accent-hover); color: #06091a; box-shadow: 0 0 0 1px rgba(94,234,212,0.65), 0 0 28px rgba(34,211,238,0.30); }

.btn--ghost       { background: rgba(255,255,255,0.04); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: rgba(255,255,255,0.08); color: var(--accent-cyan); border-color: rgba(34,211,238,0.45); }

.btn--lg { padding: 12px 22px; font-size: 15px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: var(--space-9) 0 var(--space-7);
  overflow: hidden;
  isolation: isolate;
  min-height: 640px;
  /* no dedicated background — inherits the site's dark page bg (+ faint
     full-page teaser backdrop) like every other section. */
}
.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;          /* events bubble from .hero, canvas is just paint */
  opacity: 0.85;
  mix-blend-mode: screen;        /* makes the glow add nicely over the bg */
}
.hero .container { position: relative; z-index: 2; }

.hero__hud {
  position: absolute;
  top: 0; left: 0;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent-cyan);
  background: rgba(6, 9, 26, 0.85);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity .18s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.18);
}
.hero__hud.is-visible { opacity: 1; }
/* hero atmosphere (corner glows + dot grid) removed so the hero background
   matches every other section exactly — just the site's dark page bg. */

.eyebrow {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.30);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: var(--space-5);
  font-weight: 600;
}
.hero__title {
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: var(--space-5);
  color: #fff;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 80px rgba(56, 189, 248, 0.18);
}
.hero__title-sub {
  display: block;
  font-size: clamp(20px, 2.4vw, 32px);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-muted);
  margin-top: var(--space-3);
  /* override the gradient-text fill inherited from the parent */
  -webkit-text-fill-color: currentColor;
  background: none;
}
.hero__lede {
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--text-muted);
  max-width: 72ch;
  margin-bottom: var(--space-7);
}
.hero__lede strong { color: var(--text); font-weight: 600; }

.hero__ctas { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- teaser ---------- */
.teaser { padding-bottom: var(--space-9); }
/* teaser video (16:9, click-to-play — no autoplay) */
.teaser__video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

/* ---------- figures / placeholders ---------- */
.figure { margin: 0; }
.figure img { width: 100%; height: auto; border-radius: var(--radius); }
/* paper data charts are transparent dark-mode PNGs (lightness-inverted, hue
   preserved) so they float directly on the dark page. */
.figure--paper img { background: transparent; }
/* complex diagrams with photos/colored panels (system architecture) keep their
   natural colors on a clean light card. */
.figure--light img {
  background: #fff;
  padding: var(--space-4);
  border: 1px solid var(--border);
}
/* stacked full-width paper evidence figures (Results) */
.results-evidence {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-7);
  margin-top: var(--space-7);
}
.figure--headline img { filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.22)); }
/* render a wide diagram smaller than full container width, centered */
.figure--narrow { max-width: 820px; margin-left: auto; margin-right: auto; }
.figure figcaption {
  margin-top: var(--space-4);
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}
.figure figcaption strong { color: var(--text); }

.placeholder {
  position: relative;
  width: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.015) 0 12px,
      rgba(255,255,255,0.04)  12px 24px
    ),
    var(--bg-card);
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text-soft);
}
.placeholder::after {
  content: attr(data-label);
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-4);
  background: rgba(6, 9, 26, 0.50);
  letter-spacing: 0.01em;
}
.placeholder[data-asset-id]::before {
  content: attr(data-asset-id);
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 1;
}
.placeholder[data-iframe-id]::before {
  content: attr(data-iframe-id);
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  background: var(--bg-deep);
  border: 1px solid rgba(34,211,238,0.30);
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 1;
}

.ratio-21x9 { aspect-ratio: 21 / 9; }
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-4x3  { aspect-ratio: 4 / 3; }
.ratio-1x1  { aspect-ratio: 1 / 1; }

/* ---------- at-a-glance metrics ---------- */
.glance { padding: 0 0 var(--space-9); }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.metric {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-left: 1px solid var(--border);
}
.metric:first-child { border-left: none; padding-left: 0; }
.metric__value {
  font-size: clamp(28px, 2.8vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.metric:nth-child(1) .metric__value { color: var(--accent-cyan); }
.metric:nth-child(2) .metric__value { color: var(--text); }
.metric:nth-child(3) .metric__value { color: var(--accent-mint); }
.metric:nth-child(4) .metric__value { color: var(--text); }
.metric:nth-child(5) .metric__value { color: var(--accent-magenta); }
.metric:nth-child(6) .metric__value { color: var(--accent-blue); }
.metric__label {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.metric__label span {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  color: var(--text-soft);
  font-size: 12px;
}
.metric__label em {
  display: inline-block;
  margin-top: 3px;
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
}

/* ---------- highlight cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: rgba(34,211,238,0.35); transform: translateY(-2px); }
.card__num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.1em;
}
.card__title { font-size: 20px; font-weight: 700; }
.card__body  { font-size: 15px; color: var(--text-muted); }
.card__media { margin-top: auto; }

/* highlight points — plain text, three across, no card chrome */
.points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-7);
}
.point__num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
  letter-spacing: 0.18em;
  margin-bottom: var(--space-2);
}
.point__title { font-size: 18px; font-weight: 700; margin-bottom: var(--space-3); }
.point__body  { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* ---------- architecture ---------- */
.arch {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-7);
  margin-top: var(--space-6);
}
.arch__notes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-top: var(--space-8);
}
.note {
  border-left: 3px solid var(--accent-cyan);
  padding: 4px 0 4px var(--space-4);
  background: linear-gradient(90deg, rgba(34,211,238,0.06), transparent 60%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note h4 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.note p  { font-size: 14px; color: var(--text-muted); }

/* ---------- matrix ---------- */
.matrix {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}
.matrix__row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
  align-items: center;
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border);
}
.matrix__row:first-child { border-top: none; }
.matrix__label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.matrix__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.chip--featured {
  color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.10);
  border-color: rgba(34, 211, 238, 0.45);
  font-weight: 600;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.20);
}
.chip--featured::before {
  content: '✦';
  margin-right: 6px;
  font-size: 11px;
  line-height: 1;
  color: var(--accent-cyan);
}
.chip--with-icon {
  gap: 8px;
  padding-left: 8px;
}
.chip--with-icon.chip--featured::before { content: none; }
.chip__icon {
  width: 22px;
  height: 18px;
  object-fit: contain;
  border-radius: 5px;
  background: rgba(248,250,252,0.96);
  padding: 3px;
  flex: 0 0 22px;
}
a.chip { text-decoration: none; transition: transform 120ms ease, box-shadow 120ms ease; }
a.chip:hover { text-decoration: none; transform: translateY(-1px); }
a.chip--featured:hover { box-shadow: 0 0 22px rgba(34, 211, 238, 0.32); }

.inline-link { color: var(--accent-cyan); border-bottom: 1px dashed rgba(34, 211, 238, 0.45); }
.inline-link:hover { color: var(--accent-hover); text-decoration: none; border-bottom-color: var(--accent-hover); }
.inline-link strong { color: inherit; }

/* ---------- comparison table ---------- */
.table-wrap { overflow-x: auto; }
.ctable, .ptable {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 15px;
}
.ctable th, .ctable td,
.ptable th, .ptable td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.ctable thead th, .ptable thead th {
  background: rgba(255,255,255,0.03);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.ctable th:not(:first-child),
.ctable td:not(:first-child) {
  text-align: center;
}
.ctable tbody tr:last-child td,
.ctable tbody tr:last-child th,
.ptable tbody tr:last-child td { border-bottom: none; }
.ctable tbody th { font-weight: 600; }
.ctable__highlight { background: rgba(34, 211, 238, 0.06); position: relative; }
.ctable__highlight th { color: var(--accent-cyan); }
.ctable__highlight th, .ctable__highlight td { font-weight: 700; }

/* compact comparison table — tighter rows, smaller platform icons */
.ctable { font-size: 14px; }
.ctable th, .ctable td { padding: 9px 16px; }
.ctable .platform-icons { gap: 6px; }
.ctable .platform-icon {
  width: 42px;
  height: 28px;
  flex-basis: 42px;
  border-radius: 8px;
  padding: 5px;
}


.mark {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
}
.mark.yes     { color: var(--yes); text-shadow: 0 0 12px rgba(52,211,153,0.45); }
.mark.no      { color: var(--no); }
.mark.partial { color: var(--partial); font-size: 18px; }  /* ◐ glyph runs small — enlarge to match ● / ○ */
.legend-half { font-size: 1.3em; vertical-align: -0.06em; }  /* the ◐ in the legend caption */

.platform-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}
.platform-icon {
  display: inline-flex;
  width: 52px;
  height: 36px;
  align-items: center;
  justify-content: center;
  flex: 0 0 52px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 10px;
  background: rgba(248,250,252,0.96);
  padding: 6px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.18);
}
.platform-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.platform-icon--sm {
  width: 34px;
  height: 26px;
  flex-basis: 34px;
  border-radius: 8px;
  padding: 5px;
  vertical-align: middle;
}
.platform-icon--partial {
  border-color: rgba(251,191,36,0.65);
  box-shadow: 0 0 0 1px rgba(251,191,36,0.20), 0 1px 8px rgba(0,0,0,0.18);
}
.platform-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.table-caption {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: var(--space-3);
}

/* ---------- results grid ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

/* ---------- demos / task gallery ---------- */
.subhead {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: var(--space-7) 0 var(--space-4);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.subhead:first-of-type { margin-top: 0; }
.subhead__tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

/* legacy small-tile grid (unused after gallery rewrite, kept for future small grids) */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.demo-grid--2 { grid-template-columns: repeat(2, 1fr); }
.demo { margin: 0; }
.demo figcaption {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-2);
  font-weight: 500;
}

/* task gallery — compact two-column demo cards */
.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.task {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color .2s;
}
.task:hover { border-color: rgba(34,211,238,0.30); }
.task--planned {
  background: transparent;
  border-style: dashed;
  border-color: rgba(255,255,255,0.10);
  opacity: 0.82;
}
.task--planned:hover { opacity: 0.95; border-color: rgba(34,211,238,0.25); }
.task__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}
.task__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.task__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: -0.005em;
}
.meta-chip + .meta-chip { /* no extra style needed; gap handles spacing */ }

.task__sims {
  display: block;
}
.sim { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.task__sims .placeholder.iframe-slot {
  border-color: rgba(34, 211, 238, 0.28);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.06);
}

/* iframe slots reserve demo layout; preview/play controls are wired by the
   roving MotrixSim controller. */
.iframe-slot { background: var(--bg-deep); }
iframe.iframe-slot {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

/* ---------- click-to-play demo slots ---------- */
/* The slot <div> holds a static preview <img>, a Play button, and a loading
   spinner. The single roving iframe is snapped over it (position: fixed) and
   fades in only once the live demo is drawing. */
.iframe-slot {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.slot-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slot-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 68px;
  height: 68px;
  padding-left: 5px; /* optical-center the play triangle */
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: rgba(8, 12, 20, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(34, 211, 238, 0.5);
  transition: transform 120ms ease, background 120ms ease;
}
.slot-play:hover {
  transform: scale(1.08);
  background: rgba(34, 211, 238, 0.3);
}
.slot-play svg { display: block; }
.slot-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 46px;
  height: 46px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: slot-spin 0.8s linear infinite;
  display: none;
}
@keyframes slot-spin { to { transform: rotate(360deg); } }
/* state-driven visibility (set by motrixsim_roving.js) */
.iframe-slot[data-state="loading"] .slot-play,
.iframe-slot[data-state="playing"] .slot-play { display: none; }
.iframe-slot[data-state="loading"] .slot-spinner { display: block; }

/* loading progress bar (motrixsim_roving.js) — a thin bar pinned to the slot
   bottom, below the live stage (z 2) so it's hidden once the demo draws over it.
   Tracks the wasm download, then the instantiate / scene / policy / render steps. */
.slot-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  z-index: 1;
  background: rgba(8, 12, 20, 0.55);
  overflow: hidden;
  pointer-events: none;
}
.slot-progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.65);
  transition: width 0.18s ease-out;
}

/* ---------- inline live demo stage (replaces the roving iframe) ---------- */
/* A single #motrix-stage hosts the one Bevy canvas + the examples app's perf /
   error overlays. motrixsim_roving.js loads the examples app once, reparents
   the stage into whichever card the user hits Play on (it fills the slot and
   scrolls natively with the page), and switches scenes in-place over
   postMessage. Hidden (opacity 0) until the scene is drawing, so the card's
   preview + spinner show through during load. There is no iframe — one Bevy. */
#motrix-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
}
#motrix-stage.is-ready {
  opacity: 1;
  pointer-events: auto;
}
#motrix-stage > #bevy {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
}
#motrix-stage > #bevy:active { cursor: grabbing; }
#motrix-stage > #perf-stats {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-muted);
  background: rgba(8, 12, 20, 0.6);
  border-radius: 5px;
  padding: 4px 8px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
#motrix-stage > #perf-stats.visible { opacity: 1; }
#motrix-stage > #perf-stats .stat-label { color: var(--accent-cyan); font-weight: 600; }
#motrix-stage > #error-message {
  position: absolute;
  inset: auto 10px 10px 10px;
  z-index: 4;
  display: none;
  background: rgba(20, 6, 6, 0.92);
  border: 1px solid rgba(255, 68, 68, 0.4);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: #ffb4b4;
}
#motrix-stage > #error-message.show { display: block; }

.task__note {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin: 0;
}
.task--planned .task__note { color: var(--text-soft); }

/* ---------- platform logos ---------- */
.platform-showcase {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  align-content: center;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 20%, rgba(34,211,238,0.16), transparent 32%),
    linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}
.platform-showcase__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  background: rgba(248,250,252,0.96);
  padding: var(--space-4);
}
.platform-showcase__tile img {
  width: 100%;
  height: 42px;
  object-fit: contain;
}
.logo-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-7);
}
.logo-slot { aspect-ratio: 3 / 1; }
.platform-logo-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(248,250,252,0.96);
  padding: var(--space-5);
}
.platform-logo-slot img {
  width: 100%;
  height: 54px;
  object-fit: contain;
}
.logo-slot.placeholder { border-style: solid; }

/* ---------- bibtex ---------- */
.bibtex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  align-items: stretch;
}
.bibtex {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(17,24,59,0.96), rgba(9,13,35,0.96)),
    var(--bg-card);
  border: 1px solid rgba(56,189,248,0.18);
  border-radius: var(--radius-lg);
  color: var(--text);
  box-shadow: var(--shadow);
}
.bibtex pre {
  flex: 1;
  margin: 0;
  padding: var(--space-5);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.75;
  color: var(--text);
  background: rgba(3,6,20,0.72);
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow-x: auto;
  white-space: pre;
  scrollbar-color: rgba(56,189,248,0.45) transparent;
}
.bibtex code {
  font-family: inherit;
  color: var(--accent-blue);
}
.bibtex__head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}
.bibtex__label {
  min-width: 0;
}
.bibtex__group-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.bibtex__meta {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-soft);
}
.bibtex__badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(34,211,238,0.10);
  border: 1px solid rgba(34,211,238,0.18);
  border-radius: 999px;
}
.bibtex__copy {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.bibtex__copy:hover { background: rgba(34,211,238,0.10); border-color: rgba(34,211,238,0.35); color: var(--accent-cyan); }
.bibtex__copy.is-copied { background: rgba(52,211,153,0.16); border-color: rgba(52,211,153,0.40); color: var(--accent-mint); }
.bibtex__copy-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 900px) {
  .bibtex-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .bibtex__head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .bibtex__badge { margin-left: 0; }
  .bibtex__copy { margin-left: auto; }
}

/* ---------- authors ---------- */
#authors .section-eyebrow,
#authors .section-title {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}
.authors__logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-5);
}
.authors__logos img {
  display: block;
  height: 26px;
  max-width: 138px;
  object-fit: contain;
}
/* most contributor marks are already white (their detail lives in the alpha or
   greyscale channel — inverting them would flatten it into a blob). Only the
   dark/colored marks are inverted to white so they read on the dark strip. */
.authors__logos img.logo--invert { filter: brightness(0) invert(1); }
/* Galbot is an unusually wide, short wordmark — keep its width in check. */
.authors__logos img.logo--drobot { max-width: 110px; }
.authors__logos img.logo--galbot { max-width: 110px; }
/* full-width zero-height flex item -> forces a new row in the logo strip */
.authors__logos .logo-break { flex-basis: 100%; height: 0; margin: 0; }
/* dial down the wide wordmark marks (AMD, Sharpa, Dexmal, Motphys) so they
   don't tower over the crest logos. */
.authors__logos img.logo--sm { height: 20px; max-width: 115px; }
.authors__logos img.logo--row4.logo--sm {
  height: calc(20px * 0.85);
  max-width: calc(115px * 0.85);
}
.authors__logos img.logo--row4.logo--drobot,
.authors__logos img.logo--row4.logo--galbot {
  height: calc(26px * 0.85);
  max-width: calc(110px * 0.85);
}
.authors__logos img.logo--row3 {
  height: calc(26px * 0.85);
  max-width: calc(138px * 0.85);
}
.authors__text {
  margin-top: var(--space-5);
  text-align: center;
}
.authors__text p {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}
.author-dagger {
  color: var(--accent-blue);
  font-weight: 600;
}
.authors__text p.authors__note {
  margin-top: var(--space-4);
  font-size: 13px;
  color: var(--text-soft);
}
.authors__note a { color: var(--text-soft); text-decoration: underline; }
.authors__note a:hover { color: var(--accent-cyan); }
/* ---------- footer ---------- */
.footer {
  background: rgba(4, 6, 20, 0.55);
  color: var(--text-muted);
  padding: var(--space-8) 0 var(--space-5);
  margin-top: 0;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent-cyan); text-decoration: none; }
.footer__inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.4fr 1.5fr;
  gap: var(--space-7);
  padding-bottom: var(--space-7);
  border-bottom: 1px solid var(--border);
}
.footer__brand { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.footer__tag   { font-size: 14px; color: var(--text-soft); }
.footer__heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: var(--space-3);
}
.footer__col ul li { margin-bottom: 4px; font-size: 14px; }
.footer__logos { margin-top: 0; grid-template-columns: repeat(2, 1fr); }
.footer__bottom {
  padding-top: var(--space-5);
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric { border-left: none; padding-left: var(--space-3); }
}
@media (max-width: 960px) {
  .cards         { grid-template-columns: 1fr; }
  .points        { grid-template-columns: 1fr; gap: var(--space-5); }
  .arch          { grid-template-columns: 1fr; gap: var(--space-6); }
  .arch__notes   { grid-template-columns: 1fr; }
  .results-grid  { grid-template-columns: 1fr; }
  .demo-grid     { grid-template-columns: repeat(2, 1fr); }
  .demo-grid--2  { grid-template-columns: 1fr; }
  .logo-row      { grid-template-columns: repeat(2, 1fr); }
  .footer__inner { grid-template-columns: 1fr; }
  .matrix__row   { grid-template-columns: 1fr; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
  .nav__cta .btn[data-link="docs"] { display: none; }
}
@media (max-width: 720px) {
  .container { padding: 0 var(--space-4); }
  .section { padding: var(--space-8) 0; }
  .section-title { white-space: normal; }
  .hero { padding: var(--space-8) 0 var(--space-6); min-height: 0; }
  .hero__canvas { opacity: 0.55; }
  .nav__inner { padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .nav__links { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); padding: var(--space-4); }
  .demo-grid { grid-template-columns: 1fr 1fr; }
  .task-grid { grid-template-columns: 1fr; }
  .task { padding: var(--space-4) var(--space-4) var(--space-4); }
  .task__title { font-size: 16px; }
  .ctable th, .ctable td, .ptable th, .ptable td { padding: 10px 12px; font-size: 13px; }
  .footer__bottom { flex-direction: column; }
}
@media (max-width: 480px) {
  .demo-grid    { grid-template-columns: 1fr; }
  .hero__title  { font-size: 44px; }
  .nav__cta .btn[data-link="paper"] { display: none; }
}

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

/* ---------- language switch (EN / 中文) ---------- */
[data-lang="en"] .i18n-zh { display: none !important; }
[data-lang="zh"] .i18n-en { display: none !important; }
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
}
.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active { background: var(--accent-cyan); color: #06091a; }

/* Chinese descriptions read better without the 70ch cap (CJK is compact),
   and text-wrap:balance avoids an ugly single-character last line. */
.section-lede, .figure figcaption { text-wrap: balance; }
[data-lang="zh"] .section-lede { max-width: none; }

/* cross-platform training-time table (many columns) — equal-width platform
   columns via fixed layout; the task column is wider, the rest split evenly. */
.time-table { table-layout: fixed; min-width: 760px; }
.time-table th, .time-table td { padding: 8px 8px; word-break: break-word; }
.time-table thead th { font-size: 11px; }
.time-table th:first-child, .time-table td:first-child { width: 18%; }
