.Root {
  color: var(--demo-neutral-fg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 22rem;
  max-width: calc(100vw - 8rem);
}

.Trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;

  margin: 0;
  border: 1px solid var(--demo-border);
  border-radius: 0.5rem;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: start;
  cursor: pointer;
  color: var(--demo-neutral-fg);

  outline: none;

  &:hover:not([data-disabled], :disabled) {
    background: var(--demo-neutral-subtle);
  }

  &:focus-visible {
    outline: 2px solid var(--demo-coral-focus-ring);
    outline-offset: 2px;
  }

  &[data-disabled] {
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: not-allowed;
  }
}

.Indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--demo-neutral-emphasized);
  transition: transform 120ms ease;
  transform-origin: center;

  &[data-state='open'] {
    transform: rotate(90deg);
  }

  & svg {
    width: 1rem;
    height: 1rem;
  }
}

.Content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;

  &[data-state='open'] {
    animation:
      expand-height 120ms ease-out,
      fade-in 120ms ease-out;

    &[data-has-collapsed-size] {
      animation-name: expand-height;
    }
  }

  &[data-state='closed'] {
    animation:
      collapse-height 120ms ease-out,
      fade-out 120ms ease-out;

    &[data-has-collapsed-size] {
      animation-name: collapse-height;
      box-shadow: inset 0 -12px 12px -12px rgba(0, 0, 0, 0.5);
    }
  }
}

.Body {
  padding-inline: 0.75rem;
  padding-block: 0.625rem;
  color: var(--demo-neutral-fg);
  line-height: 1.5;
  font-size: 0.875rem;

  & p + p {
    margin-top: 0.5rem;
  }

  code {
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
    color: var(--demo-neutral-fg);
    background-color: var(--demo-neutral-subtle);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
  }
}

.Nested {
  margin-top: 0.5rem;
  width: 100%;
}

@keyframes expand-height {
  from {
    height: var(--collapsed-height, 0);
  }
  to {
    height: var(--height);
  }
}

@keyframes collapse-height {
  from {
    height: var(--height);
  }
  to {
    height: var(--collapsed-height, 0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
