/* Academic-style stylesheet for Brave New Green Algorithm */

:root {
  --text-color: #1b1f23;
  --muted-text: #4b5563;
  --link-color: #114b8b;
  --link-hover: #0c3867;
  --border-color: #d3d6dc;
  --bg-color: #f6f7f9;
  --card-bg: #ffffff;
  --code-bg: #f3f5f8;
  --heading-color: #101828;
  --h1-accent: #0f4c81;
  --h2-accent: #1f6fb2;
  --h3-accent: #547da1;
  --accent-tint: rgba(17, 75, 139, 0.08);
  --blockquote-bg: rgba(31, 111, 178, 0.05);
  --target-highlight: rgba(31, 111, 178, 0.2);
  --z-sticky-header: 5;
  /* Extra room so anchor jumps do not hide content under sticky section headings. */
  --scroll-offset: 5.8rem;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: var(--scroll-offset);
}

body {
  font-family: "Charter", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  padding: 2.25rem 1rem;
}

#content, article, main {
  max-width: 52rem;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
  padding: 1.2rem 1.8rem 2rem;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Baskerville", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  color: var(--heading-color);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

h1 {
  font-size: 2.2rem;
  border-bottom: 3px double var(--h1-accent);
  padding-bottom: 0.55rem;
  margin-top: 0.4rem;
  text-align: left;
}

h2 {
  font-size: 1.5rem;
  border-left: 6px solid var(--h2-accent);
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(90deg, var(--accent-tint), transparent 55%);
  padding: 0.35rem 0.5rem 0.35rem 0.8rem;
  scroll-margin-top: var(--scroll-offset);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky-header);
  background-color: var(--card-bg);
}

h3 {
  font-size: 1.2rem;
  border-left: 4px solid var(--h3-accent);
  padding-left: 0.55rem;
  scroll-margin-top: var(--scroll-offset);
}

p {
  margin: 0.75rem 0;
  text-align: left;
  hyphens: auto;
}

a {
  color: var(--link-color);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
  transition: color 0.2s ease, background-color 0.2s ease;
}

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

a:focus-visible {
  outline: 2px solid var(--h2-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

h1 + p {
  font-size: 1.03rem;
  color: var(--muted-text);
  margin-top: 0.9rem;
  border-left: 4px solid var(--border-color);
  padding-left: 0.8rem;
}

h1 + p a {
  display: inline-block;
  margin: 0.15rem 0.35rem 0.15rem 0;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-tint);
  text-decoration: none;
}

h1 + p a:hover,
h1 + p a:focus-visible {
  text-decoration: underline;
}

ul, ol {
  padding-left: 1.8rem;
  margin: 0.5rem 0;
}

li {
  margin: 0.3rem 0;
}

/* BibTeX / code blocks */
pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--link-color);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 2px;
  margin: 1rem 0;
}

code {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
  background-color: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

blockquote {
  margin: 1rem 0.6rem 1rem 1.3rem;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--border-color);
  color: var(--muted-text);
  font-style: italic;
  background: var(--blockquote-bg);
}

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

/* Header / title area generated by pandoc */
header {
  text-align: left;
  margin-bottom: 2rem;
}

header .date {
  font-size: 0.9rem;
  color: var(--muted-text);
  font-style: italic;
}

#TOC, nav#TOC {
  border: 1px solid var(--border-color);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0 1.5rem;
}

#TOC ul, nav#TOC ul {
  margin: 0;
}

/* --- THE TRUE FIXED SIDEBAR (Desktop) --- */
@media (min-width: 1024px) {
  /* 1. Shove the entire body over to make a permanent, empty lane on the left */
  body {
    padding-left: 20rem; 
  }

  /* 2. Rip the TOC out of the white card and pin it to the window edge */
  #TOC, nav#TOC {
    position: fixed;
    top: 0;
    left: 0;
    width: 18rem;        /* Width of the sidebar */
    height: 100vh;       /* Spans the entire height of the screen */
    margin: 0;
    
    /* Overrides the rounded white box look to make it a flush sidebar */
    background-color: var(--bg-color); 
    border: none;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
    padding: 2.25rem 1.5rem;
    
    overflow-y: auto;    /* Allows the sidebar to scroll independently */
    z-index: 9999;       /* Guarantees it stays above absolutely everything */
  }
}

h2:target, h3:target {
  animation: section-highlight 1.3s ease-out;
}

@keyframes section-highlight {
  from {
    box-shadow: 0 0 0 0.25rem var(--target-highlight);
  }
  to {
    box-shadow: none;
  }
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 1rem 0.75rem;
    font-size: 0.95rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  #content, article, main {
    padding: 0.95rem 1rem 1.4rem;
    border-radius: 8px;
  }

  h2 {
    position: static;
    z-index: auto;
    background: linear-gradient(90deg, var(--accent-tint), transparent 55%);
  }
}
