/* Custom theme overrides: dark-first, readable, and simple to maintain. */
:root {
  --sidebar-w: 16.5rem;
  --bg: #e8e8e8;
  --panel: #272d36;
  --panel-2: #303845;
  --text: #e8edf2;
  --text-muted: #d0d8e0;
  --border: #455062;
  --link: #89c4ff;
  --link-hover: #b5dbff;
  --code-bg: #0b0f16;
  --code-border: #2b3647;
  --task: #f0a647;
  --tip: #57b5ff;
  --question: #6fd68a;
  --answer: #49c172;
  --glow: rgba(137, 196, 255, 0.12);
}

body {
  background:
    radial-gradient(900px 500px at 20% -10%, #1a2638 0%, transparent 60%),
    radial-gradient(900px 500px at 90% -20%, #1c2037 0%, transparent 62%),
    var(--bg);
}

.site-header,
.side-bar,
.search-input-wrap {
  background: var(--bg);
  color: var(--text);
}

.main,
.main-content-wrap {
  background: var(--bg);
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

/* Center the reading column and prevent right-biased layout. */
@media (min-width: 66.5rem) {
  .side-bar {
    width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    left: 0;
  }

  .main,
  .side-bar + .main {
    max-width: none;
    width: auto;
    margin-left: var(--sidebar-w);
    margin-right: 0;
  }

  .main-content-wrap,
  .main .main-content-wrap {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: clamp(0.75rem, 5vw, 10rem);
    padding-right: clamp(0.75rem, 10vw, 20rem);
  }

  .main-header,
  .main .main-header {
    padding-left: 0.35rem;
    padding-right: 0.75rem;
  }
}

/* Improve nav readability. */
.side-bar {
  background: var(--panel);
  border-right: 1px solid #223047;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
}

.site-header {
  height: auto;
  max-height: none;
  min-height: 0;
  padding: 0.9rem 1.1rem 0.75rem;
  border-bottom: 1px solid #223047;
  background: var(--panel);
  text-align: left;
  justify-content: flex-start;
}

.side-bar .site-header {
  height: auto;
  max-height: none;
  overflow: visible;
}

.site-title {
  display: block;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
  white-space: normal;
  text-align: left;
}

.side-bar .site-title,
.side-bar .site-title:link,
.side-bar .site-title:visited {
  color: #e8edf2;
}

.side-bar .site-title::before {
  content: "";
  display: block;
  width: min(100%, 14rem);
  aspect-ratio: 1024 / 250;
  margin: 0 0 0.65rem;
  background-image: url("/astronuc/Figures/MESA_logo.png");
  background-size: contain;
  background-position: left center;
  background-repeat: no-repeat;
}

.site-title .site-logo {
  display: none;
  width: min(100%, 14rem);
  height: auto;
  margin: 0 0 0.65rem;
}

.side-bar .site-title::after {
  content: "Astronuc: Nuclear Reactions and Networks in Stars with MESA";
  display: block;
  margin-top: 0.15rem;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  color: #e8edf2;
}

@media (max-width: 66.499rem) {
  .side-bar .site-header {
    min-height: 17.5rem;
    padding-bottom: 1.2rem;
    align-items: flex-start;
  }
}

.nav-list .nav-list-link {
  font-size: 1.08rem;
  line-height: 1.5;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-radius: 6px;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav-list .nav-list-link:hover {
  background: #1c293d;
}

.nav-list .nav-list-item > .nav-list-link.active {
  background: #1f2a3a;
  border-left: 3px solid var(--link);
  box-shadow: inset 0 0 0 1px #314866;
}

.side-bar .sidebar-page-toc {
  margin: 0.3rem 0 0.5rem 0.65rem;
  padding-left: 0.2rem;
  border-left: 1px solid #314866;
}

.side-bar .sidebar-page-toc .nav-list-link {
  font-size: 0.92rem;
  line-height: 1.35;
  padding: 0.22rem 0.45rem;
  color: #a6cfff;
}

.side-bar .sidebar-page-toc-item-h3 .nav-list-link {
  padding-left: 1.2rem;
  font-size: 0.86rem;
}

.side-bar .sidebar-page-toc .nav-list-link.active {
  color: #d7ebff;
  background: #1f2a3a;
  border-left: 2px solid var(--link);
}

/* Core content readability. */
.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4,
.main-content h5,
.main-content h6 {
  color: #000000;
  line-height: 1.25;
}

.main-content h1 {
  letter-spacing: 0.01em;
  margin-bottom: 1.05rem;
}

.main-content p,
.main-content li,
.main-content blockquote {
  color: #000000;
  line-height: 1.65;
}

/* Keep standalone display equations readable in light main-content areas. */
.main-content-wrap .MathJax_Display,
.main-content-wrap .MathJax_SVG_Display,
.main-content-wrap mjx-container[display="true"] {
  color: #000000 !important;
}

.main-content-wrap .MathJax_SVG_Display svg,
.main-content-wrap mjx-container[display="true"] svg,
.main-content-wrap mjx-container[display="true"] svg * {
  fill: #000000 !important;
  stroke: #000000 !important;
}

/* Preserve contrast inside dark answer/details panels. */
.main-content-wrap details .MathJax_Display,
.main-content-wrap details .MathJax_SVG svg,
.main-content-wrap details .MathJax_SVG_Display svg,
.main-content-wrap details mjx-container[display="true"],
.main-content-wrap details mjx-container[display="true"] svg,
.main-content-wrap details mjx-container[display="true"] svg * {
  color: #f7fbff !important;
  fill: #f7fbff !important;
  stroke: #f7fbff !important;
}

/* Make selected text readable (including MathJax) on light pages. */
.main-content ::selection,
.main-content .MathJax::selection,
.main-content .MathJax *::selection,
.main-content mjx-container::selection,
.main-content mjx-container *::selection {
  color: #000000;
  background: #9db9d8;
}

.main-content {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  text-align: left;
}

.main-content h2,
.main-content h3 {
  border-left: 4px solid #314058;
  padding-left: 0.7rem;
}

.main-content img:not(.emoji) {
  display: block;
  margin: 1rem auto 1.5rem;
  border-radius: 0.4rem;
}

.main-content img.emoji {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  margin: 0 0.35rem 0 0;
  vertical-align: -0.12em;
  border-radius: 0;
}

.main-content table {
  width: 100%;
}

.main-content table th,
.main-content table td {
  border-color: var(--border);
  color: #f7fbff;
}

.main-content thead {
  background: #202a38;
}

/* Task/Tip/Question callout tables: one-column two-row blocks used in lab pages. */
.main-content table:has(> tbody > tr > td:only-child) {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-left: 6px solid var(--tip);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.main-content table:has(> tbody > tr > td:only-child) thead th {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  text-align: left;
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.8rem 1rem;
  background: var(--panel-2);
}

.main-content table:has(> tbody > tr > td:only-child) thead th p {
  margin: 0;
}

.main-content table:has(> tbody > tr > td:only-child) tbody td {
  font-size: 1.05rem;
  padding: 0.95rem 1rem;
  color: #f7fbff;
}

.main-content table:has(> tbody > tr > td:only-child) thead th,
.main-content table:has(> tbody > tr > td:only-child) thead th p {
  color: #f7fbff;
}

.main-content table:has(img.emoji[title*="clipboard"]),
.main-content table:has(img.emoji[alt*="clipboard"]) {
  border-left-color: var(--task);
}

.main-content table:has(img.emoji[title*="information_source"]),
.main-content table:has(img.emoji[alt*="information_source"]) {
  border-left-color: var(--tip);
}

.main-content table:has(img.emoji[title*="question"]),
.main-content table:has(img.emoji[alt*="question"]) {
  border-left-color: var(--question);
}

/* Make answer blocks obvious and clearly clickable. */
.main-content details {
  margin: 1.4rem 0;
  border: 1px solid var(--border);
  border-left: 6px solid var(--answer);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.main-content details > summary {
  cursor: pointer;
  list-style: none;
  font-size: 1.08rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  background: #1d2c22;
  color: #f2f6ff;
}

.main-content details > summary::-webkit-details-marker {
  display: none;
}

.main-content details > summary::before {
  content: "▶ ";
}

.main-content details[open] > summary::before {
  content: "▼ ";
}

.main-content details > *:not(summary) {
  padding: 0.9rem 1rem;
  color: #f7fbff;
}

.main-content details > *:not(summary) p,
.main-content details > *:not(summary) li,
.main-content details > *:not(summary) blockquote {
  color: #f7fbff;
}

pre,
.main-content pre,
.highlighter-rouge .highlight {
  background: var(--code-bg);
  color: #e7f1ff;
  border: 1px solid var(--code-border);
}

code,
.main-content code {
  background: var(--code-bg);
  color: #ffb86c;
  border: 1px solid var(--code-border);
}

.main-content pre code,
.highlighter-rouge .highlight code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.highlighter-rouge .highlight .k,
.highlighter-rouge .highlight .kc,
.highlighter-rouge .highlight .kd,
.highlighter-rouge .highlight .kn,
.highlighter-rouge .highlight .kp,
.highlighter-rouge .highlight .kr,
.highlighter-rouge .highlight .kt {
  color: #ffb86c;
}

.highlighter-rouge .highlight .s,
.highlighter-rouge .highlight .s1,
.highlighter-rouge .highlight .s2,
.highlighter-rouge .highlight .sa,
.highlighter-rouge .highlight .sb,
.highlighter-rouge .highlight .sc,
.highlighter-rouge .highlight .sd,
.highlighter-rouge .highlight .se,
.highlighter-rouge .highlight .sh,
.highlighter-rouge .highlight .si,
.highlighter-rouge .highlight .sx {
  color: #a5f08e;
}

.highlighter-rouge .highlight .c,
.highlighter-rouge .highlight .c1,
.highlighter-rouge .highlight .cm {
  color: #8ea3bc;
}

.highlighter-rouge .highlight .nf,
.highlighter-rouge .highlight .nc {
  color: #7cc4ff;
}

.main-content pre,
.highlighter-rouge .highlight {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 8px 20px rgba(0, 0, 0, 0.28);
}

/* Optional light mode for users that prefer it at OS/browser level. */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9fc;
    --panel: #ffffff;
    --panel-2: #eef3fa;
    --text: #1f2731;
    --text-muted: #2b3542;
    --border: #d8e0ec;
    --link: #1358c8;
    --link-hover: #0c47a8;
    --code-bg: #f3f6fb;
    --code-border: #d1dae8;
    --glow: rgba(19, 88, 200, 0.08);
  }

  body {
    background:
      radial-gradient(900px 500px at 20% -10%, #e4edf9 0%, transparent 60%),
      radial-gradient(900px 500px at 90% -20%, #e9ecfa 0%, transparent 62%),
      var(--bg);
  }

  .main-content h2,
  .main-content h3 {
    border-left-color: #8aa3c2;
  }

  .main-content table th,
  .main-content table td {
    color: #f7fbff;
  }

  .main-content table:has(> tbody > tr > td:only-child) thead th,
  .main-content table:has(> tbody > tr > td:only-child) thead th p {
    color: #1f2731;
  }

  .main-content thead {
    background: #e7eef8;
  }

  .main-content table:has(> tbody > tr > td:only-child),
  .main-content details {
    box-shadow: 0 8px 18px rgba(32, 48, 74, 0.08);
  }

  .main-content details > summary {
    background: #e8f4eb;
    color: #173320;
  }

  .main-content details > *:not(summary),
  .main-content details > *:not(summary) p,
  .main-content details > *:not(summary) li,
  .main-content details > *:not(summary) blockquote {
    color: #1f2731;
  }

  pre,
  .main-content pre,
  .highlighter-rouge .highlight {
    color: #18212d;
    box-shadow: 0 0 0 1px rgba(19, 88, 200, 0.03), 0 8px 18px rgba(32, 48, 74, 0.08);
  }

  code,
  .main-content code,
  .highlighter-rouge .highlight .k,
  .highlighter-rouge .highlight .kc,
  .highlighter-rouge .highlight .kd,
  .highlighter-rouge .highlight .kn,
  .highlighter-rouge .highlight .kp,
  .highlighter-rouge .highlight .kr,
  .highlighter-rouge .highlight .kt {
    color: #9a4d00;
  }

  .highlighter-rouge .highlight .s,
  .highlighter-rouge .highlight .s1,
  .highlighter-rouge .highlight .s2,
  .highlighter-rouge .highlight .sa,
  .highlighter-rouge .highlight .sb,
  .highlighter-rouge .highlight .sc,
  .highlighter-rouge .highlight .sd,
  .highlighter-rouge .highlight .se,
  .highlighter-rouge .highlight .sh,
  .highlighter-rouge .highlight .si,
  .highlighter-rouge .highlight .sx {
    color: #1f6b3b;
  }

  .highlighter-rouge .highlight .c,
  .highlighter-rouge .highlight .c1,
  .highlighter-rouge .highlight .cm {
    color: #66758a;
  }

  .highlighter-rouge .highlight .nf,
  .highlighter-rouge .highlight .nc {
    color: #1358c8;
  }

  .main-content ::selection,
  .main-content .MathJax::selection,
  .main-content .MathJax *::selection,
  .main-content mjx-container::selection,
  .main-content mjx-container *::selection,
  .main-content pre::selection,
  .main-content pre *::selection,
  .main-content code::selection,
  .main-content code *::selection {
    color: #102033;
    background: #c6daf7;
  }
}
