/* pandoc-modern.css
   Modern wide-screen styling for Pandoc HTML output.

   Usage:
     1. Remove the inline <style>...</style> block from the HTML head.
     2. Add this in the <head>:
          <link rel="stylesheet" href="pandoc-modern.css">

   Optional image enlargement:
     CSS alone cannot reliably make a normal <img> click-to-enlarge without
     either wrapping images in links or adding a tiny script. This stylesheet
     supports the common pattern:
          <a href="images/example.png" class="image-link"><img src="images/example.png"></a>
     Then clicking opens the full image in the browser.
*/

:root {
  --bg: #f7f7f4;
  --paper: #ffffff;
  --text: #1d2329;
  --muted: #69717a;
  --line: #d9dedf;
  --accent: #245f73;
  --accent-soft: #e4f0f3;
  --code-bg: #f0f3f4;
  --shadow: 0 18px 50px rgba(20, 28, 34, 0.08);
  --radius: 18px;
  --content-width: min(1180px, calc(100vw - 420px));
  --toc-width: 280px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-size: 19px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 48px 56px 80px calc(var(--toc-width) + 96px);
  max-width: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

body > *:not(#TOC) {
  max-width: var(--content-width);
}

header#title-block-header {
  margin: 0 0 56px 0;
  padding: 46px 52px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

h1.title {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.author,
.date {
  color: var(--muted);
  margin: 0.5em 0 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 2.2em 0 0.7em;
  color: #10161b;
}

h1:not(.title) {
  font-size: clamp(2rem, 2.8vw, 3.1rem);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3em;
}

h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h3 {
  font-size: 1.28rem;
}

p {
  margin: 1.05em 0;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: #123947;
}

/* Sticky left index / table of contents generated by pandoc --toc */
#TOC {
  position: fixed;
  top: 24px;
  left: 24px;
  width: var(--toc-width);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  font-size: 0.86rem;
  line-height: 1.35;
}

#TOC::before {
  content: "Contents";
  display: block;
  margin: 0 0 0.9em;
  font-weight: 750;
  color: #10161b;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

#TOC ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

#TOC ul ul {
  margin-top: 0.35em;
  padding-left: 1em;
  border-left: 1px solid var(--line);
}

#TOC li {
  margin: 0.35em 0;
}

#TOC a {
  display: block;
  padding: 0.22em 0;
  color: var(--muted);
  text-decoration: none;
}

#TOC a:hover {
  color: var(--accent);
}

figure {
  margin: 2.3em 0;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

figure img,
figure svg {
  display: block;
  width: min(50vw, 100%);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
}

/* Let explicitly full-width Pandoc images stay large if they have inline width:100%. */
figure img[style*="100"],
figure svg[style*="100"] {
  width: min(100%, 1000px) !important;
}

figcaption,
caption {
  margin-top: 1em;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* If you wrap images with <a class="image-link" href="same-image">, clicking opens full image. */
a.image-link {
  display: block;
  cursor: zoom-in;
}

a.image-link::after {
  content: "Click image to enlarge";
  display: block;
  text-align: center;
  margin-top: 0.6em;
  color: var(--muted);
  font-size: 0.78rem;
}

img {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
  display: block;
  overflow-x: auto;
  margin: 2em 0;
  border-collapse: collapse;
  font-variant-numeric: lining-nums tabular-nums;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

thead,
tbody,
tr {
  width: 100%;
}

th,
td {
  padding: 0.65em 0.8em;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--accent-soft);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

blockquote {
  margin: 1.6em 0;
  padding: 1em 1.25em;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: #25313a;
  border-radius: 0 12px 12px 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 0.35em;
  padding: 0.12em 0.28em;
  hyphens: manual;
}

pre {
  overflow: auto;
  padding: 1em 1.15em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}

pre code {
  padding: 0;
  background: transparent;
  white-space: pre;
}

.math.display {
  display: block;
  overflow-x: auto;
  padding: 1em;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3em 0;
}

/* Mobile / narrow screens */
@media (max-width: 1050px) {
  body {
    padding: 28px 24px 64px;
  }

  body > *:not(#TOC) {
    max-width: 100%;
  }

  #TOC {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    max-height: none;
    margin: 0 0 28px 0;
  }

  figure img,
  figure svg,
  figure img[style*="100"],
  figure svg[style*="100"] {
    width: 100% !important;
  }

  header#title-block-header {
    padding: 30px 26px;
  }
}

@media (max-width: 620px) {
  html {
    font-size: 17px;
  }

  body {
    padding: 18px 14px 48px;
  }

  figure {
    padding: 12px;
  }
}

@media print {
  html,
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  body {
    padding: 0;
  }

  #TOC {
    position: static;
    box-shadow: none;
    border: 1px solid #bbb;
  }

  header#title-block-header,
  figure,
  table {
    box-shadow: none;
  }

  a {
    color: black;
  }
}
