/* =========================================================
   HBTP · academic page styles
   Visual direction (different from RoboWaiter):
     - System font stack (no custom Google fonts)
     - Slate / paper-card aesthetic with amber accent
     - Stacked card layout for demos (vs tab switcher)
   ========================================================= */

:root {
  --bg: #f6f7f9;
  --paper: #ffffff;
  --ink: #0f172a;          /* slate-900 */
  --ink-2: #1f2937;        /* slate-800 */
  --muted: #475569;        /* slate-600 */
  --muted-2: #64748b;      /* slate-500 */
  --line: #e2e8f0;         /* slate-200 */
  --line-2: #cbd5e1;       /* slate-300 */
  --accent: #0d9488;       /* teal-600 */
  --accent-soft: #ccfbf1;  /* teal-100 */
  --warn: #b45309;         /* amber-700 */
  --warn-soft: #fef3c7;    /* amber-100 */
  --code-bg: #0b1220;
  --code-fg: #e2e8f0;

  --shadow-xs: 0 1px 1px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .07), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .10), 0 8px 18px rgba(15, 23, 42, .05);

  --radius: 12px;
  --radius-lg: 18px;
  --maxw: 1180px;
  --maxw-narrow: 820px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--ink); }

img, video { max-width: 100%; display: block; }

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

/* ============== TOP BAR ============== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.topbar.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: var(--shadow-xs);
}
.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .2px;
}
.logo img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2px;
  object-fit: contain;
}
.logo-text { font-size: 16px; }
.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 22px;
}
.topnav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.topnav a:hover { color: var(--ink); }

.topcta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .2s ease;
}
.topcta:hover { background: #000; color: #fff; transform: translateY(-1px); }

/* ============== HERO ============== */
.hero {
  padding: 64px 0 48px;
  background:
    radial-gradient(1100px 420px at 50% -10%, rgba(13, 148, 136, .08), transparent 60%),
    linear-gradient(180deg, #fbfcfe 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero-inner { text-align: center; }

.venue-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  border-radius: 999px;
}

.title {
  margin: 18px auto 14px;
  max-width: 980px;
  font-size: clamp(1.75rem, 2.6vw + .8rem, 2.6rem);
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--ink);
}
.title-mark {
  display: inline-block;
  margin-right: .35em;
  padding: 0 .35em;
  background: linear-gradient(180deg, transparent 60%, var(--accent-soft) 60%);
  color: var(--ink);
}
.title-sub {
  display: block;
  margin-top: .35em;
  font-weight: 600;
  font-size: .82em;
  color: var(--muted);
}

.authors {
  max-width: 920px;
  margin: 14px auto 4px;
  font-size: 1rem;
  color: var(--ink-2);
  line-height: 1.9;
}
.authors .a { white-space: nowrap; }
.authors .a a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .18s ease, border-color .18s ease;
}
.authors .a a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.authors sup { color: var(--accent); font-weight: 700; }

.affil {
  margin: 4px auto 2px;
  color: var(--muted);
  font-size: .98rem;
}
.email {
  margin: 0 auto;
  color: var(--muted-2);
  font-size: .88rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
}
.email a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--line-2);
  transition: color .15s ease, border-color .15s ease;
}
.email a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.footnote {
  margin-top: 6px;
  font-size: .85rem;
  color: var(--muted-2);
}
.footnote sup { color: var(--accent); }

