/* ==========================================================================
   CLI command reference (docs/depictio-cli/usage.md, generated by
   scripts/cli-reference/render.py): group headers with a glass icon tile,
   signatures, option pills and badges.

   Scoped to the page whose title carries .dp-cli-title. Accents come from
   cards.css: a .dp-<colour> class sets --card-accent on the heading or block.
   Option colours follow `depictio --help`: long options in its command blue,
   short switches in brand purple.
   ========================================================================== */

.md-typeset:has(> h1.dp-cli-title) {
  --cli-option: #1c7ed6;
  --cli-switch: var(--depictio-purple);
  --cli-line: color-mix(in srgb, var(--md-default-fg-color) 9%, transparent);
  --cli-well: color-mix(in srgb, var(--md-default-fg-color) 4%, var(--md-default-bg-color));
}

[data-md-color-scheme="slate"] .md-typeset:has(> h1.dp-cli-title) {
  --cli-option: #74b3f0;
  --cli-switch: color-mix(in oklab, var(--depictio-purple) 70%, #fff);
}

/* Ink of an accent: the cards' glass tile mix, darker on light pages. */
.md-typeset :is(.dp-cli-group, .dp-cli-cmd, .dp-cli-sig) {
  --cli-ink: color-mix(in oklab, var(--card-accent, var(--depictio-purple)) 82%, #000);
}

[data-md-color-scheme="slate"] .md-typeset :is(.dp-cli-group, .dp-cli-cmd, .dp-cli-sig) {
  --cli-ink: color-mix(in oklab, var(--card-accent, var(--depictio-purple)) 70%, #fff);
}

/* --- Group header ---------------------------------------------------------- */

.md-typeset h2.dp-cli-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 2.6em;
  padding-top: 1.1rem;
  border-top: 1px solid var(--cli-line);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* The glass tile of the overview cards, smaller */
.md-typeset h2.dp-cli-group > .twemoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  margin-right: 0.65rem;
  border-radius: 10px;
  color: var(--cli-ink);
  background: color-mix(in srgb, var(--card-accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-accent) 24%, transparent);
}

.md-typeset h2.dp-cli-group > .twemoji svg {
  width: 1.2rem;
  height: 1.2rem;
  max-height: none;
}

.md-typeset h2.dp-cli-group > code {
  padding: 0;
  font-size: 0.95em;
  font-weight: 700;
  color: var(--md-default-fg-color);
  background: none;
}

.md-typeset h2.dp-cli-group > .headerlink {
  margin-left: 0.4rem;
}

.md-typeset .dp-cli-lede {
  margin: -0.2rem 0 0.4rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--md-default-fg-color--light);
}

.md-typeset .dp-cli-see {
  margin: 0.3rem 0 1rem;
  font-size: 0.72rem;
  color: var(--md-default-fg-color--light);
}

.md-typeset .dp-cli-see > .twemoji {
  margin-right: 0.15rem;
  color: var(--md-default-fg-color--lighter);
}

.md-typeset .dp-cli-see a {
  font-weight: 600;
}

/* --- Subcommand ------------------------------------------------------------ */

.md-typeset h3.dp-cli-cmd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 2.2em;
}

.md-typeset h3.dp-cli-cmd > code {
  padding: 0.2em 0.6em;
  border-radius: 7px;
  font-size: 0.9em;
  font-weight: 700;
  color: var(--cli-ink);
  background: color-mix(in srgb, var(--card-accent) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-accent) 20%, transparent);
}

.md-typeset h3.dp-cli-cmd > .headerlink {
  margin-left: 0.4rem;
}

/* Signature: the command as typed, with a prompt the copy button leaves out */
.md-typeset .dp-cli-sig.highlight {
  margin: 0.6em 0 0.8em;
}

.md-typeset .dp-cli-sig.highlight > pre > code {
  border-left: 3px solid var(--card-accent);
  border-radius: 6px;
  font-weight: 500;
  background: color-mix(in srgb, var(--card-accent) 6%, var(--md-code-bg-color));
}

.md-typeset .dp-cli-sig.highlight > pre > code::before {
  content: "$ ";
  color: var(--md-default-fg-color--lighter);
  user-select: none;
}

.md-typeset .dp-cli-also {
  margin: -0.3rem 0 0.8rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

.md-typeset .dp-cli-also code {
  font-size: 0.95em;
  color: var(--md-default-fg-color--light);
}

/* "Project and runs", "Dashboards": the panels of ingest --help */
.md-typeset .dp-cli-panel {
  margin: 1.4em 0 -0.3em;
  font-size: 0.64rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light);
}

/* --- Options table --------------------------------------------------------- */

.md-typeset:has(> h1.dp-cli-title) .md-typeset__table:has(.dp-flag, .dp-arg) {
  display: block;
}

.md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) {
  display: table;
  width: 100%;
  border: 1px solid var(--cli-line);
  border-radius: 10px;
  font-size: 0.7rem;
  box-shadow: none;
}

.md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) th {
  padding: 0.55em 0.75em;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-default-fg-color--light);
  background: var(--cli-well);
  border-bottom: 1px solid var(--cli-line);
}

.md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) td {
  padding: 0.65em 0.75em;
  vertical-align: top;
  border-top: 1px solid var(--cli-line);
  line-height: 1.55;
}

.md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) tbody tr:first-child td {
  border-top: 0;
}

