/* Web look of the guide.
   - Site chrome (top bar, sidebar, typography) follows the Texas Air Quality
     Portal strategies page.
   - Tables, equations, figures and captions follow the MOSERS web application
     (mosers_app/utils/shared_style.py and static_files/mosers_styles.py).
   The PDF equivalents live in pdf-preamble.tex; guide.lua maps the same class
   names onto them. */

/* Libre Franklin is shipped with the site (styles/fonts/, SIL Open Font
   License) so no page depends on an outside font service. The upright file is
   a variable font covering every weight used here. */
@font-face {
  font-family: "Libre Franklin";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/libre-franklin-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Libre Franklin";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/libre-franklin-latin-italic.woff2") format("woff2");
}

:root {
  /* Portal palette */
  --portal-navy: #14375a;
  --portal-blue: #396aa2;
  --portal-ink: #1a202c;
  --portal-text: #2d3748;
  --portal-muted: #718096;
  --portal-band: #f2f6fa;
  --portal-rule: #e2e8f0;
  --portal-accent: #f5a524;

  /* Web application palette */
  --app-primary: #3498db;
  --app-primary-dark: #2980b9;
  --app-secondary: #2c3e50;
  --app-light: #f8f9fa;
  --app-hover: #eaf6ff;
  --app-border: #e0e0e0;
  --app-note: #666666;
  --app-radius: 6px;
  --app-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ----- site chrome ------------------------------------------------------ */

body {
  color: var(--portal-text);
  font-family: "Franklin Gothic", "Franklin Gothic Book", "Libre Franklin", Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* The body column is wide (see grid in _quarto.yml) so tables and equations
   can use the room; running text keeps a readable line length. */
main.content :is(section, #quarto-document-content) > :is(p, ul, ol),
main.content .strategy-summary {
  max-width: 80ch;
}

.navbar {
  background-color: var(--portal-navy) !important;
}

/* Embedded in a frame (class set by embedded.html): the host page has its own
   header, so the guide's top bar goes. The bar under it, which holds the
   sidebar toggle on narrow screens, stays; the layout script sizes the top
   offset from whatever remains of the header. */
.embedded #quarto-header > nav.navbar {
  display: none;
}

.embedded body.nav-fixed {
  padding-top: 0;
}

/* Desktop sidebar: the category legend and search stay put and only the
   chapter list scrolls (sidebar-scroll.html brings the current page into view). */
@media (min-width: 992px) {
  #quarto-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
  }

  #quarto-sidebar .quarto-sidebar-header {
    position: static;
    flex: 0 0 auto;
  }

  #quarto-sidebar .sidebar-menu-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  /* Keep the legend, search and chapter list close together: each block
     otherwise brings its own top padding and margins. */
  #quarto-sidebar .category-legend {
    margin-bottom: 0;
  }

  #quarto-sidebar .quarto-sidebar-header + div {
    margin-top: 0 !important;
    padding-top: 0.25rem;
  }

  #quarto-sidebar .sidebar-menu-container {
    padding-top: 0;
  }
}

/* Sidebar search: a "Search" label beside the icon, set like the entries below it. */
#quarto-sidebar .aa-DetachedSearchButton {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 0.5rem 0.25rem;
  color: var(--portal-blue);
}

#quarto-sidebar .aa-DetachedSearchButton::after {
  content: "Search";
  margin-left: 0.5rem;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}

#quarto-sidebar .aa-DetachedSearchButton:hover {
  color: var(--portal-navy);
}

.navbar .navbar-brand,
.navbar .navbar-title {
  color: #ffffff !important;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.navbar .aa-DetachedSearchButton,
.navbar .navbar-toggler,
.navbar .bi {
  color: #ffffff;
}

h1,
h2,
h3,
h4 {
  color: var(--portal-ink);
  font-weight: 700;
}

h1.title {
  font-size: 1.9rem;
}

h2 {
  margin-top: 2rem;
  padding-bottom: 0;
  border-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  font-size: 1.15rem;
}

a {
  color: var(--portal-blue);
}

a:hover {
  color: var(--portal-navy);
}

/* Left sidebar: the portal's vertical strategy list. */
#quarto-sidebar {
  border-right: 1px solid var(--portal-rule);
}

.sidebar-navigation .sidebar-item {
  margin: 0;
  padding: 0;
}

.sidebar-navigation .sidebar-link,
.sidebar-navigation .sidebar-item-text {
  display: block;
  padding: 0.5rem 0.25rem;
  border-bottom: 2px solid transparent;
  color: var(--portal-blue);
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}

.sidebar-navigation .sidebar-link:hover {
  border-bottom-color: var(--portal-muted);
  color: var(--portal-navy);
}

