@use "../../../variables/index" as *;

@use "../../mixins/c8y-scrollbar";


/**
 * code - Component styles
 *
 * Note: Uses $size-* tokens for spacing where applicable.
 *
 * Intentionally hardcoded values:
 * - Component-specific dimensions: Fixed sizes for component layout
 * - Off-grid spacing: Component-specific positioning
 * - Border widths (1px, 2px, 3px): Standard borders
 * - Font-sizes: Typography
 * - Percentages: Layout
 */
code,
kbd,
pre,
samp,
.text-code {
  font-family: $code-font-family;
}

code {
  padding: 2px $size-4;
  border-radius: $code-border-radius;
  background-color: $code-background;
  color: $code-color;
  font-size: $code-font-size;
}

kbd {
  padding: 2px $size-4;
  border-radius: $kbd-border-radius;
  background-color: $kbd-background;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  color: $kbd-color;
  font-size: $code-font-size;
  kbd {
    padding: 0;
    box-shadow: none;
    font-weight: bold;
    font-size: 100%;
  }
}

pre {
  display: block;
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid $pre-border-color;
  border-radius: $pre-border-radius;
  background-color: $pre-background;
  color: $pre-color;
  word-break: break-all;
  font-size: $code-font-size;
  line-height: $line-height-base;
  overflow-wrap: break-word;

  code {
    padding: 0;
    border-radius: 0;
    background-color: transparent;
    color: inherit;
    word-break: break-word;
    font-size: inherit;
    overflow-wrap: break-word;
  }
}

// pre:has(code) {
//   background-color: var(--c8y-code-background);
//   color: var(--c8y-code-color);
//   border-color: color-mix(in srgb, var(--c8y-code-background), black 5%);
// }

.pre-scrollable {
  overflow-y: scroll;
  max-height: $pre-scrollable-max-height;
}

.pre-scrollable, pre{
  @include c8y-scrollbar.c8y-scrollbar();
}

.pre-wrapped,
.text-code {
  white-space: pre-wrap;
  white-space: -moz-pre-wrap;
  white-space: -pre-wrap;
  white-space: -o-pre-wrap;
}
