/* Grid cards on the index page */
.md-typeset .grid.cards > ul > li {
  border-radius: 0.6rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s, transform 0.2s;
}

.md-typeset .grid.cards > ul > li:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

/* Collapsible document tree */
.md-typeset details {
  border-radius: 0.4rem;
}

/* Header image on the index page */
.md-typeset img[alt="index"] {
  border-radius: 0.6rem;
}

/* Index page: the "Start reading" button scrolls to the topics; animate it unless the user prefers less motion */
@media (prefers-reduced-motion: no-preference) {
  html:has(.home-top) {
    scroll-behavior: smooth;
  }
}

/* Hero section on the index page: kicker, title, lead, buttons, summary chips, quote */
.hero {
  padding: 1rem 0 2rem;
}

.hero-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--md-typeset-a-color);
}

.md-typeset .hero h1 {
  margin: 0 0 0.6rem;
  font-size: 2.2em;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--md-default-fg-color);
  text-wrap: balance; /* split a wrapped title evenly instead of leaving one word on the last line */
}

.hero h1 + p {
  max-width: 36rem;
  font-size: 0.9rem;
}

/* Dark mode: the outlined (non-primary) buttons use the blue-grey primary colour, which is
   too dark on the dark background; use the link colour instead. Hover/focus keep the theme's accent. */
[data-md-color-scheme="slate"] .md-typeset .md-button:not(.md-button--primary):not(:hover):not(:focus) {
  color: var(--md-typeset-a-color);
  border-color: var(--md-typeset-a-color);
}

.hero-byline {
  margin: -0.3rem 0 1rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

.hero-byline p {
  margin: 0;
}

.hero-byline a {
  font-weight: 700;
}

.hero img {
  max-width: 100%;
}

.hero > p:last-child {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

/* Summary chips (generated by hooks/stats.py) */
.home-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.2rem 0;
}

.home-chip {
  padding: 0.1rem 0.7rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
  background: var(--md-code-bg-color);
}

.home-chip strong {
  color: var(--md-default-fg-color);
}

/* Two-column hero on the About page: logo left, info right */
.about-hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1rem 0 2rem;
}

.about-hero__logo {
  flex: 0 0 auto;
}

/* Logo has a transparent background; lift its dark parts on the dark scheme */
[data-md-color-scheme="slate"] .about-hero__logo img {
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35));
}

.about-hero__logo p,
.about-hero__info p {
  margin: 0.4rem 0;
}

.about-hero__info {
  flex: 1 1 auto;
}

/* Stack on narrow screens */
@media (max-width: 44.9375em) {
  .about-hero {
    flex-direction: column;
    text-align: center;
  }
}

/* Statistics block on the index page (generated by hooks/stats.py) */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.6rem;
}

.stats-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 0.4rem;
  border-radius: 0.6rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.stats-card strong {
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--md-primary-fg-color);
}

.stats-card span {
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

.stats-chart {
  margin-bottom: 1rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 8rem 1fr 4rem;
  align-items: center;
  gap: 0.6rem;
  margin: 0.25rem 0;
  font-size: 0.75rem;
}

.stats-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0;
  background: var(--md-default-fg-color--lightest);
  border-radius: 0.2rem;
}

.stats-bar {
  display: block;
  height: 0.8rem;
  min-width: 2px;
  border-radius: 0.2rem;
}

.stats-bar.stats-pages {
  background: var(--md-primary-fg-color);
}

.stats-bar.stats-lines {
  background: var(--md-accent-fg-color);
}

.stats-num {
  text-align: right;
  color: var(--md-default-fg-color--light);
}

@media (max-width: 40rem) {
  .stats-row {
    grid-template-columns: 5.5rem 1fr 3.5rem;
  }
}

/* Yearly chart (SVG): bars = new notes (left axis), line = lines written (right axis) */
.stats-yearbox {
  margin: 0 auto 1rem;
}

.stats-year {
  display: block;
  width: 100%;
  height: auto;
}

.stats-year .stats-grid {
  stroke: var(--md-default-fg-color--lightest);
  stroke-width: 1;
}

.stats-year .stats-axis,
.stats-year .stats-value {
  font-size: 11px;
  fill: var(--md-default-fg-color--light);
}

/* Values may sit on top of a bar: a halo in the page colour keeps them readable */
.stats-year .stats-value {
  fill: var(--md-default-fg-color);
  stroke: var(--md-default-bg-color);
  stroke-width: 3px;
  paint-order: stroke;
  stroke-linejoin: round;
}

.stats-year .stats-axis-col {
  fill: var(--md-primary-fg-color);
}

.stats-year .stats-axis-curve {
  fill: var(--md-accent-fg-color);
}

