/* IGN-1734: the rendered help article on /help and /kb, from the approved exemplar. Tokens sit on .help-theme so the
   page stylesheets can use them; every other rule here is inside .help-article. Page chrome stays in the page files. */
.help-theme {
  --ha-ink: #202939;
  --ha-surface: #ffffff;
  --ha-hairline: #d9dfe6;
  --ha-navy: #2f476b;
  --ha-blue-tint: #eaf2fd;
  --ha-blue-ink: #1565c0;
  --ha-green-tint: #e6f2ee;
  --ha-green-ink: #327566;
  --ha-warn-tint: #fff4e5;
  --ha-warn-ink: #8a4b00;
  --ha-chip: #eef1f5;
  --ha-chip-ink: #2f476b;
  --ha-shot: #e7ecf2;
}

/* /help follows the app's theme toggle; /kb has no shell, so it follows the browser. */
.shell-dark .help-theme {
  --ha-ink: #e7ebf2;
  --ha-surface: #1c232d;
  --ha-hairline: #303946;
  --ha-navy: #a1bce9;
  --ha-blue-tint: #1d2b40;
  --ha-blue-ink: #a1bce9;
  --ha-green-tint: #20382f;
  --ha-green-ink: #8accb3;
  --ha-warn-tint: #3a2c1a;
  --ha-warn-ink: #f2c38c;
  --ha-chip: #263449;
  --ha-chip-ink: #c9d8f2;
  --ha-shot: #303946;
}

@media (prefers-color-scheme: dark) {
  body.help-open.help-theme {
    --ha-ink: #e7ebf2;
    --ha-surface: #1c232d;
    --ha-hairline: #303946;
    --ha-navy: #a1bce9;
    --ha-blue-tint: #1d2b40;
    --ha-blue-ink: #a1bce9;
    --ha-green-tint: #20382f;
    --ha-green-ink: #8accb3;
    --ha-warn-tint: #3a2c1a;
    --ha-warn-ink: #f2c38c;
    --ha-chip: #263449;
    --ha-chip-ink: #c9d8f2;
    --ha-shot: #303946;
  }
}

.help-article p {
  margin: 0 0 1rem;
}

.help-article p:last-child {
  margin-bottom: 0;
}

.help-article pre {
  overflow-x: auto;
}

/* IGN-1737: a reference table scrolls inside itself, so a wide one never makes the page scroll sideways. */
.help-article table {
  display: block;
  max-width: 100%;
  margin: 0 0 1rem;
  overflow-x: auto;
  border-collapse: collapse;
}

.help-article th,
.help-article td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--ha-hairline);
  text-align: left;
  vertical-align: top;
  /* The page body breaks anywhere; a cell keeps its words whole so the table scrolls instead of splitting them. */
  overflow-wrap: normal;
  word-break: normal;
}

.help-article th {
  border-bottom-width: 2px;
  font-weight: 600;
  white-space: nowrap;
}

.help-article strong {
  font-weight: 650;
}

/* IGN-1750: the app reset zeroes list padding, which hangs markers outside the column. Steps and callouts override below. */
.help-article ul,
.help-article ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.help-article li > ul,
.help-article li > ol {
  margin: .25rem 0 0;
}

/* Callouts: Before you start, Tip, Warning and Result. */
.help-article .help-callout {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  margin: 0 0 1rem;
  padding: 14px 16px;
  border: 1px solid var(--ha-hairline);
  border-radius: 10px;
}

.help-article .help-callout-icon {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--ha-navy);
}

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

.help-article .help-callout-title {
  margin: 0;
  font-weight: 600;
}

.help-article .help-callout-body > * {
  margin: 4px 0 0;
}

.help-article .help-callout-body > .help-callout-title {
  margin-top: 0;
}

.help-article .help-callout-body ul,
.help-article .help-callout-body ol {
  padding-left: 18px;
}

.help-article .help-callout-tip {
  background: var(--ha-blue-tint);
  border-color: transparent;
}

.help-article .help-callout-tip .help-callout-icon {
  color: var(--ha-blue-ink);
}

.help-article .help-callout-warning {
  background: var(--ha-warn-tint);
  border-color: transparent;
}

.help-article .help-callout-warning .help-callout-icon {
  color: var(--ha-warn-ink);
}

.help-article .help-callout-result {
  background: var(--ha-green-tint);
  border-color: transparent;
  border-left: 3px solid var(--ha-green-ink);
  border-radius: 0 10px 10px 0;
}

.help-article .help-callout-result .help-callout-icon {
  color: var(--ha-green-ink);
}

/* Steps. The number sits in the padding, not a grid column, so a loose item's paragraphs, lists and images stay in
   one column beside it. */
.help-article ol.help-steps {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
  display: grid;
  gap: 14px;
}

.help-article ol.help-steps > li {
  position: relative;
  min-height: 26px;
  padding-left: 42px;
  counter-increment: help-step;
}

.help-article ol.help-steps > li::before {
  content: counter(help-step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ha-navy);
  color: var(--ha-surface);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.help-article ol.help-steps > li > p {
  margin: 0 0 .5rem;
}

.help-article ol.help-steps > li > :last-child {
  margin-bottom: 0;
}

/* Every article image sits on the exemplar's tinted mat, at the full width of the article column. */
.help-article img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  margin: .5rem 0 1rem;
  padding: 8px;
  border: 1px solid var(--ha-hairline);
  border-radius: 10px;
  background: var(--ha-shot);
}
