/* ===========================================================================
   chemicalfiend.github.io — owned stylesheet.

   Originally hugo-classic's static/css/style.css (MIT, goodroot / Yihui Xie),
   rewritten around CSS custom properties. This file shadows the theme's copy;
   the theme itself is never edited.

   Dark is the DEFAULT for every visitor, not a prefers-color-scheme branch.
   Light is opt-in via the header toggle, which sets data-theme="light".
   =========================================================================== */

:root {
  /* Dark — the default */
  --bg:            #14161a;
  --bg-elev:       #1b1e24;
  --bg-code:       #0d1117;   /* matches the github-dark chroma stylesheet */
  --fg:            #d7dbe0;
  --fg-strong:     #f0f2f5;
  --fg-muted:      #949ca8;
  --accent:        #7aa2f7;
  --accent-hover:  #a3c0ff;
  --border:        #2a2f38;
  --header-bg:     #1b1e24;
  --header-fg:     #cfd5dd;
  --selection:     #2d3b57;

  --maxw:          900px;
  --maxw-prose:    680px;
}

[data-theme="light"] {
  --bg:            #fdfdfc;
  --bg-elev:       #f3f3f1;
  --bg-code:       #0d1117;   /* code stays dark in both themes — see note below */
  --fg:            #24272c;
  --fg-strong:     #0f1115;
  --fg-muted:      #5f666f;
  --accent:        #2b5fd9;
  --accent-hover:  #1a48b0;
  --border:        #dcdcd8;
  --header-bg:     #24272c;
  --header-fg:     #f0f2f5;
  --selection:     #cfe0ff;
}

::selection { background: var(--selection); }

html { -webkit-text-size-adjust: 100%; }

body {
  max-width: var(--maxw);
  margin: auto;
  padding: 0.2em;
  line-height: 1.6;
  background: var(--bg);
  color: var(--fg);
}

