/* Sizes are rem-based: browser font preferences and zoom remain available. */
:root {
  --header-height: max(62px, calc(var(--help-button-height) + 14px));
  --help-body-size: 1rem;
  --help-body-line: 1.5;
  --help-h1-size: 2rem;
  --help-h1-line: 1.25;
  --help-h2-size: 1.5rem;
  --help-h2-line: 1.333333;
  --help-h3-size: 1.25rem;
  --help-h3-line: 1.4;
  --help-nav-size: .875rem;
  --help-nav-line: 1.428571;
  --help-caption-size: .875rem;
  --help-caption-line: 1.5;
  --help-button-size: 1rem;
  --help-button-line: 1.5;
  --help-button-height: 2.75rem;
  --help-text-color: #1f2737;
  --help-link-color: var(--docs-primary);
}

:root[data-help-text-size="s"] {
  --help-body-size: .875rem;
  --help-h1-size: 1.75rem;
  --help-h2-size: 1.3125rem;
  --help-h2-line: 1.333333;
  --help-h3-size: 1.125rem;
  --help-h3-line: 1.388889;
  --help-nav-size: .8125rem;
  --help-nav-line: 1.384615;
  --help-caption-size: .75rem;
  --help-button-size: .875rem;
  --help-button-line: 1.428571;
  --help-button-height: 2.5rem;
}

:root[data-help-text-size="l"] {
  --help-body-size: 1.125rem;
  --help-h1-size: 2.25rem;
  --help-h2-size: 1.6875rem;
  --help-h3-size: 1.4375rem;
  --help-h3-line: 1.391304;
  --help-nav-size: 1rem;
  --help-nav-line: 1.5;
  --help-caption-size: 1rem;
  --help-button-size: 1.125rem;
  --help-button-height: 3rem;
}

.g-root_theme_dark {
  --help-text-color: #ecedee;
  --help-link-color: var(--docs-primary);
}

body {
  font-family: var(--help-font-family);
  font-size: var(--help-body-size);
  font-weight: 400;
  line-height: var(--help-body-line);
}

/* Override Gravity/YFM's local size presets as well as the global UI tokens. */
.g-root,
.g-root .yfm {
  --g-text-body-1-font-size: var(--help-nav-size);
  --g-text-body-1-line-height: calc(var(--help-nav-size) * var(--help-nav-line));
  --g-text-body-2-font-size: var(--help-body-size);
  --g-text-body-2-line-height: calc(var(--help-body-size) * var(--help-body-line));
  --g-text-body-3-font-size: var(--help-body-size);
  --g-text-body-3-line-height: calc(var(--help-body-size) * var(--help-body-line));
  --g-text-body-short-font-size: var(--help-nav-size);
  --g-text-body-short-line-height: calc(var(--help-nav-size) * var(--help-nav-line));
  --g-text-caption-1-font-size: var(--help-caption-size);
  --g-text-caption-1-line-height: calc(var(--help-caption-size) * var(--help-caption-line));
  --g-text-caption-2-font-size: var(--help-caption-size);
  --g-text-caption-2-line-height: calc(var(--help-caption-size) * var(--help-caption-line));
  --g-text-header-1-font-size: var(--help-h3-size);
  --g-text-header-1-line-height: calc(var(--help-h3-size) * var(--help-h3-line));
  --g-text-header-2-font-size: var(--help-h2-size);
  --g-text-header-2-line-height: calc(var(--help-h2-size) * var(--help-h2-line));
  --g-text-display-2-font-size: var(--help-h1-size);
  --g-text-display-2-line-height: calc(var(--help-h1-size) * var(--help-h1-line));
  --g-text-subheader-1-font-size: var(--help-nav-size);
  --g-text-subheader-2-font-size: var(--help-body-size);
  --g-text-subheader-3-font-size: var(--help-h3-size);
  --g-text-subheader-1-line-height: calc(var(--help-nav-size) * var(--help-nav-line));
  --g-text-subheader-2-line-height: calc(var(--help-body-size) * var(--help-body-line));
  --g-text-subheader-3-line-height: calc(var(--help-h3-size) * var(--help-h3-line));
  --g-text-accent-font-weight: 600;
  --yfm-font-size: var(--help-body-size);
  --yfm-font-line-height: var(--help-body-line);
  --yfm-font-size-h1: var(--help-h1-size);
  --yfm-font-size-h2: var(--help-h2-size);
  --yfm-font-size-h3: var(--help-h3-size);
  --yfm-color-text: var(--help-text-color);
  --yfm-color-link: var(--help-link-color);
  --dc-code-font-size: var(--help-nav-size);
  --dc-code-line-height: calc(var(--help-nav-size) * 1.5);
  --dc-code-short-font-size: 1em;
  --dc-code-short-line-height: inherit;
}

