/* Lembas project page. Builds on ../../css/styles.css (nav, footer, base type). */
.lembas-page {
  --ink: #191919;
  --ink-2: #4a4a4a;
  --mute: #666666;
  --line: #e7e7e7;
  --axis: #c2c2c2;
  --plane: #f7f7f5;
  --surface: #ffffff;
  --frame: #257de0;    /* frames, and Lembas in charts */
  --frame-2: #9dc8f7;  /* lighter step of the same ramp */
  --text: #f47230;     /* subtitles */
  --base: #9a9a9a;     /* baselines */
  --good: #0aac23;
  --bad: #dc3c3d;
  --stage: #0b0e14;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  background: var(--surface);
  color: var(--ink);
}

.lembas-page .top-nav { margin-bottom: 0; }

.lb-wrap, .lb-main, .lb-toc-inner { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ---------- hero ---------- */
.lb-hero {
  background: var(--stage);
  color: #eef1f5;
  padding: 56px 0 40px;
}
.lb-kicker, .lb-eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lb-kicker { color: #8b94a5; margin-bottom: 6px; }
.lb-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(4rem, 11vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.lb-sub {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.2;
  color: #c9cfda;
  margin: 10px 0 22px;
  max-width: 820px;
}
.lb-authors { font-size: 1.05rem; color: #eef1f5; }
.lb-authors a { color: inherit; font-weight: 600; text-decoration: none; border-bottom: 1px solid #4b5363; }
.lb-authors a:hover { border-color: #eef1f5; }
.lb-affil { font-size: 0.9rem; color: #8b94a5; margin-top: 2px; }
.lb-hero sup { font-size: 0.65em; }

.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 32px; }
.lb-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid #2c3442; border-radius: 999px;
  color: #eef1f5; text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  background: #131822;
  transition: background-color .15s, border-color .15s;
}
.lb-btn:hover { background: #1c2230; border-color: #4b5363; text-decoration: none; color: #fff; }
.lb-btn-logo { height: 15px; width: auto; filter: invert(1) brightness(1.6); }

.lb-player { margin: 0; }
.lb-player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--stage);
  box-shadow: 0 0 0 1px #1d2330, 0 30px 80px -30px rgba(51, 140, 237, .35);
}
.lb-player video { display: block; width: 100%; height: 100%; object-fit: cover; }
.lb-player-bar { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.lb-vbtn {
  flex: none; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid #2c3442; background: #131822; color: #eef1f5; cursor: pointer;
}
.lb-vbtn svg { fill: currentColor; }
.lb-vbtn .i-play { display: none; }
.lb-vbtn.paused .i-play { display: block; }
.lb-vbtn.paused .i-pause { display: none; }
.lb-chapters { flex: 1; display: flex; gap: 4px; min-width: 0; }
.lb-chapters button {
  position: relative; min-width: 0;
  background: none; border: 0; padding: 12px 0 0; cursor: pointer;
  color: #8b94a5; text-align: left;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-chapters button::before, .lb-chapters button::after {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; border-radius: 2px;
}
.lb-chapters button::before { right: 0; background: #262d3b; }
.lb-chapters button::after { width: calc(var(--p, 0) * 100%); background: #338ced; }
.lb-chapters button.on { color: #eef1f5; }
.lb-chapters button:hover { color: #eef1f5; }
.lb-player figcaption { margin-top: 14px; color: #8b94a5; font-size: 0.9rem; max-width: 760px; }

/* ---------- section nav ---------- */
.lb-toc {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.lb-toc-inner { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.lb-toc-inner::-webkit-scrollbar { display: none; }
.lb-toc a {
  flex: none; padding: 13px 0 11px;
  font-size: 0.88rem; color: var(--mute); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.lb-toc a:hover { color: var(--ink); }
.lb-toc a.on { color: var(--ink); border-color: var(--ink); }

/* ---------- body ---------- */
.lb-main { padding-top: 40px; padding-bottom: 40px; }
.lb-section { padding: 56px 0 8px; scroll-margin-top: 48px; }
.lb-eyebrow { color: var(--frame); margin-bottom: 10px; }
.lb-section h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 4.2vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  max-width: 820px;
  margin-bottom: 18px;
  border: 0; padding: 0;
}
.lb-section h2 em { font-style: italic; }
.lb-prose { max-width: 700px; }
.lb-prose p, .lb-abstract p { margin-bottom: 14px; font-size: 1.02rem; line-height: 1.68; color: var(--ink-2); }
.lb-prose strong { color: var(--ink); }
.lb-points { margin: 6px 0 18px 1.2em; }
.lb-points li { margin-bottom: 10px; line-height: 1.65; color: var(--ink-2); }
.lb-dim { color: var(--mute); font-weight: 400; }
.lb-mono { font-family: var(--mono); font-size: 0.82rem; }

.lb-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line);
}
.lb-stat { padding: 22px 24px 22px 0; }
.lb-stat + .lb-stat { padding-left: 24px; border-left: 1px solid var(--line); }
.lb-stat-num { font-size: clamp(2.2rem, 5vw, 3.1rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.lb-stat-num span { font-size: 0.5em; font-weight: 500; letter-spacing: 0; color: var(--mute); }
.lb-stat-label { margin-top: 10px; font-size: 0.9rem; color: var(--mute); line-height: 1.45; }

.lb-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px 16px;
  margin: 26px 0 0;
}
.lb-card-title {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px;
  font-size: 0.95rem; font-weight: 600; margin-bottom: 8px;
}
.lb-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 0.8rem; font-weight: 400; color: var(--mute); }
.lb-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); margin-left: 8px; }
.lb-legend i.lb-dot { border-radius: 50%; width: 10px; height: 10px; }
.lb-legend i.lb-outline { background: none; border: 1.5px solid var(--axis); }
.lb-play-legend { display: flex; margin: 12px 0 2px; }
.lb-play-legend i:first-child { margin-left: 0; }
.lb-legend i.lb-tick { height: 2px; border-radius: 0; background: var(--ink); vertical-align: middle; }
.lb-chart .lb-new { animation: lb-new .5s ease both; }
@keyframes lb-new { from { opacity: 0; } to { opacity: 1; } }
.lb-caption { margin-top: 12px; font-size: 0.86rem; color: var(--mute); max-width: 760px; line-height: 1.5; }
.lb-note { margin-top: 8px; font-size: 0.84rem; color: var(--mute); line-height: 1.5; }
.lb-readout { margin-top: 6px; font-size: 0.92rem; color: var(--ink-2); min-height: 2.9em; line-height: 1.5; }

.lb-figure { margin: 34px 0 0; }
.lb-figure img { width: 100%; height: auto; display: block; }
.lb-figure figcaption { margin-top: 10px; font-size: 0.86rem; color: var(--mute); }

.lb-eq { margin: 20px 0 22px; padding: 18px 12px; overflow-x: auto; background: var(--plane); border-radius: 10px; font-size: 1.05rem; text-align: center; }

/* segmented control & buttons */
.lb-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--plane); border: 1px solid var(--line); border-radius: 9px; flex-wrap: wrap; }
.lb-seg button {
  border: 0; background: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px;
  font: inherit; font-size: 0.86rem; color: var(--mute);
}
.lb-seg button:hover { color: var(--ink); }
.lb-seg button[aria-pressed="true"], .lb-seg button[aria-selected="true"] {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line);
}
.lb-ghost {
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 0.86rem; color: var(--ink);
}
.lb-ghost:hover { border-color: var(--axis); background: var(--plane); }
.lb-btns { display: flex; gap: 8px; }
.lb-filters { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.lb-filters-results { justify-content: flex-start; margin-top: 22px; }

.lb-control { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--ink-2); }
.lb-control label { white-space: nowrap; }
.lb-control input[type=range] { flex: 1; min-width: 80px; accent-color: var(--frame); }
.lb-control output { min-width: 3.6em; text-align: right; color: var(--ink); }
.lb-sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 22px; margin: 14px 0 4px; }

.lb-chart { position: relative; width: 100%; }
.lb-chart svg { display: block; overflow: visible; }
.lb-chart text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.lb-chart .ax { font-size: 11px; fill: var(--mute); font-variant-numeric: tabular-nums; }
.lb-chart .lab { font-size: 12.5px; fill: var(--ink); }
.lb-chart .lane { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; fill: var(--mute); text-transform: uppercase; }

/* fig 2 */
.lb-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.lb-q { display: grid; gap: 2px; }
.lb-q-label { font-family: var(--mono); font-size: 0.7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.lb-q-text { font-family: var(--serif); font-size: 1.6rem; line-height: 1.15; }
.lb-q-opts { font-size: 0.9rem; color: var(--ink-2); }
.lb-grid { display: grid; gap: 6px; }
.lb-grid-rag { grid-template-columns: repeat(4, 1fr); }
.lb-grid-lembas { grid-template-columns: repeat(6, 1fr); }
.lb-grid img, .lb-grid figure img { width: 100%; height: auto; display: block; border-radius: 4px; aspect-ratio: 16/9; object-fit: cover; }
.lb-grid figure { margin: 0; }
.lb-grid figcaption { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-family: var(--mono); font-size: 0.7rem; color: var(--mute); }
.lb-grid figcaption .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.lb-grid figcaption .bar b { display: block; height: 100%; background: var(--frame); border-radius: 2px; }
.lb-fig2-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 14px; }
.lb-answer { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 999px; border: 1.5px solid var(--line); font-weight: 600; font-size: 0.92rem; }
.lb-answer .lb-bad, .lb-answer .lb-good { font-size: 1.05rem; }
.lb-bad { color: var(--bad); }
.lb-good { color: var(--good); }
.lb-fig2-note { font-size: 0.86rem; color: var(--mute); }
[hidden] { display: none !important; }

/* playground */
.lb-play-chart { margin-top: 10px; touch-action: none; }
.lb-play-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.lb-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.86rem; margin: 0; }
.lb-kv dt { color: var(--mute); }
.lb-kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.lb-compare-title { font-size: 0.86rem; font-weight: 600; margin-bottom: 6px; }
.lb-cmp-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px; font-size: 0.84rem; height: 22px; }
.lb-cmp-row .track { height: 8px; border-radius: 4px; background: var(--plane); position: relative; }
.lb-cmp-row .track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--base); transition: width .4s ease; }
.lb-cmp-row.me .track b { background: var(--frame); }
.lb-cmp-row.me { font-weight: 600; }
.lb-cmp-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* multi-turn */
.lb-mt-body { display: grid; grid-template-columns: 260px 1fr; gap: 22px; margin-top: 16px; }
.lb-chat { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: start; }
.lb-chat li {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 0.88rem; line-height: 1.4; color: var(--mute); cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}
.lb-chat li b { display: block; font-family: var(--mono); font-size: 0.68rem; letter-spacing: .1em; font-weight: 500; text-transform: uppercase; margin-bottom: 2px; }
.lb-chat li.on { border-color: var(--frame); color: var(--ink); background: #f3f8fe; }
.lb-chat li.future { opacity: .45; }
.lb-mt-totals { display: grid; gap: 6px; margin-top: 12px; }
.lb-total { display: grid; grid-template-columns: 236px 1fr 76px; align-items: center; gap: 10px; font-size: 0.84rem; }
.lb-total .track { height: 10px; border-radius: 5px; background: var(--plane); position: relative; }
.lb-total .track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; transition: width .5s ease; }
.lb-total span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* results */
.lb-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.lb-two > *, .lb-mt-body > *, .lb-play-foot > * { min-width: 0; }
.lb-details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 14px; }
.lb-details summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.lb-table-wrap { overflow-x: auto; margin-top: 12px; }
.lb-table { border-collapse: collapse; width: 100%; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.lb-table th, .lb-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lb-table th:first-child, .lb-table td:first-child { text-align: left; }
.lb-table thead th { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--axis); vertical-align: bottom; }
.lb-table .grp td { font-family: var(--mono); font-size: 0.72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); padding-top: 14px; }
.lb-table .me td { font-weight: 700; }
.lb-table td.best { color: var(--frame); }

