/* ============================================================
   Note page template — the standard look for every generated
   notes/<slug>.html page. Inherits the site palette + type from
   site.css; adds the minimal top bar (name + back button, no menu,
   no language switch), the metadata header, and the reading column.
   A per-note custom <style> can override anything below.
   ============================================================ */

.note-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule-soft);
}
.note-topbar-inner {
  height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.note-back-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; font-size: 1.15rem; line-height: 1;
  color: var(--text-2); border: 1px solid var(--rule); border-radius: 8px;
  transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.note-back-btn:hover { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-dim); transform: translateX(-2px); }

/* Reading column */
.note-page main { padding: 8px 0 40px; }
.note-article { max-width: 100%; margin: 0 auto; padding: 40px 0 0; }

.note-meta { padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--rule-soft); }
.note-page-title {
  font-family: var(--font-serif); font-weight: 500; line-height: 1.18;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); color: var(--text); margin-bottom: 12px;
}
.note-byline {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px;
  font-size: .82rem; color: var(--text-muted);
}
.note-authors { color: var(--text-2); }
.note-dates { font-family: var(--font-mono); font-size: .74rem; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
/* EN | PT toggle for a paired (translated) note. */
.note-lang { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-family: var(--font-mono); font-size: .74rem; }
.note-lang-btn {
  color: var(--text-muted); text-decoration: none; border: 1px solid transparent;
  border-radius: 5px; padding: 0.12em 0.5em; letter-spacing: 0.06em; transition: color .15s, border-color .15s, background .15s;
}
.note-lang-btn:hover { color: var(--accent-2); }
.note-lang-btn.active { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-dim); cursor: default; }
.note-lang-sep { color: var(--rule); }

/* Text body */
.note-content.note-body { font-size: 1.02rem; color: var(--text); line-height: 1.8; }
.note-content.note-body p { margin-top: 20px; }
.note-content.note-body p:first-child { margin-top: 0; }
.note-content.note-body a { border-bottom: 1px solid var(--accent-line); }
.note-content .katex-display { margin: 22px 0; overflow-x: auto; overflow-y: hidden; }

/* Prose structure (Markdown-lite: headings, lists, rules, inline code) */
.note-content.note-body h2,
.note-content.note-body h3,
.note-content.note-body h4 {
  font-family: var(--font-serif); font-weight: 500; color: var(--text);
  line-height: 1.25; margin: 40px 0 0;
}
.note-content.note-body h2 { font-size: 1.5rem; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--rule-soft); }
.note-content.note-body h3 { font-size: 1.2rem; }
.note-content.note-body h4 { font-size: 1.02rem; color: var(--text-2); }
.note-content.note-body h2:first-child,
.note-content.note-body h3:first-child { margin-top: 0; }
.note-content.note-body ul { margin: 16px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; }
.note-content.note-body li { line-height: 1.6; }
.note-content.note-body hr { margin: 34px 0; border: 0; border-top: 1px solid var(--rule-soft); }
.note-content.note-body :not(pre) > code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--accent-dim); border: 1px solid var(--accent-line);
  border-radius: 5px; padding: 0.08em 0.36em; color: var(--accent-2);
  overflow-wrap: anywhere;
}

/* Interactive body — seamless, not a boxed embed. The mini-site's own
   background matches the site, so a borderless, wider-than-column frame
   reads as part of the page rather than an inset widget. */
.note-page main { padding-bottom: 0; }
.note-article[data-type="interactive"] { padding-bottom: 0; }
.note-content .note-frame-wrap {
  margin: 18px 0 0; border: 0; border-radius: 0; overflow: hidden; background: transparent;
  width: min(1120px, 96vw); margin-left: 50%; transform: translateX(-50%);
}
.note-content .note-frame { width: 100%; height: 100%; border: 0; display: block; background: transparent; }

.note-article .note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 28px; }

/* Inline images (per-note assets, embedded by id) */
.note-figure { margin: 24px 0; }
.note-figure img { display: block; max-width: 100%; height: auto; border-radius: 8px; }
.note-figure figcaption { margin-top: 8px; font-size: .82rem; color: var(--text-muted); text-align: center; }

/* Compiled TeX figures (```tex blocks → vector SVG via the note TeX engine).
   Rendered in the page's light ink on a transparent background, so a tableau
   or TikZ diagram reads as a native part of the dark page — no card. The SVG
   fills the figure's width (scaled up from its natural size by the engine),
   staying crisp because it is vector, and centres on the page. */
