:root {
  /* The site's one brand color, plus a soft tint for callouts. Figures carry
     the full palette (teal, amber, slate) in page/_palette.py; the pages
     themselves only need the primary. */
  --primary: #008080;
  --primary-soft: #eef4f2;
}

h1 {
  text-align: center;
}

h1, h2, h3, h4 {
  color: var(--primary);
}

/* Page title — the index title ("The Book") and each page's own title. The ID
   selector outranks the theme's heading color so the title is always the brand color. */
#title-block-header .title {
  color: var(--primary);
}

/* Listing entry titles (the page links on the index). The cosmo theme colors
   post links dark grey (div.quarto-post a); this higher-specificity rule puts
   the entry titles back to the brand color. */
div.quarto-post .listing-title a {
  color: var(--primary);
}

/* Images resize responsively */
.responsive-img {
  display: block;
  margin: 1em auto;
  max-width: 100%;
  width: 100%;
  height: auto;
}
@media (min-width: 768px) {
  .responsive-img {
    width: 700px;
  }
}

/* Scrollable block math on small screens */
mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

mjx-container[display="true"] {
  display: block;
}

mjx-container > svg {
  max-width: 100%;
  height: auto;
}

/* Collapsible proof block */
.proof-block details {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
}

.proof-block summary {
  font-weight: bold;
  cursor: pointer;
  list-style: none;
}

.proof-block summary::-webkit-details-marker {
  display: none; /* hide default marker */
}

.proof-block summary::before {
  content: "▶ ";
  transition: transform 0.2s ease;
}

.proof-block details[open] summary::before {
  transform: rotate(90deg);
  display: inline-block;
}

/* Display table: wrap a pipe table in a .compress-table div. Centered and
   compact with hairline rules; the first body row (the one the surrounding
   prose reads) is shaded in the brand tint behind a teal edge, echoing the
   proof blocks. !important outranks Bootstrap's .table cell rules. */
.compress-table {
  overflow-x: auto;
}
.compress-table table {
  width: auto;
  margin: 1.6em auto;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #ccd6d2;
  border-radius: 10px;
  overflow: hidden;
}
.compress-table th,
.compress-table td {
  border: none !important;
  background: none !important;
  box-shadow: none !important;
  padding: 0.5em 1.5em !important;
}
.compress-table thead th {
  color: #6b7975;
  font-weight: 600;
  font-size: 0.88em;
  letter-spacing: 0.015em;
  border-bottom: 1px solid #ccd6d2 !important;
  padding-top: 0.7em !important;
}
.compress-table tbody tr + tr td {
  border-top: 1px solid #eef4f2 !important;
}
.compress-table tbody tr:first-child td {
  background: var(--primary-soft) !important;
}
.compress-table tbody tr:first-child td:first-child {
  box-shadow: inset 4px 0 0 var(--primary) !important;
}

/* Estimated reading time, prepended to each page body by readtime.lua */
.reading-time {
  font-size: 0.85em;
  color: #6c757d;
  margin-top: -0.3em;
  margin-bottom: 1.6em;
}

/* Listing: these pages carry no thumbnail, so the default "image-right"
   layout (flex row-reverse) leaves an empty image column on the left and
   pushes the title, tags, and description to the right. Collapse it to a
   left-aligned block. */
.quarto-post,
.quarto-post.image-right,
.quarto-post.image-left {
  display: block !important;
}
.quarto-post .metadata {
  display: none !important;
}
.quarto-post .body {
  flex-basis: auto !important;
  width: 100%;
}

/* Category tags: colored pills. The per-category background and (contrast-
   picked) text color are set by a small script in header.html so a category is
   the same color everywhere; var(--primary) here is only the fallback before that runs. */
.listing-categories,
.quarto-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
  margin: 0.5em 0;
  border: none !important;
}
.listing-categories .listing-category,
.quarto-categories .quarto-category {
  display: inline-block;
  color: #ffffff;
  background-color: var(--primary);
  border: none !important;
  border-radius: 999px !important;
  padding: 0.16em 0.78em !important;
  margin: 0 !important;
  font-size: 0.72em !important;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none !important;
  /* cosmo dims the page-header tags to opacity .6; keep them at full color */
  opacity: 1 !important;
  transition: transform 0.15s ease;
  cursor: pointer;
}
.listing-categories .listing-category:hover,
.quarto-categories .quarto-category:hover {
  transform: translateY(-1px);
}

/* Rainbow filter bar (listing page): built in header.html, reuses Quarto's
   listing filter. Pills are colored per category, so laid out in order they
   sweep the spectrum. Selecting a tag dims the rest; "All" clears the filter. */
.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em;
  max-width: 780px;
  margin: 0.25em auto 2.2em;
}
.tag-filter {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
  background-color: #6c757d;
  border: none;
  border-radius: 999px;
  padding: 0.34em 0.95em;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.tag-filter:hover {
  transform: translateY(-1px);
}
.tag-filter.active {
  transform: scale(1.06);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.22);
}
.tag-filter.active:hover {
  transform: scale(1.06) translateY(-1px);
}
/* When a specific tag is selected, fade the others so the choice stands out.
   In the default ("All") state nothing is faded, so the full rainbow shows. */
.tag-filter-bar.filtering .tag-filter:not(.active) {
  opacity: 0.35;
}
