/* ============================================================
   EC005 — Calm Classic Textbook Style
   Baskerville headings, centered text column, soft gradient
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=JetBrains+Mono:wght@400;500&display=swap');


/* ── Design tokens ─────────────────────────────────────────── */

:root {
  --tx: #3F3F37;
  --bg: #FFF;
  --muted: #6E6E65;
  --rule: #D0D8BC;

  /* Slate blue — primary: links, section numbers, def/thm borders */
  --purple: #4A6FA5;
  --purple-dark: #3A5A8A;
  --purple-soft: #E8EEF7;

  /* Sage — secondary: tips, examples, sidebar */
  --green: #7A9A62;
  --green-soft: #EAF0DC;

  /* Muted sage — accent: code borders, blockquotes, TOC */
  --yellow: #A0B880;
  --yellow-soft: #EDF2E2;

  --gold: #8A9E6A;
  --code-bg: #F0F4E8;
  --code-border: #C8D4B0;

  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --display: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;

  --lh: 1.68;
  --measure: 64ch;
}


/* ── Overall page balance ─────────────────────────────────── */

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--serif);
  font-size: 18px;
  line-height: var(--lh);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

#quarto-document-content,
.chapter-content {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}


/* ── Body text ─────────────────────────────────────────────── */

p,
li,
td,
th,
blockquote,
figcaption,
.callout-body {
  font-family: var(--serif);
  font-size: 1rem;
}

#quarto-document-content p,
.chapter-content p {
  max-width: var(--measure);
  line-height: var(--lh);
  hyphens: auto;
  -webkit-hyphens: auto;
  margin-left: auto;
  margin-right: auto;
}

p {
  margin-bottom: 1rem;
}


/* Center non-paragraph content to match the text column */

#quarto-document-content ul,
#quarto-document-content ol,
#quarto-document-content pre,
#quarto-document-content blockquote,
#quarto-document-content .callout,
#quarto-document-content table,
#quarto-document-content figure,
.chapter-content ul,
.chapter-content ol,
.chapter-content pre,
.chapter-content blockquote,
.chapter-content .callout,
.chapter-content table,
.chapter-content figure {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}


/* ── Title block ───────────────────────────────────────────── */

#title-block-header {
  margin-bottom: 3rem;
  padding-top: 0.5rem;
  padding-bottom: 1.25rem;
  border-bottom: none;
}

h1.title {
  font-family: var(--display);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1.08;
  color: var(--tx);
  text-transform: uppercase;
}

.subtitle {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.085em;
  color: var(--muted);
  text-transform: uppercase;
}

.quarto-title-meta {
  margin-top: 1.6rem;
  font-size: 0.95rem;
  color: var(--muted);
}

#title-block-header::after {
  content: '';
  display: block;
  height: 2px;
  background: var(--tx);
  margin: 1.4rem auto 0 auto;
}


/* ── Chapter and section headings ──────────────────────────── */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--display);
  color: var(--tx);
  line-height: 1.2;
}

.chapter > h1,
section > h1,
h1:not(.title):not(#title-block-header h1) {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 3.2rem;
  margin-bottom: 1.8rem;
  padding-bottom: 0;
  border-bottom: none;
}

.chapter > h1::after,
section > h1::after,
h1:not(.title)::after {
  content: none;
}

h2 {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 2.8rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

h2::before {
  content: none;
}

h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
  text-align: center;
}

h4 {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1.5rem;
  color: var(--muted);
}

.header-section-number {
  color: var(--purple);
  font-weight: 700;
  margin-right: 0.35em;
}


/* ── Links and accents ─────────────────────────────────────── */

a {
  color: var(--purple);
  text-decoration: none;
}

a:hover {
  color: var(--purple-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}


/* ── Sidebar: calm paper-like gradient ─────────────────────── */

#quarto-sidebar {
  background: linear-gradient(
    180deg,
    #E8EEF7 0%,
    #EAF0DC 55%,
    #E2E8CE 100%
  ) !important;
  border-right: 1px solid #E2DCCF !important;
  box-shadow: none !important;
  font-family: var(--serif);
}

.sidebar-title,
.sidebar-title a {
  font-family: var(--display);
  color: #3A5A8A !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  letter-spacing: 0.07em !important;
  text-transform: uppercase;
  padding-bottom: 0.9rem !important;
  margin-bottom: 1rem !important;
}

.sidebar-item {
  padding: 0.08rem 0;
}

.sidebar-item a {
  border-radius: 4px;
}

.sidebar-item a:hover {
  background: rgba(255,255,255,.45);
}

.sidebar-item-text {
  font-family: var(--serif);
  color: #3F3F37 !important;
  font-size: 0.94rem;
  line-height: 1.25;
}

.sidebar-item-text:hover {
  color: var(--purple-dark) !important;
}

.sidebar-item.active,
.sidebar-item .active {
  background: rgba(255,255,255,.50);
  border-radius: 4px;
}

.sidebar-item.active .sidebar-item-text,
.active > .sidebar-item-text {
  color: var(--purple-dark) !important;
  font-weight: 700;
}


/* ── Search box ────────────────────────────────────────────── */

.aa-DetachedSearchButton,
#quarto-search {
  font-family: var(--serif);
}

.aa-DetachedSearchButton {
  border: 1px solid rgba(74,111,165,.15) !important;
  border-radius: 4px !important;
  background: rgba(255,255,255,.80) !important;
  box-shadow: none !important;
}


/* ── Right table of contents ───────────────────────────────── */

#TOC {
  font-family: var(--serif);
  border-left: 2px solid var(--gold);
  padding-left: 1rem;
  font-size: 0.9rem;
}

