/* style.css — belief-cost-geometry project page.
   Lightweight monospace page (Sparkling-Wasure style) that keeps the two
   interactive canvas figures + KaTeX. Figure semantics (belief=violet,
   info=blue, energy=orange) mirror js/util.js; the canvas .stage stays light
   in both themes. Single self-contained sheet — no Bulma, no template. */

:root {
  --bg: #fdfdfb; --fg: #1a1a1a; --muted: #6a6a6a;
  --accent: #b5121b; --accent-hover: #8e0e15; --line: #e2e2dd; --code-bg: #f4f4f0;
  /* figure semantics */
  --belief: #6D28D9; --info: #1E6FB8; --energy: #C2410C; --proved: #0E7C5A;
  --ink: #15171C; --ink-2: #5B606B; --hair: #DCDCE4;
  --surface: #ffffff; --surface-2: #f4f4fa;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "IBM Plex Mono",
          Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  --bg: #11131a; --fg: #d6d6d0; --muted: #7e8696;
  --accent: #ff5f6d; --accent-hover: #ff8088; --line: #232631; --code-bg: #171a22;
  --ink: #d6d6d0; --ink-2: #9aa1ad; --hair: #222633;
  --surface: #171a22; --surface-2: #1b1e27;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .25);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #11131a; --fg: #d6d6d0; --muted: #7e8696;
    --accent: #ff5f6d; --accent-hover: #ff8088; --line: #232631; --code-bg: #171a22;
    --ink: #d6d6d0; --ink-2: #9aa1ad; --hair: #222633;
    --surface: #171a22; --surface-2: #1b1e27;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0; color: var(--fg);
  font-family: var(--mono); font-size: 15px; line-height: 1.6;
}
main { max-width: 54rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

a {
  color: var(--fg); text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 2px;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.prompt { color: var(--accent); margin-right: .1rem; }
em { font-style: italic; }
strong { font-weight: 600; }

/* back link + theme toggle */
.back { margin: 0 0 1.75rem; font-size: .9rem; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--accent); }
.theme-toggle {
  position: fixed; top: .8rem; right: .8rem; z-index: 50;
  font: 600 12px var(--mono); color: var(--muted);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: .2rem .55rem; cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* header */
.page-head { text-align: center; }
.page-head h1 { font-size: 1.7rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.tagline { color: var(--fg); margin: .6rem auto .9rem; max-width: 40rem; }
.authors { margin: .5rem 0 .2rem; }
.authors a { color: var(--accent); text-decoration: none; }
.authors a:hover { text-decoration: underline; }
.venue { color: var(--muted); font-size: .85rem; margin: .2rem 0 .9rem; }
.links { font-size: .95rem; margin: 0; }

/* sections */
section { margin-top: 2.75rem; }
section.teaser { margin-top: 2rem; }
h2 {
  font-size: 1.05rem; font-weight: 600; margin: 0 0 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--line);
}
h2::before { content: "# "; color: var(--accent); }
h3 { font-size: .95rem; font-weight: 600; margin: 1.6rem 0 .7rem; }
h3::before { content: "## "; color: var(--accent); }
section p { margin: 0 0 1rem; }
section p:last-child { margin-bottom: 0; }
section ul { padding-left: 1.2rem; margin: 0 0 1rem; }
section li { margin: 0 0 .6rem; font-size: .95rem; line-height: 1.6; }
.btn.active { border-color: var(--belief); color: var(--belief); }
.fig-lead { text-align: center; color: var(--fg); margin: 1rem auto 0; max-width: 44rem; }
.closing { text-align: center; color: var(--muted); margin-top: .8rem; }

/* ---- interactive figures (canvas + controls) --------------------------- */
.fig { margin: 1.25rem 0 .5rem; }
.stage { border: 1px solid var(--line); border-radius: 12px; background: #FBFBFE; padding: 10px; overflow: hidden; }
.fig canvas { display: block; width: 100%; border-radius: 6px; touch-action: none; }
.caption { font-size: .92rem; line-height: 1.55; color: var(--ink-2); margin: .8rem .2rem 0; text-align: center; }
.caption b { color: var(--ink); font-weight: 650; }
.figerr { color: var(--energy); font: 13px var(--mono); padding: 20px; }

/* collapsible step-by-step legend (native <details>) */
.legend-list { margin: 1rem 0 .5rem; }
.legend-list details { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); margin: 0 0 .5rem; overflow: hidden; }
.legend-list summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .55rem;
  padding: .6rem .9rem; font-weight: 650; color: var(--fg); user-select: none; }
.legend-list summary::-webkit-details-marker { display: none; }
.legend-list summary::before { content: "▸"; color: var(--muted); font-size: .8em; transition: transform .15s ease; }
.legend-list details[open] > summary::before { transform: rotate(90deg); }
.legend-list summary:hover { background: var(--surface-2); }
.legend-list details[open] > summary { border-bottom: 1px solid var(--line); }
.legend-list details > p { margin: 0; padding: .7rem .95rem .85rem; font-size: .92rem; line-height: 1.6; color: var(--ink-2); }

.controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: center; margin: .75rem .2rem 0; }
.ctl { display: flex; align-items: center; gap: 8px; font: 500 12.5px/1 var(--mono); color: var(--ink-2); }
.sl-lab { white-space: nowrap; }
input[type=range].sl { -webkit-appearance: none; appearance: none; height: 4px; width: 120px; border-radius: 3px; background: var(--line); outline: none; margin: 0; }
input[type=range].sl::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--belief); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--hair); cursor: pointer; }
input[type=range].sl::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: var(--belief); cursor: pointer; }
input[type=range].sl-info::-webkit-slider-thumb { background: var(--info); }
input[type=range].sl-info::-moz-range-thumb { background: var(--info); }
input[type=range].sl-energie::-webkit-slider-thumb { background: var(--energy); }
input[type=range].sl-energie::-moz-range-thumb { background: var(--energy); }
.sl-val { font: 600 12px var(--mono); color: var(--ink); min-width: 62px; }
.btn { font: 600 12.5px var(--mono); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; cursor: pointer; }
.btn:hover { border-color: var(--belief); color: var(--belief); }
.tg { display: inline-flex; align-items: center; gap: 7px; font: 500 12.5px var(--mono); color: var(--ink-2); cursor: pointer; }
.readouts { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: .75rem .2rem 0; }
.ro { display: inline-flex; align-items: baseline; gap: 6px; font: 600 12px var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; }
.ro-k { color: var(--ink-2); font-weight: 500; }
.ro-v { color: var(--ink); }
.ro-soudure { color: var(--belief); } .ro-info { color: var(--info); } .ro-energie { color: var(--energy); } .ro-encre { color: var(--ink); }

