/* GlowHarness page. Sits on top of ../home.css and ../spark/spark.css and adds only what is new here:
   the brain row, the step timeline with its permission prompt, the answer block, the tool list with its
   three-way switches, the notebook, the suite table and the code sample. */

/* home.css and spark.css give buttons a display of their own, which would beat the hidden attribute. */
.harness-page [hidden] {
  display: none !important;
}

.harness-page .writer textarea {
  min-height: 58px;
}

.harness-page .seg button {
  min-height: 36px;
}

.harness-page .chips {
  flex-wrap: wrap;
  overflow: visible;
}

.desk-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.desk-label {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.desk-note {
  margin: 8px 0 12px;
  max-width: 70ch;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.desk-note b {
  color: var(--text);
  font-weight: 600;
}

.seg button:focus-visible,
.chip:focus-visible,
.note-del:focus-visible,
.act:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- timeline: one row for each thing the engine did ---- */
.timeline {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.step-tag {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1;
}

.step-body {
  min-width: 0;
  padding: 4px 0 2px;
}

.step-head {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.step-head b {
  font-weight: 650;
}

.step-head small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.step-text {
  margin: 3px 0 0;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.step-pre {
  margin: 5px 0 0;
  padding: 8px 10px;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  font: 12.5px/1.5 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.step.task .step-tag {
  background: color-mix(in srgb, var(--accent) 30%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.step.model .step-tag {
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
}

.step.result .step-pre {
  border-left: 3px solid var(--room);
}

.step.result.untrusted .step-pre {
  border-left-color: var(--gold);
}

.step.result.failed .step-pre,
.step.err .step-pre {
  border-left: 3px solid #e5484d;
}

.step.err .step-tag,
.step.blocked .step-tag {
  border-color: color-mix(in srgb, #e5484d 55%, var(--border));
}

.step.warn .step-tag,
.step.ask .step-tag {
  border-color: color-mix(in srgb, var(--gold) 60%, var(--border));
}

.step.thinking .step-head,
.step.wait .step-head {
  color: var(--muted);
}

.step.thinking .step-tag,
.step.wait .step-tag {
  animation: harnessPulse 1.1s ease-in-out infinite;
}

@keyframes harnessPulse {
  50% {
    opacity: 0.45;
  }
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.badge.fix {
  border-color: color-mix(in srgb, var(--room) 50%, var(--border));
  color: var(--text);
}

.badge.caution {
  border-color: color-mix(in srgb, var(--gold) 65%, var(--border));
  color: var(--text);
}

.badge.stop {
  border-color: color-mix(in srgb, #e5484d 60%, var(--border));
  color: var(--text);
}

/* ---- the permission prompt, inline in the timeline ---- */
.ask-box {
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--border));
}

.ask-box p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ask-box p.ask-what {
  font-weight: 650;
}

.ask-box p.ask-why {
  margin-top: 3px;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  font-size: 13.5px;
}

.ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.ask-actions .btn {
  flex: 1 1 auto;
}

.ask-box.settled {
  background: var(--card);
  border-color: var(--border);
}

.ask-box.settled .ask-actions {
  display: none;
}

.ask-box p.ask-verdict {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13.5px;
}

.ask-box p.ask-verdict.yes {
  color: var(--room);
}

.ask-box p.ask-verdict.no {
  color: #e5484d;
}

/* ---- the answer ---- */
.answer {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--room) 9%, var(--card));
  border: 1px solid color-mix(in srgb, var(--room) 45%, var(--border));
}

.answer.partial {
  background: color-mix(in srgb, var(--gold) 9%, var(--card));
  border-color: color-mix(in srgb, var(--gold) 50%, var(--border));
}

.answer.failed {
  background: color-mix(in srgb, #e5484d 8%, var(--card));
  border-color: color-mix(in srgb, #e5484d 45%, var(--border));
}

.answer-label {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.answer-text {
  margin-top: 4px;
  font-size: clamp(16.5px, 2.4vw, 18.5px);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.replay-result {
  margin: 8px 0 4px;
}

.replay-result:empty {
  display: none;
}

/* ---- tools and the notebook ---- */
.tool-list,
.note-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.tool-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 4px 11px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
}

.tool-row.off .tool-icon,
.tool-row.off .tool-main {
  opacity: 0.55;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--panel);
  font-size: 17px;
}

.tool-main {
  min-width: 0;
}

.tool-name {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
}

.tool-name code {
  margin-left: 6px;
  color: var(--muted);
  font: 400 12px ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

.tool-desc {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.tool-desc em {
  font-style: normal;
  color: color-mix(in srgb, var(--text) 80%, var(--muted));
}

.tool-switch button {
  padding: 5px 10px;
  font-size: 13px;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px 7px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 14.5px;
  line-height: 1.45;
}

.note-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.note-row b {
  font-weight: 650;
}

.note-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

.note-del:hover {
  color: #e5484d;
  background: var(--panel);
}

/* ---- the numbers ---- */
.harness-page .stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.harness-page .stat b {
  overflow-wrap: anywhere;
}

@media (min-width: 700px) {
  .harness-page .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.suite-bars .bar {
  grid-template-columns: minmax(132px, 40%) 1fr auto;
}

.suite-bars .bar.pair-start {
  margin-top: 6px;
}

.bars-note {
  margin-top: 12px;
}

.bars-note span {
  display: block;
}

.bars-note span + span {
  margin-top: 3px;
}

#paired-note span + span {
  margin-top: 8px;
}

.versus.suite {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.versus.suite thead th {
  overflow-wrap: anywhere;
}

.versus.suite th,
.versus.suite td {
  padding: 7px 10px;
}

.versus.suite thead th {
  vertical-align: bottom;
  text-align: right;
}

.versus.suite thead th:first-child {
  text-align: left;
}

.versus.suite thead th.group {
  text-align: center;
  border-left: 1px solid var(--border);
}

.versus.suite tbody th {
  width: auto;
}

.versus.suite td {
  text-align: right;
  white-space: nowrap;
}

.versus.suite .total th,
.versus.suite .total td {
  border-top: 2px solid var(--border);
  color: var(--text);
  font-weight: 700;
}

.versus.suite .sub th,
.versus.suite .sub td {
  font-size: 12.5px;
}

.method-list {
  font-size: 13.5px;
  color: var(--muted);
}

.method-list b {
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  font-weight: 600;
}

.code {
  margin: 10px 0 0;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  font: 12.5px/1.55 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
}

.code code {
  font: inherit;
  white-space: pre;
}

/* The comparison reads as a list on a phone: one block for each question, one line for each tool. */
@media (max-width: 720px) {
  .versus.compare,
  .versus.compare tbody,
  .versus.compare tr,
  .versus.compare tbody th,
  .versus.compare td {
    display: block;
    width: auto;
    min-width: 0;
  }

  .versus.compare thead {
    display: none;
  }

  .versus.compare tbody tr {
    padding: 4px 0 8px;
    border-bottom: 1px solid var(--border);
  }

  .versus.compare tbody tr:last-child {
    border-bottom: 0;
  }

  .versus.compare tbody th {
    padding: 8px 12px 3px;
    border-bottom: 0;
    color: var(--text);
    font-size: 14px;
  }

  .versus.compare td {
    padding: 3px 12px;
    border-bottom: 0;
  }

  .versus.compare td::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 600;
  }

  .versus.compare td.win::before {
    content: "✓ " attr(data-label) ": ";
    color: var(--room);
  }

  .versus.compare td.lose::before {
    content: "✕ " attr(data-label) ": ";
    color: #e5484d;
  }
}

/* Two models make five columns of numbers, more than a phone can show side by side. Each group of tasks
   gets a line of its own, with its numbers in a row underneath, lined up under the column heads. */
@media (max-width: 600px) {
  .versus.suite.stacked,
  .versus.suite.stacked thead,
  .versus.suite.stacked tbody {
    display: block;
  }

  .versus.suite.stacked tr {
    display: grid;
    grid-template-columns: repeat(var(--suite-cols, 5), minmax(0, 1fr));
  }

  .versus.suite.stacked thead th {
    padding: 7px 3px 3px;
    border-bottom: 0;
    border-left: 0;
    font-size: 11.5px;
    line-height: 1.3;
    text-align: center;
  }

  .versus.suite.stacked thead th.corner {
    display: none;
  }

  .versus.suite.stacked thead th.pair {
    grid-column: span 2;
  }

  .versus.suite.stacked thead tr + tr th {
    padding: 0 3px 7px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 400;
  }

  .versus.suite.stacked tbody th {
    grid-column: 1 / -1;
    padding: 8px 10px 0;
    border-bottom: 0;
  }

  .versus.suite.stacked tbody td {
    padding: 2px 3px 8px;
    text-align: center;
  }

  .versus.suite.stacked .total td {
    border-top: 0;
  }
}

@media (max-width: 560px) {
  .tool-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .tool-switch {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .suite-bars .bar {
    grid-template-columns: minmax(104px, 44%) 1fr auto;
  }

  .harness-page .stat b {
    font-size: 20px;
  }

  .step {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 8px;
  }

  .step-tag {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    font-size: 13px;
  }
}

/* The floating GlowLead bubble steps aside while it covers a control or touches an open permission question
   (keepCrownClear in harness.js). It is only made see-through, never removed, so the keyboard still reaches it
   and focus brings it back. */
.harness-page .glow-widget-bubble {
  transition: opacity 0.15s ease;
}

html.crown-aside .glow-widget-bubble:not(:focus-visible):not(:active):not([aria-expanded="true"]) {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .step.thinking .step-tag,
  .step.wait .step-tag {
    animation: none;
  }

  .harness-page .glow-widget-bubble {
    transition: none;
  }
}

/* The two fold-out headings are tap targets too. */
.harness-page .books summary {
  padding: 7px 0;
}
