/* Status colors shared by the homepage demos and diagrams. */
#main {
  --status-green: #32a064;
  --status-green-ink: #218050;
  --status-green-on-dark: #a2e8b8;
}
#main .pill.good {
  --pill-mark: var(--status-green);
  color: var(--status-green-ink);
  background: color-mix(in srgb, var(--pill-mark) 8%, white);
}
#main .pill.accent {
  --pill-mark: var(--brand-on-light);
  color: color-mix(in srgb, var(--pill-mark) 70%, var(--fg));
  background: color-mix(in srgb, var(--pill-mark) 12%, white);
}
#main .pill:is(.good, .accent) { box-shadow: 0 0 0 1px var(--pill-mark); }
#main .pill:is(.good, .accent)::before { background: var(--pill-mark); }

/* Context, optimization and the improvement cycle use the same column lines as Deploy. */
#main > :is(#secrets, #improve, #how) > .wrap {
  row-gap: clamp(28px, 4vw, 60px);
}
#main > :is(#secrets, #how) {
  padding-block: var(--section-space);
  border-top: 1px solid var(--border);
}
#main > #secrets {
  border-top-color: rgb(45 27 18 / 22%);
  background:
    radial-gradient(ellipse at 24% 12%, transparent 8%, rgb(95 39 17 / 12%) 54%, rgb(95 39 17 / 32%)),
    var(--brand-on-light);
}
#main > #improve { padding-bottom: var(--section-space); }
#main :is(#secrets, #improve, #how) .section-head {
  display: block;
  grid-column: 1 / -1;
  margin: 0;
  max-width: none;
}
#improve .section-head, #how .section-head { container-type: inline-size; }
#main :is(#improve, #how) .section-head h2 {
  max-width: none;
  margin: 0;
  font-size: min(var(--type-h2), 9.1cqi);
  line-height: 1.03;
}
#main #how .section-head h2 { font-size: min(var(--type-h2), 6cqi); }
#main :is(#improve, #how) h2 .line { display: block; margin: 0; }
#main #secrets .section-head {
  --fg: #fff;
  --fg-2: var(--fg);
  color: var(--fg);
  text-align: center;
}
#main #secrets h2 { max-width: 1080px; margin-inline: auto; text-wrap: balance; }
#secrets h2 .line { display: block; margin: 0; }
#main #secrets .section-head .lead {
  max-width: 62ch;
  margin: clamp(18px, 2vw, 28px) auto 0;
  text-wrap: pretty;
}
#secrets .carry {
  --panel-inset: clamp(16px, 2vw, 30px);
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: none;
  margin: 0;
}
#secrets .carry > figure {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow:
    0 2px 5px rgb(66 29 14 / 13%),
    0 12px 26px -11px rgb(66 29 14 / 34%);
}
#secrets .term {
  --code-bar: #2a221d;
  --code-bg: #211c18;
  --code-border: #534338;
  --code-fg: #fff;
  --code-dim: var(--code-fg);
}
#secrets .term .term-bar { padding: 17px var(--panel-inset); }
#secrets .term .term-title { font-size: 12px; }
#secrets .term .term-body {
  min-height: 0;
  padding: clamp(20px, 2.4vw, 34px) var(--panel-inset);
  font: 400 clamp(12px, 1.08vw, 15px)/1.95 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#secrets .carry-arrow {
  width: 100%;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--brand-on-dark) 18%, white);
  transform: none;
}
#secrets .carry-arrow svg {
  width: 46px;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 2px currentColor) drop-shadow(0 0 6px var(--brand-on-dark));
  transform: rotate(90deg);
}
#secrets .carry > .card {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
}
#secrets .card-head {
  padding: 16px var(--panel-inset);
  background: transparent;
  font-size: 14px;
}
#secrets .rows { padding: 4px var(--panel-inset) 12px; }
#secrets .rows > div {
  grid-template-columns: minmax(6rem, .55fr) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  font-size: 14px;
}
#secrets .rows dd { font-size: 12px; }