.stats-year .stats-col {
  fill: var(--md-primary-fg-color);
}

.stats-year .stats-curve {
  fill: none;
  stroke: var(--md-accent-fg-color);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.stats-year .stats-dot {
  fill: var(--md-accent-fg-color);
  stroke: var(--md-default-bg-color);
  stroke-width: 1.5;
}

.stats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  margin: 0 0 0.4rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

.stats-legend span {
  white-space: nowrap;
}

.stats-key {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  vertical-align: -0.1rem;
  border-radius: 0.15rem;
}

.stats-key-col {
  background: var(--md-primary-fg-color);
}

.stats-key-curve {
  border-radius: 50%;
  background: var(--md-accent-fg-color);
}

/* Let wide line charts scroll instead of shrinking the text */
.stats-linebox {
  overflow-x: auto;
}

/* Commit activity calendar (a column per year, a row per month) */
.stats-heat {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.stats-heat .stats-axis {
  font-size: 10px;
  fill: var(--md-default-fg-color--light);
}

.stats-heat .stats-day.l0 {
  fill: var(--md-default-fg-color--lightest);
}

.stats-heat .stats-day.l1,
.stats-heat .stats-day.l2,
.stats-heat .stats-day.l3,
.stats-heat .stats-day.l4 {
  fill: var(--md-primary-fg-color);
}

.stats-heat .stats-day.l1 { fill-opacity: 0.3; }
.stats-heat .stats-day.l2 { fill-opacity: 0.55; }
.stats-heat .stats-day.l3 { fill-opacity: 0.8; }
.stats-heat .stats-day.l4 { fill-opacity: 1; }

.stats-heat .stats-count {
  font-size: 10px;
  pointer-events: none;
  fill: var(--md-default-fg-color);
}

.stats-heat .stats-count.l3,
.stats-heat .stats-count.l4 {
  fill: #fff;
}

/* Index page layout: use the full width on wide screens (marked by .home-top) */
body:has(.home-top) .md-grid {
  max-width: 84rem;
}

.home-top {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: stretch;
}

.home-top .hero {
  padding: 0;
}

.home-latest {
  display: flex;
  flex-direction: column;
  padding: 0.2rem 1.2rem 0;
  border-radius: 0.6rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.home-latest h2 {
  margin-top: 0.8rem;
}

.home-tree {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  gap: 0 1.2rem;
  align-items: start;
}

@media (max-width: 60em) {
  .home-top {
    grid-template-columns: minmax(0, 1fr);
  }
}

.home-article {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.home-article a {
  font-weight: 600;
}

.home-article small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  color: var(--md-default-fg-color--light);
}

/* Category label on the latest articles: a small pill that links to the category page */
.md-typeset .home-article a.home-pill {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--md-typeset-a-color);
  background: var(--md-code-bg-color);
  background: color-mix(in srgb, var(--md-typeset-a-color) 16%, transparent);
}

.md-typeset .home-article a.home-pill:hover {
  color: var(--md-accent-fg-color);
  background: color-mix(in srgb, var(--md-accent-fg-color) 16%, transparent);
}

.home-article p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--md-default-fg-color--light);
}

.home-latest > p:last-child {
  margin: auto 0 0;
  padding: 0.6rem 0;
}

/* Bubble chart: lines by topic */
.stats-bubbles {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 1rem;
}

/* Bubble colours: six hues of similar weight, each dark enough for white text (contrast >= 4.5:1,
   checked against #fff). The first follows the theme's primary colour. Fills are solid, so the
   contrast does not depend on the page background. */
.stats-bubbles {
  --bubble-0: var(--md-primary-fg-color); /* blue grey */
  --bubble-1: #4a5bc7; /* indigo */
  --bubble-2: #00796b; /* teal */
  --bubble-3: #b45309; /* amber */
  --bubble-4: #7b3fa0; /* purple */
  --bubble-5: #2e7d32; /* green */
}

.stats-bubble circle {
  stroke-width: 1.5;
}

.stats-bubble:hover circle {
  filter: brightness(1.15);
}

/* Dark mode: a light ring keeps the darker bubbles apart from the dark background */
[data-md-color-scheme="slate"] .stats-bubbles .stats-bubble circle {
  stroke: rgba(255, 255, 255, 0.4);
}

.stats-bubble text {
  font-size: 11px;
  fill: #fff;
  pointer-events: none;
}

.stats-bubble .stats-bubble-num {
  font-size: 10px; /* full opacity: fading the white text would drop it below 4.5:1 */
}

