/* QuantInvariant interactive walkthrough — static mockup styles. */

:root {
  --paper: #f4f5f2;
  --card: #ffffff;
  --ink: #131519;
  --muted: #6d7278;
  --faint: #9aa0a6;
  --line: #e2e4e0;
  --line-strong: #cfd2cd;
  --accent: #f2ea4f;
  --accent-deep: #e3da2f;
  --accent-soft: #fbfbdd;
  --green: #5f9b2e;
  --green-soft: #a8c46f;
  --pink: #e08a95;
  --amber: #c9962b;
  --grey-curve: #b9bdb7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: #e9eae6;
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px clamp(18px, 2.2vw, 48px) 14px;
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- intro ---------- */

.stage {
  margin-top: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.stage__intro h1 {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}

.stage__intro p {
  margin: 6px 0 0;
  font-size: 15px;
  color: #4a5057;
}

/* ---------- app window ---------- */

.window {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(15, 20, 25, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 320px;
}

.window__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.stagebadge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  background: #f2f4f1;
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4d5359;
}

.stagebadge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa0a6;
}

.stagebadge.is-real {
  background: #eef5e7;
  border-color: #cfe2ba;
  color: #3f6b1d;
}

.stagebadge.is-real .stagebadge__dot {
  background: var(--green);
}

/* searched -> being checked -> checked on real data */
.stagebadge.is-review {
  background: #fbf3dc;
  border-color: #e8d9a8;
  color: #6b5518;
}

.stagebadge.is-review .stagebadge__dot {
  background: #c9962b;
}

.stagebadge.is-streaming .stagebadge__dot {
  animation: pulseDot 1.1s ease-in-out infinite;
}

@keyframes pulseDot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0.55;
  }
}

.lockbadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 3px 9px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink);
  animation: pop 260ms ease both;
}

@keyframes pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.window__controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 250px));
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  animation: stateIn 260ms ease both;
}

.specbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  animation: stateIn 260ms ease both;
}

/* the only controls in the walkthrough: three bars, typed, that the search obeys */
.specbar--edit {
  align-items: flex-end;
  gap: 6px 18px;
}

.specfield {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 1 auto;
}

.specfield__label {
  font-size: 9.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}

.specfield__box {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 2px 7px 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.specfield__box:focus-within {
  border-color: #a8c46f;
  box-shadow: 0 0 0 3px rgba(168, 196, 111, 0.22);
}

/* the bar that is shutting the search down, flagged only when it is */
.specfield__box.is-tight {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(201, 150, 43, 0.16);
}

.specfield__box input {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  width: 3.1em;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: right;
}

.specfield__box input:focus {
  outline: none;
}

.specfield__box i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
}

