/* ============================================================
   BIE survey pages — overview (BIE_in_Scat.html) + chapter pages
   Uses the theme variables from styles.css (light / dark / pirate).
   ============================================================ */

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 2rem;
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }

/* ── Overview layout ────────────────────────────────────────── */
.project-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 3rem; align-items: start; }
.project-main { min-width: 0; }

.project-header { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border); }
.project-header-tag {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-gold-dark); margin-bottom: 0.75rem;
}
body.theme-pirate .project-header-tag { font-style: italic; text-transform: none; letter-spacing: 0.02em; font-size: 0.85rem; }
.project-header h1 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.5rem); font-weight: 300;
  letter-spacing: -0.02em; line-height: 1.2; color: var(--text-primary); margin-bottom: 1rem;
}
.project-header-lead { font-size: 1.05rem; color: var(--text-secondary); line-height: 1.7; font-weight: 300; max-width: 650px; }

.project-header-lead a { color: var(--accent); text-decoration: none; }
.project-header-lead a:hover { text-decoration: underline; }
.project-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; font-weight: 500;
  padding: 0.55rem 1.1rem; border-radius: 999px; text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { color: var(--accent); border: 1px solid var(--border-strong); background: var(--bg-card); }
.btn-secondary:hover { border-color: var(--accent); }
body.theme-pirate .btn-primary, body.theme-pirate .btn-secondary { border-radius: 0; font-style: italic; }

.project-section { margin-bottom: 3rem; }
.project-section > h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.9rem; color: var(--text-primary); }
.project-section p { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 0.75rem; }
.project-section .subhead {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-gold-dark); margin: 1.5rem 0 0.5rem;
}

/* chapter cards */
.chapter-cards { display: flex; flex-direction: column; gap: 1rem; }
.chapter-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem; box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.chapter-card:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
body.theme-pirate .chapter-card { border-radius: 2px; border: 2px solid var(--accent-gold); }
.chapter-card-num {
  font-size: 0.7rem !important; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-gold-dark) !important; margin-bottom: 0.25rem !important;
}
.chapter-card-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; line-height: 1.3; margin-bottom: 0.6rem; }
.chapter-card-title a { color: var(--text-primary); text-decoration: none; }
.chapter-card-title a:hover { color: var(--accent); }
.chapter-card-pre p { font-size: 0.9rem !important; }
.chapter-card-secs {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.75rem 0 1rem;
}
.chapter-card-secs li {
  font-size: 0.72rem; color: var(--text-secondary); background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 20px; padding: 0.15rem 0.6rem;
}
body.theme-pirate .chapter-card-secs li { border-radius: 0; }
.chapter-card-cta { font-size: 0.85rem; font-weight: 500; color: var(--accent); text-decoration: none; }
.chapter-card-cta:hover { text-decoration: underline; }

/* papers */
.papers-list { display: flex; flex-direction: column; gap: 0.85rem; }
.paper-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow); scroll-margin-top: 90px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.paper-item:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.paper-item:target { border-color: var(--accent); }
body.theme-pirate .paper-item { border-radius: 2px; border: 2px solid var(--accent-gold); }
.paper-item p { margin-bottom: 0.3rem !important; }
.paper-title { font-family: var(--font-display); font-size: 0.97rem !important; font-weight: 600; color: var(--text-primary) !important; line-height: 1.35 !important; }
.paper-num { color: var(--text-muted); font-weight: 400; margin-right: 0.2rem; }
.paper-authors { font-size: 0.8rem !important; color: var(--text-muted) !important; }
.paper-venue { font-size: 0.78rem !important; color: var(--text-muted) !important; font-style: italic; }
.paper-links { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.4rem; }
.paper-used { font-size: 0.72rem; color: var(--text-muted); }
.paper-used a { color: var(--accent); text-decoration: none; }
.paper-used a:hover { text-decoration: underline; }