.stats-bubble.c0 circle { fill: var(--bubble-0); stroke: var(--bubble-0); }
.stats-bubble.c1 circle { fill: var(--bubble-1); stroke: var(--bubble-1); }
.stats-bubble.c2 circle { fill: var(--bubble-2); stroke: var(--bubble-2); }
.stats-bubble.c3 circle { fill: var(--bubble-3); stroke: var(--bubble-3); }
.stats-bubble.c4 circle { fill: var(--bubble-4); stroke: var(--bubble-4); }
.stats-bubble.c5 circle { fill: var(--bubble-5); stroke: var(--bubble-5); }

/* Tinted cards on the index page: latest articles and the topic cards (also the
   category cards on the Articles index). The code background is the fallback; the
   tint mixes in the theme's primary colour. */
.home-latest,
.home-top ~ .grid.cards > ul > li,
.home-topics > ul > li {
  background: var(--md-code-bg-color);
}

@supports (background: color-mix(in srgb, red 10%, blue)) {
  .home-latest,
  .home-top ~ .grid.cards > ul > li,
  .home-topics > ul > li {
    background: color-mix(in srgb, var(--md-primary-fg-color) 10%, var(--md-default-bg-color));
  }
}

/* Topic cards on the index page: all 9 cards the same size, 3 x 3 (one column on phones).
   The title link is stretched over the whole card, so the card itself is the click target. */
.md-typeset .grid.home-topics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Articles index: 4 category cards in 2 x 2 */
.md-typeset .grid.home-topics.topics-2col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 40em) {
  .md-typeset .grid.home-topics.topics-2col,
  .md-typeset .grid.home-topics {
    grid-template-columns: minmax(0, 1fr);
  }
}

.md-typeset .home-topics > ul > li {
  position: relative;
}

.md-typeset .home-topics > ul > li > p:first-child a {
  color: inherit;
}

.md-typeset .home-topics > ul > li > p:first-child a::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* Topic icon: large, faded, top right; no divider line, and room reserved so text never runs under it */
.md-typeset .home-topics > ul > li > hr {
  display: none;
}

.md-typeset .home-topics > ul > li > p {
  padding-right: 2.8rem;
}

.md-typeset .home-topics > ul > li > p:first-child .twemoji {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--md-typeset-a-color);
  opacity: 0.3;
  transition: opacity 0.2s;
}

.md-typeset .home-topics > ul > li > p:first-child .twemoji svg {
  width: 100%;
  height: 100%;
  max-height: none;
}

.md-typeset .home-topics > ul > li:hover > p:first-child .twemoji {
  opacity: 0.6;
}

@media (max-width: 40em) {
  .md-typeset .home-topics > ul > li > p:first-child .twemoji {
    width: 1.8rem;
    height: 1.8rem;
  }
}

/* Cover banner at the top of an article; also shown in the article list */
.article-cover {
  display: block;
  width: 100%;
  border-radius: .4rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}

/* Heatmap tables: cells get a level class from javascripts/heatmap.js */
:root {
  --heat-4: rgba(46, 160, 67, 0.55);
  --heat-3: rgba(46, 160, 67, 0.32);
  --heat-2: rgba(210, 153, 34, 0.35);
  --heat-1: rgba(128, 128, 128, 0.14);
}

.md-typeset .heatmap td.heat {
  text-align: center;
}

.md-typeset .heatmap td.lvl-4 { background-color: var(--heat-4); font-weight: 600; }
.md-typeset .heatmap td.lvl-3 { background-color: var(--heat-3); }
.md-typeset .heatmap td.lvl-2 { background-color: var(--heat-2); }
.md-typeset .heatmap td.lvl-1 { background-color: var(--heat-1); }
.md-typeset .heatmap td.lvl-0 { color: var(--md-default-fg-color--lighter); }

/* Header: the repository block and the icon links (extra.header_links) next to it.
   Material gives the repository block a fixed 11.7rem (room for the stars/forks facts),
   which leaves a wide gap before the next header button; let it shrink to its content. */
.md-header__source {
  width: auto;
}

/* ...and drop the percentage max-width on the repo name, which would otherwise be
   resolved against the shrunken block and cut "GitHub" down to "G…". */
.md-header__source .md-source__repository {
  max-width: none;
}

/* Icon links are shown on wide screens only, like the repository block. */
.md-header__link {
  /* the repo link sits 1rem from the search box; keep the same 1rem (0.2rem header
     padding + 0.8rem) between the icon button and the right edge of the header */
  margin-left: 0.2rem;
  margin-right: 0.8rem;
}

@media screen and (max-width: 59.9844em) {
  .md-header__link {
    display: none;
  }
}

/* Site logo in the header: the flat penguin badge reads better a bit larger than Material's default */
.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 1.8rem;
  width: auto;
}
