/*
 * Content components for Abacus One Group Integration Services.
 *
 * Everything a page can contain, in the order below. A page is written in Markdown and uses
 * these by structure (a table, a task list, an admonition) or by a wrapper class (.cards,
 * .steps, .facts). See docs/design-system.md for when to use each.
 *
 *   Prose        headings, paragraphs, links, lists, inline code
 *   Callout      a note that interrupts the page (Markdown admonition)
 *   Checklist    tasks the reader ticks off (Markdown task list)
 *   Steps        a numbered sequence that happens in order (.steps)
 *   Cards        a few equal choices (.cards)
 *   Facts        short label and value pairs (.facts)
 *   Table        the same attributes for several things
 *
 * Rules: no raw colour, size or duration here. Every value is a token from tokens.css.
 */

/* ---- Prose ------------------------------------------------------------------------------ */

.md-typeset {
  font-size: var(--ao-text-base);
  line-height: var(--ao-leading-relaxed);
  color: var(--ao-color-foreground);
  letter-spacing: var(--ao-tracking-normal);
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  font-weight: var(--ao-weight-semibold);
  color: var(--ao-color-foreground);
  letter-spacing: var(--ao-tracking-tight);
  text-wrap: balance;
}

.md-typeset h1 {
  margin: 0 0 var(--ao-space-4);
  font-size: var(--ao-text-4xl);
  font-weight: var(--ao-weight-bold);
  line-height: var(--ao-leading-tight);
}

/* A phone fits about twenty characters of the largest size on a line, so h1 steps down one. */
@media screen and (max-width: 44.984375em) {
  .md-typeset h1 {
    font-size: var(--ao-text-3xl);
  }
}

.md-typeset h2 {
  margin: var(--ao-space-12) 0 var(--ao-space-4);
  font-size: var(--ao-text-2xl);
  line-height: var(--ao-leading-snug);
}

.md-typeset h3 {
  margin: var(--ao-space-8) 0 var(--ao-space-3);
  font-size: var(--ao-text-lg);
  line-height: var(--ao-leading-snug);
}

.md-typeset h2 + h3 {
  margin-top: var(--ao-space-6);
}

.md-typeset p {
  margin: 0 0 var(--ao-space-4);
}

/* The lead: the first paragraph of a page says what the page is. */
.md-typeset h1 + p {
  margin-bottom: var(--ao-space-6);
  font-size: var(--ao-text-lg);
  line-height: var(--ao-leading-normal);
  color: var(--ao-color-muted-foreground);
}

.md-typeset strong {
  font-weight: var(--ao-weight-semibold);
}

/* Links are underlined: colour alone never marks a link. */
.md-typeset a {
  color: var(--ao-color-primary);
  text-decoration: underline;
  text-decoration-thickness: var(--ao-border-width);
  text-underline-offset: 0.2em;
  transition: color var(--ao-duration-fast) var(--ao-ease);
}

.md-typeset a:hover,
.md-typeset a:focus {
  color: var(--ao-color-primary-hover);
  text-decoration-thickness: var(--ao-focus-width);
}

.md-typeset .headerlink,
.md-typeset .headerlink:hover {
  color: var(--ao-color-subtle-foreground);
  text-decoration: none;
}

.md-typeset ul,
.md-typeset ol {
  margin-top: 0;
  margin-bottom: var(--ao-space-4);
}

.md-typeset ul li,
.md-typeset ol li {
  margin-bottom: var(--ao-space-2);
}

.md-typeset ul li::marker {
  color: var(--ao-color-subtle-foreground);
}

.md-typeset code {
  padding: 0.125em 0.375em;
  font-family: var(--ao-font-mono);
  font-size: 0.875em;
  color: var(--ao-color-code);
  overflow-wrap: anywhere;
  background-color: var(--ao-color-code-surface);
  border-radius: var(--ao-radius-sm);
}

/* ---- Callout ---------------------------------------------------------------------------- */

.md-typeset .admonition {
  padding: var(--ao-space-4) var(--ao-space-5);
  margin: var(--ao-space-6) 0;
  font-size: var(--ao-text-sm);
  line-height: var(--ao-leading-relaxed);
  color: var(--ao-color-foreground);
  background-color: var(--ao-color-primary-subtle);
  border: var(--ao-border-width) solid var(--ao-color-primary-border);
  border-radius: var(--ao-radius-lg);
}

.md-typeset .admonition > .admonition-title {
  padding: 0 0 0 var(--ao-space-6);
  margin: 0 0 var(--ao-space-1);
  font-size: var(--ao-text-sm);
  font-weight: var(--ao-weight-semibold);
}

.md-typeset .admonition > .admonition-title::before {
  top: 0.2em;
  width: var(--ao-space-4);
  height: var(--ao-space-4);
  background-color: var(--ao-color-primary);
  mask-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4M12 8h.01'/></svg>");
}

html .md-typeset .admonition > :last-child {
  margin-bottom: 0;
}

.md-typeset .admonition > p:not(.admonition-title) {
  padding-left: var(--ao-space-6);
}

/* ---- Checklist -------------------------------------------------------------------------- */

