/* Payment flow simulator - matches the Cactus dark theme */
.payment-sim {
  --ps-accent: #2bbc8a;
  --ps-text: #c9cacc;
  --ps-muted: #908d8d;
  --ps-bad: #e06c75;
  --ps-wait: #e5c07b;
  --ps-bg: #1d1f21;
  --ps-panel: #222427;

  margin: 1.5rem 0 0.5rem 0;
  padding: 1rem;
  border: 1px dotted var(--ps-muted);
  border-radius: 4px;
  background: var(--ps-panel);
  font-family: "Menlo", "Meslo LG", monospace;
  font-size: 13px;
  color: var(--ps-text);
}

.ps-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.ps-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ps-group-label {
  font-size: 11px;
  color: var(--ps-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ps-segmented {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid rgba(43, 188, 138, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.ps-option,
.ps-replay {
  font: inherit;
  font-size: 12px;
  color: var(--ps-text);
  background: transparent;
  border: none;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.ps-option + .ps-option {
  border-left: 1px solid rgba(43, 188, 138, 0.4);
}

.ps-option:hover {
  background: rgba(43, 188, 138, 0.1);
}

.ps-option.ps-active {
  background: rgba(43, 188, 138, 0.2);
  color: var(--ps-accent);
  font-weight: 600;
}

.ps-option:focus-visible,
.ps-replay:focus-visible {
  outline: 2px solid var(--ps-accent);
  outline-offset: -2px;
}

/* Sequence diagram */
.ps-diagram {
  position: relative;
  min-height: 3rem;
}

.ps-lifelines {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  pointer-events: none;
}

.ps-lifeline {
  justify-self: center;
  width: 0;
  border-left: 1px dashed rgba(144, 141, 141, 0.45);
}

.ps-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  min-height: 2.4rem;
}


.ps-header {
  min-height: 0;
  margin-bottom: 0.4rem;
}

.ps-lane {
  justify-self: center;
  position: relative;
  z-index: 1;
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(43, 188, 138, 0.5);
  border-radius: 3px;
  background: var(--ps-bg);
  color: var(--ps-accent);
  font-weight: 600;
  font-size: 12px;
}

/* Arrows between lanes */
.ps-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 0.45rem;
}

.ps-label {
  font-size: 11.5px;
  line-height: 1.3;
  text-align: center;
  padding: 0 0.3rem 0.2rem 0.3rem;
  overflow-wrap: break-word;
}

.ps-line {
  position: relative;
  width: 0;
  visibility: hidden;
  border-top: 2px solid var(--ps-text);
  transition: width 0.26s ease-out;
}

/* The line grows from the sender's lifeline, carrying the arrowhead with it */
.ps-right .ps-line {
  align-self: flex-start;
}

.ps-left .ps-line {
  align-self: flex-end;
}

.ps-visible .ps-line {
  width: 100%;
  visibility: visible;
}

.ps-label {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ps-visible .ps-label {
  opacity: 1;
}

.ps-line::after {
  content: "";
  position: absolute;
  top: -6px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.ps-right .ps-line::after {
  right: -1px;
  border-left: 8px solid var(--ps-text);
}

.ps-left .ps-line::after {
  left: -1px;
  border-right: 8px solid var(--ps-text);
}

/* Notes sitting on a lifeline */
.ps-note {
  position: relative;
  z-index: 1;
  margin-bottom: 0.35rem;
  padding: 0.25rem 0.5rem;
  border: 1px dotted var(--ps-muted);
  border-radius: 3px;
  background: var(--ps-bg);
  font-size: 11.5px;
  line-height: 1.35;
  text-align: center;
  width: max-content;
  max-width: 100%;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ps-visible .ps-note {
  opacity: 1;
  transform: none;
}

.ps-note.ps-lane-0 {
  justify-self: start;
}

.ps-note.ps-lane-3 {
  justify-self: end;
}

.ps-note.ps-lane-1,
.ps-note.ps-lane-2 {
  justify-self: center;
  max-width: 180%;
}

.ps-note.ps-good {
  border: 1px solid var(--ps-accent);
  color: var(--ps-accent);
}

.ps-note.ps-bad {
  border: 1px solid var(--ps-bad);
  color: var(--ps-bad);
}

.ps-note.ps-wait {
  border: 1px solid var(--ps-wait);
  color: var(--ps-wait);
}

/* Outcome + replay */
.ps-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  min-height: 2.2rem;
}

.ps-outcome {
  flex: 1;
  padding: 0.45rem 0.7rem;
  border-radius: 3px;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ps-outcome.ps-visible {
  opacity: 1;
}

.ps-outcome.ps-good {
  background: rgba(43, 188, 138, 0.12);
  color: var(--ps-accent);
}

.ps-outcome.ps-bad {
  background: rgba(224, 108, 117, 0.12);
  color: var(--ps-bad);
}

.ps-replay {
  flex-shrink: 0;
  border: 1px solid rgba(43, 188, 138, 0.4);
  border-radius: 4px;
}

.ps-replay:hover {
  background: rgba(43, 188, 138, 0.1);
}

@media (max-width: 768px) {
  .payment-sim {
    padding: 0.75rem;
  }

  .ps-lane {
    padding: 0.2rem 0.3rem;
    font-size: 11px;
  }

  .ps-label,
  .ps-note {
    font-size: 10.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ps-line,
  .ps-label,
  .ps-note,
  .ps-outcome {
    transition: none;
  }
}

/* Three-column variant of the post's table */
.cactus-table-wrapper col.col-situation {
  width: 34% !important;
}

.cactus-table-wrapper col.col-state {
  width: 33% !important;
}

.cactus-table-wrapper .verdict-good {
  color: #2bbc8a;
  font-weight: 600;
}

.cactus-table-wrapper .verdict-bad {
  color: #e06c75;
  font-weight: 600;
}

.cactus-table-wrapper .verdict-detail {
  display: block;
  color: #908d8d;
  font-size: 12px;
}
