/* ============================================================
   EC102 — Microeconomics for Business
   Classic textbook style: Baskerville headings, centered text
   column, warm terracotta and ochre palette. Same skeleton as
   the EC104A stylesheet, different colors, plus .pod and
   .banner classes for problems of the day and notices.
   ============================================================ */

@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: #3B3733;
  --bg: #FFFDFA;
  --muted: #6F6862;
  --rule: #E3D5C4;

  /* Terracotta — primary: links, section numbers, note callouts */
  --primary: #B5563A;
  --primary-dark: #8F3F28;
  --primary-soft: #F7E9E2;

  /* Ochre — secondary: tips, examples, sidebar */
  --secondary: #C8963E;
  --secondary-soft: #F8EFDC;

  /* Sand — accent: code borders, blockquotes, TOC */
  --accent: #D9B98C;
  --accent-soft: #F5EDE0;

  /* Rose — problems of the day */
  --pod-bg: #FBE9EE;
  --pod-border: #E6B7C3;

  --code-bg: #F7F1E8;
  --code-border: #E0CFB8;

  --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;
}

#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,
#quarto-document-content .pod,
#quarto-document-content .banner,
.chapter-content ul,
.chapter-content ol,
.chapter-content pre,
.chapter-content blockquote,
.chapter-content .callout,
.chapter-content table,
.chapter-content figure,
.chapter-content .pod,
.chapter-content .banner {
  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(--primary);
  font-weight: 700;
  margin-right: 0.35em;
}


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

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

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


/* ── Problems of the day and banners ───────────────────────── */

/* Use either ::: {.pod} ... ::: in Quarto markdown, or the inline
   <div style="background-color: #ffe6ef; ..."> from the EC104A pages;
   both render the same way. */

.pod,
div[style*="background-color: #ffe6ef"] {
  background: var(--pod-bg) !important;
  border: 1px solid var(--pod-border);
  border-radius: 6px;
  padding: 0.6rem 1.1rem 0.4rem 1.1rem !important;
  margin-top: 1.6rem;
  margin-bottom: 1.6rem;
}

.pod h3,
div[style*="background-color: #ffe6ef"] h3 {
  margin-top: 0.6rem;
}

.pod p:last-child {
  margin-bottom: 0.4rem;
}

.banner {
  background: var(--secondary-soft);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 16px 20px;
  text-align: center;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 1.2rem auto;
}


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

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

.sidebar-title,
.sidebar-title a {
  font-family: var(--display);
  color: var(--primary-dark) !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: var(--tx) !important;
  font-size: 0.94rem;
  line-height: 1.25;
}

.sidebar-item-text:hover {
  color: var(--primary-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(--primary-dark) !important;
  font-weight: 700;
}

.sidebar-item-section .sidebar-item-text {
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted) !important;
}


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

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

.aa-DetachedSearchButton {
  border: 1px solid rgba(181,86,58,.18) !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(--accent);
  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(--primary);
  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: var(--primary-soft);
  border: 1px solid #E4C7BB;
  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(--accent) !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(--accent);
  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;
  vertical-align: bottom;
}

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;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: rgba(245,237,224,.55);
}


/* ── 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(--primary) !important;
  background: rgba(181,86,58,.06) !important;
}

.callout-tip {
  border-left-color: var(--secondary) !important;
  background: rgba(200,150,62,.08) !important;
}

.callout-warning {
  border-left-color: var(--accent) !important;
  background: rgba(217,185,140,.14) !important;
}

.callout-important {
  border-left-color: var(--primary-dark) !important;
  background: rgba(143,63,40,.07) !important;
}

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


/* ── Definitions and examples ──────────────────────────────── */

.def {
  border-left: 4px solid var(--primary);
  background: rgba(181,86,58,.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 {
  color: var(--primary-dark);
}

.example {
  border-left: 4px solid var(--secondary);
  background: rgba(200,150,62,.07);
  border-radius: 0 3px 3px 0;
  padding: 0.75rem 1.1rem 0.75rem 1.3rem;
  margin-top: 1.6rem;
  margin-bottom: 1.6rem;
}


/* ── 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(--primary);
  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;
  }
}