/* A task list is one card, with a row per task. It prints as a list of empty boxes. */
.md-typeset ul.task-list {
  --ao-checklist-box: calc(1.25 * var(--ao-rem));

  padding: 0;
  margin: 0 0 var(--ao-space-8);
  list-style: none;
  background-color: var(--ao-color-card);
  border: var(--ao-border-width) solid var(--ao-color-border);
  border-radius: var(--ao-radius-lg);
  box-shadow: var(--ao-shadow-sm);
}

.md-typeset .task-list > .task-list-item {
  position: relative;
  padding: var(--ao-space-4) var(--ao-space-5) var(--ao-space-4)
    calc(var(--ao-space-5) + var(--ao-checklist-box) + var(--ao-space-3));
  margin: 0;
  border-top: var(--ao-border-width) solid var(--ao-color-border);
  break-inside: avoid;
}

.md-typeset .task-list > .task-list-item:first-child {
  border-top: 0;
}

@media screen and (max-width: 44.984375em) {
  .md-typeset .task-list > .task-list-item {
    padding: var(--ao-space-4) var(--ao-space-4) var(--ao-space-4)
      calc(var(--ao-space-4) + var(--ao-checklist-box) + var(--ao-space-3));
  }

  .md-typeset .task-list-control {
    left: var(--ao-space-4);
  }
}

.md-typeset .task-list-control {
  position: absolute;
  top: calc(var(--ao-space-4) + 0.15em);
  left: var(--ao-space-5);
  width: var(--ao-checklist-box);
  height: var(--ao-checklist-box);
}

/*
 * The checklist is read and printed, not filled in on the page. The theme's disabled, unlabelled
 * checkbox is removed, so a screen reader hears a list of tasks and not eighteen dead controls.
 * The box that is drawn is decoration.
 */
.md-typeset .task-list .task-list-item [type="checkbox"] {
  display: none;
}

.md-typeset .task-list .task-list-indicator::before {
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: var(--ao-checklist-box);
  height: var(--ao-checklist-box);
  background-color: var(--ao-color-background);
  border: var(--ao-focus-width) solid var(--ao-color-border-strong);
  border-radius: var(--ao-radius-sm);
  mask-image: none;
}

/* The details asked for inside a task. */
.md-typeset .task-list-item > ul {
  margin: var(--ao-space-3) 0 0;
  color: var(--ao-color-muted-foreground);
}

.md-typeset .task-list-item > ul > li {
  margin-bottom: var(--ao-space-1);
  margin-left: var(--ao-space-4);
}

/* ---- Steps ------------------------------------------------------------------------------ */

.md-typeset .steps > ol {
  --ao-steps-marker: var(--ao-space-8);

  padding: 0;
  margin: 0 0 var(--ao-space-4);
  list-style: none;
  counter-reset: ao-step;
}

.md-typeset .steps > ol > li {
  position: relative;
  min-height: var(--ao-steps-marker);
  padding: var(--ao-space-1) 0 var(--ao-space-5) calc(var(--ao-steps-marker) + var(--ao-space-4));
  margin: 0;
  counter-increment: ao-step;
}

.md-typeset .steps > ol > li:last-child {
  padding-bottom: 0;
}

.md-typeset .steps > ol > li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--ao-steps-marker);
  height: var(--ao-steps-marker);
  font-size: var(--ao-text-sm);
  font-weight: var(--ao-weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ao-color-primary);
  content: counter(ao-step);
  background-color: var(--ao-color-primary-subtle);
  border: var(--ao-border-width) solid var(--ao-color-primary-border);
  border-radius: var(--ao-radius-full);
}

/* The rail that joins one step to the next. */
.md-typeset .steps > ol > li:not(:last-child)::after {
  position: absolute;
  top: calc(var(--ao-steps-marker) + var(--ao-space-1));
  bottom: var(--ao-space-1);
  left: calc(var(--ao-steps-marker) / 2);
  width: var(--ao-border-width);
  content: "";
  background-color: var(--ao-color-border);
}

/* ---- Cards ------------------------------------------------------------------------------ */

.md-typeset .cards > ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(13 * var(--ao-rem))), 1fr));
  gap: var(--ao-space-4);
  padding: 0;
  margin: 0 0 var(--ao-space-4);
  list-style: none;
}

.md-typeset .cards > ul > li {
  padding: var(--ao-space-5);
  margin: 0;
  font-size: var(--ao-text-sm);
  line-height: var(--ao-leading-normal);
  color: var(--ao-color-muted-foreground);
  background-color: var(--ao-color-card);
  border: var(--ao-border-width) solid var(--ao-color-border);
  border-radius: var(--ao-radius-lg);
  box-shadow: var(--ao-shadow-sm);
}

.md-typeset .cards > ul > li > p {
  margin: 0;
}

.md-typeset .cards > ul > li > p:first-child {
  margin-bottom: var(--ao-space-2);
  font-size: var(--ao-text-base);
  line-height: var(--ao-leading-snug);
  color: var(--ao-color-foreground);
}

/* ---- Facts ------------------------------------------------------------------------------ */

