/* Tool 3: the harness diagram drawn from the model's ```harness block. The chat page's look is in kit/chat.css. */

/* Inside the diagram the accent is the tool's violet (the rest of the page is black and white). */
.h3-diagram { --accent: var(--tool); --accent-ink: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .h3-diagram { --accent-ink: #17132e; } }

:root {
  --h3-model: #c2453d;
  --h3-l1: #2f8f83;  /* user prompt */
  --h3-l2: #b0661a;  /* user system prompt */
  --h3-l3: #6b5bd2;  /* harness system prompt */
  --h3-l4: #2f6fc4;  /* planner prompt */
  --h3-lc: #3f4b56;  /* code */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --h3-model: #ef7d73; --h3-l1: #5cc4b6; --h3-l2: #e5a35a; --h3-l3: #a497ee; --h3-l4: #78aaf0; --h3-lc: #b6c3ce;
  }
}
:root[data-theme="dark"] { --h3-model: #ef7d73; --h3-l1: #5cc4b6; --h3-l2: #e5a35a; --h3-l3: #a497ee; --h3-l4: #78aaf0; --h3-lc: #b6c3ce; }

.k-block-harness { margin: 14px 0 18px; }
.h3-wait { border: 2px dashed var(--edge); border-radius: 14px; padding: 22px 18px; }

.h3-diagram {
  margin: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0;
  background: var(--panel-2); border: 1px solid var(--edge); border-radius: 16px; padding: 14px;
}

/* the class banner */
.h3-class { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.h3-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.h3-tag { font: 800 12px/1 var(--body); letter-spacing: 0.06em; text-transform: uppercase; border-radius: 999px; padding: 6px 10px; border: 2px solid var(--edge); }
.h3-tag.shape { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.h3-tag.stakes.hi { border-color: var(--bad); color: var(--bad); }
.h3-tag.stakes.mid { border-color: var(--warn); color: var(--warn); }
.h3-tag.stakes.lo { color: var(--muted); }
.h3-tag.pattern { color: var(--ink); background: var(--panel); }
.h3-class dl { margin: 0; display: grid; gap: 2px; font-size: 14px; line-height: 1.4; flex: 1 1 280px; }
.h3-class dl div { display: flex; gap: 8px; }
.h3-class dt { flex: none; width: 72px; font: 800 11px/1.9 var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.h3-class dd { margin: 0; }

/* user and result */
.h3-end { align-self: center; max-width: 440px; width: 100%; text-align: center; background: var(--panel); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.4; font-weight: 600; }
.h3-end span { display: block; font: 800 11px/1.3 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.h3-end.result { border-color: var(--good); }

.h3-arrow { display: flex; justify-content: center; padding: 3px 0; }
.h3-arrow svg, .h3-arrows3 svg { width: 18px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.h3-arrows3 { display: flex; justify-content: space-around; padding: 3px 0; }
.h3-side { display: flex; align-items: center; justify-content: center; }
.h3-side svg { width: 26px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the harness outline and its grid */
.h3-harness { position: relative; border: 2px dashed var(--good); border-radius: 18px; padding: 26px 12px 12px; }
.h3-harness-label {
  position: absolute; top: -11px; left: 14px; right: 14px; width: max-content; max-width: calc(100% - 28px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--panel-2); padding: 0 8px; font: 800 12px/22px var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--good);
}
.h3-grid {
  display: grid; gap: 0;
  grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1.15fr) 30px minmax(0, 1fr);
  grid-template-areas:
    "prompt prompt prompt prompt prompt"
    ". . a1 . ."
    "memory h1 loop h2 retrieval"
    "a2 a2 a2 a2 a2"
    "tools . gates . evals";
}

/* a box */
.h3-box { min-width: 0; background: var(--panel); border: 2px solid var(--edge-strong); border-radius: 12px; padding: 9px 11px 10px; display: flex; flex-direction: column; gap: 5px; }
.h3-box.big { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.h3-box.off { border: 2px dashed var(--edge); background: transparent; color: var(--muted); }
/* the box the student asked about ("focus" in the block) */
.h3-box.focus { border-color: #d49a1f; background: color-mix(in srgb, #f2b33d 12%, var(--panel)); box-shadow: 0 0 0 4px color-mix(in srgb, #f2b33d 38%, transparent); }
.h3-box.focus .h3-box-head em.h3-focus-tag { background: #f2b33d; color: #2b2100; }
.h3-box-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; font: 800 11px/1.3 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.h3-box-head em { font-style: normal; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 2px 7px; font-size: 10px; letter-spacing: 0.05em; }
.h3-name { font: 600 16px/1.25 var(--head); color: var(--ink); }
.h3-box.off .h3-name { color: var(--muted); }
.h3-does { font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.h3-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.h3-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.h3-chips .k-term { font-size: 12px; padding: 2px 8px; white-space: normal; text-align: left; }

/* the loop holds the model, as on the course picture */
.h3-box[data-box="loop"] { border-color: var(--h3-model); }
.h3-box[data-box="loop"].big { border-color: var(--h3-model); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.h3-model { background: var(--h3-model); color: #fff; border-radius: 9px; padding: 6px 10px; text-align: center; }
.h3-model b { display: block; font: 600 15px/1.2 var(--head); letter-spacing: 0.03em; text-transform: uppercase; }
.h3-model span { font-size: 12px; line-height: 1.3; opacity: 0.95; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .h3-model { color: #2a0f0c; } }
:root[data-theme="dark"] .h3-model { color: #2a0f0c; }

/* prompt layer tags and the four-layer strip */
.h3-layer { display: inline-flex; align-items: center; gap: 5px; font: 800 11px/1.2 var(--body); letter-spacing: 0.04em; text-transform: uppercase; border-radius: 6px; padding: 3px 7px; border: 1.5px solid currentColor; }
.h3-layer b { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--c); }
.h3-layer b, .h3-strip b { color: var(--panel); font-size: 10px; }
.l1 { --c: var(--h3-l1); } .l2 { --c: var(--h3-l2); } .l3 { --c: var(--h3-l3); } .l4 { --c: var(--h3-l4); } .lc { --c: var(--h3-lc); } .ln { --c: var(--muted); }
.l1, .l2, .l3, .l4, .lc, .ln { color: var(--c); }
.h3-layer.lc { border-style: dashed; }
.h3-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 2px 0 2px; }
.h3-strip span { display: flex; align-items: center; gap: 5px; font: 800 10.5px/1.2 var(--body); letter-spacing: 0.03em; text-transform: uppercase; border: 1.5px dashed currentColor; border-radius: 6px; padding: 4px 6px; opacity: 0.6; min-width: 0; }
.h3-strip span b { flex: none; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--c); }
.h3-strip span.on { opacity: 1; border-style: solid; background: color-mix(in srgb, var(--c) 10%, var(--panel)); }

/* where a person approves */
.h3-approvals { margin-top: 12px; border: 2px solid var(--h3-l4); border-radius: 12px; padding: 8px 12px; background: color-mix(in srgb, var(--h3-l4) 8%, var(--panel)); }
.h3-approvals.none { border-style: dashed; border-color: var(--edge); background: transparent; }
.h3-approvals-head { display: flex; align-items: center; gap: 6px; font: 800 11px/1.3 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--h3-l4); }
.h3-approvals.none .h3-approvals-head { color: var(--muted); }
.h3-person { width: 15px; height: 15px; fill: currentColor; flex: none; }
.h3-approvals ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.45; }

/* legend and buttons */
.h3-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.h3-legend span { display: inline-flex; align-items: center; gap: 5px; }
.h3-legend .sw { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }
.h3-legend .sw.lc { background: transparent; border: 1.5px dashed var(--h3-lc); }
.h3-legend .sw.big { background: transparent; border: 2px solid var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.h3-legend span:has(.l1) { color: var(--h3-l1); } .h3-legend span:has(.l2) { color: var(--h3-l2); }
.h3-legend span:has(.l3) { color: var(--h3-l3); } .h3-legend span:has(.l4) { color: var(--h3-l4); }
.h3-legend span:has(.lc), .h3-legend span:has(.big) { color: var(--muted); }
.h3-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* phone and narrow widths: one column, the loop right under the prompt */
@media (max-width: 700px) {
  .h3-diagram { padding: 10px; margin: 0 -4px; }
  .h3-harness { padding: 24px 8px 8px; }
  .h3-grid {
    grid-template-columns: minmax(0, 1fr); row-gap: 8px;
    grid-template-areas: "prompt" "a1" "loop" "memory" "retrieval" "tools" "gates" "evals";
  }
  .h3-side, .h3-arrows3 { display: none; }
  .h3-grid > .h3-arrow { padding: 0; }
  .h3-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .h3-class dt { width: 72px; }
}
