/*
 * tuning-database.co.uk, v3: one article (templates/post.php). The text at a
 * reading measure, its contents beside it from a laptop up (as the legal
 * pages have theirs) and above it on a phone, the boxes the author drew as
 * callouts, tables that scroll sideways, then sharing and related articles.
 * Colours come from the tokens only, so both themes draw it.
 */

.article__title {
  max-width: 24ch;
}

.article-layout {
  display: grid;
  gap: var(--sp-6);
  max-width: calc(var(--measure) + 2 * var(--gutter));
}

@media (min-width: 1100px) {
  .article-layout--toc {
    grid-template-columns: 250px minmax(0, var(--measure));
    gap: var(--sp-8);
    align-items: start;
    max-width: var(--page-max);
  }

  .article-share-band .article-layout {
    max-width: var(--page-max);
    padding-left: calc(var(--gutter) + 250px + var(--sp-8));
  }

  .toc {
    position: sticky;
    top: calc(var(--header-h) + var(--sp-5));
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* ---- contents ----------------------------------------------------------- */

.toc__box {
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--bg-raised);
}

.toc__box summary {
  padding: var(--sp-3) var(--sp-4);
  color: var(--ink);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.toc__list {
  margin: 0;
  padding: 0 var(--sp-4) var(--sp-4);
  list-style: none;
  font-size: var(--step--1);
}

.toc__item a {
  display: block;
  padding: var(--sp-1) 0 var(--sp-1) var(--sp-3);
  border-left: 2px solid var(--line);
  color: var(--ink-2);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.toc__item--h3 a {
  padding-left: var(--sp-5);
  color: var(--ink-3);
}

.toc__item a:hover {
  color: var(--ink);
}

.toc__item a[aria-current="true"] {
  border-left-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

/* ---- the body ----------------------------------------------------------- */

.article-body {
  min-width: 0;
}

/* Below the header when a contents link jumps to it. */
.article-body :is(h2, h3) {
  scroll-margin-top: calc(var(--header-h) + var(--sp-5));
}

/* Paragraphs inside a box or a list item are spaced like the rest. */
.article-body :where(div, li, blockquote) > * + * {
  margin-top: 1em;
}

.article-body .lede {
  color: var(--ink);
  font-size: var(--step-1);
  line-height: var(--leading-snug);
}

.callout {
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-2);
  background: var(--bg-sunk);
}

.callout > :first-child,
.article-cta > :first-child {
  margin-top: 0;
}

.article-cta {
  padding: var(--sp-5) var(--sp-6);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-2);
  background: var(--bg-raised);
}

.article-cta h2,
.article-cta h3 {
  font-size: var(--step-1);
}

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

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-1);
}

.table-scroll table {
  min-width: 480px;
  margin: 0;
}

.article-body th {
  background: var(--bg-sunk);
  color: var(--ink);
}

.article-body tr:last-child > * {
  border-bottom: 0;
}

.article-body pre {
  padding: var(--sp-3) var(--sp-4);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-1);
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  line-height: 1.55;
}

.article-body pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  white-space: pre;
}

/* Inline code (a long software number, a path) breaks where it must on a phone instead of pushing the page sideways. */
.article-body :not(pre) > code {
  overflow-wrap: anywhere;
}

/* ---- share -------------------------------------------------------------- */

.article-share-band {
  padding-top: 0;
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}

.share__label {
  margin-right: var(--sp-2);
  color: var(--ink-2);
  font-size: var(--step--1);
}

.share__btn {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--step--1);
  text-decoration: none;
  cursor: pointer;
}

.share__btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

/* ---- related ------------------------------------------------------------ */

.related {
  display: grid;
  gap: var(--sp-4);
  margin: var(--sp-5) 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 800px) {
  .related {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.related__card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  height: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--bg-raised);
  color: var(--ink);
  text-decoration: none;
}

.related__card:hover {
  border-color: var(--line-strong);
  background: var(--bg-hover);
}

.related__topic {
  color: var(--accent-ink);
  font-size: var(--step--1);
  font-weight: 600;
}

.related__title {
  font-weight: 700;
  line-height: var(--leading-snug);
}

.related__card .small {
  margin-top: auto;
}
