/* The hero's self-playing lesson step, drawn like the app's Blueprint graph (js/demo.js). */

/* ---------- The self-playing lesson step (dark canvas, drawn like the app's graph) ---------- */

.demo {
  margin: 0;
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--night-ink);
  overflow: hidden;
  --focus: var(--sky);
}

.demo-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px 8px 20px;
  background: var(--canvas-bar);
}

.demo-label {
  margin-right: auto;
  font-size: var(--t-small);
  font-weight: 900;
}

.demo-steps {
  display: flex;
  gap: 6px;
}

.demo-steps span {
  width: 28px;
  height: 8px;
  border-radius: 99px;
  background: #34404a;
  transition: background-color 300ms;
}

.demo-steps span.on {
  background: var(--lime);
}

.demo .button-ghost {
  --face: #2a3139;
  --lip: #0f1418;
  --label: #ffffff;
}

.demo-toggle .icon {
  width: 16px;
  height: 16px;
}

/* The question gets its own strip above the graph, like the app's cue line. Two lines are
   reserved so the step never changes height. */
.demo-cue {
  min-height: calc(32px + 2 * 1.45em);
  padding: 16px 20px;
  border-bottom: 1px solid #34404a;
  font-weight: 800;
  font-size: var(--t-body);
  line-height: 1.45;
}

.demo-cue strong {
  color: var(--sky);
}

/* The answer feedback sits under the graph as a green banner; it keeps its space while empty. */
.demo-feedback {
  min-height: calc(24px + 2 * 1.45em);
  margin: 4px 16px 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid currentColor;
  background: color-mix(in srgb, var(--lime) 12%, transparent);
  font-weight: 800;
  font-size: var(--t-body);
  line-height: 1.45;
}

.demo-feedback:empty {
  visibility: hidden;
}

.demo-feedback.good {
  color: var(--lime);
}

.demo-caption {
  margin-top: 14px;
  font-size: var(--t-small);
}

.canvas {
  width: 100%;
  height: auto;
  margin-top: 12px;
  text-rendering: geometricPrecision;
  user-select: none;
  -webkit-user-select: none;
}

.canvas text {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 800;
}

.node-body {
  fill: #2a3139;
}

/* Drawn after the header, so the outline sits on top of the header colour. */
.node-edge {
  fill: none;
  stroke: #0f1418;
  stroke-width: 1;
}

.node.is-active .node-edge {
  stroke: var(--sky);
  stroke-width: 2;
}

.node.is-correct .node-edge {
  stroke: var(--lime);
  stroke-width: 2;
}

.node-title {
  fill: #ffffff;
  font-size: 12.5px;
}

.node-sub {
  fill: #dbe4ff;
  font-size: 9px;
  font-style: italic;
}

.msg-icon {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.pin-label {
  fill: #e8eaf0;
  font-size: 12px;
}

.note-text {
  fill: #e8eaf0;
  font-size: 11px;
}

.wire,
.wire-glow {
  fill: none;
  stroke-linecap: round;
}

.wire {
  opacity: 0.85;
}

.wire-exec {
  stroke: #ffffff;
  stroke-width: 3;
}

.wire-bool {
  stroke: #fd0000;
  stroke-width: 2;
}

.wire-object {
  stroke: #00aaf5;
  stroke-width: 2;
}

.is-dim .wire {
  opacity: 0.2;
}

/* A lit wire gets a soft halo five units wider than the wire itself. */
.wire-glow {
  stroke: #ffffff;
  stroke-width: 8;
  opacity: 0;
}

[data-wire="condition"] .wire-glow {
  stroke: #fd0000;
  stroke-width: 7;
}

[data-wire="target"] .wire-glow {
  stroke: #00aaf5;
  stroke-width: 7;
}

.is-lit .wire-glow {
  opacity: 0.25;
}

.pin-exec {
  fill: #ffffff;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.pin-exec.pin-open {
  fill: #2a3139;
}

.pin-bool {
  fill: #fd0000;
}

.pin-object {
  fill: #00aaf5;
  stroke: #00aaf5;
  stroke-width: 1.5;
}

.pin-object.pin-open {
  fill: #2a3139;
}

.pill-box {
  fill: #3a434c;
  stroke: #2a333b;
  stroke-width: 1;
}

.pill-text {
  fill: #8fa1ab;
  font-size: 11px;
}

.pill.is-on .pill-box {
  fill: #172b1a;
  stroke: var(--lime);
  stroke-width: 2;
}

.pill.is-on .pill-text {
  fill: var(--lime);
}

.note-text,
.pill-text,
.pin-label,
.node-title,
.node-sub,
.msg-icon {
  pointer-events: none;
}

.canvas .demo-out {
  fill: var(--sky);
  font-size: 14px;
  font-weight: 900;
}

.canvas .demo-out.is-done {
  fill: var(--lime);
}

.demo-out.is-hidden {
  visibility: hidden;
}

.canvas .run-face text {
  fill: #ffffff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

/* What the step asks you to tap: a sky ring, solid unless motion is welcome. */
.tap-ring {
  fill: none;
  stroke: var(--sky);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  --ring-scale: 1.05;
}

.tap-ring-value {
  fill: rgb(73 192 248 / 0.15);
  --ring-scale: 1.15;
}

.is-target > .tap-ring {
  opacity: 1;
}

.run-face,
.finger-dot,
.finger-ripple {
  transform-box: fill-box;
  transform-origin: center;
}

.exec-dot {
  opacity: 0;
  pointer-events: none;
}

.finger {
  opacity: 0;
  pointer-events: none;
}

.finger-dot {
  fill: #ffffff;
  stroke: #0f1418;
  stroke-width: 2;
}

.finger-halo {
  fill: #ffffff;
  opacity: 0.25;
}

.finger-ripple {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .is-target > .tap-ring {
    animation: tap-ring 1.2s ease-in-out infinite alternate;
  }

  @keyframes tap-ring {
    to {
      opacity: 0.45;
      transform: scale(var(--ring-scale));
    }
  }
}

/* Phones reserve more cue lines (three, four on the narrowest), so the step never changes height. */
@media (max-width: 479px) {
  .demo-cue {
    min-height: calc(32px + 3 * 1.45em);
  }

  .demo-label {
    font-size: 13px;
  }

  .demo-steps span {
    width: 16px;
  }
}

@media (max-width: 359px) {
  .demo-cue {
    min-height: calc(32px + 4 * 1.45em);
  }

  /* The narrowest phones keep the label to two lines; the cue already says which step this is. */
  .demo-steps {
    display: none;
  }
}

/* Wide screens: one centred column (question, graph, feedback) so the eye reads top to bottom. */
@media (min-width: 1024px) {
  .demo-in {
    max-width: 860px;
    margin-inline: auto;
  }

  .demo-cue {
    padding: 20px 28px;
    font-size: 20px;
  }

  .canvas {
    padding-inline: 16px;
  }

  .demo-feedback {
    margin: 4px 28px 24px;
    font-size: 18px;
  }
}
