/*
 * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 *
 * The toy controllers' data flow (toy-flow.js), in the tutorial figures'
 * palette (docs/tutorials/figures/_style.py): drive green, readout rose,
 * classical calls and latencies teal, in the theme's light and dark modes.
 * The outlines are darker than that palette's rule color: boxes, wires,
 * links and the slots of pulses not yet played carry meaning here, so they
 * are at least 3:1 on the page. A conditional pulse is outlined dashed, a
 * busy link or box is drawn thicker and the current instruction is outlined,
 * so color is never the only cue.
 */

.pulse-toy-flow {
  --tf-drive: #5b8c00;
  --tf-readout: #c2185b;
  --tf-classical: #00796b;
  --tf-text: #1a1a1a;
  --tf-muted: #5c636a;
  --tf-grid: #e8e8e8;
  --tf-rule: #80868c;
  --tf-panel: rgba(0, 0, 0, 0.025);
  --tf-pc: rgba(91, 140, 0, 0.16);
  --tf-on-pill: #ffffff;
  margin: 1rem 0 0.5rem;
  text-align: left;
}

html[data-theme="dark"] .pulse-toy-flow {
  --tf-drive: #76b900;
  --tf-readout: #f06292;
  --tf-classical: #4dd0c4;
  --tf-text: #eeeeee;
  --tf-muted: #b4bac1;
  --tf-grid: #2c2f33;
  --tf-rule: #6b7177;
  --tf-panel: rgba(255, 255, 255, 0.03);
  --tf-pc: rgba(118, 185, 0, 0.22);
  --tf-on-pill: #0b0b0b;
}

.pulse-toy-flow:empty,
.pulse-data-figure .pulse-fallback[hidden] {
  display: none;
}

.pulse-toy-flow .tf-svg {
  display: block;
  width: 100%;
  height: auto;
}

.tf-svg text {
  fill: var(--tf-text);
  font-size: 12px;
}

.tf-svg .tf-title {
  font-weight: 600;
}

.tf-svg .tf-muted,
.tf-svg .tf-small,
.tf-svg .tf-lane {
  fill: var(--tf-muted);
}

/* The smallest text is about 10 px where the figure is as wide as the
   article's column. */
.tf-svg .tf-small {
  font-size: 11.5px;
}

.tf-svg .tf-span {
  fill: var(--tf-classical);
}

.tf-svg .tf-lane,
.tf-svg .tf-code,
.tf-svg .tf-pill text {
  font-family: var(--pst-font-family-monospace, ui-monospace, Menlo, Consolas, monospace);
}

.tf-svg .tf-code.tf-skipped {
  fill: var(--tf-muted);
  text-decoration: line-through;
}

.tf-box {
  fill: var(--tf-panel);
  stroke: var(--tf-rule);
}

.tf-box.tf-busy {
  stroke: var(--tf-classical);
  stroke-width: 2.5;
}

/* The band on a controller's current instruction. The tint alone is 1.2:1
   on the panel, so the band is outlined. */
.tf-pc {
  fill: var(--tf-pc);
  stroke: var(--tf-drive);
  stroke-width: 1.5;
}

.tf-bus,
.tf-link,
.tf-wire,
.tf-qudit {
  fill: none;
  stroke: var(--tf-rule);
  stroke-width: 1.5;
}

.tf-link {
  stroke-dasharray: 4 3;
}

.tf-link.tf-on {
  stroke: var(--tf-classical);
  stroke-width: 2.5;
}

.tf-grid {
  stroke: var(--tf-grid);
}

.tf-head {
  stroke: var(--tf-text);
  opacity: 0.6;
}

.tf-wire.tf-on,
.tf-qudit.tf-on {
  stroke-width: 3;
}

/* A live wire's dashes run while the figure plays and at no other time:
   toy-flow.js sets tf-playing on the figure only while it draws frames. */
.pulse-toy-flow.tf-playing .tf-wire.tf-on {
  stroke-dasharray: 6 4;
  animation: tf-flow 0.6s linear infinite;
}

.tf-drive {
  stroke: var(--tf-drive);
}

.tf-readout {
  stroke: var(--tf-readout);
}

@keyframes tf-flow {
  to {
    stroke-dashoffset: -10;
  }
}

.tf-ghost {
  fill: none;
  stroke: var(--tf-rule);
}

.tf-ghost.tf-cond {
  stroke-dasharray: 3 2;
}

.tf-ghost.tf-window-ghost {
  stroke: var(--tf-classical);
  stroke-dasharray: 2 2;
}

.tf-fill.tf-drive {
  fill: var(--tf-drive);
}

.tf-fill.tf-readout {
  fill: var(--tf-readout);
}

.tf-fill.tf-classical {
  fill: var(--tf-classical);
}

.tf-fill.tf-window,
.tf-window {
  fill: var(--tf-classical);
  opacity: 0.35;
}

.tf-pill rect {
  fill: var(--tf-classical);
}

.tf-svg .tf-pill text {
  fill: var(--tf-on-pill);
}

.tf-pill.tf-pending rect {
  fill: none;
  stroke: var(--tf-classical);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}

.tf-svg .tf-pill.tf-pending text {
  fill: var(--tf-classical);
}

/* The status line holds two lines of text, so the buttons under it stay
   where they are from step to step. On a narrow screen the longest step
   wraps to four. */
.pulse-toy-flow .pulse-toy-flow-status {
  min-height: 2.8em;
  margin: 0.3rem 0 0.3rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

@media (max-width: 719.98px) {
  .pulse-toy-flow .pulse-toy-flow-status {
    min-height: 5.6em;
  }
}

.pulse-toy-flow .pulse-toy-flow-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.pulse-toy-flow .tf-button {
  min-width: 24px;
  min-height: 24px;
  color: var(--pst-color-text-base, inherit);
  background: var(--pst-color-surface, transparent);
  border: 1px solid var(--pst-color-border, #c8c8c8);
  border-radius: 0.25rem;
  padding: 0.1rem 0.6rem;
  font-size: max(0.875rem, 14px);
}

/* The first button reads Pause, Play or Replay. It is as wide as the longest
   of them, so the step buttons do not move when it changes. */
.pulse-toy-flow .tf-toggle {
  min-width: 5em;
}

/* A step button at its end keeps the focus, so the arrow keys go on working
   there; it is dashed as well as muted. */
.pulse-toy-flow .tf-button[aria-disabled="true"] {
  color: var(--pst-color-text-muted, #666666);
  border-color: currentColor;
  border-style: dashed;
  cursor: default;
}

@media (forced-colors: active) {
  .pulse-toy-flow .tf-button[aria-disabled="true"] {
    color: GrayText;
  }
}

/* A figure with no still shows what it plays as text until the script draws:
   each outcome, then its moments in order. */
.pulse-data-figure .tf-story {
  text-align: start;
}

@media (prefers-reduced-motion: reduce) {
  .pulse-toy-flow.tf-playing .tf-wire.tf-on {
    stroke-dasharray: none;
    animation: none;
  }
}
