:root {
  --font-dm-sans: "DM Sans", sans-serif;
  --font-source-serif: "source-serif-4-subhead", serif;
  --foreground: #000000;
  --background: #f4f5f6;
  --border: #000000;
  --muted: #6b7280;
}

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  max-width: 140vw;
  overflow-x: hidden;
  font-family: var(--font-source-serif);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  font-size: 1.1rem;
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--foreground);
}

a:hover {
  opacity: 0.8;
}

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.2;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2.5rem;
  font-weight: 600;
}
h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.title {
  font-size: 4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 2.2rem;
  font-weight: 400;
  margin-top: 0.1rem;
}

.header {
  margin-bottom: 0.5rem;
}

.table-of-contents-title {
  margin-top: 0.5rem;
  margin-bottom: 1.2rem;
}

code {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Container */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  /* border-bottom: 1px solid var(--border); */
}

/* Table of Contents */
#table-of-contents {
  margin-bottom: 3rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.02);
}

#table-of-contents ol {
  margin-left: 1.5rem;
}

#table-of-contents li {
  margin-bottom: 0.5rem;
}

/* New table of contents styling for better hierarchy */
#table-of-contents > ol > li > a {
  font-size: 1.1rem;
  font-weight: 500;
}

#table-of-contents > ol > li > ul > li > a {
  font-size: 0.95rem;
  font-weight: 400;
}

#table-of-contents > ol > li > ul > li > ul > li > a {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

#table-of-contents ul {
  margin-top: 0.3rem;
  margin-bottom: 0.5rem;
}

/* Content */
section {
  margin-bottom: 0;
}

p {
  margin-bottom: 1rem;
}

ul,
ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

sup {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
  cursor: pointer;
}

sup:hover {
  text-decoration: underline;
}

.arrow-list {
  list-style: none;
  margin-left: 0;
}

.arrow-list li {
  position: relative;
  padding-left: 1.5rem;
}

.arrow-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--foreground);
}

ol.list-decimal {
  list-style-type: decimal;
}

ol.list-decimal li {
  margin-bottom: 0.75rem;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

footer p {
  margin-bottom: 0.5rem;
}

.github-link {
  margin-top: 1rem;
}

.github-link a {
  color: var(--foreground);
  font-weight: 500;
  border-bottom: 1px solid var(--foreground);
  transition: opacity 0.2s ease;
}

.github-link a:hover {
  opacity: 0.7;
}

/* Chapter Row Layout */
.chapter-row {
  display: flex;
  margin-bottom: 4rem;
  position: relative;
  gap: 3rem;
}

.chapter-content {
  flex: 3;
}

.chapter-notes {
  flex: 1;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Footnotes aligned at the bottom of chapter content */
.chapter-footnotes {
  position: static;
  padding-left: 1rem;
  /* border-left: 1px solid var(--border); */
  margin-top: auto;
}

.chapter-footnotes h3 {
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--foreground);
  opacity: 0.7;
}

.footnote {
  margin-bottom: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .chapter-row {
    flex-direction: column;
    gap: 1rem;
  }

  .chapter-notes {
    justify-content: flex-start;
  }

  .chapter-footnotes {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1rem;
    margin-top: 1rem;
  }
}

.chapter-image {
  margin-top: 40px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* New class for positioned images */
.chapter-image-positioned {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: 20px; /* Default sticky position from top */
  margin-bottom: 30px; /* Add space between positioned images */
  z-index: 1; /* Ensure proper stacking */
}

/* Class to adjust the vertical position of an image */
.image-position-adjust {
  margin-top: var(--position-offset, 0);
}

/* Class for images that should appear within the content flow */
.chapter-image-inline {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 30px 0;
}

.basic-loop-image {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.image-caption {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  font-weight: 400;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

/* Binary paragraph numbers */
.binary-paragraph-number {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--muted);
  opacity: 0.6;
  text-align: left;
  letter-spacing: 1px;
}

.binary-container {
  position: absolute;
  right: 0;
  width: 100%;
  text-align: left;
  pointer-events: none;
}

/* Remove page indicator styles since we're not using it anymore */
#page-indicator {
  display: none;
}

pre {
  background-color: #bdbdbd;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 16px;
  overflow: auto;
  margin: 16px 0;
  max-width: 100%;
  box-sizing: border-box;
}

pre code {
  background-color: transparent;
  padding: 0;
  border: none;
  font-family: "DM Mono", monospace, Consolas, Monaco, "Andale Mono",
    "Ubuntu Mono";
  font-size: 0.7em;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  display: block;
  width: 100%;
}

.nobreak {
  white-space: nowrap;
  word-break: keep-all;
}

/* Table styles moved from inline CSS */
.latency-table {
  margin-top: 20px;
  font-size: 0.9em;
}

.latency-table h4 {
  font-size: 1em;
  margin-bottom: 10px;
  font-weight: 500;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 0.85em;
  font-family: "DM Mono", monospace;
}

.data-table th {
  background-color: #f2f2f2;
  color: #333;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid #ddd;
}

.data-table td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  vertical-align: middle;
}

.data-table tr:nth-child(even) {
  background-color: #f8f8f8;
}

.data-table tr:hover {
  background-color: #f0f0f0;
}

.table-caption {
  font-size: 0.85em;
  margin-top: 8px;
  margin-bottom: 16px;
  font-style: italic;
  color: #555;
}

/* Specific styling for cost and latency tables */
.model-comparison td:first-child {
  font-weight: 500;
}

.model-comparison td:not(:first-child) {
  text-align: center;
}

.latency-breakdown td:last-child {
  text-align: right;
  font-family: "DM Mono", monospace;
}

.total-row {
  border-top: 2px solid #ccc;
  background-color: #f2f2f2 !important;
}

.total-row td {
  font-weight: 600;
}

.footnote-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.footnote .image-caption {
  font-size: 0.85em;
  margin-top: 4px;
  margin-bottom: 12px;
  font-style: italic;
  color: #555;
}

.language-python {
  font-family: "DM Mono", monospace;
  background-color: #343433;
  color: #f8f8f8;
  padding: 0;
}

.subtle-code {
  background-color: #f4f5f6;
  color: #1e773e;
}
