/*
 * The post page: the table of contents beside the text, the FAQ cards, the sources, the tables. Loaded on posts only, after
 * academy.css, whose tokens it uses. See docs/design-system.md.
 */

/* A heading reached from the table of contents stops under the floating header. */
.entry-content [id] {
  scroll-margin-top: calc(var(--cs-header-initial-height) + var(--academy-header-inset) + 1.5rem);
}

/*
 * 1. Table of contents. On a phone it opens the text as a card. From 1020px it stands beside the text and stays in
 * view, the share buttons in a row under it; academy.js marks the section being read with aria-current.
 */
.academy-has-toc .cs-entry__metabar {
  display: block;
  margin-bottom: 2rem;
}
.academy-has-toc .cs-entry__metabar-item {
  align-items: stretch;
  width: 100%;
}
.academy-has-toc .cs-entry__metabar .pk-share-buttons-wrap {
  display: none;
}
.academy-toc a {
  color: var(--cs-color-post-meta-link);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.academy-toc a:hover,
.academy-toc a[aria-current] {
  color: var(--cs-color-primary);
}
.academy-toc a[aria-current] {
  font-weight: 600;
}
.academy-toc li:has(> a[aria-current])::before {
  background: var(--academy-brand);
  color: #141614;
}
@media (min-width: 1020px) {
  .single .cs-metabar-enabled .academy-has-toc {
    grid-template-columns: minmax(0, 18rem) minmax(0, var(--cs-entry-content-width));
  }
  .academy-has-toc .cs-entry__metabar {
    margin: 0;
  }
  /* A long table of contents scrolls inside its card, so the share buttons stay in view. */
  .academy-has-toc .cs-entry__metabar-inner {
    max-height: calc(100vh - var(--cs-header-initial-height) - var(--academy-header-inset) - 3rem);
  }
  .academy-has-toc .cs-entry__metabar-item {
    gap: 1rem;
    min-height: 0;
  }
  .academy-toc {
    min-height: 0;
    overflow-y: auto;
    border-radius: var(--academy-radius-lg);
    scrollbar-width: thin;
  }
  .academy-toc .pk-toc {
    --pk-toc-ol-font-size: 0.875rem;
    --pk-toc-ol-ol-font-size: 0.8125rem;
    margin: 0;
    padding: 1.25rem;
  }
  .academy-has-toc .cs-entry__metabar .pk-share-buttons-wrap {
    display: block;
    margin: 0;
    padding: 0;
  }
  .academy-has-toc .cs-entry__metabar .pk-share-buttons-items {
    flex-direction: row;
    gap: 0.5rem;
    margin: 0;
  }
  .academy-has-toc .cs-entry__metabar .pk-share-buttons-wrap .pk-share-buttons-item {
    margin: 0;
  }
}
@media (prefers-reduced-motion: no-preference) {
  :root:has(.academy-toc) {
    scroll-behavior: smooth;
  }
}

/* 2. FAQ: every question is a card, and a tap opens its answer; the first card is open. */
.entry-content .saswp-faq-block-section ol,
.entry-content .schema-faq {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}
.academy-faq {
  border-radius: var(--academy-radius);
  background: var(--cs-color-widgets-background);
}
.academy-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  list-style: none;
  cursor: pointer;
}
.academy-faq summary::-webkit-details-marker {
  display: none;
}
.academy-faq summary::after {
  content: '+';
  flex: none;
  color: var(--cs-color-post-meta);
  font-size: 1.5rem;
  line-height: 1;
  transition: rotate 0.2s var(--academy-ease-snap);
}
.academy-faq[open] summary::after {
  rotate: 45deg;
}
.entry-content .academy-faq summary > * {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}
.entry-content .academy-faq > p {
  margin: 0;
  padding: 0 1.25rem 1.25rem;
  font-size: 1rem;
}
/* Answers of old posts open with a line break left by the editor. */
.academy-faq > p > br:first-child {
  display: none;
}
/* The answer slides open and shut where the browser can animate to its natural height; elsewhere it just appears. */
@media (prefers-reduced-motion: no-preference) {
  .academy-faq {
    interpolate-size: allow-keywords;
  }
  .academy-faq::details-content {
    block-size: 0;
    overflow: clip;
    opacity: 0;
    transition: block-size 0.3s var(--academy-ease), opacity 0.3s, content-visibility 0.3s allow-discrete;
  }
  .academy-faq[open]::details-content {
    block-size: auto;
    opacity: 1;
  }
}

