@layer components {
  .artifact {
    display: inline-block;
    position: relative;

    summary {
      cursor: pointer;
    }

    &[open] > summary {
      color: var(--color-link);
    }

    &[open]::before {
      background: oklch(var(--lch-black) / 50%);
      content: "";
      inset: 0;
      position: fixed;
      z-index: 999;
    }
  }

  .artifact__content {
    background: var(--color-ink-lightest);
    border-radius: 0.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 80vh;
    left: 50%;
    overflow: hidden;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    z-index: 1000;
  }

  .artifact__header {
    align-items: flex-start;
    background: var(--color-ink-lighter);
    border-bottom: var(--border);
    display: flex;
    flex-shrink: 0;
    gap: var(--block-space);
    justify-content: space-between;
    padding: calc(var(--block-space) * 0.75) var(--block-space);
  }

  .artifact__header-text {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
  }

  .artifact__probe {
    color: var(--color-ink);
    font-size: var(--text-small);
  }

  .artifact__probe-target {
    color: var(--color-ink-medium);
    font-size: var(--text-x-small);
  }

  .artifact__probe-time {
    color: var(--color-ink-light);
    font-size: var(--text-x-small);
  }

  .artifact__title {
    color: var(--color-ink-medium);
    font-size: var(--text-x-small);
    font-weight: 500;
    letter-spacing: 0.02em;
    margin: 1em 0 0;
    text-transform: uppercase;
  }

  .artifact__body {
    flex: 1;
    overflow: auto;
    padding: var(--block-space);
  }

  .artifact__body video {
    border-radius: 0.125rem;
    display: block;
  }

  .artifact__body pre {
    background: var(--color-ink-lightest);
    border-radius: 0;
    color: var(--color-ink);
    font-family: var(--font-mono);
    font-size: var(--text-x-small);
    line-height: 1.6;
    margin: calc(var(--block-space) * -1);
    padding: var(--block-space);
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .artifact__close {
    align-items: center;
    background: transparent;
    border-radius: 0.25rem;
    border: 0;
    color: var(--color-negative);
    cursor: pointer;
    display: flex;
    font-size: 1.25rem;
    font-weight: 300;
    height: 1.5rem;
    justify-content: center;
    line-height: 1;
    padding: 0;
    width: 1.5rem;

    &:hover {
      background: var(--color-negative);
      color: var(--color-canvas);
    }
  }

  td .artifact + .artifact {
    margin-left: calc(var(--inline-space) / 2);
  }

  @media (max-width: 140ch) {
    .artifact__content {
      width: calc(100vw - var(--block-space) * 2);
      height: calc(100vh - var(--block-space) * 2);
      left: 50%;
      top: 50%;
    }
  }

  @media (max-width: 55ch) {
    .artifact__content {
      inset: 0;
      width: 100%;
      height: 100%;
      transform: none;
      border-radius: 0;
    }
  }
}