/* The proposal is the visual evidence alongside the three editorial points. */
.improve-points, #improve .improve-demo { grid-column: 1 / -1; min-width: 0; }
.improve-points {
  list-style: none;
  display: grid;
  padding: 0;
  margin: 0;
}
.improve-points li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
}
.improve-points li:last-child { padding-bottom: 0; }
.improve-points .ip-icon { padding-top: 3px; color: var(--accent); }
.improve-points h3, .proposal .improve-fix h3 {
  margin: 0 0 6px;
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 500;
  line-height: 1.25;
}
.improve-points p, .proposal-desc {
  margin: 0;
  color: var(--fg-2);
  font-size: 15px;
  line-height: 1.6;
}
#improve .improve-demo {
  --report-inset: clamp(18px, 3.8cqw, 32px);
  container-type: inline-size;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--brand-on-light);
  border-radius: clamp(12px, 1.3vw, 19px);
  background: color-mix(in srgb, var(--surface) 75%, white);
  box-shadow:
    0 0 12px -3px color-mix(in srgb, var(--brand-on-light) 32%, transparent),
    0 10px 28px -18px color-mix(in srgb, var(--brand-on-light) 52%, transparent);
}
#improve .improve-demo::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0 7% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-on-light) 32%, #fff3df 58%, transparent);
  pointer-events: none;
}
#improve .proposal {
  --good: var(--status-green-ink);
  width: 100%;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
#improve .proposal .card-head {
  flex-wrap: wrap;
  padding: 20px var(--report-inset);
  border-radius: 0;
  background: transparent;
  font-size: 17px;
}
#improve .improve-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#improve .improve-fix, #improve .improve-compare { min-width: 0; padding: var(--report-inset); }
#improve .improve-compare { gap: 20px; border-top: 0; border-left: 1px solid var(--border); background: transparent; }
#improve .improve-label {
  color: var(--fg-2);
  font: 500 11px/1.5 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .07em;
}
#improve .improve-label { margin: 0 0 16px; }
#improve .compare-head { display: grid; justify-content: start; gap: 6px; }
#improve .compare-head .improve-label { margin: 0; }
#improve .metric-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; }
#improve .metric-key .v2::before, #improve .metric-bar.v2 i { background: var(--status-green); }
#improve .improve-diff {
  --code-green: var(--status-green-on-dark);
  --good-soft: #294332;
  margin-top: 20px;
  padding: 12px 0;
  font: 12px/1.8 var(--font-mono);
}
#improve .improve-diff > div { padding-inline: 12px; }
.improve-diff .del { color: #e3a091; }
.improve-diff .dim { color: var(--code-dim); }
#improve .metric { grid-template-columns: minmax(0, 1fr); gap: 4px; }
#improve .metric-name {
  grid-row: auto;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 2px;
  font-size: 14px;
}
.metric-name .delta { font: 500 12px/1.5 var(--font-mono); color: var(--good); }
.metric-name .same { color: var(--fg-3); }
#improve .metric-bar { display: grid; grid-template-columns: minmax(0, 1fr) 6ch; gap: 10px; font-size: 12px; text-align: right; }
#improve .metric-bar i { width: calc(var(--w) * 1%); border-radius: 2px; }
#improve [data-demo][data-state] .metric:not(.shown) .metric-bar.v2 i { width: 0; }
#improve .improve-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px var(--report-inset);
}
#improve .approval { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--fg-2); font-size: 13px; }
#improve .improve-buttons .btn { min-height: 34px; padding: 7px 12px; font-size: 12px; }
.proposal-note { margin: 14px var(--report-inset); color: var(--fg-2); font-size: 12px; line-height: 1.5; }
#improve .demo-controls { margin: 0; padding: 0 var(--report-inset) 14px; }
html:not(.js) #improve .demo-controls { display: none; }
@container (max-width: 540px) {
  #improve .improve-body { grid-template-columns: minmax(0, 1fr); }
  #improve .improve-compare { border-left: 0; border-top: 1px solid var(--border); }
}

