/* Native element styles. Loaded twice on purpose:
   - into documents via the theme (mandatory, like base/body.css),
   - into every component shadow root via mirrors/elements.styles.ts (adopted by
     EdElement), where the ed-base layer loses to the component's own unlayered styles. */
@layer ed-base {
  /* region Block Text ~~~~~~~~~~~~~~~~~~~~~~ */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--ed-font-family-heading);
    font-weight: var(--ed-font-weight-heading);
    line-height: var(--ed-line-height-normal);
    color: var(--ed-color-title);
    text-wrap: balance;
  }

  h1 {
    font-size: var(--ed-font-size-2xl);
  }

  h2 {
    font-size: var(--ed-font-size-xl);
  }

  h3 {
    font-size: var(--ed-font-size-l);
  }

  h4,
  h5,
  h6 {
    font-size: var(--ed-font-size-l);
  }

  p {
    text-wrap: pretty;
  }

  /* endregion */
  /* region Thematic Break ~~~~~~~~~~~~~~~~~~ */
  hr {
    margin: var(--ed-space-4) 0;
    border: none;
    border-top: solid var(--ed-border-width-1) var(--ed-color-border);
  }

  /* endregion */
  /* region Inline Text ~~~~~~~~~~~~~~~~~~~~~ */
  strong,
  b {
    font-weight: var(--ed-font-weight-bold);
  }

  em,
  i {
    font-style: italic;
  }

  u {
    text-decoration-line: underline;
    text-decoration-thickness: 0.09375em;
    text-underline-offset: 0.125em;
  }

  s {
    text-decoration-line: line-through;
    text-decoration-thickness: 0.09375em;
  }

  ins {
    text-decoration-color: var(--ed-color-success-fill-normal);
    text-decoration-line: underline;
    text-decoration-thickness: 0.09375em;
    text-underline-offset: 0.125em;
  }

  del {
    color: color-mix(in oklab, currentColor, transparent 10%);
    text-decoration-color: var(--ed-color-danger-fill-normal);
    text-decoration-line: line-through;
    text-decoration-thickness: 0.09375em;
  }

  mark {
    background-color: var(--ed-color-warning-fill-light);
    border-radius: var(--ed-border-radius-1x);
  }

  small {
    font-size: var(--ed-font-size-smaller);
  }

  sub,
  sup {
    font-size: var(--ed-font-size-smaller);
    line-height: 0;
  }

  sub {
    vertical-align: sub;
  }

  sup {
    vertical-align: super;
  }

  abbr[title] {
    text-decoration-line: underline;
    text-decoration-style: dotted;
    text-decoration-thickness: 0.09375em;
    text-underline-offset: 0.125em;

    cursor: help;
  }

  kbd {
    padding: 0.125em 0.25em;
    font-family: var(--ed-font-family-code);
    font-size: var(--ed-font-size-smaller);
    font-weight: var(--ed-font-weight-code);
    border: solid var(--ed-border-width-1) color-mix(in oklab, currentColor, transparent 50%);
    border-radius: var(--ed-border-radius-2x);
    box-shadow: 0 0.125em 0 0 color-mix(in oklab, currentColor, transparent 50%);

    ed-icon {
      vertical-align: -2px;
    }
  }

  /* endregion */
  /* region Links ~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  a {
    color: var(--ed-color-text-link);
    text-decoration: var(--ed-link-decoration-default);
    -webkit-text-decoration: var(--ed-link-decoration-default);
    text-decoration-thickness: round(0.0625em, 1px);
    text-underline-offset: 0.125em;
  }

  /* Light-DOM ancestors only: this context cannot be seen from inside a shadow root,
     so accent-context recoloring intentionally does not replicate for shadow content. */
  *:is([appearance~='accent'], .ed-accent) {
    a,
    a:hover {
      color: currentColor;
    }
  }

  @media (hover: hover) {
    a:hover {
      text-decoration: var(--ed-link-decoration-hover);
      -webkit-text-decoration: var(--ed-link-decoration-hover);
    }
  }

  a:active {
    text-decoration: var(--ed-link-decoration-hover);
    -webkit-text-decoration: var(--ed-link-decoration-hover);
    text-decoration-thickness: round(0.125em, 1px);
  }

  a:focus,
  button:focus {
    outline: none;
  }

  a:focus-visible,
  button:focus-visible {
    outline: var(--ed-focus-ring);
    outline-offset: var(--ed-focus-ring-offset);
  }

  /* endregion */
  /* region Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  code,
  samp,
  var {
    padding: 0.125em 0.25em;

    font-family: var(--ed-font-family-code);
    font-size: var(--ed-font-size-smaller);
    font-weight: var(--ed-font-weight-code);
    background-color: var(--ed-color-code-highlight);
    border-radius: var(--ed-border-radius-1x);
  }

  pre {
    padding: var(--ed-space-4);
    font-family: var(--ed-font-family-code);
    font-size: var(--ed-font-size-smaller);
    font-weight: var(--ed-font-weight-code);
    white-space: pre;
    background-color: var(--ed-color-code-highlight);
    border-radius: var(--ed-border-radius-2x);

    /* Remove overlapping styles for child code elements */

    & code,
    & samp,
    & var {
      padding: 0;
      font-size: 1em;
      background-color: transparent;
    }

    /* Print styles */
    @media print {
      background: none;
      border: solid var(--ed-border-width-1) var(--ed-color-border);
    }
  }
  /* endregion */
}