.note-tex {
  margin: 30px auto; display: block; width: 100%;
  overflow-x: auto; text-align: center;
}
.note-tex img, .note-tex svg { display: inline-block; width: 100%; height: auto; vertical-align: middle; }
.note-tex-error {
  margin: 24px 0; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--accent-line); background: var(--accent-dim);
  color: var(--text-2); font-size: .86rem;
}
.note-tex-error pre { margin: 8px 0 0; white-space: pre-wrap; font-family: var(--font-mono); font-size: .74rem; color: var(--text-muted); }

/* References (auto-generated, English author–year). Language-agnostic:
   a horizontal divider introduces the list — no heading. */
.note-references { margin-top: 34px; border-top: 1px solid var(--rule); padding-top: 24px; }
.note-ref-list { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; }
.note-ref-list li { font-size: .86rem; color: var(--text-2); line-height: 1.55; }
.note-ref-list li em { color: var(--text); font-style: italic; }

/* Publication landing page — download links (chips on the note body). */
.pub-dl-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 6px; }
.note-body a.pub-dl {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .02em;
  padding: 5px 12px; border: 1px solid var(--rule); border-radius: 7px;
  color: var(--text-2); border-bottom: 1px solid var(--rule);
}
.note-body a.pub-dl:hover { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-2); }

/* The note's own citation — after another divider. No worded label
   (language-agnostic): a quotation glyph marks it, then the reference text
   and a copyable BibTeX entry. */
.note-cite { margin-top: 34px; border-top: 1px solid var(--rule); padding-top: 22px; }
.note-cite-mark {
  display: block; font-family: var(--font-serif); font-size: 2.4rem;
  line-height: 0.7; height: 0.7em; color: var(--text-muted); user-select: none;
}
.note-cite-text { font-size: .88rem; color: var(--text-2); line-height: 1.6; margin: 0; overflow-wrap: anywhere; }
.note-cite-text em { color: var(--text); font-style: italic; }
.note-cite-bib {
  margin: 14px 0 0; padding: 12px 14px; overflow-x: auto; white-space: pre;
  font-family: var(--font-mono); font-size: .74rem; line-height: 1.6; color: var(--text-muted);
  background: transparent; border: 1px solid var(--rule-soft); border-radius: 8px;
}
/* Inline author–year citations sit inside the prose already; nothing extra. */

/* Runnable code cells (Python / Lean) — display + ▶ + output.
   Background matches the page; a border delimits the cell (no filled panel). */
.note-cells { margin-top: 30px; display: flex; flex-direction: column; gap: 18px; }
.note-cell { border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: transparent; }
.note-cell-head {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: transparent; border-bottom: 1px solid var(--rule-soft);
}
.note-cell-lang {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-2); background: var(--accent-dim); border: 1px solid var(--accent-line);
  border-radius: 3px; padding: 2px 7px;
}
.note-cell-label { font-size: .86rem; color: var(--text-2); flex: 1; min-width: 0; }
.note-cell-run {
  margin-left: auto; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; font-size: .8rem; cursor: pointer;
  color: var(--accent-2); background: var(--accent-dim); border: 1px solid var(--accent-line); border-radius: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.note-cell-run:hover { background: var(--accent-2); color: var(--bg); border-color: var(--accent-2); }
.note-cell-run.is-running { opacity: .5; cursor: default; }
.note-cell-code {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; color: var(--text);
  white-space: pre; tab-size: 2;
}
.note-cell-out {
  margin: 0; padding: 12px 16px; border-top: 1px dashed var(--rule);
  background: transparent; font-family: var(--font-mono); font-size: .8rem; line-height: 1.55;
  color: var(--accent-2); white-space: pre-wrap; word-break: break-word;
}
.note-cell-out.is-running { color: var(--text-muted); }
.note-cell-out.is-error { color: #E0A17F; }

/* Language-agnostic footer: name + copyright year · published date (DD-MM-YYYY) */
.note-footer { border-top: 1px solid var(--rule-soft); margin-top: 64px; padding: 26px 0; }
.note-footer-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.note-copy { font-size: .82rem; color: var(--text-muted); }
.note-pubdate { font-family: var(--font-mono); font-size: .74rem; letter-spacing: 0.03em; color: var(--text-muted); font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .note-article { padding-top: 28px; }
}
