/* ---------------------------------------------------------------------------
   Concept Formation in Computational Creativity — web edition theme
   Matched to the giovannilion.link portfolio: Ayu-dark terminal aesthetic.
   IBM Plex Mono for chrome/headings, IBM Plex Sans for long-form prose.
   Layered on top of pandoc's chunkedhtml output.
--------------------------------------------------------------------------- */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,700;1,400&display=swap");

:root {
  --bg: #0a0e14;
  --bg-elev: #11151c;
  --bg-soft: #14191f40;
  --fg: #e6e1cf;
  --fg-mute: #a0a4aa;
  --fg-dim: #5c6166;
  --rule: #1f232c;
  --rule-strong: #2d333e;
  --accent: #ffb454;   /* amber */
  --accent-2: #b8cc52; /* lime */
  --accent-3: #36a3d9; /* blue */
  --accent-4: #f07178; /* coral */
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --measure: 46rem;      /* reading column ≈ 72ch of Plex Sans */
  --measure-wide: 64rem; /* figures / tables breakout */
  font-size: 18px;
}

* { box-sizing: border-box; }

html {
  color: var(--fg);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: 0 1.5rem 7rem;
  font-family: var(--sans);
  line-height: 1.72;
  hyphens: auto;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

/* CRT scanlines overlay — subtle, terminal-feel (from the portfolio). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    transparent 0,
    transparent 2px,
    rgba(255, 255, 255, 0.015) 2px,
    rgba(255, 255, 255, 0.015) 3px
  );
}

::selection { background: var(--accent); color: var(--bg); }

/* --- site banner (injected before body) --- */
.sitebar {
  position: sticky;
  top: 0;
  z-index: 50;
  max-width: var(--measure);
  margin: 0 auto 1.5rem;
  padding: 0.85rem 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(to bottom, rgba(10, 14, 20, 0.92), rgba(10, 14, 20, 0.72));
  backdrop-filter: blur(8px);
  font-family: var(--mono);
}
.sitebar .home {
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-mute);
  text-decoration: none;
}
.sitebar .home::before { content: "> "; color: var(--accent-2); }
.sitebar .home:hover { color: var(--fg); }
.sitebar .spacer { flex: 1; }
.sitebar .ext {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fg-mute);
}
.sitebar .ext:hover { color: var(--accent); }
.sitebar .pdf {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--rule-strong);
  padding: 0.4em 0.9em;
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 180ms ease, color 180ms ease;
}
.sitebar .pdf:hover { border-color: var(--accent); color: var(--accent); }

/* --- typography --- */
h1, h2, h3, h4, h5 {
  font-family: var(--mono);
  font-weight: 500;
  line-height: 1.18;
  color: var(--fg);
  letter-spacing: -0.01em;
  margin: 2.4em 0 0.6em;
}
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); margin-top: 1.1em; letter-spacing: -0.02em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.22rem; color: var(--fg); }
h4, h5 { font-size: 1.05rem; color: var(--fg-mute); }

.header-section-number {
  color: var(--accent);
  font-weight: 500;
  margin-right: 0.5em;
}

p { margin: 1.1em 0; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px;
  transition: color 160ms ease, border-color 160ms ease;
}
a:hover { color: var(--accent); border-bottom-color: currentColor; }

strong { font-weight: 700; }
em { font-style: italic; }

/* small-caps spans (pandoc renders \textsc / \newthought openers) */
.smallcaps { font-variant: small-caps; letter-spacing: 0.02em; }

/* --- chapter epigraphs (savequote) render as leading blockquotes --- */
blockquote {
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--fg-mute);
  font-style: italic;
}
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

/* --- math display --- */
.display.math { display: block; text-align: center; margin: 0.5rem auto; color: var(--fg); }

/* --- figures --- */
figure {
  margin: 2.4em auto;
  text-align: center;
  max-width: var(--measure-wide);
}
figure img, img {
  max-width: 100%;
  height: auto;
  display: block;
  margin-inline: auto;
  border: 1px solid var(--rule);
  background: var(--bg-elev);
  filter: saturate(0.95);
}
figcaption {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-mute);
  margin-top: 0.8em;
  line-height: 1.5;
  text-align: left;
}

/* boxed prompt examples / tcolorbox -> pandoc renders as block quotes or divs */
div.mycolorboxpar, .tcolorbox {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-3);
  padding: 1.1em 1.3em;
  margin: 1.8em 0;
  font-size: 0.96rem;
}

/* --- tables --- */
table {
  border-collapse: collapse;
  margin: 2em auto;
  width: 100%;
  max-width: var(--measure-wide);
  font-family: var(--mono);
  font-size: 0.82rem;
}
th, td {
  border: 1px solid var(--rule);
  padding: 0.5em 0.7em;
  text-align: left;
}
thead th {
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 500;
  letter-spacing: 0.02em;
}
caption {
  caption-side: bottom;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-mute);
  padding-top: 0.6em;
  text-align: left;
}

/* --- code --- */
code, pre { font-family: var(--mono); }
code {
  background: var(--bg-elev);
  padding: 0.12em 0.35em;
  border-radius: 4px;
  font-size: 0.86em;
  color: var(--accent-2);
}
pre {
  background: var(--bg-elev);
  padding: 1em 1.1em;
  border-radius: 6px;
  border: 1px solid var(--rule);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; color: var(--fg); }

/* --- footnotes & references --- */
.csl-bib-body, #refs { font-size: 0.9rem; line-height: 1.55; color: var(--fg-mute); }
.csl-entry { margin-bottom: 0.8em; padding-left: 1.6em; text-indent: -1.6em; }
.csl-entry a, #refs a { color: var(--accent-3); }
section.footnotes {
  font-size: 0.84rem;
  color: var(--fg-mute);
  border-top: 1px solid var(--rule);
  margin-top: 3.5em;
  padding-top: 1.2em;
}
.citation a { border-bottom: none; color: var(--accent-3); }
.citation a:hover { border-bottom: 1px solid currentColor; }

/* --- document header / hero (index + chapter title blocks) --- */
header#title-block-header {
  margin: 2.5rem 0 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
header#title-block-header h1.title {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.08;
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
}
header#title-block-header p.author,
header#title-block-header p.date {
  color: var(--fg-mute);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  margin: 0.2em 0;
}

/* --- contents (index page) --- */
nav#TOC, #toc { font-family: var(--mono); font-size: 0.92rem; }
nav#TOC::before, #toc::before {
  content: "> contents";
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  margin-bottom: 1rem;
}
nav#TOC ul, #toc ul { list-style: none; padding-left: 1.2em; }
nav#TOC > ul, #toc > ul { padding-left: 0; }
nav#TOC li, #toc li { margin: 0.18em 0; }
nav#TOC a, #toc a { text-decoration: none; color: var(--fg-mute); border-bottom: none; }
nav#TOC a:hover, #toc a:hover { color: var(--accent); }
.toc-section-number { color: var(--fg-dim); margin-right: 0.6em; }

/* --- prev/next site navigation (pandoc chunkedhtml) --- */
nav#sitenav {
  margin: 4em 0 0;
  padding-top: 1.4em;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.78rem;
}
div.sitenav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.5em 1.5em; margin-bottom: 0.4em; }
span.navlink { flex: 1; min-width: 11em; }
span.navlink-label {
  color: var(--accent-2);
  display: inline-block;
  min-width: 4.5em;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
nav#sitenav a { text-decoration: none; color: var(--fg-mute); border-bottom: none; }
nav#sitenav a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 640px) {
  :root { font-size: 17px; }
  body { padding: 0 1.1rem 5rem; }
}