/* sidebar */
.project-sidebar { display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 88px; }
.sidebar-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow);
}
body.theme-pirate .sidebar-card { border-radius: 2px; border: 2px solid var(--accent-gold); }
.sidebar-card h3 {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-gold-dark); margin-bottom: 0.75rem;
}
body.theme-pirate .sidebar-card h3 { font-style: italic; text-transform: none; letter-spacing: 0.02em; font-size: 0.88rem; }
.sidebar-members { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.sidebar-member { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.35; }
.sidebar-member a { color: var(--accent); text-decoration: none; font-weight: 500; }
.sidebar-member a:hover { text-decoration: underline; }
.sidebar-chapters { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
.sidebar-chapters a { color: var(--accent); text-decoration: none; }
.sidebar-chapters a:hover { text-decoration: underline; }
.sidebar-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.sidebar-tag {
  font-size: 0.72rem; color: var(--text-secondary); background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 20px; padding: 0.2rem 0.65rem;
}
body.theme-pirate .sidebar-tag { border-radius: 0; font-style: italic; }

/* ── Chapter page layout ────────────────────────────────────── */
.chapter-container { max-width: 1180px; }
.chapter-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 3.5rem; align-items: start; }
.chapter-main { min-width: 0; max-width: 780px; }

.chapter-header { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--border); }
.chapter-kicker {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-gold-dark); margin-bottom: 0.5rem;
}
.chapter-header h1 {
  font-family: var(--font-display); font-size: clamp(1.9rem, 4vw, 2.7rem); font-weight: 300;
  letter-spacing: -0.02em; line-height: 1.15; color: var(--text-primary); margin-bottom: 1.25rem;
}
.chapter-intro p { font-size: 1.02rem; color: var(--text-secondary); font-weight: 300; }

/* table of contents */
.chapter-toc { position: sticky; top: 88px; max-height: calc(100vh - 110px); overflow-y: auto; }
.toc-card { border-left: 2px solid var(--border); padding: 0.25rem 0 0.25rem 1.1rem; }
.toc-title {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-gold-dark); margin-bottom: 0.75rem;
}
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.toc-list a { font-size: 0.8rem; color: var(--text-secondary); text-decoration: none; line-height: 1.35; display: block; }
.toc-list a:hover, .toc-list a.active { color: var(--accent); }
.toc-l2 { padding-left: 0.9rem; }
.toc-l2 a { font-size: 0.76rem; color: var(--text-muted); }
.toc-num { color: var(--text-muted); font-variant-numeric: tabular-nums; margin-right: 0.15rem; }
.toc-foot { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.4rem; }
.toc-foot a { font-size: 0.78rem; color: var(--accent); text-decoration: none; }
.toc-foot a:hover { text-decoration: underline; }

