/*
 * Styling for the interactive Harbor eval diagram (harbor-diagram.js).
 * Colors come from CSS variables so the widget follows the light/dark toggle.
 */

.harbor-diagram {
  --hd-accent: #3b82f6;
  --hd-accent-strong: #2563eb;
  --hd-ok: #22c55e;
  --hd-node: #ffffff;
  --hd-node-2: #f3f6fa;
  --hd-border: #d6dbe3;
  --hd-fg: #1b1f24;
  --hd-muted: #5c6672;
  --hd-edge: #c3ccd7;
  --hd-cluster: #b6c0cc;
  --hd-pill: #eef1f5;

  margin: 1.5em 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 12px;
  padding: 0.5rem 0.75rem 0.9rem;
  background: var(--md-default-bg-color);
}

[data-md-color-scheme="slate"] .harbor-diagram {
  --hd-node: #141a22;
  --hd-node-2: #1b2029;
  --hd-border: #2c3743;
  --hd-fg: #eef2f6;
  --hd-muted: #98a5b4;
  --hd-edge: #38434f;
  --hd-cluster: #3a4653;
  --hd-pill: #232c37;
}

.harbor-diagram .hd-stage { width: 100%; }
.harbor-diagram svg { width: 100%; height: auto; display: block; overflow: visible; }
.harbor-diagram text { font-family: var(--md-text-font, inherit); }

/* ---- nodes ---- */
.harbor-diagram .hd-box {
  fill: var(--hd-node);
  stroke: var(--hd-border);
  stroke-width: 1.2;
  transition: stroke 0.25s ease, fill 0.25s ease, filter 0.25s ease;
}
.harbor-diagram .hd-cluster .hd-box {
  fill: none;
  stroke: var(--hd-cluster);
  stroke-width: 1.4;
  stroke-dasharray: 6 6;
}
.harbor-diagram .hd-gateway .hd-box,
.harbor-diagram .hd-res .hd-box { fill: var(--hd-node-2); }

.harbor-diagram .hd-node.is-active .hd-box {
  stroke: var(--hd-accent);
  stroke-width: 1.8;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hd-accent) 45%, transparent));
}
.harbor-diagram .hd-cluster.is-active .hd-box { stroke: var(--hd-accent); filter: none; }

.harbor-diagram .hd-title { fill: var(--hd-fg); font-size: 15.5px; font-weight: 600; }
.harbor-diagram .hd-sub,
.harbor-diagram .hd-row-text { fill: var(--hd-muted); font-size: 11.5px; }
.harbor-diagram .hd-cluster-title { fill: var(--hd-fg); opacity: 0.72; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }
.harbor-diagram .hd-res-title { fill: var(--hd-muted); font-size: 12.5px; }

.harbor-diagram .hd-dot { fill: var(--hd-border); transition: fill 0.25s ease; }
.harbor-diagram .hd-row.is-active .hd-dot { fill: var(--hd-accent); }
.harbor-diagram .hd-row.is-active .hd-row-text { fill: var(--hd-fg); }

/* status pill */
.harbor-diagram .hd-pill-box { fill: var(--hd-pill); stroke: none; transition: fill 0.25s ease; }
.harbor-diagram .hd-pill-box.is-run { fill: color-mix(in srgb, var(--hd-accent) 22%, var(--hd-node)); }
.harbor-diagram .hd-pill-box.is-done { fill: color-mix(in srgb, var(--hd-ok) 24%, var(--hd-node)); }
.harbor-diagram .hd-pill-text { fill: var(--hd-fg); font-size: 11.5px; font-weight: 600; }

/* ---- edges + particles ---- */
.harbor-diagram .hd-edge {
  fill: none;
  stroke: var(--hd-edge);
  stroke-width: 1.3;
  transition: stroke 0.25s ease, stroke-width 0.25s ease;
}
.harbor-diagram .hd-edge.is-active { stroke: var(--hd-accent); stroke-width: 2; }
.harbor-diagram .hd-arrowhead { fill: var(--hd-edge); fill: context-stroke; }
.harbor-diagram .hd-particle { fill: var(--hd-accent); }

