:root {
  --font-size: 20px;
  --header-footer-bg: rgba(255, 255, 255, 0.7);
  --header-footer-border: rgba(0, 0, 0, 0.08);
  --header-footer-height: 60px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --text: #e5e7eb;
  --accent: #60a5fa;
  --card: #1e293b;
  --header-footer-bg: rgba(15, 23, 42, 0.7);
  --header-footer-border: rgba(255, 255, 255, 0.08);
}

[id^="fn"],
[id^="ref"] {
  scroll-margin-top: var(--header-footer-height);
}

.cite-link{
  scroll-margin-top: var(--header-footer-height);
}

/* Put this on bibliography entries */
.references li{
  scroll-margin-top: var(--header-footer-height);
}

#main {
  flex: 1;
  font-size: var(--font-size);
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  text-justify: inter-word;
  font-family: 'Open Sans', sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 60%;
  margin-left: 20%;
  margin-top: 60px;
  margin-bottom: 60px;
}

a {
  color: #4F9CF9;
  text-decoration: none;
}

a:hover {
  color: #7AB8FF;
  text-decoration: underline;
}

a:visited {
  color: #A78BFA;
}

header,
footer {
  font-size: 24 px;
  position: fixed;
  left: 0;
  width: 100%;

  display: flex;
  justify-content: center;  /* centers content horizontally */
  align-items: center;       /* centers vertically */

  height: var(--header-footer-height);
  background: var(--bg);
  color: var(--text);
  z-index: 1000;
  background: var(--header-footer-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  border-color: var(--header-footer-border);
}

header {
  top: 0;
}

footer {
  bottom: 0;
  display: flex;
  gap: 20px;
}

#face {
float:left;
}

.footnotes ol {
  font-size: calc(var(--font-size) - 4px);
}

/* ================================
   SCROLLABLE LABELED EQUATIONS
   MathJax v3 (equation, align, tag)
================================ */

/* 1. OUTER CONTAINER SCROLL */
mjx-container[jax="CHTML"][display="true"] {
  display: block !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* 2. FORCE AMS TABLE TO DEFINE WIDTH (CRITICAL) */
mjx-container[jax="CHTML"] mjx-mtable {
  display: inline-block !important;
  width: max-content !important;
  min-width: 100% !important;
}

/* 3. PREVENT ROW SHRINKING */
mjx-container[jax="CHTML"] mjx-mtr {
  width: max-content !important;
}

/* 4. EQUATION NUMBER FIX (so it doesn’t break layout) */
mjx-container[jax="CHTML"] mjx-eqn {
  position: sticky;
  right: 0;
  background: inherit;
}

/* 5. SAFETY: prevent flex/grid parents breaking scroll */
mjx-container {
  min-width: 0 !important;
}
mjx-mtable { width: max-content; }

mjx-container a[href*="mjx-eqn"] {
  color: #bb6627;
}

table {
  border-collapse: collapse;
  border: 2px solid rgb(140 140 140);
  font-size: calc(var(--font-size) - 4px);
  letter-spacing: 1px;
}

caption {
  caption-side: top;
  padding: --font-size;
  font-weight: bold;
}

thead,
tfoot {
  background-color: var(--bg);
}

th,
td {
  border: 1px solid rgb(160 160 160);
  padding: 8px 10px;
}

td:last-of-type {
  text-align: center;
}

tbody > tr:nth-of-type(even) {
  background-color: var(--bg);
}

tfoot th {
  text-align: right;
}

tfoot td {
  font-weight: bold;
}