/* ── Typeset notes ──────────────────────────────────────────── */
.tex-body { color: var(--text-primary); }
.tex-body p { font-size: 1rem; line-height: 1.75; color: var(--text-primary); margin-bottom: 1rem; }
.chapter-main .sec-heading { scroll-margin-top: 88px; font-family: var(--font-display); color: var(--text-primary); }
.chapter-main h2.sec-heading {
  font-size: 1.55rem; font-weight: 600; margin: 3rem 0 1.1rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.chapter-main h3.sec-heading { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 0.8rem; }
.sec-num { color: var(--accent-gold-dark); font-weight: 400; margin-right: 0.35rem; }
.chapter-header + h2.sec-heading { border-top: none; padding-top: 0; }
.anchor { position: relative; top: -88px; display: block; height: 0; }

.math-display { overflow-x: auto; overflow-y: hidden; margin: 0.5rem 0 1.1rem; padding: 0.1rem 0; }
mjx-container[display="true"] { margin: 0.4em 0 !important; }

/* theorem-like environments */
.thm {
  margin: 1.4rem 0; padding: 1rem 1.2rem 0.3rem; background: var(--bg-card);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; scroll-margin-top: 88px;
}
.thm:target { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.thm-definition, .thm-problem { border-left-color: var(--accent-gold); }
.thm-remark, .thm-observation, .thm-example { border-left-color: var(--border-strong); background: transparent; }
.thm-lemma, .thm-corollary, .thm-proposition { border-left-color: color-mix(in srgb, var(--accent) 60%, var(--bg-card)); }
.thm-head { margin-bottom: 0.5rem !important; }
.thm-head strong { color: var(--accent); font-weight: 600; }
.thm-definition .thm-head strong, .thm-problem .thm-head strong { color: var(--accent-gold-dark); }
.thm-remark .thm-head strong, .thm-observation .thm-head strong, .thm-example .thm-head strong { color: var(--text-secondary); }
.thm-remark p, .thm-observation p { color: var(--text-secondary); }
.thm-name { font-weight: 400; color: var(--text-secondary); }
body.theme-pirate .thm { border-radius: 0; }

.proof { margin: -0.4rem 0 1.4rem; padding: 0.4rem 0 0.2rem 1.2rem; border-left: 1px dashed var(--border-strong); position: relative; }
.proof-head { margin-bottom: 0.35rem !important; color: var(--text-secondary) !important; }
.proof .qed { display: block; text-align: right; color: var(--text-muted); margin-top: -0.6rem; }

.tex-list { margin: 0.25rem 0 1rem 1.5rem; }
.tex-list li { line-height: 1.7; margin-bottom: 0.3rem; }

a.xref, a.cite { color: var(--accent); text-decoration: none; }
a.xref:hover, a.cite:hover { text-decoration: underline; }
.cite-group { white-space: nowrap; }

/* figures: plots are drawn on white, so they sit on a white panel in every theme */
.tex-figure { margin: 1.8rem 0; scroll-margin-top: 88px; }
.fig-row {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.5rem 2%;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem; color: #1a1a1a;
}
.fig-row + .fig-row { border-top: none; border-radius: 0 0 var(--radius) var(--radius); margin-top: -1px; }
.fig-cell { display: flex; justify-content: center; }
.fig-cell img { max-width: 100%; height: auto; display: block; }
.fig-op { font-size: 1.6rem; color: #1a1a1a; }
.c-curve { width: min(320px, 90%); height: auto; color: #1a1a1a; }
.tex-figure figcaption { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.55; margin-top: 0.7rem; padding: 0 0.25rem; }
.tex-figure figcaption strong { color: var(--text-primary); }
.missing-fig { color: var(--text-muted); font-style: italic; }

/* work-in-progress placeholder */
.wip-box {
  margin: 1rem 0 1.5rem; padding: 1.1rem 1.25rem; border: 1px dashed var(--accent-gold);
  border-radius: var(--radius-lg); background: var(--bg-secondary);
}
.wip-box p { margin-bottom: 0.3rem !important; color: var(--text-secondary) !important; font-size: 0.93rem !important; }
.wip-box .wip-title { font-weight: 600; color: var(--accent-gold-dark) !important; }
.wip-box a { color: var(--accent); }

/* per-chapter references */
.chapter-refs { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.chapter-refs h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin-bottom: 1rem; scroll-margin-top: 88px; }
.ref-list { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.ref-item { display: grid; grid-template-columns: 2.4rem 1fr; font-size: 0.9rem; line-height: 1.55; color: var(--text-secondary); scroll-margin-top: 90px; border-radius: var(--radius); }
.ref-item:target { background: var(--bg-secondary); }
.ref-num { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ref-body em { color: var(--text-primary); }
.ref-title-link { color: var(--accent); text-decoration: none; }
.ref-title-link:hover { text-decoration: underline; }
.paper-title .ref-title-link { color: var(--text-primary); }
.paper-title .ref-title-link:hover { color: var(--accent); }

/* prev / next */
.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; }
.chapter-pager a {
  display: flex; flex-direction: column; gap: 0.2rem; padding: 1rem 1.2rem; text-decoration: none;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text-primary); font-family: var(--font-display); font-size: 1rem; line-height: 1.3;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chapter-pager a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.chapter-pager a span { font-family: var(--font-body); font-size: 0.72rem; color: var(--accent); letter-spacing: 0.04em; }
.pager-next { text-align: right; }
body.theme-pirate .chapter-pager a { border-radius: 0; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .chapter-layout { grid-template-columns: 1fr; }
  .chapter-toc { position: static; max-height: none; order: -1; }
  .toc-card { border-left: none; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem; background: var(--bg-card); }
}
@media (max-width: 760px) {
  .project-layout { grid-template-columns: 1fr; }
  .project-sidebar { position: static; }
}
@media (max-width: 600px) {
  .page-container.chapter-container, .overview-page .page-container { padding: 2.5rem 1rem; }
  .chapter-pager { grid-template-columns: 1fr; }
  .thm { padding: 0.9rem 0.9rem 0.2rem; }
  .fig-row { padding: 0.5rem; }
  .fig-cell[style*="width:47.5%"] { width: 100% !important; }
}