/* ---- controls ---- */
.harbor-diagram .hd-controls { margin-top: 0.5rem; }
.harbor-diagram .hd-steps {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem;
}
.harbor-diagram .hd-step {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  background: var(--hd-node-2);
  color: var(--hd-muted);
  border-radius: 999px; padding: 0.16rem 0.55rem 0.16rem 0.26rem;
  font-size: 0.68rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease;
}
.harbor-diagram .hd-step:hover { color: var(--hd-fg); border-color: var(--hd-accent); }
.harbor-diagram .hd-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.05rem; height: 1.05rem; border-radius: 999px;
  background: var(--hd-pill); color: var(--hd-muted); font-size: 0.64rem;
}
.harbor-diagram .hd-step[aria-selected="true"] {
  color: #fff; background: var(--hd-accent-strong); border-color: var(--hd-accent-strong);
}
.harbor-diagram .hd-step[aria-selected="true"] .hd-step-num { background: rgba(255, 255, 255, 0.25); color: #fff; }

.harbor-diagram .hd-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.harbor-diagram .hd-btn {
  border: 1px solid var(--md-default-fg-color--lightest);
  background: var(--hd-node-2); color: var(--hd-fg);
  border-radius: 7px; padding: 0.3rem 0.7rem; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease;
}
.harbor-diagram .hd-btn:hover:not(:disabled) { border-color: var(--hd-accent); color: var(--hd-accent); }
.harbor-diagram .hd-btn:disabled { opacity: 0.4; cursor: default; }
.harbor-diagram .hd-play { margin-left: auto; }
.harbor-diagram .hd-counter { font-size: 0.78rem; color: var(--hd-muted); min-width: 3.2rem; text-align: center; }

.harbor-diagram .hd-caption {
  margin: 0.7rem 0 0.1rem; font-size: 0.82rem; line-height: 1.5;
  color: var(--md-default-fg-color--light); min-height: 3.6em;
}

/* Focus visibility for keyboard users. */
.harbor-diagram .hd-step:focus-visible,
.harbor-diagram .hd-btn:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .harbor-diagram .hd-box, .harbor-diagram .hd-edge { transition: none; }
}

/*
 * Static, theme-aware eval.yaml schema map (embedded in reference/eval-yaml.md).
 * Text, borders and surfaces use Material vars so the widget follows the
 * light/dark toggle automatically. The four category hues and the two field
 * badges are local tokens with a slate override — the same pattern as
 * .harbor-diagram above.
 */
.schema-diagram {
  --sd-define: #2563eb;
  --sd-execute: #15803d;
  --sd-score: #b45309;
  --sd-observe: #7c3aed;
  --sd-llm: #1d4ed8;
  --sd-py: #92400e;

  margin: 1.5em 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 12px;
  container-type: inline-size;
  padding: 1rem 1rem 1.15rem;
  background: var(--md-default-bg-color);
}

[data-md-color-scheme="slate"] .schema-diagram {
  --sd-define: #60a5fa;
  --sd-execute: #4ade80;
  --sd-score: #fbbf24;
  --sd-observe: #a78bfa;
  --sd-llm: #60a5fa;
  --sd-py: #fbbf24;
}

.schema-diagram .sd-meta {
  margin: 0 0 0.9rem;
  font-size: clamp(0.58rem, 1.55cqi, 0.72rem);
  line-height: 1.55;
  color: var(--md-default-fg-color--light);
}

.schema-diagram .sd-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.4rem, 1.35cqi, 0.85rem);
  align-items: start;
}

/* Phones / very narrow windows: four columns stop being legible — fall back
   to two, preserving the Define → Execute → Score → Observe reading order.
   Uses a viewport media query (reliable) rather than a container query. */
@media screen and (max-width: 600px) {
  .schema-diagram .sd-grid { grid-template-columns: repeat(2, 1fr); }
}
@media screen and (max-width: 430px) {
  .schema-diagram .sd-grid { grid-template-columns: 1fr; }
}

.schema-diagram .sd-col {
  display: flex;
  flex-direction: column;
  gap: clamp(0.38rem, 1.05cqi, 0.6rem);
  min-width: 0;
}