.md-typeset .facts > dl {
  display: grid;
  grid-template-columns: minmax(calc(9 * var(--ao-rem)), max-content) 1fr;
  margin: 0 0 var(--ao-space-4);
  font-size: var(--ao-text-sm);
  line-height: var(--ao-leading-normal);
  border-top: var(--ao-border-width) solid var(--ao-color-border);
}

.md-typeset .facts > dl > dt,
.md-typeset .facts > dl > dd {
  padding: var(--ao-space-3) 0;
  margin: 0;
  border-bottom: var(--ao-border-width) solid var(--ao-color-border);
}

.md-typeset .facts > dl > dt {
  padding-right: var(--ao-space-6);
  font-weight: var(--ao-weight-regular);
  color: var(--ao-color-muted-foreground);
}

.md-typeset .facts > dl > dd {
  font-weight: var(--ao-weight-medium);
  color: var(--ao-color-foreground);
}

.md-typeset .facts > dl > dd > p {
  margin: 0;
}

@media screen and (max-width: 29.984375em) {
  .md-typeset .facts > dl {
    grid-template-columns: 1fr;
  }

  .md-typeset .facts > dl > dt {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .md-typeset .facts > dl > dd {
    padding-top: var(--ao-space-1);
  }
}

/* ---- Table ------------------------------------------------------------------------------ */

.md-typeset__scrollwrap {
  margin: var(--ao-space-4) 0 var(--ao-space-6);
}

.md-typeset__table {
  display: block;
  padding: 0;
  margin: 0;
}

.md-typeset table:not([class]) {
  display: table;
  width: 100%;
  overflow: visible;
  font-size: var(--ao-text-sm);
  line-height: var(--ao-leading-normal);
  border-spacing: 0;
  background-color: var(--ao-color-card);
  border: var(--ao-border-width) solid var(--ao-color-border);
  border-radius: var(--ao-radius-lg);
}

/* The heading row follows the table's rounded corners. */
.md-typeset table:not([class]) th:first-child {
  border-top-left-radius: calc(var(--ao-radius-lg) - var(--ao-border-width));
}

.md-typeset table:not([class]) th:last-child {
  border-top-right-radius: calc(var(--ao-radius-lg) - var(--ao-border-width));
}

.md-typeset table:not([class]) th {
  min-width: 0;
  padding: var(--ao-space-3) var(--ao-space-4);
  font-size: var(--ao-text-xs);
  font-weight: var(--ao-weight-semibold);
  color: var(--ao-color-muted-foreground);
  text-transform: uppercase;
  letter-spacing: var(--ao-tracking-wide);
  white-space: nowrap;
  background-color: var(--ao-color-surface);
}

.md-typeset table:not([class]) td {
  padding: var(--ao-space-3) var(--ao-space-4);
  border-top: var(--ao-border-width) solid var(--ao-color-border);
}

/* The first column names the row. */
.md-typeset table:not([class]) td:first-child {
  font-weight: var(--ao-weight-medium);
  color: var(--ao-color-foreground);
}

.md-typeset table:not([class]) tbody tr {
  transition: background-color var(--ao-duration-fast) var(--ao-ease);
}

.md-typeset table:not([class]) tbody tr:hover {
  background-color: var(--ao-color-surface);
  box-shadow: none;
}

/*
 * On a phone a table becomes a list: each row is a block, the first cell is its title, and the
 * column headings are hidden from view but still read out. Nothing scrolls sideways.
 */
@media screen and (max-width: 44.984375em) {
  .md-typeset table:not([class]),
  .md-typeset table:not([class]) tbody,
  .md-typeset table:not([class]) tr,
  .md-typeset table:not([class]) td {
    display: block;
  }

  .md-typeset table:not([class]) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .md-typeset table:not([class]) tbody tr {
    padding: var(--ao-space-3) var(--ao-space-4);
    border-top: var(--ao-border-width) solid var(--ao-color-border);
  }

  .md-typeset table:not([class]) tbody tr:first-child {
    border-top: 0;
  }

  .md-typeset table:not([class]) td {
    padding: 0;
    border-top: 0;
  }

  .md-typeset table:not([class]) td:empty {
    display: none;
  }

  .md-typeset table:not([class]) td:first-child {
    font-weight: var(--ao-weight-semibold);
  }

  /* A middle cell is a qualifier of the title: smaller and quieter. */
  .md-typeset table:not([class]) td:not(:first-child, :last-child) {
    font-size: var(--ao-text-xs);
    color: var(--ao-color-muted-foreground);
  }

  .md-typeset table:not([class]) td:last-child:not(:first-child) {
    margin-top: var(--ao-space-1);
  }
}

/* ---- Print ------------------------------------------------------------------------------ */

@media print {
  .md-typeset h2,
  .md-typeset h3 {
    break-after: avoid;
  }

  .md-typeset .task-list,
  .md-typeset .cards > ul > li,
  .md-typeset table:not([class]) {
    box-shadow: none;
  }

  /* A printed link to another site shows where it goes. */
  .md-typeset a[href^="https://"]:not([href*="abacusops.com"])::after {
    font-size: 0.85em;
    content: " (" attr(href) ")";
    overflow-wrap: anywhere;
  }
}