/* 3. Sources: an end note under a hairline, smaller and quieter than the text, its items numbered. */
.academy-sources {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--academy-line);
  color: var(--cs-color-post-meta);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.entry-content .academy-sources h2 {
  margin: 0 0 0.75rem;
  color: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
}
.entry-content .academy-sources ul {
  display: grid;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: academy-source;
}
.entry-content .academy-sources li {
  position: relative;
  margin: 0;
  padding-inline-start: 1.75rem;
  counter-increment: academy-source;
}
.entry-content .academy-sources li::before {
  content: counter(academy-source);
  position: absolute;
  inset-inline-start: 0;
  opacity: 0.7;
}
.academy-sources a {
  color: var(--cs-color-post-meta-link);
}

/*
 * 4. Tables: a quiet panel a shade off the page. The names of the columns lie on the panel, in the size of the text;
 * the rows are one card inside it, parted by hairlines. No brand colour: a table is read, it does not call. On a phone
 * the columns fold: a row is a card with its cells one under another, each under the name of its column (data-label,
 * set by the table block), and short values share a line.
 */
.entry-content .wp-block-table table {
  --academy-table-radius: calc(var(--academy-radius-lg) - 0.375rem);
  padding: 0.375rem;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--academy-radius-lg);
  background: color-mix(in srgb, currentColor 3%, transparent);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.entry-content .wp-block-table :is(th, td) {
  padding: 0.875rem 1rem;
  border: 0;
  text-align: start;
  vertical-align: top;
}
.entry-content .wp-block-table th {
  padding-block: 0.625rem;
  font-weight: 400;
  vertical-align: bottom;
}
.entry-content .wp-block-table td:first-child {
  font-weight: 500;
}
@media (min-width: 600px) {
  .entry-content .wp-block-table td {
    border-top: 1px solid var(--academy-line);
    background: var(--cs-color-widgets-background);
    transition: background 0.2s;
  }
  .entry-content .wp-block-table td:first-child {
    border-inline-start: 1px solid var(--academy-line);
  }
  .entry-content .wp-block-table td:last-child {
    border-inline-end: 1px solid var(--academy-line);
  }
  .entry-content .wp-block-table tr:last-child td {
    border-bottom: 1px solid var(--academy-line);
  }
  .entry-content .wp-block-table tbody tr:first-child td:first-child {
    border-start-start-radius: var(--academy-table-radius);
  }
  .entry-content .wp-block-table tbody tr:first-child td:last-child {
    border-start-end-radius: var(--academy-table-radius);
  }
  .entry-content .wp-block-table tr:last-child td:first-child {
    border-end-start-radius: var(--academy-table-radius);
  }
  .entry-content .wp-block-table tr:last-child td:last-child {
    border-end-end-radius: var(--academy-table-radius);
  }
  .entry-content .wp-block-table tr:hover td {
    background: color-mix(in srgb, currentColor 3%, var(--cs-color-widgets-background));
  }
}
@media (max-width: 599px) {
  .entry-content .wp-block-table :is(table, tbody, td) {
    display: block;
  }
  /* The header stays for a screen reader; the eye reads the names on the cells. */
  .entry-content .wp-block-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .entry-content .wp-block-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    padding: 1rem;
    border: 1px solid var(--academy-line);
    border-radius: var(--academy-table-radius);
    background: var(--cs-color-widgets-background);
  }
  .entry-content .wp-block-table tr + tr {
    margin-top: 0.375rem;
  }
  .entry-content .wp-block-table td {
    padding: 0;
  }
  .entry-content .wp-block-table td:first-child {
    flex: 0 0 100%;
    font-size: 1rem;
  }
  /* Two short values share a line, in two even columns; a long one takes the line. */
  .entry-content .wp-block-table td + td {
    flex: 1 1 auto;
    min-width: calc(50% - 0.75rem);
  }
  .entry-content .wp-block-table td + td::before {
    content: attr(data-label);
    display: block;
    color: var(--cs-color-post-meta);
    font-size: 0.75rem;
  }
}