.g-root .dc-doc-page__body.yfm {
  font-size: var(--help-body-size);
  font-weight: 400;
  line-height: var(--help-body-line);
  text-align: start;
}

.g-root .yfm :is(p, ul, ol, blockquote, table, pre) {
  margin-block: 0 1em;
}

.g-root .yfm :is(strong, b, th) { font-weight: 600; }
.g-root .yfm :is(figcaption, .yfm-image-caption) {
  font-size: var(--help-caption-size);
  line-height: var(--help-caption-line);
}

/* Limit prose lines without narrowing screenshots, tables or the search column. */
.g-root .dc-doc-page__body.yfm > :is(p, ul, ol, blockquote) {
  max-width: 68ch;
}

.g-root .dc-doc-page__body.yfm table {
  font-size: var(--help-body-size);
  line-height: var(--help-body-line);
}

.g-root .g-button {
  font-family: var(--help-font-family);
  font-size: var(--help-button-size);
  font-weight: 600;
  line-height: var(--help-button-line);
}

.g-root .g-button:has(.g-button__text) {
  height: auto;
  min-height: var(--help-button-height);
  padding-block: .5em;
}

.g-root .g-button .g-button__text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.g-root :is(.g-text-input__control, .g-text-area__control) {
  font-family: var(--help-font-family);
  font-size: var(--help-body-size);
  line-height: var(--help-body-line);
}

.g-root :is(.g-breadcrumbs, .dc-doc-page__breadcrumbs, .dc-doc-page__updated-at) {
  font-size: var(--help-caption-size);
  line-height: var(--help-caption-line);
}

@media (pointer: coarse) {
  :root { --help-button-height: max(2.75rem, 44px); }
  .g-root .dc-doc-page__controls .dc-controls > :is(button, a),
  .g-root .dc-back-to-top {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Keep branding and actions within the header when text alone is enlarged. */
.g-root .pc-desktop-navigation__wrapper .pc-desktop-navigation__logo {
  min-width: 0;
  flex-shrink: 1;
}

.g-root .pc-desktop-navigation__logo .pc-logo__text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.g-root .dc-toc .dc-toc__top-header {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  :root {
    --header-height: max(62px, calc(var(--help-button-height) + 14px), 3.875rem);
  }

  .g-root .pc-desktop-navigation__left {
    min-width: 0;
    flex: 0 1 auto;
  }
}

/* Use the brand color consistently for text links, including visited links. */
.g-root {
  --g-color-text-link: var(--docs-primary);
  --g-color-text-link-hover: var(--docs-primary);
  --g-color-text-link-visited: var(--docs-primary);
}

.g-root .yfm {
  --yfm-color-link: var(--docs-primary);
  --yfm-color-link-hover: var(--docs-primary);
  --yfm-color-link-visited: var(--docs-primary);
}

.g-root a:not(.g-button):not(.pc-logo):not(.dc-toc-item__link):not(.dc-mini-toc__section-link),
.g-root .dc-doc-page__body.yfm a:not(.yfm-anchor) {
  color: var(--docs-primary);
}