.links {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  white-space: nowrap;
}
.pill-solid {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.pill-solid:hover { background: #000; color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.pill-ghost {
  background: #fff;
  color: var(--ink-2);
  border-color: var(--line);
}
.pill-ghost.is-disabled {
  color: var(--muted-2);
  cursor: not-allowed;
  background: #f8fafc;
}
.pill-arxiv {
  background: #b31b1b;
  color: #fff;
  border-color: #b31b1b;
  box-shadow: 0 1px 2px rgba(179, 27, 27, .25);
}
.pill-arxiv:hover {
  background: #8c1313;
  border-color: #8c1313;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(179, 27, 27, .35);
}

/* ============== BLOCKS ============== */
.block { padding: 72px 0; }
.block-soft {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.block-head {
  text-align: center;
  margin-bottom: 28px;
}
.kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.block-head h2 {
  margin: 0 auto 8px;
  font-size: clamp(1.5rem, 2vw + .6rem, 2rem);
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.25;
  max-width: 900px;
}
.block-head .lead {
  margin: 8px auto 0;
  color: var(--muted);
  max-width: 780px;
}

.paragraph {
  font-size: 1.02rem;
  color: var(--ink-2);
  margin: 0 0 1.1em;
  text-align: justify;
  hyphens: auto;
}
.paragraph strong { color: var(--ink); }

/* ============== VIDEO ============== */
.video-frame {
  margin: 0 auto;
  max-width: 880px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.video-frame video {
  width: 100%;
  display: block;
  background: #000;
}

/* ============== FRAMEWORK FIGURE ============== */
.figure-card {
  margin: 0 auto;
  max-width: 1100px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
}
.figure-card img { width: 100%; height: auto; border-radius: 10px; }
.figure-card figcaption {
  margin-top: 14px;
  padding: 0 6px;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.7;
}
.figure-card figcaption strong { color: var(--ink-2); }

/* ============== DEMO CARDS ============== */
/* difficulty switcher */
.demo-tabs {
  display: inline-flex;
  margin: 0 auto 26px;
  padding: 6px;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
}
.block-soft .block-head + .demo-tabs,
#demos .demo-tabs { display: flex; width: fit-content; }
#demos .wrap { text-align: center; }
#demos .demo-card { text-align: left; }
.demo-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: .5rem 1.5rem;
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .4px;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.demo-tab:hover { color: var(--ink); }
.demo-tab.is-active {
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.demo-tab.level-easy.is-active   { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.demo-tab.level-medium.is-active { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.demo-tab.level-hard.is-active   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

.demo-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px;
  margin-bottom: 26px;
  transition: box-shadow .2s ease, transform .15s ease;
}
.demo-card.is-active { display: block; animation: demoFade .35s ease both; }
@keyframes demoFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.demo-card:hover { box-shadow: var(--shadow-md); }
.demo-card:last-child { margin-bottom: 0; }

.demo-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px dashed var(--line);
}
.demo-head h3 {
  margin: 0;
  font-size: 1.02rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
  word-break: break-word;
}
.demo-head h3 .op { color: var(--accent); margin: 0 .2em; font-weight: 700; }

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.level-easy   { color: #047857; background: #d1fae5; border-color: #a7f3d0; }
.level-medium { color: #b45309; background: #fef3c7; border-color: #fde68a; }
.level-hard   { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 28px;
  align-items: start;
}

.reason {
  margin: 0 0 18px;
  display: grid;
  gap: 10px;
}
.reason > div {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.reason dt {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.reason dd {
  margin: 0;
  color: var(--ink-2);
  font-size: .94rem;
}
.reason code {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88rem;
  color: var(--ink);
  word-break: break-word;
}

.bt-tree {
  margin: 0;
  padding: 14px;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.bt-tree figcaption {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 8px;
}
.bt-tree img { width: 100%; height: auto; }

.demo-video {
  position: sticky;
  top: 76px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.demo-video video {
  width: 100%;
  display: block;
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ============== BIBTEX ============== */
.codeblock {
  position: relative;
  background: #f8fafc;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.codeblock pre {
  margin: 0;
  padding: 22px 22px 22px 22px;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .9rem;
  line-height: 1.65;
}
.codeblock code { font-family: inherit; color: var(--ink-2); }
.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============== FOOTER ============== */
.footer {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 28px 0 32px;
}
.footer-inner { text-align: center; }
.footer p { margin: 4px 0; font-size: .9rem; }
.footer a { color: var(--accent); }
.footer a:hover { color: var(--ink); }
.footer .muted { color: var(--muted-2); }

/* ============== INTERACTION ENHANCEMENTS ============== */
/* scroll progress bar */
#scrollProgress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0;
  background: linear-gradient(90deg, var(--accent), #2dd4bf 60%, var(--warn));
  z-index: 60;
  transition: width .08s linear;
}

/* scroll-spy active nav link */
.topnav a {
  position: relative;
  padding: 4px 2px;
}
.topnav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform .2s ease;
}
.topnav a:hover::after,
.topnav a.active::after { transform: scaleX(1); }
.topnav a.active { color: var(--ink); font-weight: 600; }

/* reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .6s cubic-bezier(.2,.7,.2,1);
  will-change: opacity, transform;
}
.reveal.in { opacity: 1; transform: none; }

/* hero entrance */
.hero .venue-pill,
.hero .title,
.hero .authors,
.hero .affil,
.hero .email,
.hero .footnote,
.hero .links {
  opacity: 0;
  transform: translateY(16px);
  animation: heroIn .7s cubic-bezier(.2,.7,.2,1) forwards;
}
.hero .title    { animation-delay: .06s; }
.hero .authors  { animation-delay: .12s; }
.hero .affil    { animation-delay: .16s; }
.hero .email    { animation-delay: .20s; }
.hero .footnote { animation-delay: .24s; }
.hero .links    { animation-delay: .30s; }
@keyframes heroIn {
  to { opacity: 1; transform: none; }
}

/* link pills lift micro-interaction already exists; add focus ring */
.pill:focus-visible,
.copy-btn:focus-visible,
.demo-tab:focus-visible,
.topcta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* back-to-top */
#backToTop {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 55;
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.92);
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease, background .2s ease, color .2s ease;
}
#backToTop.show { opacity: 1; visibility: visible; transform: none; }
#backToTop:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-2px); }

/* zoomable framework figure */
.figure-card img { cursor: zoom-in; transition: transform .25s ease; }
.figure-card:hover img { transform: scale(1.006); }

/* lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vw;
  background: rgba(15, 23, 42, .82);
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
#lightbox.open { opacity: 1; visibility: visible; }
#lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
  transform: scale(.97);
  transition: transform .25s ease;
}
#lightbox.open img { transform: scale(1); }
#lightboxClose {
  position: fixed;
  top: 18px; right: 24px;
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: .85;
  transition: opacity .2s ease;
}
#lightboxClose:hover { opacity: 1; }

/* RESPONSIVE */
@media (max-width: 960px) {
  .demo-grid { grid-template-columns: 1fr; }
  .demo-video { position: static; }
  .reason > div { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 720px) {
  .topnav { display: none; }
  .hero { padding: 44px 0 36px; }
  .block { padding: 56px 0; }
  .demo-card { padding: 18px; }
  .demo-head { gap: 10px; }
  .pill { padding: 8px 13px; font-size: .86rem; }
  .topcta span { display: none; }
  .topcta { padding: 7px; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .title-mark { padding: 0 .25em; }
}

/* ============== A11y ============== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ============== Print ============== */
@media print {
  .topbar, .footer, .pill, .copy-btn, video { display: none !important; }
  .block, .hero { padding: 16px 0; }
  body { background: #fff; }
  .demo-card, .figure-card, .codeblock { box-shadow: none; border-color: #e5e7eb; }
}