.sidebar-navigation .sidebar-link.active,
.sidebar-navigation .sidebar-link.active:hover {
  border-bottom-color: var(--portal-navy);
  color: var(--portal-navy);
  font-weight: 600;
}

.sidebar-navigation .sidebar-section .sidebar-section .sidebar-link,
.sidebar-navigation ul ul .sidebar-link {
  font-size: 0.92rem;
}

#TOC .nav-link.active {
  border-left-color: var(--portal-navy);
  color: var(--portal-navy);
}

.nav-page a {
  color: var(--portal-blue);
}

/* One-line statement of what the chapter or strategy does. */
.strategy-summary {
  margin: 0 0 1.5rem;
}

.strategy-summary p {
  margin: 0;
}

/* ----- tables (web application style) ---------------------------------- */

main table {
  /* Let the row colours below show through Bootstrap's per-cell background. */
  --bs-table-bg: transparent;
  --bs-table-accent-bg: transparent;
  width: 100%;
  margin-bottom: 20px;
  border-collapse: collapse;
  border-radius: 4px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

main table thead th {
  padding: 12px 15px;
  border-bottom: 2px solid var(--app-primary-dark);
  background-color: var(--app-primary) !important;
  color: #ffffff !important;
  font-weight: bold;
  text-align: left;
}

main table td {
  padding: 10px 15px;
  border-bottom: 1px solid var(--app-border);
  text-align: left;
  vertical-align: top;
}

main table tbody tr:nth-child(even) {
  background-color: var(--app-light);
}

main table tbody tr:hover {
  background-color: var(--app-hover);
  transition: background-color 0.2s ease;
}

main table td:first-child,
main table th:first-child {
  font-weight: bold;
}

.var-table,
.input-table {
  overflow-x: auto;
}

.var-table td:first-child {
  white-space: nowrap;
}

/* Source line under a table, and captions: the application's note text. */
.table-note,
figcaption,
.figure-caption,
caption,
.table-caption {
  color: var(--app-note);
  font-size: 13px;
  font-style: italic;
  line-height: 1.4;
  text-align: left;
}

.table-note {
  margin: -10px 0 1.5rem;
}

.table-note p {
  margin: 0;
}

/* ----- equations (web application card) --------------------------------- */

/* The strategy's main equation: card header + body. */
.eq-primary {
  margin: 1.75rem 0 0;
  border-radius: var(--app-radius) var(--app-radius) 0 0;
  background: #ffffff;
  box-shadow: var(--app-shadow);
  overflow-x: auto;
}

.eq-primary::before {
  content: "Equation";
  display: block;
  padding: 12px 20px;
  background-color: var(--app-secondary);
  color: #ffffff;
  font-weight: bold;
}

/* A numbered label ("Equation 1") set with {.eq-primary label="..."}. */
.eq-primary[data-label]::before {
  content: attr(data-label);
}

.eq-primary p {
  margin: 0;
  padding: 0.6rem 20px;
}

.eq-primary .katex-display,
.eq-primary math[display="block"] {
  margin: 0.4rem 0;
  text-align: left;
}

.eq-primary .katex-display > .katex {
  text-align: left;
}

/* The terms (A, B, ...) of the main equation, each with its description. */
.eq-terms {
  margin: 0 0 1.75rem;
  padding: 0.25rem 20px 0.75rem;
  border-top: 1px solid var(--app-border);
  border-radius: 0 0 var(--app-radius) var(--app-radius);
  background: #ffffff;
  box-shadow: var(--app-shadow);
}

.eq-term {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--app-border);
  overflow-x: auto;
}

.eq-term:last-child {
  border-bottom: 0;
}

.eq-term p {
  margin: 0;
}

.eq-term .katex-display,
.eq-term math[display="block"] {
  margin: 0.2rem 0 0.35rem;
  text-align: left;
}

.eq-term .katex-display > .katex {
  text-align: left;
}

.eq-term p:not(:first-child) {
  color: var(--app-note);
  font-size: 0.95rem;
}

.eq-subheading {
  margin-top: 0.75rem;
  color: var(--app-secondary);
  font-size: 18px;
  font-weight: bold;
}

.eq-subheading p {
  margin: 0;
}

/* ----- figures (web application card) ----------------------------------- */

main figure,
.quarto-figure {
  margin: 1.5rem 0;
  padding: 15px;
  border-radius: var(--app-radius);
  background: #ffffff;
  box-shadow: var(--app-shadow);
}

main figure img,
.quarto-figure img {
  max-width: 100%;
  height: auto;
}

main figure figcaption {
  margin-top: 10px;
}
