/* Parse result inside the input tab: the Text view replaces the editor, the Tree of found facts sits on the right. */
#types-panel:not(.result-available) .editor-result-action,
#types-panel:not(.result-available) .result-tree-show,
.text-editor-body:not(.result-tree-hidden) .result-tree-show {
  display: none !important;
}

#result-edit[aria-pressed="true"],
#text-wrap[aria-pressed="true"] {
  color: var(--accent);
}

/* The Spec pane: its toolbar over the YAML editor. */
.spec-pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The Text pane: its toolbar over the editor, the Markdown preview or the Text view. */
.result-text-pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.result-text-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* Lines run past the right edge unless they wrap. */
.text-editor-body.text-nowrap .interactive-view {
  white-space: pre;
  overflow-wrap: normal;
}

.text-editor-body:not(.text-nowrap) .result-text-content > .studio-editor {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-text-content > .result-text-view,
.text-editor-body > .result-tree {
  display: none;
}

.text-editor-body[data-result="view"] .result-text-content > .studio-editor,
.text-editor-body[data-result="view"] .result-text-content > .markdown-preview {
  display: none;
}

.text-editor-body[data-result="view"] .result-text-content > .result-text-view {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  cursor: text;
}

.text-editor-body[data-result="view"] > .result-tree,
.text-editor-body[data-result="edit"] > .result-tree {
  display: flex;
}

.text-editor-body.result-tree-hidden > .result-tree {
  display: none !important;
}

/* While the text is being edited the tree belongs to the previous run. */
.text-editor-body[data-result="edit"] > .result-tree .result-tree-body {
  opacity: 0.45;
  pointer-events: none;
}

.result-tree {
  position: relative;
  flex: 0 0 var(--result-tree-width, 18rem);
  width: var(--result-tree-width, 18rem);
  max-width: 45%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-left: 1px solid var(--line-2);
  background: var(--bg);
}

.result-tree-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  z-index: 3;
  width: 6px;
  cursor: col-resize;
}

.result-tree-resizer:hover,
.result-tree.resizing .result-tree-resizer {
  background: rgb(var(--accent-rgb) / 0.35);
}

.result-pane-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.2rem 0.4rem 0.2rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.pane-header-start {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

/* The main action of the file: labelled and green, apart from the view options on the right. */
.pane-run-button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 1.45rem;
  padding: 0 0.55rem 0 0.4rem;
  border: 1px solid rgb(var(--ok-rgb) / 0.35);
  border-radius: 5px;
  background: rgb(var(--ok-rgb) / 0.1);
  color: var(--ok);
  font: 600 0.72rem/1 var(--font-ui);
  cursor: pointer;
}

.pane-run-button:hover,
.pane-run-button:focus-visible {
  background: rgb(var(--ok-rgb) / 0.2);
  border-color: rgb(var(--ok-rgb) / 0.6);
  outline: none;
}

.pane-header-start .studio-ai-action {
  height: 1.45rem;
}

.pane-run-button[hidden] {
  display: none;
}

.pane-run-button .app-icon {
  width: 0.75rem;
  height: 0.75rem;
  fill: currentColor;
}

.result-pane-title {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink-3);
  font: 700 0.68rem/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.result-tree-chevron {
  display: none;
}

.result-tree-chevron .app-icon {
  width: 0.8rem;
  height: 0.8rem;
  transition: transform 0.14s ease;
}

.result-tree-title[aria-expanded="true"] .result-tree-chevron .app-icon {
  transform: rotate(90deg);
}

/* The rightmost buttons keep their tooltips inside the window. */
.result-pane-actions .mini-action:last-child[data-tooltip]::after {
  left: auto;
  right: 0;
  transform: translate(0, -3px);
}

.result-pane-actions .mini-action:last-child[data-tooltip]::before {
  left: auto;
  right: 0.5rem;
  transform: translate(0, -3px) rotate(45deg);
}

.result-pane-actions .mini-action:last-child[data-tooltip]:hover::after,
.result-pane-actions .mini-action:last-child[data-tooltip]:focus-visible::after {
  transform: translate(0, 0);
}

.result-pane-actions .mini-action:last-child[data-tooltip]:hover::before,
.result-pane-actions .mini-action:last-child[data-tooltip]:focus-visible::before {
  transform: translate(0, 0) rotate(45deg);
}

.result-pane-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.result-tree-separator {
  width: 1px;
  height: 0.9rem;
  margin: 0 0.2rem;
  background: rgb(var(--neutral-rgb) / 0.38);
}

.result-tree-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}

.result-tree .match-tree {
  min-height: 0;
  padding: 0.45rem 0.5rem 1rem 0.65rem;
  overflow: visible;
}

.result-tree .match-tree-summary {
  gap: 0.35rem;
}

.result-tree .match-tree-children {
  margin-left: 0.3rem;
  padding-left: 0.6rem;
}

.result-tree .match-tree-node:not(.match-tree-has-children) > .match-tree-summary {
  cursor: pointer;
}

.match-tree-selected > .match-tree-summary,
.match-tree-selected > .match-tree-summary:hover {
  background: var(--semantic-pinned-bg);
  box-shadow: inset 0 0 0 1px var(--semantic-pinned-border);
}

/* JSON and test results open in a wide modal. */
.result-dialog .result-dialog-panel {
  width: min(60rem, calc(100vw - 2rem));
  height: min(48rem, calc(100vh - 3rem));
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr);
}

.result-dialog-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.result-dialog-subtitle {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-3);
  font: 500 0.76rem/1.2 var(--font-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-dialog-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.2rem;
}

.result-dialog-close {
  margin-left: 0.35rem;
}

.result-dialog-body {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}

.status-tests {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}

.status-tests.hidden {
  display: none;
}

.status-tests .app-icon {
  width: 0.8rem;
  height: 0.8rem;
}

.status-tests.passed {
  border-color: rgb(var(--ok-rgb) / 0.4);
  background: rgb(var(--ok-rgb) / 0.1);
  color: var(--ok);
}

.status-tests.failed {
  border-color: rgb(var(--danger-rgb) / 0.4);
  background: var(--danger-soft);
  color: var(--danger);
}

.status-tests.running .app-icon {
  animation: spin 1s linear infinite;
}

.status-tests:hover,
.status-tests:focus-visible {
  border-color: currentColor;
  outline: none;
}

@media (max-width: 760px) {
  .text-editor-body[data-result="view"],
  .text-editor-body[data-result="edit"] {
    flex-direction: column;
  }

  .result-tree {
    flex: 0 0 38%;
    width: auto;
    max-width: none;
    border-left: 0;
    border-top: 1px solid var(--line-2);
  }

  .result-tree-resizer,
  .panel-hide-button,
  .result-tree-show {
    display: none !important;
  }

  /* A hidden tree keeps its header: tap it to unfold the tree again. */
  .text-editor-body[data-result="view"].result-tree-hidden > .result-tree,
  .text-editor-body[data-result="edit"].result-tree-hidden > .result-tree {
    display: flex !important;
    flex: 0 0 auto;
  }

  .text-editor-body.result-tree-hidden .result-tree-body,
  .text-editor-body.result-tree-hidden .result-tree-actions {
    display: none;
  }

  .result-pane-header {
    min-height: 2.4rem;
  }

  .result-tree-title {
    pointer-events: auto;
    cursor: pointer;
    min-height: 2rem;
  }

  .result-tree-chevron {
    display: inline-flex;
  }
}