.lb-abstract { max-width: 760px; padding-top: 0; padding-bottom: 32px; }
.lb-bib { position: relative; }
.lb-bib pre {
  background: var(--plane); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; overflow-x: auto; font-family: var(--mono); font-size: 0.82rem; line-height: 1.6;
}
.lb-copy { position: absolute; top: 10px; right: 10px; }
#mt-table .lb-table td:first-child { white-space: normal; }

/* tooltip */
.lb-tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 10px;
  font-size: 0.8rem; line-height: 1.45; max-width: 260px;
  opacity: 0; transition: opacity .12s;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.lb-tip b { font-weight: 600; }
.lb-tip .k { color: #b9b9b9; }

.m { white-space: nowrap; }

@media (max-width: 820px) {
  .lb-sliders { grid-template-columns: 1fr; }
  .lb-play-foot, .lb-two, .lb-mt-body { grid-template-columns: 1fr; }
  .lb-stats { grid-template-columns: 1fr; }
  .lb-stat + .lb-stat { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .lb-grid-lembas { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .lb-wrap, .lb-main, .lb-toc-inner { padding: 0 16px; }
  .lb-grid-rag { grid-template-columns: repeat(2, 1fr); }
  .lb-card { padding: 14px 12px; }
  .lb-chapters button { font-size: 0; }
  .lb-total { grid-template-columns: 132px 1fr 64px; }
  .lb-bib pre { padding-top: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .lb-cmp-row .track b, .lb-total .track b { transition: none; }
  .lb-chart .lb-new { animation: none; }
}