h1, h2, h3, h4 { color: var(--fg-strong); line-height: 1.3; }
h1 { line-height: 1.4; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

hr { border: 0; border-top: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   Header / nav
   -------------------------------------------------------------------------- */
header {
  position: relative;
  width: 100%;
  font-size: 1rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
header ul, header ol { margin: 0; padding: 0; list-style: none; }
header nav {
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
}
header nav ul {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
}
header a {
  color: var(--header-fg);
  line-height: 2rem;
  padding: 0 0.5rem;
  display: inline-block;
}
header a:hover, header .current a { color: #fff; text-decoration: none; }
header .current a { font-weight: 700; }
.pull-left  { margin-right: auto; }
.pull-right { margin-left: auto; }

/* Light/dark toggle */
.theme-toggle {
  background: none;
  border: 1px solid transparent;
  color: var(--header-fg);
  cursor: pointer;
  font: inherit;
  line-height: 2rem;
  padding: 0 0.5rem;
  border-radius: 4px;
}
.theme-toggle:hover { color: #fff; border-color: var(--border); }
.theme-toggle svg { width: 16px; height: 16px; fill: currentColor; vertical-align: -2px; }
[data-theme="light"] .icon-sun  { display: none; }
.icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* --------------------------------------------------------------------------
   Article meta
   -------------------------------------------------------------------------- */
.article-meta, .menu a {
  text-decoration: none;
  padding: 5px;
  border-radius: 5px;
  margin: 20px 0;
  color: var(--fg);
}
.article-meta { text-align: center; }
.article-meta .title { font-size: 1.6em; display: block; }
.article-meta .date, .article-meta .author {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--fg-muted);
}
.terms { font-size: 0.9em; color: var(--fg-muted); }
.terms a { color: var(--fg-muted); }
.terms a:hover { color: var(--accent); }
.menu li { display: inline-block; }
.menu, footer { text-align: center; }

footer {
  margin-top: 3rem;
  padding: 1rem 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
footer a { color: var(--fg-muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Content
   -------------------------------------------------------------------------- */
main {
  hyphens: auto;
  max-width: var(--maxw-prose);
  margin: 0 auto;
  line-height: 1.7em;
  display: block;
  font-size: 1.05em;
}
main a { font-weight: 600; }

.content-wrapper { padding: 0 12px; }

blockquote {
  border-left: 4px solid var(--border);
  background: var(--bg-elev);
  padding: 0.4em 1em;
  margin-left: 0;
  color: var(--fg-muted);
}

/* Code. The github-dark chroma sheet (static/css/chroma.css) supplies token
   colours; these rules supply the box. Code blocks stay dark in light mode —
   deliberate, so one chroma stylesheet serves both themes. */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1em;
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.5;
}
pre code { background: none; padding: 0; color: inherit; }
code {
  background-color: var(--bg-elev);
  color: var(--fg-strong);
  border-radius: 3px;
  padding: 0.15em 0.35em;
  font-size: 0.92em;
}
.highlight { margin: 1.2em 0; }
.highlight pre { margin: 0; }

/* Maths. KaTeX inherits currentColor; display maths must scroll rather than
   overflow the page on narrow screens. */
.katex { font-size: 1.05em; }
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5em 0;
}

img, iframe, video {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

table {
  margin: auto;
  border-collapse: collapse;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
table thead th { border-bottom: 1px solid var(--border); }
th, td { padding: 5px 8px; }
tr:nth-child(even) { background: var(--bg-elev); }

#TableOfContents, #TOC {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-elev);
}

/* ===========================================================================
   Profile homepage (layouts/index.html)
   =========================================================================== */

.profile {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2.25rem;
  max-width: var(--maxw);
  margin: 2.25rem auto 0;
  align-items: start;
}

.profile-side { text-align: center; }

.portrait {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 0.9rem;
  border: 1px solid var(--border);
}

.profile-name { font-size: 1.45rem; margin: 0.2rem 0; line-height: 1.3; }
.profile-role { margin: 0.1rem 0; font-size: 0.95rem; color: var(--fg); }
.profile-org  { margin: 0.1rem 0; font-size: 0.9rem;  color: var(--fg-muted); }

.network-icon {
  list-style: none;
  padding: 0;
  margin: 1.1rem 0 0;
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.network-icon li { display: inline-block; }
.network-icon a { display: inline-flex; color: var(--fg-muted); }
.network-icon a:hover { color: var(--accent); }
.network-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: color 0.15s ease;
}

.profile-main .bio > p:first-child { margin-top: 0; }

.profile-cols {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 1.75rem;
  margin-top: 1.4rem;
}
.profile-cols h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-muted);
  margin: 0 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.profile-cols ul { margin: 0; padding-left: 1.1rem; }
.profile-cols li { margin-bottom: 0.35rem; font-size: 0.95rem; line-height: 1.45; }

.edu-list { list-style: none; padding-left: 0; }
.edu-list li { margin-bottom: 0.6rem; }
.edu-course { display: block; }
.edu-meta { display: block; font-size: 0.85rem; color: var(--fg-muted); }

/* Recent posts */
.recent-posts { max-width: var(--maxw); margin: 2.75rem auto 0; }
.recent-posts h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-muted);
  margin-bottom: 0.7rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.post-list .date {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.9rem;
}
.all-posts { display: inline-block; margin-top: 0.8rem; font-size: 0.9rem; }

/* Post list pages (/post/, /tags/x/) reuse the theme's plain <ul> */
.content-wrapper > ul { list-style: none; padding-left: 0; }
.content-wrapper > ul > li { margin-bottom: 0.5rem; }
.content-wrapper > ul > li .date {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  margin-right: 0.75rem;
  font-size: 0.9rem;
}

@media only screen and (max-width: 700px) {
  .profile { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.25rem; }
  .profile-cols { grid-template-columns: 1fr; gap: 1.1rem; }
  .post-list li { flex-direction: column; gap: 0; margin-bottom: 0.8rem; }
}
