/* Figures and diagram captions */
figure {
  margin: 2rem 0;
  text-align: center;
}

figure svg {
  max-width: 100%;
  height: auto;
}

/* On narrow screens, shrinking a detailed diagram to fit makes its labels
   unreadable. Scroll it at a legible size instead. */
@media (max-width: 700px) {
  figure {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  figure svg {
    min-width: 620px;
    max-width: none;
  }
}

/* Printing: diagrams must fit the page, and scroll containers must not clip. */
@media print {
  figure,
  .content table {
    overflow: visible !important;
    width: auto !important;
    display: table;
    break-inside: avoid;
  }

  figure svg {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  figure {
    display: block;
  }
}

/* Font sizes use em, not rem: mdBook sets the root font size to 62.5%, so
   1rem is only 10px. */
figcaption {
  margin-top: 0.6rem;
  font-size: 0.875em;
  line-height: 1.5;
  opacity: 0.72;
  font-style: italic;
  text-align: center;
}

/* "Where this connects" footers */
h2#where-this-connects {
  font-size: 1.1em;
  opacity: 0.85;
}

h2#where-this-connects + ul {
  font-size: 0.925em;
}

/* Wide reference tables should scroll rather than overflow the page */
.content table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  width: max-content;
  margin: 1.2rem 0;
}

/* Keep long code samples from forcing horizontal page scroll */
.content pre > code {
  overflow-x: auto;
}

/* Exercise hints and solutions: folded by default, clearly clickable */
.content details {
  margin: 0.4rem 0 1.4rem;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--links);
  background: var(--quote-bg);
  border-radius: 0 4px 4px 0;
}

.content details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.925em;
  opacity: 0.85;
}

.content details[open] > summary {
  margin-bottom: 0.6rem;
}

.content details + details {
  margin-top: -0.8rem;
}

/* Printing: theme/print-details.js opens every <details> before printing,
   so hints and solutions appear in the PDF. */