.schema-diagram .sd-group {
  padding-left: 0.15rem;
  font-size: clamp(0.52rem, 1.5cqi, 0.7rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.schema-diagram .sd-col.define  .sd-group { color: var(--sd-define); }
.schema-diagram .sd-col.execute .sd-group { color: var(--sd-execute); }
.schema-diagram .sd-col.score   .sd-group { color: var(--sd-score); }
.schema-diagram .sd-col.observe .sd-group { color: var(--sd-observe); }

.schema-diagram .sd-card {
  position: relative;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-left: 3px solid var(--sd-bar, var(--md-default-fg-color--lighter));
  border-radius: var(--doc-radius, 0.55rem);
  padding: clamp(0.35rem, 1.05cqi, 0.5rem) clamp(0.4rem, 1.2cqi, 0.6rem) clamp(0.4rem, 1.15cqi, 0.55rem);
  background: var(--md-default-bg-color);
  transition: border-color 0.2s ease;
}
.schema-diagram .sd-col.define  .sd-card { --sd-bar: var(--sd-define); }
.schema-diagram .sd-col.execute .sd-card { --sd-bar: var(--sd-execute); }
.schema-diagram .sd-col.score   .sd-card { --sd-bar: var(--sd-score); }
.schema-diagram .sd-col.observe .sd-card { --sd-bar: var(--sd-observe); }
.schema-diagram .sd-card:hover { border-color: var(--sd-bar, var(--md-default-fg-color--lighter)); }
.schema-diagram .sd-card.deprecated { border-style: dashed; }

.schema-diagram .sd-key {
  font-family: var(--md-code-font, monospace);
  font-size: clamp(0.6rem, 1.9cqi, 0.82rem);
  font-weight: 700;
  color: var(--md-default-fg-color);
}

/* Card title as a link; the ::after stretches over the whole card so a click
   anywhere on the pane navigates to that key's reference page. */
.schema-diagram a.sd-key {
  text-decoration: none;
  color: var(--md-default-fg-color);
}
.schema-diagram a.sd-key:hover { color: var(--sd-bar, var(--md-default-fg-color)); }
.schema-diagram a.sd-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.schema-diagram .sd-purpose {
  margin: 0.12rem 0 0.42rem;
  font-size: clamp(0.52rem, 1.5cqi, 0.71rem);
  line-height: 1.4;
  color: var(--md-default-fg-color--light);
}

.schema-diagram .sd-fields {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.16rem, 0.5cqi, 0.28rem);
}

.schema-diagram .sd-f {
  font-family: var(--md-code-font, monospace);
  font-size: clamp(0.5rem, 1.45cqi, 0.68rem);
  color: var(--md-default-fg-color);
  background: var(--md-code-bg-color);
  border-radius: 0.3rem;
  padding: 0.06rem clamp(0.24rem, 0.7cqi, 0.36rem);
  overflow-wrap: anywhere;
}

.schema-diagram .sd-badge {
  margin-left: clamp(0.14rem, 0.5cqi, 0.28rem);
  padding: 0 0.26rem;
  border: 1px solid currentcolor;
  border-radius: 999px;
  font-family: var(--md-text-font, inherit);
  font-size: clamp(0.44rem, 1.15cqi, 0.56rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}
.schema-diagram .sd-badge.llm { color: var(--sd-llm); }
.schema-diagram .sd-badge.py  { color: var(--sd-py); }
.schema-diagram .sd-badge.dep { color: var(--md-primary-fg-color); }

.schema-diagram .sd-meta code { font-size: 0.9em; }

@media (prefers-reduced-motion: reduce) {
  .schema-diagram .sd-card { transition: none; }
}

/*
 * Ambient "eval loop" hero diagram (loop-diagram.js). Six stages as a
 * left-to-right pipeline that closes back on itself. Uses the brand-red accent
 * (unlike the blue Harbor diagram) so it reads as the product's own signature
 * on the landing page. Same token pattern as .harbor-diagram: local tokens with
 * a slate override, everything else from Material vars.
 */
.loop-diagram {
  --ld-accent: var(--md-primary-fg-color);
  --ld-node: #ffffff;
  --ld-border: #dbe0e8;
  --ld-fg: #1b1f24;
  --ld-muted: #5c6672;
  --ld-edge: #cdd4de;
  --ld-badge: #f0f2f6;

  margin: 1.6em 0 1.2em;
}

[data-md-color-scheme="slate"] .loop-diagram {
  --ld-node: #151b23;
  --ld-border: #2c3743;
  --ld-fg: #eef2f6;
  --ld-muted: #9aa7b6;
  --ld-edge: #3a4653;
  --ld-badge: #222b36;
}

.loop-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.loop-diagram text { font-family: var(--md-text-font, inherit); }

/* ---- nodes ---- */
.loop-diagram .ld-box {
  fill: var(--ld-node);
  stroke: var(--ld-border);
  stroke-width: 1.3;
  transition: stroke 0.3s ease, filter 0.3s ease;
}
[data-md-color-scheme="default"] .loop-diagram .ld-box {
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.06));
}
.loop-diagram .ld-node.is-active .ld-box {
  stroke: var(--ld-accent);
  stroke-width: 2;
  filter: drop-shadow(0 0 9px color-mix(in srgb, var(--ld-accent) 50%, transparent));
}

.loop-diagram .ld-badge {
  fill: var(--ld-badge);
  transition: fill 0.3s ease;
}
.loop-diagram .ld-node.is-active .ld-badge {
  fill: color-mix(in srgb, var(--ld-accent) 20%, var(--ld-node));
}
.loop-diagram .ld-badge-num {
  fill: var(--ld-muted);
  font-size: 14px;
  font-weight: 700;
  transition: fill 0.3s ease;
}
.loop-diagram .ld-node.is-active .ld-badge-num { fill: var(--ld-accent); }

.loop-diagram .ld-title { fill: var(--ld-fg); font-size: 17px; font-weight: 650; }
.loop-diagram .ld-cmd {
  fill: var(--ld-muted);
  font-family: var(--md-code-font, monospace);
  font-size: 13px;
}
.loop-diagram .ld-node.is-active .ld-cmd { fill: var(--ld-fg); }

/* ---- edges + feedback arc + particles ---- */
.loop-diagram .ld-edge,
.loop-diagram .ld-arc {
  fill: none;
  stroke: var(--ld-edge);
  stroke-width: 1.6;
  transition: stroke 0.3s ease, stroke-width 0.3s ease;
}
.loop-diagram .ld-arc { stroke-dasharray: 6 6; }
.loop-diagram .ld-edge.is-active,
.loop-diagram .ld-arc.is-active { stroke: var(--ld-accent); stroke-width: 2.2; }
.loop-diagram .ld-arrowhead { fill: var(--ld-edge); fill: context-stroke; }
.loop-diagram .ld-particle { fill: var(--ld-accent); }

.loop-diagram .ld-arc-label {
  fill: var(--ld-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.loop-diagram .ld-caption {
  margin: 0.4rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--md-default-fg-color--light);
}