/* The four original steps form an open sequence on the responsive site grid. */
#how .flow, .flow-steps {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  gap: 0 var(--layout-gap);
  margin: 0;
  padding: 0;
}
.flow-steps { list-style: none; }
.flow-item { grid-column: span 4; min-width: 0; }
.flow-eyebrow, .flow-cycle { margin: 0 0 12px; }
.flow-eyebrow {
  color: var(--fg);
  font: 600 13px/1.5 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .045em;
}
.flow-cycle {
  display: grid;
  grid-template-columns: auto minmax(12px, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.flow-cycle .flow-eyebrow { margin: 0; }
.flow-cycle::before {
  content: "";
  grid-area: 1 / 2;
  border-top: 1px dashed var(--brand-on-light);
}
.cycle-versions { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--fg-2); font: 12px/1.5 var(--font-mono); }
.cycle-versions i { font-style: normal; color: var(--fg-3); }
.cycle-versions .next { color: var(--accent); }
.flow-step { position: relative; border-top: 1px solid var(--border-strong); padding-block: 18px 28px; }
.flow-step::before { content: ""; position: absolute; left: 0; top: -2px; width: var(--step-progress, 25%); height: 3px; background: var(--brand-on-light); }
.flow-item:nth-child(2) { --step-progress: 50%; }
.flow-item:nth-child(3) { --step-progress: 75%; }
.flow-item:nth-child(4) { --step-progress: 100%; }
.flow-num { color: var(--accent); font: 600 clamp(16px, 1.3vw, 18px)/1.4 var(--font-mono); }
.flow-step h3 { margin: 12px 0 4px; font: 400 clamp(24px, 2.55vw, 38px)/1.12 var(--font-ui); letter-spacing: -.045em; }
.flow-step p { margin: 0; color: var(--fg-2); font-size: 15px; }
.flow-art { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 20px; }
.flow-runs span { font: 12px/1.5 var(--font-mono); }
.flow-runs span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; margin: 0 7px 2px 0; border-radius: 100%; background: var(--border-strong); }
.flow-trace { display: block; }
.cycle-loop { grid-column: 1 / -1; margin-top: 8px; padding-top: 14px; border-top: 3px solid var(--brand-on-light); }
.cycle-loop span { display: flex; gap: 8px; align-items: center; color: var(--fg-2); font-size: 13px; }
.cycle-loop svg { flex: none; color: var(--accent); }

.mt-row {
  display: grid; grid-template-columns: 13ch minmax(0, 1fr); align-items: center; gap: 7px;
  height: 17px; font: 11px/1.3 var(--font-mono);
}
.mt-name { white-space: nowrap; }
.mt-row.nest .mt-name { padding-left: 8px; color: var(--fg-3); }
.mt-track { position: relative; height: 100%; background: linear-gradient(var(--border), var(--border)) center / 100% 1px no-repeat; }
.mt-track i {
  position: absolute; top: 50%; left: calc(var(--s) * 1%); transform: translateY(-50%);
  width: max(2px, calc(var(--w) * 1%)); height: 5px; border-radius: 1px; background: var(--k-model);
}
.mt-row.k-run i { background: var(--border-strong); }
.mt-row.k-tool i { background: var(--k-tool); }
.mt-row.k-verify i { background: var(--status-green); }
.mt-row.k-sub i { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.mt-row.mark i { width: 5px; transform: translateY(-50%) rotate(45deg); background: var(--k-harness); }
.mt-axis { margin-top: 3px; }
.mt-axis .mt-track { background: none; border-top: 1px solid var(--border); }
.mt-axis b { position: absolute; top: 4px; left: calc(var(--at) * 1%); font: 10px/1 var(--font-mono); color: var(--fg-3); }
.mt-axis b:last-child { transform: translateX(-70%); }

@media (min-width: 720px) {
  #secrets .carry {
    grid-template-columns: minmax(0, 1fr) clamp(48px, 6vw, 80px) minmax(0, 1fr);
    column-gap: clamp(8px, 1vw, 16px);
  }
  #secrets .carry-arrow svg { width: 100%; transform: none; }
}
@media (min-width: 600px) {
  .flow-item { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .flow-step { grid-row: 2; }
  .cycle-loop { margin-top: 16px; }
}
@media (min-width: 768px) {
  .improve-points { grid-column: var(--intro-columns); }
  #improve .improve-demo { grid-column: var(--detail-columns); }
}
@media (min-width: 1200px) {
  .flow-item { grid-column: span 3; }
  /* Run, Trace and Improve share one cycle heading; v1 starts above Improve. */
  .flow-cycle {
    width: calc(300% + 2 * var(--layout-gap));
    grid-template-columns: max-content 1fr calc((100% - 2 * var(--layout-gap)) / 3);
    gap: 12px;
  }
  .flow-item { grid-template-rows: 32px 1fr; }
  .cycle-versions { gap: 8px; }
  .cycle-loop { grid-column: 4 / -1; }
}