.speclink {
  font: inherit;
  font-size: 11.5px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0 0 4px;
  margin-left: auto;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.speclink:hover {
  color: var(--ink);
}

.spec {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 190px;
}

/* the frozen bars only need their value read back, not a full column */
.specbar:not(.specbar--edit) .spec {
  flex: 0 1 auto;
  flex-direction: row;
  align-items: baseline;
  gap: 7px;
}

.specbar:not(.specbar--edit) .spec__label {
  font-size: 9.5px;
}

.spec__label {
  font-size: 9.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.spec__value {
  font-size: 12.5px;
  color: #303539;
  white-space: nowrap;
}

/* the frozen bars can still say which one is shutting the search down */
.spec.is-tight .spec__value {
  color: var(--amber);
}

.window__body {
  position: relative;
  padding: 12px 14px 6px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.charthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.charttitle {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.chart {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 180px;
  cursor: crosshair;
}

.chartplot {
  position: absolute;
  inset: 0;
}

.chartplot svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- chart primitives ---------- */

.grid-line {
  stroke: #eceeea;
  stroke-width: 1;
}

.axis-line {
  stroke: #d8dbd6;
  stroke-width: 1;
}

.tick-label {
  fill: var(--faint);
  font-size: 9.5px;
  font-family: inherit;
}

.axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: inherit;
}

.curve {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.end-dot {
  fill: var(--green);
  stroke: #ffffff;
  stroke-width: 1.2;
  pointer-events: none;
}

.guide-line {
  stroke: #c6c9c3;
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0;
  transition: opacity 140ms linear;
  pointer-events: none;
}

.guide-line.is-visible {
  opacity: 1;
}

.stream-marker {
  fill: #ffffff;
  stroke: var(--green);
  stroke-width: 2;
  pointer-events: none;
}

.curve--candidate {
  stroke: var(--grey-curve);
  stroke-width: 0.7;
  opacity: 0.5;
}

.curve--candidate.is-hovered,
.curve--candidate.is-pinned {
  stroke: var(--ink);
  stroke-width: 1.6;
  opacity: 0.95;
}

.curve--rejected {
  stroke: var(--pink);
  stroke-width: 0.8;
  stroke-dasharray: 3 3;
  opacity: 0.4;
}

.curve--rejected.is-hovered {
  stroke: #c25563;
  stroke-width: 1.6;
  opacity: 1;
}

.curve--survivor {
  stroke: var(--green-soft);
  stroke-width: 2.2;
  opacity: 1;
}

.curve--survivor.is-hovered {
  stroke: var(--green);
  stroke-width: 3;
}

/* The screen only ever runs because a button was pressed, so the rules that
   clear the bars light up in turn instead of the plot swapping in one frame. */
@keyframes screenIn {
  from {
    opacity: 0;
    stroke-width: 1;
  }
  to {
    opacity: 1;
  }
}

.chart[data-stage="screened"] .curve--survivor {
  animation: screenIn 420ms ease both;
}

.curve--context {
  stroke: var(--green-soft);
  stroke-width: 1.2;
  opacity: 0.5;
}

/* a rule that cleared the search but not the validation draw */
.curve--failed {
  stroke: var(--amber);
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
  opacity: 0.8;
}

.curve--failed.is-hovered {
  stroke-width: 2.2;
  opacity: 1;
}

.curve--failed.is-pick,
.curve--rejected.is-pick {
  stroke-width: 2.6;
  opacity: 1;
}

.curve--survivor.is-selected,
.curve--selected {
  stroke: var(--green);
  stroke-width: 2.6;
  opacity: 1;
}

/* a failed frozen pick keeps its weight, so it stays the one to watch */
.chart[data-verdict="failed"] .end-dot {
  fill: var(--amber);
}

.curve--baseline {
  stroke: #8f948d;
  stroke-width: 1.8;
}

.curve--baseline.is-hovered {
  stroke: #5f645d;
  stroke-width: 2.2;
}

.end-label {
  font-size: 13px;
  font-weight: 600;
  fill: var(--green);
}

.curve--survivor,
.curve--rejected,
.curve--failed,
.end-dot {
  transition: stroke 340ms ease, stroke-width 340ms ease, opacity 340ms ease;
}

/* before the run, every candidate is just a candidate */
.chart[data-stage="pre"] .curve--rejected,
.chart[data-stage="pre"] .curve--failed,
.chart[data-stage="pre"] .curve--survivor {
  stroke: var(--grey-curve);
  stroke-width: 0.7;
  stroke-dasharray: none;
  opacity: 0.3;
}

.chart[data-stage="pre"] .end-dot {
  opacity: 0;
}

/* ---------- tooltip ---------- */

.tip {
  position: absolute;
  z-index: 6;
  width: 208px;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(15, 20, 25, 0.14);
  padding: 10px 11px;
  font-size: 11.5px;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 110ms linear;
}

.tip.is-visible {
  opacity: 1;
}

.tip__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 7px;
}

.tip__id {
  font-size: 13px;
  font-weight: 700;
}

.tip__head > span:last-child:not(.tip__id) {
  color: var(--muted);
}

.tip__family {
  margin: 0 0 7px;
  color: #3c4147;
}

.tip__params {
  margin: 0 0 7px;
  padding: 6px 0;
  list-style: none;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
}

.tip__params li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  padding: 1px 0;
}

.tip__params b {
  color: var(--ink);
  font-weight: 500;
}

.tip__metric {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  padding: 1px 0;
}

.tip__metric b {
  color: var(--ink);
  font-weight: 600;
}

/* the card also marks which of the three bars this rule did or did not clear */
.tip__metric.is-pass b {
  color: var(--green);
}

.tip__metric.is-miss b {
  color: var(--amber);
}

.tip__metric.is-miss span {
  color: #7c8288;
}

.tip__notes {
  margin: 7px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.toolbar__legend {
  margin-left: auto;
  min-width: 0;
}

.runbutton {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 5px;
  padding: 8px 13px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.runbutton:hover {
  background: #f6ef6a;
}

.runbutton--ghost {
  background: #fff;
  border-color: var(--line-strong);
  font-weight: 500;
  color: #3c4147;
}

.runbutton--ghost:hover {
  background: #f7f8f5;
}

.runbutton:not(.is-done):not(.is-running):not(.runbutton--ghost) {
  animation: invite 3.4s ease-in-out infinite;
}

@keyframes invite {
  0%,
  64%,
  100% {
    box-shadow: 0 0 0 0 rgba(227, 218, 47, 0.55);
  }
  80% {
    box-shadow: 0 0 0 7px rgba(227, 218, 47, 0);
  }
}

.runbutton.is-running {
  background: #fff;
  animation: none;
  position: relative;
  overflow: hidden;
}

.runbutton.is-running::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 42%;
  background: var(--accent-deep);
  animation: sweep 1.1s ease-in-out infinite;
}

@keyframes sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

.runbutton:disabled {
  cursor: default;
}

.runbutton.is-done {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--muted);
  font-weight: 500;
  animation: none;
}

.runcaption {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 460px;
}

.live {
  margin: 0;
  font-size: 12.5px;
  color: #303539;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.live b {
  font-weight: 600;
}

.live .live__gap {
  color: var(--green);
  font-weight: 600;
}

/* ---------- legend ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 18px;
  font-size: 11px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.legend b {
  color: var(--ink);
  font-weight: 600;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top-width: 2px;
  border-top-style: solid;
}

.swatch--survivor {
  border-top-color: var(--green-soft);
}

.swatch--selected {
  border-top-color: var(--green);
}

.swatch--baseline {
  border-top-color: #8f948d;
}

.swatch--rejected {
  border-top: 2px dashed var(--pink);
}

.swatch--failed {
  border-top: 2px dashed var(--amber);
}

.swatch--other {
  border-top-color: var(--grey-curve);
}

/* ---------- validation draws ---------- */

.runstrip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.drawchip {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 11px 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #4d5359;
  font-size: 11.5px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.drawchip i {
  font-style: normal;
  font-size: 10.5px;
  color: var(--faint);
}

.drawchip:hover {
  border-color: #b0b5ae;
}

.drawchip.is-active {
  outline: 2px solid rgba(19, 21, 25, 0.16);
  outline-offset: 0;
}

.drawchip.is-pass {
  color: #3f6b1d;
  background: #f3f9ed;
  border-color: #cfe2ba;
}

.drawchip.is-part {
  color: #6b5518;
  background: #fdf8e7;
  border-color: #e8d9a8;
}

.drawchip.is-fail {
  color: #9c4a34;
  background: #fdf2ef;
  border-color: #efc9c0;
}

.drawchip.is-pending {
  color: var(--faint);
  background: #f7f8f5;
  border-style: dashed;
}

.drawchip:disabled {
  cursor: default;
}

.drawchip.is-pass i,
.drawchip.is-part i,
.drawchip.is-fail i {
  color: inherit;
  opacity: 0.6;
}

.metahint {
  margin: 0;
  font-size: 11.5px;
  color: var(--faint);
}

.metahint.is-tight {
  color: var(--amber);
}

.ghostaction {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #3c4147;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.ghostaction:hover {
  background: #f7f8f5;
}

/* ---------- step bar ---------- */

.stepbar {
  position: relative;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 12px 9px 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: 0 4px 14px rgba(15, 20, 25, 0.08);
}

.metabar {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 28px;
  min-width: 0;
}

.metabar--grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  column-gap: clamp(24px, 3vw, 64px);
  row-gap: 3px;
  align-content: center;
}

.metabar.is-pending {
  opacity: 0.45;
  transition: opacity 300ms ease;
}

.metaitem {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.metaitem > span {
  font-size: 11.5px;
  color: var(--muted);
}

.metaitem > b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.stepbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.primary {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 140ms ease, background 140ms ease;
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary:disabled {
  background: #EFF0ED;
  color: var(--faint);
  border-color: var(--line-strong);
  cursor: default;
}

.disclaimer {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

@keyframes stateIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Short viewports: trim vertical rhythm so the whole walkthrough stays visible. */
@media (max-height: 880px) and (min-width: 861px) {
  .stage__intro h1 {
    font-size: 23px;
  }

  .stage__intro p {
    margin-top: 4px;
    font-size: 14.5px;
  }

  .window {
    margin-top: 8px;
  }

  .window__bar {
    padding: 6px 14px;
  }

  .window__controls {
    padding: 7px 14px;
  }

  .window__body {
    padding: 8px 14px 4px;
  }

  .chart {
    min-height: 126px;
  }

  .toolbar {
    padding: 6px 14px;
  }

  .stepbar {
    padding: 6px 12px 6px 16px;
    margin-top: 7px;
  }

}

@media (max-width: 860px) {
  .specbar--edit {
    gap: 5px 14px;
  }

  .specfield__box input {
    width: 2.6em;
    font-size: 12.5px;
  }

  .speclink {
    margin-left: 0;
  }

  .page {
    padding: 16px 14px 20px;
    min-height: 0;
  }

  .stage__intro h1 {
    font-size: 23px;
  }

  .stage__intro p {
    font-size: 14px;
  }

  .window {
    min-height: 0;
  }

  .charthead {
    flex-direction: column;
    gap: 4px;
  }

  .chart {
    min-height: 240px;
  }

  .window__controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
  }

  .controllabel {
    font-size: 9px;
    letter-spacing: 0.06em;
  }

  .select {
    font-size: 11px;
    padding: 5px 6px;
  }

  .stepbar {
    border-radius: 16px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    box-shadow: 0 8px 22px rgba(15, 20, 25, 0.14);
  }

  .metabar {
    gap: 4px 16px;
  }

  .legend {
    justify-content: flex-start;
  }

  /* six hold-out rows would make a sticky bar taller than the plot */
  .metabar--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
  }

  .metaitem > span,
  .metaitem > b {
    font-size: 11px;
  }

  .metaitem {
    white-space: normal;
    align-items: flex-start;
  }

  .stepbar__actions {
    justify-content: space-between;
  }

  .primary {
    flex: 1 1 auto;
    text-align: center;
  }
}
