/*
 * Copyright 2023 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:host {
  display: block;
  /**
    Adjusts the max height of the code area.
    This can be changed from outside by targeting `devtools-code-block` element.
  */
  --code-block-max-code-height: none;
  /**
    Adjusts the background color of the code block element.
    This can be changed from outside by targeting `devtools-code-block` element.
  */
  --code-block-background-color: var(--sys-color-surface2);
}

.codeblock {
  box-sizing: border-box;
  color: var(--sys-color-on-surface);
}

.codeblock .editor-wrapper {
  color: var(--sys-color-on-surface);
  background: var(--code-block-background-color); /* stylelint-disable-line plugin/use_theme_colors */
  padding: 10px 5px 0;
  border-bottom-left-radius: var(--sys-shape-corner-extra-small);
  border-bottom-right-radius: var(--sys-shape-corner-extra-small);
}

.codeblock .editor-wrapper:has(.heading) {
  padding: var(--sys-size-3) var(--sys-size-4) 0 5px;
}

.codeblock:not(:has(.toolbar)) .editor-wrapper {
  border-radius: var(--sys-shape-corner-extra-small);
}

.codeblock .editor-wrapper .code {
  max-height: var(--code-block-max-code-height);
  overflow: auto;
  padding-bottom: 10px;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--sys-size-11);
}

.heading-text-wrapper {
  display: flex;

  .citation {
    text-decoration: underline;
    color: var(--sys-color-primary);
    background-color: transparent;
    cursor: pointer;
    outline-offset: var(--sys-size-2);
    border: none;
    padding-bottom: 2px;
    font-size: 11px;
    font-family: var(--default-font-family);
  }
}

.heading-text {
  font: var(--sys-typescale-body5-bold);
  padding-left: var(--sys-size-4);
  padding-right: var(--sys-size-2);
}

.codeblock .lang {
  padding: var(--sys-size-4) 0;
  flex: 1;
}

.codeblock .copy-button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: var(--sys-typescale-body5-size);

  span {
    padding-right: var(--sys-size-4);
  }
}

.notice {
  margin-top: var(--sys-size-2);
  padding: var(--sys-size-4) var(--sys-size-5);
  background-color: var(--code-block-background-color); /* stylelint-disable-line plugin/use_theme_colors */
  border-radius: var(--sys-shape-corner-extra-small);

  .link {
    font: var(--sys-typescale-body4-regular);
    color: var(--sys-color-primary);
    text-decoration-line: underline;
  }
}
