/*
 * The knowledge base contents card.
 *
 * Built by parse-toc.js from the headings in the article, so this file styles
 * markup nothing in HubSpot authored. Everything is scoped under .parse-toc so
 * it cannot reach the article's own lists, and the colours are declared as
 * --parse-toc-* custom properties on the card itself rather than read from the
 * theme: the knowledge base theme does not publish brand variables, and a card
 * that inherits whatever the theme happens to define is a card that changes
 * colour the next time somebody edits the theme.
 *
 * Values are the Parse palette: Indigo #550088, Dark Indigo #25003B, Dark Lilac
 * #9966B8, Lilac #DFCEE8, Pink Steel #B6007C, Dark Gray #525252.
 */

.parse-toc {
  --parse-toc-indigo: #550088;
  --parse-toc-indigo-dark: #25003b;
  --parse-toc-lilac-dark: #9966b8;
  --parse-toc-lilac: #dfcee8;
  --parse-toc-pink: #b6007c;
  --parse-toc-gray: #525252;
  --parse-toc-line: rgba(85, 0, 136, 0.14);
  --parse-toc-tint: rgba(85, 0, 136, 0.035);

  margin: 0 0 2.25rem;
  padding: 1.375rem 1.625rem;
  border: 1px solid var(--parse-toc-line);
  border-radius: 10px;
  background: var(--parse-toc-tint);
}

/* Shut, the card is one bar. The summary's own bottom margin would otherwise
   leave a strip of empty tint under it. */
.parse-toc:not([open]) {
  padding-top: 1.0625rem;
  padding-bottom: 1.0625rem;
}

/* ── The summary, which is the control ─────────────────────────────────────── */

.parse-toc__title {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  margin: 0 0 0.875rem;
  color: var(--parse-toc-indigo-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  /* Both are needed to take the disclosure triangle off: the standard property
     for current browsers, the pseudo-element for older WebKit. */
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
}

.parse-toc__title::-webkit-details-marker {
  display: none;
}

.parse-toc[open] .parse-toc__title {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--parse-toc-line);
}

.parse-toc:not([open]) .parse-toc__title {
  margin-bottom: 0;
}

.parse-toc__title:hover {
  color: var(--parse-toc-pink);
}

.parse-toc__title:focus-visible {
  outline: 2px solid var(--parse-toc-pink);
  outline-offset: 4px;
  border-radius: 4px;
}

.parse-toc__icon {
  flex: none;
  color: var(--parse-toc-pink);
}

/* The label and the chevron both read the open state, so neither needs a
   script to keep them in step with the card. */
.parse-toc__state {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  margin-left: auto;
  color: var(--parse-toc-lilac-dark);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.parse-toc__state::before {
  content: "Show";
}

.parse-toc[open] .parse-toc__state::before {
  content: "Hide";
}

.parse-toc__state svg {
  transition: transform 0.18s ease;
}

.parse-toc[open] .parse-toc__state svg {
  transform: rotate(180deg);
}

.parse-toc__title:hover .parse-toc__state {
  color: var(--parse-toc-pink);
}

/* ── The list ──────────────────────────────────────────────────────────────── */

/*
 * The knowledge base theme styles article lists with a selector that outranks a
 * single class, so an ordered list here kept the browser's own numbers on top
 * of the counter below, numbering the sub-entries too. The theme is a HubSpot
 * default asset and cannot be edited, so the markers are taken off with
 * !important rather than by out-specifying a selector that may change.
 */
.parse-toc__list,
.parse-toc .parse-toc__list li {
  list-style: none !important;
}

.parse-toc__list {
  margin: 0;
  padding: 0;
  counter-reset: parse-toc;
}

.parse-toc__list li {
  margin: 0 0 0.5625rem;
  padding: 0;
}

.parse-toc__list li:last-child {
  margin-bottom: 0;
}

.parse-toc__list li::before {
  content: none; /* some knowledge base themes draw their own list bullets */
}

.parse-toc__list li.is-sub {
  margin-left: 1.25rem;
}

/*
 * Block, so the whole row is the hit area, which is also why hover cannot be an
 * underline: the border ran the full width of the card rather than the width of
 * the words. Colour alone says it.
 */
.parse-toc__list a {
  display: block;
  color: var(--parse-toc-indigo-dark);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.14s ease;
}

.parse-toc__list li.is-sub a {
  color: var(--parse-toc-gray);
  font-size: 0.8rem;
  font-weight: 400;
}

.parse-toc__list a::before {
  counter-increment: parse-toc;
  content: counter(parse-toc) ".";
  display: inline-block;
  width: 1.25rem;
  color: var(--parse-toc-pink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* A sub-entry is not numbered: the numbers count top-level sections, and a
   second series under them reads as a different article. */
.parse-toc__list li.is-sub a::before {
  counter-increment: none;
  content: "";
  width: 0.75rem;
  height: 1px;
  margin: 0 0.5rem 0.25rem 0;
  background: var(--parse-toc-lilac-dark);
  vertical-align: middle;
}

.parse-toc__list a:hover,
.parse-toc__list a:focus-visible {
  color: var(--parse-toc-pink);
}

/* ── Where the links land ──────────────────────────────────────────────────── */

/*
 * The knowledge base header is sticky, so a heading jumped to lands underneath
 * it without this. It is set on the article's headings rather than globally
 * because the value is the header's height, which is only right here.
 */
.parse-toc-host :is(h2, h3)[id] {
  scroll-margin-top: 5rem;
}

/* A printed protocol does not need navigation, and the card prints as a block
   of blue text at the top of page one. */
@media print {
  .parse-toc {
    display: none;
  }
}