.md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) tbody tr:hover {
  background: color-mix(in srgb, var(--md-default-fg-color) 2.5%, transparent);
  box-shadow: none;
}

/* Option and type columns stay on one line; the description takes the rest
   and the table scrolls sideways on a phone. */
.md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:first-child {
  min-width: 9rem;
}

.md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:nth-child(3) {
  white-space: nowrap;
}

.md-typeset:has(> h1.dp-cli-title) table:has(.dp-choices) td:nth-child(2) {
  min-width: 7rem;
}

.md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:last-child {
  min-width: 12rem;
  color: var(--md-default-fg-color--light);
}

/* An option name moves to the next line whole rather than breaking at a hyphen */
.md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:last-child code {
  word-break: normal;
  overflow-wrap: anywhere;
  color: var(--md-default-fg-color);
}

/* Phones: each option a stacked row, flag, type and default on one line and
   the description under them, so nothing hides off to the side. */
@media screen and (max-width: 44.9375em) {
  .md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) {
    display: block;
    border-radius: 10px;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) thead {
    display: none;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) tbody {
    display: block;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    padding: 0.7em 0.85em;
    border-top: 1px solid var(--cli-line);
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) tbody tr:first-child {
    border-top: 0;
  }

  .md-typeset:has(> h1.dp-cli-title) table:not([class]):has(.dp-flag, .dp-arg) td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:first-child,
  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:last-child {
    min-width: 0;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:last-child {
    flex-basis: 100%;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:nth-child(3):empty {
    display: none;
  }

  .md-typeset:has(> h1.dp-cli-title) table:has(.dp-flag, .dp-arg) td:nth-child(3):not(:empty)::before {
    content: "default ";
    font-size: 0.6rem;
    color: var(--md-default-fg-color--lighter);
  }

}

/* Pills: long options blue, short switches purple, arguments neutral */
.md-typeset code.dp-flag,
.md-typeset code.dp-arg {
  display: inline-block;
  margin: 0.08rem 0;
  padding: 0.12em 0.5em;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--cli-option);
  background: color-mix(in srgb, var(--cli-option) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cli-option) 22%, transparent);
  scroll-margin-top: 4.5rem;
}

.md-typeset code.dp-flag.dp-short {
  color: var(--cli-switch);
  background: color-mix(in srgb, var(--cli-switch) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cli-switch) 22%, transparent);
}

.md-typeset .dp-sep {
  color: var(--md-default-fg-color--lighter);
}

.md-typeset code.dp-arg {
  color: var(--md-default-fg-color);
  background: var(--cli-well);
  box-shadow: inset 0 0 0 1px var(--cli-line);
  letter-spacing: 0.02em;
}

/* A linked option row, as #ingest-skip */
.md-typeset code.dp-flag:target,
.md-typeset code.dp-arg:target {
  outline: 2px solid color-mix(in srgb, var(--cli-option) 45%, transparent);
  outline-offset: 2px;
}

.md-typeset .dp-type,
.md-typeset .dp-badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 5px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--md-default-fg-color--light);
  background: var(--cli-well);
  box-shadow: inset 0 0 0 1px var(--cli-line);
}

.md-typeset .dp-type.dp-multi {
  color: var(--md-default-fg-color--lighter);
  background: none;
}

/* Choices wrap inside a narrow column rather than widening the table */
.md-typeset .dp-choices {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  max-width: 9.5rem;
  white-space: normal;
}

.md-typeset code.dp-choice {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  margin: 0.08rem 0;
  padding: 0.05em 0.4em;
  border-radius: 5px;
  font-size: 0.64rem;
  color: var(--cli-switch);
  background: color-mix(in srgb, var(--cli-switch) 9%, transparent);
}

.md-typeset .dp-badge {
  margin-top: 0.25rem;
  text-transform: uppercase;
  font-size: 0.55rem;
  letter-spacing: 0.07em;
}

.md-typeset .dp-badge.dp-req {
  color: color-mix(in oklab, var(--depictio-orange) 75%, #000);
  background: color-mix(in srgb, var(--depictio-orange) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--depictio-orange) 30%, transparent);
}

[data-md-color-scheme="slate"] .md-typeset .dp-badge.dp-req {
  color: color-mix(in oklab, var(--depictio-orange) 75%, #fff);
}

.md-typeset .dp-badge.dp-dep {
  text-decoration: line-through;
}

.md-typeset .dp-env {
  display: inline-block;
  margin-left: 0.2rem;
  font-size: 0.62rem;
  white-space: nowrap;
  color: var(--md-default-fg-color--lighter);
}

/* --- Overview cards -------------------------------------------------------- */

.md-typeset .dp-cli-overview > ul > li > p:first-child > strong code {
  padding: 0;
  font-size: 0.86rem;
  color: inherit;
  background: none;
}

.md-typeset .dp-cli-overview > ul > li > p:nth-child(4):last-child {
  margin-top: auto;
  padding-top: 0.7rem;
  line-height: 1.9;
}

.md-typeset .dp-cli-overview > ul > li > p:nth-child(4):last-child code {
  margin-right: 0.1rem;
  padding: 0.08em 0.45em;
  border-radius: 999px;
  font-size: 0.64rem;
  color: var(--card-ink);
  background: color-mix(in srgb, var(--card-accent) 10%, transparent);
}

/* Former names: the old and new names stay whole */
.md-typeset:has(> h1.dp-cli-title) details table td:nth-child(-n + 2) code {
  white-space: nowrap;
}
