@import "../main.css";
@import "./scrollbar.css";

@layer components {
  .typo {
    font-family: var(--font-ui);
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    font-weight: var(--font-weight-ui);
    color: var(--color-root--text);
    text-wrap: wrap;

    &:focus-visible {
      outline: none;
    }
  }

  .typo h1 {
    font-size: var(--text-ui-xl);
    line-height: var(--text-ui-xl--line-height);
    font-weight: var(--font-weight-ui-xl);
    color: var(--color-ui--text);
    margin-block: var(--spacing-ui-padding-xl);

    &:focus-visible {
      outline: none;
    }
  }

  .typo h2 {
    font-size: var(--text-ui-lg);
    line-height: var(--text-ui-lg--line-height);
    font-weight: var(--font-weight-ui-lg);
    color: var(--color-ui--text);
    margin-block: var(--spacing-ui-padding-lg);

    &:focus-visible {
      outline: none;
    }
  }

  .typo h3 {
    font-size: var(--text-ui-lg);
    line-height: var(--text-ui-lg--line-height);
    font-weight: var(--font-weight-ui-lg);
    color: var(--color-ui--text);
    margin-block: var(--spacing-ui-padding);

    &:focus-visible {
      outline: none;
    }
  }

  .typo h4 {
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    font-weight: var(--font-weight-ui);
    color: var(--color-ui--text);
    margin-block: var(--spacing-ui-padding-sm);
  }

  .typo p {
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    font-weight: var(--font-weight-ui);
    color: var(--color-ui--text);
    margin-block: var(--spacing-ui-padding-sm);
  }

  .typo small {
    font-size: var(--text-ui-sm);
    line-height: var(--text-ui-sm--line-height);
    font-weight: var(--font-weight-ui-sm);
    margin-block: var(--spacing-ui-padding-sm);
  }

  .typo mark {
    background: var(--color-ui-success);
    color: var(--color-ui-success--text);
    padding: 0.1em 0.25em;
    border-radius: 0.25em;
  }

  .typo abbr[title] {
    border-bottom: 1px dotted var(--color-ui--border);
    cursor: help;
    text-decoration: none;
  }

  .typo sup,
  .typo sub {
    font-size: 0.75em;
    line-height: 1;
    position: relative;
    vertical-align: baseline;
  }

  .typo sup {
    top: -0.5em;
  }

  .typo sub {
    bottom: -0.25em;
  }

  .typo kbd {
    font-family: var(--font-mono);
    background: var(--color-layer);
    color: var(--color-layer--text);
    border-radius: var(--radius-ui);
    border: 1px solid var(--color-layer--border);
    padding: 0.25em;
    margin-inline: 0.25em;
  }

  .typo del {
    text-decoration: line-through;
    color: var(--color-ui--alert);
  }

  .typo ins {
    text-decoration: underline;
    color: var(--color-ui--success);
  }

  .typo b,
  .typo strong {
    font-weight: var(--font-weight-ui-lg);
  }

  .typo i,
  .typo em {
    font-style: italic;
  }

  .typo blockquote {
    background: var(--color-layer);
    color: var(--color-layer--text);
    box-shadow: var(--shadow-layer);
    font-style: italic;
    border-end-end-radius: var(--radius-ui);
    border-start-end-radius: var(--radius-ui);
    border: 1px solid var(--color-layer--border);
    border-inline-start: 4px solid var(--color-layer--info);
    margin-block: var(--spacing-ui);
    padding: var(--spacing-ui-padding);
    gap: var(--spacing-ui-gap);
    width: fit-content;

    & p {
      margin-block: 0;
    }
  }

  .typo hr {
    border-top: 1px solid var(--color-ui--border);
    margin-block: 5em;
    margin-inline: auto;
    width: 80%;
  }

  .typo dt {
    font-weight: var(--font-weight-ui-lg);
    font-style: italic;
  }

  .typo figcaption {
    font-size: var(--text-ui-sm);
    line-height: var(--text-ui-sm--line-height);
    color: var(--color-ui--muted);
    margin-top: 1em;
  }

  .table-scroll {
    margin-block: 2em;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll table {
    width: 100%;
    min-width: max-content;
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    border-collapse: collapse;
    table-layout: auto;
  }

  .table-scroll table th,
  .table-scroll table td {
    min-width: min-content;
    text-align: left;
    padding: 1em;
    border-bottom: 1px solid var(--color-ui--border);
  }

  .table-scroll table th:not(:last-child),
  .table-scroll table td:not(:last-child) {
    padding-inline-end: 1.75em;
  }

  .table-scroll table a {
    white-space: nowrap;
  }

  .table-scroll [data-clickable="row"] {
    cursor: pointer;
  }

  .table-scroll [data-cell="action"] {
    width: 1%;
    min-width: max-content;
    white-space: nowrap;
    text-align: right;
  }

  .table-scroll [data-cell="action"] > div {
    display: inline-flex;
    gap: var(--spacing-ui-gap);
    flex-shrink: 0;
    justify-content: flex-end;
    margin-inline-start: auto;
  }

  .table-scroll [data-cell="action"] > div > * {
    flex-shrink: 0;
    min-width: min-content;
  }

  .typo table {
    display: block;
    width: 100%;
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    margin-block: 2em;
    border-collapse: collapse;
  }

  .typo table th,
  .typo table td {
    text-align: left;
    padding: 1em;
    border-bottom: 1px solid var(--color-ui--border);
    white-space: wrap;
  }

  .typo table a {
    white-space: wrap;
  }

  .typo .list {
    width: 100%;
    font-size: var(--text-ui);
    line-height: var(--text-ui--line-height);
    margin-block: 2em;
    border-collapse: collapse;
    border: 1px solid var(--color-ui--border);
    border-radius: var(--radius-ui);
    overflow: hidden;
    list-style: none;
    padding: 0;
  }

  .typo .list li {
    text-align: left;
    padding: var(--spacing-ui-padding);
    border-bottom: 1px solid var(--color-ui--border);
    white-space: normal;
    color: var(--color-ui--text);
  }

  .typo .list li:last-child {
    border-bottom: none;
  }

  .typo .list li:hover {
    background: var(--color-layer);
  }

  .typo form {
    width: var(--container-mini);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-ui-gap-lg);
  }

  .typo pre {
    @apply scrollbar scrollbar--sm;

    font-family: var(--font-code);
    font-size: var(--text-ui-sm);
    line-height: var(--text-ui-sm--line-height);
    padding: var(--spacing-ui-padding-sm);
    background-color: var(--color-ui);
    color: var(--color-ui--text);
    border: 1px solid var(--color-ui--border);
    overflow: auto;
  }
}
