/* ============================================================
   AERMOD Smelter Tool — Methodology page
   Palette and tokens inherited from style.css
   ============================================================ */

:root {
  --bg1: #f7f7f8;
  --bg2: #ececef;
  --bg3: #e3e3e7;
  --surface: #ffffff;
  --border: #d4d4d8;
  --border2: #a1a1aa;
  --text1: #18181b;
  --text2: #3f3f46;
  --text3: #71717a;
  --primary: #1f3864;
  --primary-hover: #15264a;
  --accent: #2e5496;
  --info: #2563eb;
  --warn: #d97706;
  --danger: #dc2626;
  --success: #059669;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text1);
  background: var(--bg1);
  font-size: 15px;
  line-height: 1.65;
}

/* ============ Header (matches the tool's main header) ============ */
header {
  background: var(--primary);
  color: white;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.3rem; font-weight: 600; }
header .subtitle { font-size: 0.85rem; opacity: 0.85; }
header .header-nav-link,
header .back-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
header .header-nav-link:hover,
header .back-link:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.6);
}
/* The first right-cluster link gets the auto margin; subsequent ones ride the
   header's gap:1rem rule. Any nav-link or back-link that follows another such
   link loses the auto margin so the cluster stays glued together on the right. */
header .header-nav-link,
header .back-link { margin-left: auto; }
header .header-nav-link ~ .header-nav-link,
header .header-nav-link ~ .back-link,
header .back-link ~ .back-link { margin-left: 0; }

/* ============ Mobile menu toggle ============ */
.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  margin: 0.8rem 1rem 0;
  width: calc(100% - 2rem);
  text-align: left;
  font-family: inherit;
}

/* ============ Layout ============ */
.doc-wrap {
  display: grid;
  grid-template-columns: 270px 1fr;
  max-width: 1180px;
  margin: 0 auto;
}

aside.toc {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.4rem 1rem 2rem 1.5rem;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  font-size: 0.85rem;
}
aside.toc h2 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 0 0 0.7rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}
aside.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
aside.toc > ul > li {
  margin: 0.3rem 0;
}
aside.toc ul ul {
  margin: 0.2rem 0 0.5rem 0.9rem;
}
aside.toc ul ul li {
  margin: 0.15rem 0;
}
aside.toc a {
  color: var(--text2);
  text-decoration: none;
  display: block;
  padding: 0.18rem 0.5rem;
  border-radius: 3px;
  border-left: 2px solid transparent;
  margin-left: -0.5rem;
  line-height: 1.4;
}
aside.toc a:hover {
  color: var(--accent);
  background: var(--bg2);
}
aside.toc a:target,
aside.toc a:focus {
  color: var(--accent);
}
aside.toc .toc-special {
  margin-bottom: 0.8rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--border);
}
aside.toc .toc-special a {
  color: var(--accent);
  font-style: italic;
}

/* ============ Main content ============ */
main.doc {
  padding: 2rem 2.5rem 4rem;
  max-width: 800px;
}

main.doc h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.4rem;
  line-height: 1.2;
}
main.doc .doc-meta {
  font-size: 0.85rem;
  color: var(--text3);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
main.doc .doc-meta strong { color: var(--text2); }

main.doc h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary);
  margin: 2.6rem 0 0.9rem;
  padding-top: 1.2rem;
  border-top: 2px solid var(--border);
  line-height: 1.3;
  scroll-margin-top: 1rem;
}
main.doc h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text1);
  margin: 1.7rem 0 0.55rem;
  scroll-margin-top: 1rem;
}

main.doc p { margin: 0 0 0.95rem; }
main.doc strong { color: var(--text1); font-weight: 600; }
main.doc em { color: var(--text2); }

main.doc ul, main.doc ol {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}
main.doc li { margin: 0.3rem 0; }
main.doc li > ul, main.doc li > ol { margin: 0.3rem 0; }

main.doc a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(46, 84, 150, 0.35);
  text-underline-offset: 2px;
}
main.doc a:hover {
  text-decoration-color: var(--accent);
}

/* ============ Executive Summary callout ============ */
.exec-summary {
  background: #f0f4fc;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 1.2rem 1.4rem 0.7rem;
  margin: 1rem 0 2.5rem;
}
.exec-summary > h2 {
  font-size: 0.9rem;
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.7rem;
  padding: 0;
  border: 0;
}
.exec-summary > p {
  margin: 0 0 0.8rem;
  font-size: 0.95rem;
}
.exec-summary h3 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1rem 0 0.4rem;
}
.exec-summary ul {
  margin: 0 0 0.6rem;
  padding-left: 1.2rem;
}
.exec-summary li {
  font-size: 0.9rem;
  margin: 0.25rem 0;
  line-height: 1.55;
}

/* ============ Tables ============ */
main.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
main.doc thead {
  background: var(--bg2);
}
main.doc th {
  text-align: left;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  /* Intentionally NOT text-transform: uppercase. CSS uppercase converts the
     micro sign µ (U+00B5) to Greek capital mu Μ (U+039C), which is visually
     indistinguishable from Latin M — so `µg/dL` renders as `MG/DL` and gets
     misread as milligrams per decilitre (a 1000× unit error). Headers stay
     in natural case so SI units display verbatim. */
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
main.doc td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text1);
  vertical-align: top;
}
main.doc tbody tr:last-child td {
  border-bottom: 0;
}
main.doc tbody tr:hover {
  background: var(--bg1);
}

/* ============ Inline code and math blocks ============ */
main.doc code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg2);
  padding: 0.12em 0.35em;
  border-radius: 3px;
  color: var(--text1);
}
main.doc pre {
  font-family: var(--mono);
  font-size: 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  line-height: 1.55;
  color: var(--text1);
}
main.doc pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ============ Institutional / research-agenda accent ============ */
.research-agenda {
  margin: 1.8rem 0 1.2rem;
  padding: 1.1rem 1.4rem 0.8rem;
  background: #f5f9ff;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.research-agenda h3 {
  margin-top: 0.2rem;
}
.research-agenda > *:last-child {
  margin-bottom: 0;
}

/* ============ Doc footer ============ */
footer.doc-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text3);
}
footer.doc-footer a { color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 800px) {
  body { font-size: 14px; line-height: 1.6; }
  header {
    padding: 0.7rem 1rem;
  }
  header h1 { font-size: 1.05rem; }
  header .subtitle { font-size: 0.75rem; }
  header .back-link {
    font-size: 0.78rem;
    padding: 0.3rem 0.6rem;
  }
  .menu-toggle { display: block; }
  .doc-wrap {
    grid-template-columns: 1fr;
  }
  aside.toc {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: none;
    display: none;
    padding: 0.8rem 1rem 1.2rem;
  }
  aside.toc.open { display: block; }
  main.doc {
    padding: 1.2rem 1.2rem 3rem;
    max-width: none;
  }
  main.doc h1 { font-size: 1.4rem; }
  main.doc h2 {
    font-size: 1.15rem;
    margin: 2rem 0 0.7rem;
    padding-top: 1rem;
  }
  main.doc table {
    font-size: 0.82rem;
  }
  main.doc th, main.doc td {
    padding: 0.45rem 0.6rem;
  }
}