/* ---- the central problem, boxed ---------------------------------------- */
.problembox {
  border: 1px solid var(--hair); border-left: 3px solid var(--belief);
  background: var(--surface-2); border-radius: 8px; padding: 1rem 1.15rem; margin: 1.1rem 0 0;
  font-style: italic; color: var(--ink); text-align: left;
}

/* highlighted key result (dimensionless metric / nats) */
.keybox {
  border: 1px solid var(--hair); border-left: 4px solid var(--belief);
  background: var(--surface-2); border-radius: 8px; padding: 1rem 1.2rem; margin: 1.5rem 0 .5rem;
}
.keybox p { margin: 0; font-size: .96rem; line-height: 1.66; color: var(--ink); text-align: left; }
.keybox strong { color: var(--belief); }

/* abstract: headline results as a marked list */
.abstract-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.abstract-list li { position: relative; padding-left: 1.15rem; margin: .55rem 0; font-size: .98rem; line-height: 1.6; color: var(--ink); text-align: left; }
.abstract-list li::before { content: "\203A"; position: absolute; left: .15rem; color: var(--belief); font-weight: 700; }
.abs-group { font-weight: 650; color: var(--ink); margin: 1rem 0 .1rem; }

/* ---- card grids -------------------------------------------------------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.25rem; }

.post { height: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); padding: 1.4rem 1.4rem 1.2rem; }
.post .tag { display: inline-block; font: 700 12px/1 var(--mono); letter-spacing: .02em; color: #fff; background: var(--belief); padding: 6px 11px; border-radius: 6px; margin-bottom: .7rem; }
.post h3 { font: 650 1.15rem/1.3 var(--mono); color: var(--ink); margin: .1rem 0 .5rem; }
.post p { font-size: .98rem; line-height: 1.6; color: var(--ink); margin: .4rem 0; text-align: left; }
.ladder { font-size: .98rem; color: var(--ink-2); margin-top: 1.1rem; text-align: center; }

.res { height: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 1.1rem 1.15rem; }
.res .rk { font: 700 12px/1 var(--mono); letter-spacing: .02em; text-transform: uppercase; color: var(--belief); }
.res h3 { font: 650 1.02rem/1.3 var(--mono); color: var(--ink); margin: .5rem 0 .35rem; }
.res p { font-size: .92rem; line-height: 1.55; color: var(--ink-2); margin: .3rem 0; text-align: left; }

/* ---- KaTeX ------------------------------------------------------------- */
.katex { font-size: 1.03em; }
.formula-center { margin: .9rem 0; text-align: center; overflow-x: auto; }
.post .formula-center { margin: .7rem 0 0; }

/* ---- bibtex ------------------------------------------------------------ */
.bibtex {
  position: relative; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 1rem 1.1rem; margin: 0; overflow-x: auto;
}
.bibtex code { font-family: var(--mono); font-size: .8rem; line-height: 1.5; color: var(--fg); white-space: pre; }
.copy {
  position: absolute; top: .55rem; right: .55rem;
  font: 600 11px var(--mono); color: var(--muted);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: .15rem .45rem; cursor: pointer;
}
.copy:hover { color: var(--accent); border-color: var(--accent); }

/* ---- footer ------------------------------------------------------------ */
footer {
  margin-top: 3.5rem; padding-top: 1rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .8rem;
}
footer p { margin: 0 0 .3rem; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* ---- mobile ------------------------------------------------------------ */
@media (max-width: 46rem) {
  .cards, .cards-3 { grid-template-columns: 1fr; }
}
@media (max-width: 30rem) {
  .page-head h1 { font-size: 1.4rem; }
}
