/* ═══════════════════════════════════════════════════════════
   style.css — org-mode blog theme
   ═══════════════════════════════════════════════════════════ */

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Palette — wombat ────────────────────────────────────── */
:root {
  --fg:       #f6f3e8;
  --fg-soft:  #99968b;
  --bg:       #242424;
  --bg-alt:   #303030;
  --rule:     #444;
  --accent:   #8ac6f2;
  --accent-h: #cae682;
  --code-fg:  #f6f3e8;
  --code-bg:  #1a1a1a;
  --sel:      rgba(138,198,242,.15);
  --mono:     "Iosevka", "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, monospace;
  --serif:    "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans:     "Inter", "Helvetica Neue", -apple-system, system-ui, sans-serif;
  --w:        42rem;
}
img[src$=".svg"] { filter: invert(.85) hue-rotate(180deg); }

/* ── Base ────────────────────────────────────────────────── */
html {
  font-size: 17px;
  scroll-behavior: smooth;
}
body {
  font-family: var(--serif);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--sel); }

/* ── Layout ──────────────────────────────────────────────── */
#preamble, #content, #postamble {
  max-width: var(--w);
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ── Preamble (header/nav) ───────────────────────────────── */
#preamble {
  padding-top: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.5rem;
}
header.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--sans);
}
.site-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.site-title:hover { color: var(--accent); text-decoration: none; }
header.site-header nav a {
  font-size: 0.85rem;
  color: var(--fg-soft);
  text-decoration: none;
  margin-left: 1.4rem;
  transition: color 0.2s;
}
header.site-header nav a:hover { color: var(--fg); }

/* ── Content ─────────────────────────────────────────────── */
#content { padding-top: 0.5rem; padding-bottom: 4rem; }

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  line-height: 1.3;
  font-weight: 600;
  margin-top: 2.2rem;
  margin-bottom: 0.6rem;
}
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.0rem; }

/* Org section numbers — dim them */
.section-number-2, .section-number-3, .section-number-4 {
  color: var(--fg-soft);
  font-weight: 400;
  margin-right: 0.3em;
}

/* Title on blog posts */
h1.title {
  margin-top: 0;
  margin-bottom: 0.15rem;
  line-height: 1.25;
}
.subtitle {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--fg-soft);
  margin-bottom: 2rem;
}

p { margin-bottom: 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--accent-h); text-decoration: underline; text-underline-offset: 2px; }

b, strong { font-weight: 600; }
i, em { font-style: italic; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.6rem 0 0.6rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: var(--fg-soft);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* ── Links bar (index page) ──────────────────────────────── */
.links {
  font-family: var(--sans);
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}
.links a {
  display: inline-block;
  margin-right: 0.8rem;
  padding: 0.15rem 0;
}

/* ── Post listing (index page) ───────────────────────────── */
.homepage ul {
  list-style: none;
  padding: 0;
}
.homepage ul > li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.5;
}
.homepage ul > li:last-child {
  border-bottom: none;
}
.homepage ul > li a {
  font-family: var(--sans);
}

/* ── Scrollable Log List ─────────────────────────────────── */
.log-list {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 1rem;
  margin-bottom: 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-alt) transparent;
}
.log-list::-webkit-scrollbar {
  width: 6px;
}
.log-list::-webkit-scrollbar-track {
  background: transparent;
}
.log-list::-webkit-scrollbar-thumb {
  background-color: var(--bg-alt);
  border-radius: 10px;
}

/* ── Lists (general) ─────────────────────────────────────── */
ul, ol { padding-left: 1.4rem; margin-bottom: 1rem; }
li { margin-bottom: 0.3rem; }
li > p { margin-bottom: 0.3rem; }

/* ── Code ────────────────────────────────────────────────── */
code {
  font-family: var(--mono);
  font-size: 0.84em;
  color: var(--code-fg);
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

pre {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--code-fg);
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* Hugo syntax highlighting */
.highlight {
  margin: 1.5rem 0;
  border-radius: 6px;
  overflow-x: auto;
  background: var(--code-bg) !important;
}
.highlight pre {
  margin: 0;
  border: none;
  background: transparent !important;
  overflow-x: visible;
}

/* Org src block language label */
pre.src { position: relative; padding-top: 1.6rem; }
pre.src:before {
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.15rem 0.6rem;
  font-size: 0.68rem;
  font-family: var(--sans);
  color: var(--fg-soft);
  background: var(--bg-alt);
  border-bottom-left-radius: 4px;
  border-top-right-radius: 5px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* ── Tables ──────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
th, td {
  padding: 0.45rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-soft);
}

/* ── Images & Figures ────────────────────────────────────── */
img { max-width: 100%; height: auto; }
.figure { margin: 2rem 0; }
.figure p { text-align: center; }
figcaption,
.figure p:last-child:not(:first-child) {
  font-size: 0.82rem;
  color: var(--fg-soft);
  font-family: var(--sans);
  margin-top: 0.5rem;
}
.org-svg { width: 100%; height: auto; }

/* ── Math (MathJax) ──────────────────────────────────────── */
.MathJax_Display, mjx-container[jax="output/chtml"][display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0;
}

/* ── Footnotes ───────────────────────────────────────────── */
.footref {
  font-size: 0.75em;
  vertical-align: super;
  text-decoration: none;
  line-height: 0;
}
h2.footnotes {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-soft);
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
#text-footnotes {
  font-size: 0.88rem;
  color: var(--fg-soft);
  line-height: 1.6;
}
.footdef { margin-bottom: 0.5rem; }
.footpara { display: inline; }
.footnum { font-weight: 600; margin-right: 0.3em; }

/* ── TOC ─────────────────────────────────────────────────── */
#table-of-contents {
  margin: 1.5rem 0 2.5rem;
  padding: 1rem 1.2rem;
  background: var(--bg-alt);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 0.88rem;
}
#table-of-contents h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
  margin-top: 0;
  margin-bottom: 0.5rem;
}
#table-of-contents ul { margin-bottom: 0; }

/* ── Tags ────────────────────────────────────────────────── */
.tag span {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg-soft);
  background: var(--bg-alt);
  padding: 0.1em 0.5em;
  border-radius: 3px;
}

/* ── Timestamps ──────────────────────────────────────────── */
.timestamp, .timestamp-kwd {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--fg-soft);
}

/* ── Org task keywords ───────────────────────────────────── */
.todo { font-family: var(--mono); color: #e5786d; font-weight: 600; }
.done { font-family: var(--mono); color: #95e454; font-weight: 600; }
.priority { font-family: var(--mono); color: #cae682; }

/* ── Postamble (footer) ──────────────────────────────────── */
#postamble {
  margin-top: 3rem;
  padding-top: 1rem;
  padding-bottom: 2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--fg-soft);
}
#postamble p { margin-bottom: 0.15rem; }
#postamble a { color: var(--fg-soft); }
#postamble a:hover { color: var(--accent); }

/* hide the validation link, it's noisy */
#postamble .validation { display: none; }

/* ── Misc Org elements ───────────────────────────────────── */
.underline { text-decoration: underline; text-underline-offset: 2px; }
.verse { margin-left: 2rem; font-style: italic; }
dt { font-weight: 600; font-family: var(--sans); }
.inlinetask {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-alt);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  :root { --w: 100%; }
  #preamble { padding-top: 1.5rem; }
  header.site-header { flex-direction: column; gap: 0.4rem; }
  header.site-header nav { margin-left: 0; }
  header.site-header nav a { margin-left: 0; margin-right: 1.2rem; }
  pre { font-size: 0.8rem; padding: 0.8rem; }
}