#TOC .toc-title {
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tx);
}

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

#TOC a:hover,
#TOC a.active {
  color: var(--purple);
  text-decoration: none;
}


/* ── Lists ─────────────────────────────────────────────────── */

ul,
ol {
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.25em;
}

li > p {
  margin: 0;
}


/* ── Inline code ───────────────────────────────────────────── */

code:not(pre code) {
  font-family: var(--mono);
  font-size: 0.82em;
  background: #E8EEF7;
  border: 1px solid #BACBE0;
  border-radius: 3px;
  padding: 0.05em 0.35em;
  color: var(--tx);
}


/* ── Code blocks ───────────────────────────────────────────── */

pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--code-border) !important;
  border-left: 4px solid var(--gold) !important;
  border-radius: 3px !important;
  padding: 1rem 1.2rem !important;
  font-family: var(--mono) !important;
  font-size: 0.82rem !important;
  line-height: 1.55 !important;
  overflow-x: auto;
  box-shadow: none !important;
}

pre code {
  font-family: var(--mono) !important;
  font-size: inherit !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: var(--tx) !important;
}

.code-copy-button {
  opacity: 0.45;
}

.code-copy-button:hover {
  opacity: 1;
}


/* ── Blockquotes ───────────────────────────────────────────── */

blockquote {
  border-left: 3px solid var(--gold);
  padding: 0.5rem 0 0.5rem 1.4rem;
  color: var(--muted);
  font-style: italic;
}

blockquote p {
  margin: 0;
}


/* ── Tables ────────────────────────────────────────────────── */

table {
  font-family: var(--serif);
  font-size: 0.95rem;
  border-collapse: collapse;
  width: 100%;
  margin-top: 1.6rem;
  margin-bottom: 1.6rem;
}

thead tr {
  border-top: 2px solid var(--tx);
  border-bottom: 1.5px solid var(--tx);
}

thead th {
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--code-border);
}

tbody tr:last-child {
  border-bottom: 2px solid var(--tx);
}

tbody td {
  padding: 0.35rem 0.8rem;
}

tbody tr:nth-child(even) {
  background: rgba(226,232,206,.40);
}


/* ── Figures and captions ──────────────────────────────────── */

figure {
  margin-top: 2rem;
  margin-bottom: 2rem;
  text-align: center;
}

figcaption,
.figure-caption,
.quarto-float-caption {
  font-family: var(--serif);
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.5rem;
  text-align: center;
}


/* ── Callouts ──────────────────────────────────────────────── */

.callout {
  border-radius: 3px;
  border-left-width: 4px;
  font-family: var(--serif);
  box-shadow: none;
}

.callout-note {
  border-left-color: var(--purple) !important;
  background: rgba(74,111,165,.06) !important;
}

.callout-tip {
  border-left-color: var(--green) !important;
  background: rgba(122,154,98,.07) !important;
}

.callout-warning {
  border-left-color: var(--gold) !important;
  background: rgba(138,158,106,.10) !important;
}

.callout-important {
  border-left-color: #8A5A3A !important;
  background: rgba(138,90,58,.07) !important;
}

.callout-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}


/* ── Custom math-style environments ─────────────────────────── */

.def,
.thm,
.lem,
.prop,
.cor {
  border-left: 4px solid var(--purple);
  background: rgba(74,111,165,.05);
  border-radius: 0 3px 3px 0;
  padding: 0.75rem 1.1rem 0.75rem 1.3rem;
  margin-top: 1.6rem;
  margin-bottom: 1.6rem;
}

.def > p:first-child > strong:first-child,
.thm > p:first-child > strong:first-child,
.lem > p:first-child > strong:first-child,
.prop > p:first-child > strong:first-child,
.cor > p:first-child > strong:first-child {
  color: var(--purple-dark);
}

.example {
  border-left: 4px solid var(--green);
  background: rgba(122,154,98,.06);
  border-radius: 0 3px 3px 0;
  padding: 0.75rem 1.1rem 0.75rem 1.3rem;
  margin-top: 1.6rem;
  margin-bottom: 1.6rem;
}

.proof {
  border-left: 4px solid var(--gold);
  padding: 0.6rem 1rem 0.6rem 1.3rem;
  margin-top: 1.2rem;
  margin-bottom: 1.2rem;
  font-style: italic;
  color: var(--muted);
}

.proof::before {
  content: 'Proof. ';
  font-style: normal;
  font-weight: 700;
  color: var(--tx);
}

.proof::after {
  content: ' □';
  float: right;
  font-style: normal;
}


/* ── Rules, navigation, footnotes ──────────────────────────── */

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

.page-navigation {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1.2rem;
  font-family: var(--serif);
  font-size: 0.92rem;
}

.nav-page-text {
  color: var(--muted);
}

.nav-page a {
  color: var(--purple);
  font-weight: 700;
}

.footnotes {
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
  padding-top: 1rem;
}

.footnotes p {
  text-align: left;
}


/* ── Math display ──────────────────────────────────────────── */

.math.display,
span.math.display {
  margin: 1.4rem 0;
}

.katex,
.MathJax {
  font-size: 1.02em;
}


/* ── Responsive tweaks ─────────────────────────────────────── */

@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  #quarto-document-content,
  .chapter-content {
    max-width: 100%;
  }

  h1.title {
    font-size: 2.05rem;
  }

  .chapter > h1,
  section > h1,
  h1:not(.title):not(#title-block-header h1) {
    font-size: 1.65rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  #title-block-header::after {
    width: 6rem;
  }
}