/* monitoring/style.css — paper page typography & sidebar layout */

:root {
  --fg: #1a1a1a;
  --fg-soft: #4a4a4a;
  --fg-mute: #6a6a6a;
  --bg: #fdfdfc;
  --bg-side: #f5f3ef;
  --accent: #8a1a1a;          /* HKUST-ish red, used sparingly */
  --rule: #d8d3c8;
  --link: #1a4480;
  --link-hover: #8a1a1a;
  --max-content: 760px;
  --sidebar-w: 300px;
  --font-serif: "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.skip-link {
  position: absolute; left: -9999px;
}
.skip-link:focus {
  left: 12px; top: 12px; background: #fff; padding: 6px 10px;
  border: 1px solid var(--rule); z-index: 100;
}

/* ===== Layout ===== */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--rule);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-inner {
  padding: 28px 22px 40px;
  font-family: var(--font-sans);
  font-size: 14px;
}

.sidebar-back a {
  color: var(--fg-mute);
  text-decoration: none;
  font-size: 13px;
}
.sidebar-back a:hover { color: var(--link-hover); }

.paper-short {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.3;
  margin: 18px 0 8px;
  color: var(--fg);
  font-weight: 600;
}

.paper-author { margin: 0; color: var(--fg-soft); }
.paper-date   { margin: 2px 0 18px; color: var(--fg-mute); font-size: 13px; }

.pdf-download {
  display: inline-block;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 3px;
  margin-bottom: 26px;
  transition: background 0.15s;
}
.pdf-download:hover { background: #6c1414; }

.toc-heading {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.toc ul { list-style: none; padding: 0; margin: 0; }
.toc > ul { margin-bottom: 0; }
.toc ul ul { padding-left: 14px; font-size: 13px; }
.toc li { margin: 4px 0; }
.toc a {
  color: var(--fg-soft);
  text-decoration: none;
  display: block;
  padding: 2px 0;
  border-left: 2px solid transparent;
  padding-left: 8px;
  margin-left: -10px;
  transition: color 0.12s, border-color 0.12s;
}
.toc a:hover { color: var(--link-hover); }
.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ===== Main content ===== */

.content {
  padding: 56px 64px 80px;
  max-width: calc(var(--max-content) + 128px);
}

.paper-header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 28px;
  margin-bottom: 36px;
}

.paper-title {
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.paper-byline {
  font-size: 16px;
  margin: 0;
  color: var(--fg-soft);
}

.paper-affil {
  font-size: 13px;
  color: var(--fg-mute);
  margin: 4px 0 16px;
  line-height: 1.5;
}

.paper-date-inline {
  font-size: 14px;
  color: var(--fg-mute);
  margin: 0 0 24px;
  font-style: italic;
}

.abstract {
  background: #fafaf7;
  border-left: 3px solid var(--accent);
  padding: 18px 22px;
  margin: 24px 0 18px;
  font-size: 17px;
  line-height: 1.6;
}

.abstract-heading {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 0 10px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.abstract p { margin: 0; }
.abstract p + p { margin-top: 12px; }

.paper-keywords, .paper-jel {
  font-size: 14px;
  color: var(--fg-soft);
  margin: 6px 0;
}

/* ===== Headings ===== */

.paper-body h1, .paper-body h2, .paper-body h3, .paper-body h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.003em;
  scroll-margin-top: 16px;
}

.paper-body h1, .paper-body h2 {
  font-size: 24px;
  margin: 48px 0 14px;
  padding-bottom: 4px;
}

.paper-body h3 {
  font-size: 19px;
  margin: 32px 0 10px;
  color: var(--fg-soft);
}

.paper-body h4 {
  font-size: 17px;
  margin: 24px 0 8px;
  font-style: italic;
  color: var(--fg-soft);
}

/* Section numbers from pandoc --number-sections */
.header-section-number {
  color: var(--fg-mute);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* ===== Body text ===== */

.paper-body p { margin: 0 0 14px; text-align: justify; hyphens: auto; }
.paper-body a { color: var(--link); text-decoration: none; border-bottom: 1px solid rgba(26,68,128,0.25); }
.paper-body a:hover { color: var(--link-hover); border-bottom-color: var(--link-hover); }

.paper-body ul, .paper-body ol { padding-left: 26px; margin: 0 0 16px; }
.paper-body li { margin: 6px 0; }

.paper-body blockquote {
  border-left: 3px solid var(--rule);
  margin: 16px 0;
  padding: 4px 18px;
  color: var(--fg-soft);
  font-style: italic;
}

/* ===== Theorem-like blocks ===== */

.theorem-block {
  margin: 22px 0;
  padding: 14px 18px 14px 20px;
  border-left: 3px solid var(--rule);
  background: #faf9f6;
  font-style: italic;
}

.theorem-block.theorem,
.theorem-block.lemma,
.theorem-block.proposition,
.theorem-block.corollary {
  border-left-color: var(--accent);
}

.theorem-block.assumption,
.theorem-block.definition {
  border-left-color: #6b6b6b;
  background: #f7f6f3;
}

.theorem-block.remark,
.theorem-block.implication {
  border-left-color: var(--rule);
  background: transparent;
  font-style: normal;
}

.theorem-head {
  font-style: normal;
  font-weight: 700;
  color: var(--fg);
  margin-right: 6px;
}

.theorem-block p { margin: 0 0 10px; }
.theorem-block p:last-child { margin-bottom: 0; }

/* ===== Proofs ===== */

.proof-block {
  margin: 18px 0 26px;
  padding-left: 14px;
  border-left: 2px dotted var(--rule);
  color: var(--fg-soft);
}

.proof-head { color: var(--fg); font-style: italic; }
.proof-block p:last-child .qed {
  float: right;
  font-size: 18px;
  color: var(--fg);
}
.qed { font-style: normal; }

/* ===== Math ===== */

mjx-container[display="true"] {
  margin: 14px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

mjx-container { color: var(--fg); }

/* Equation numbers (right-aligned) */
mjx-container[display="true"][jax="CHTML"] {
  text-align: center;
}

/* ===== Figures ===== */

figure {
  margin: 28px auto;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: #fff;
}

figcaption {
  font-size: 14px;
  color: var(--fg-soft);
  margin-top: 10px;
  font-style: italic;
  text-align: center;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Tables ===== */

table {
  border-collapse: collapse;
  margin: 20px auto;
  font-size: 15px;
  width: auto;
}

th, td {
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

thead th { border-top: 2px solid var(--fg); border-bottom: 1px solid var(--fg); }
tbody tr:last-child td { border-bottom: 2px solid var(--fg); }

/* ===== Footnotes ===== */

.footnotes {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--fg-soft);
}
.footnotes ol { padding-left: 22px; }
.footnotes p { margin: 4px 0; }

/* ===== References ===== */

#refs, .references {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

#refs .csl-entry, .references .csl-entry {
  margin: 10px 0;
  padding-left: 24px;
  text-indent: -24px;
  font-size: 15px;
  line-height: 1.5;
}

/* ===== Footer ===== */

.paper-footer {
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--fg-mute);
  text-align: center;
}

/* ===== Responsive ===== */

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .sidebar-inner { padding: 20px 22px 24px; }
  .toc { max-height: 240px; overflow-y: auto; }
  .content { padding: 32px 24px 56px; }
  .paper-title { font-size: 25px; }
}

@media print {
  .sidebar, .paper-footer { display: none; }
  .layout { display: block; }
  .content { padding: 0; max-width: 100%; }
  body { font-size: 11pt; }
}
