/*
 * Steps panel (the description of the current replay step) and explanation card. Colours only through the
 * --sg-color-* tokens (and the --sg-board-* frame colours for the legend swatches).
 */

/* ---- The step on show ---- */
.step-detail {
  display: flex;
  flex-direction: column;
  gap: var(--sg-space-3);
  min-width: 0;
}

.step-detail:empty {
  display: none;
}

.step-detail__empty {
  margin: 0;
  color: var(--sg-color-text-muted);
  font-size: var(--sg-font-size-sm);
}

.step-detail__meta {
  margin: 0;
  color: var(--sg-color-text-muted);
  font-size: var(--sg-font-size-sm);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.step-detail__text {
  margin: 0;
  font-size: var(--sg-font-size-sm);
  overflow-wrap: anywhere;
}

.step-detail__techniques {
  min-width: 0;
}

.step-detail__subtitle {
  margin: 0 0 var(--sg-space-2);
  font-size: var(--sg-font-size-sm);
  font-weight: 650;
}

/* ---- Legend of the board frames ---- */
.steps-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sg-space-1) var(--sg-space-4);
  margin: var(--sg-space-3) 0 0;
  padding: 0;
  color: var(--sg-color-text-muted);
  font-size: var(--sg-font-size-sm);
  list-style: none;
}

.steps-legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--sg-space-2);
}

.steps-legend__swatch {
  display: inline-block;
  flex: none;
  width: 1rem;
  height: 1rem;
  border: 3px solid currentColor;
  border-radius: 2px;
}

.steps-legend__swatch--dug {
  border-color: var(--sg-board-probe);
}

.steps-legend__swatch--kept {
  border-color: var(--sg-board-restore);
  border-style: dashed;
}

.steps-legend__swatch--revealed {
  border-color: var(--sg-board-technique);
  border-style: dotted;
}

/* A sign: a chevron drawn with two borders, dashed and faded like a sign taken away, or red like one kept. */
.steps-legend__swatch--signRemoved,
.steps-legend__swatch--signKept {
  width: 0.6rem;
  height: 0.6rem;
  margin-inline: 0.2rem;
  border: 0;
  border-radius: 0;
  border-bottom: 3px solid var(--sg-board-sign);
  border-left: 3px solid var(--sg-board-sign);
  transform: rotate(45deg);
}

.steps-legend__swatch--signRemoved {
  border-bottom-style: dashed;
  border-left-style: dashed;
  opacity: 0.45;
}

.steps-legend__swatch--signKept {
  border-bottom-color: var(--sg-board-restore);
  border-left-color: var(--sg-board-restore);
}

/* ---- Explanation card ---- */
.explain-card {
  display: flex;
  flex-direction: column;
  gap: var(--sg-space-3);
  min-width: 0;
}

.explain-card__empty {
  margin: 0;
  color: var(--sg-color-text-muted);
}

.explain-card__kicker {
  margin: 0;
  color: var(--sg-color-text-muted);
  font-size: var(--sg-font-size-sm);
  font-weight: 650;
}

.explain-card__title {
  margin: 0;
  font-size: var(--sg-font-size-lg);
}

.explain-card__live {
  margin: 0;
  padding: var(--sg-space-2) var(--sg-space-3);
  border: 1px solid var(--sg-color-border);
  border-inline-start: 4px solid var(--sg-color-accent);
  border-radius: var(--sg-radius-2);
  background: var(--sg-color-surface);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.explain-card__live[hidden] {
  display: none;
}

.explain-card__live-label {
  margin-inline-end: var(--sg-space-2);
  color: var(--sg-color-accent);
  font-weight: 700;
}

.explain-card__parts {
  display: flex;
  flex-direction: column;
  gap: var(--sg-space-3);
  margin: 0;
}

.explain-card__label {
  color: var(--sg-color-accent);
  font-size: var(--sg-font-size-sm);
  font-weight: 700;
}

.explain-card__text {
  margin: 0;
}

.explain-card__subtitle {
  margin: 0 0 var(--sg-space-2);
  font-size: var(--sg-font-size-sm);
  font-weight: 700;
}

/* The pseudocode: line numbers from a counter, indentation from --indent, the line of the step marked by a
   bar, a bold face and an arrow in place of its number. */
.explain-code {
  margin: 0;
  padding: var(--sg-space-2) 0;
  border: 1px solid var(--sg-color-border);
  border-radius: var(--sg-radius-2);
  background: var(--sg-color-surface);
  counter-reset: sg-line;
  font-family: var(--sg-font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.explain-code__line {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  align-items: baseline;
  padding: 0.125rem var(--sg-space-2) 0.125rem 0;
  border-inline-start: 4px solid transparent;
  counter-increment: sg-line;
}

.explain-code__line::before {
  padding-inline-end: var(--sg-space-2);
  color: var(--sg-color-text-muted);
  content: counter(sg-line);
  text-align: end;
}

.explain-code__text {
  padding-inline-start: calc(var(--indent, 0) * 1.25em);
  font: inherit;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.explain-code__line.is-active {
  border-inline-start-color: var(--sg-color-accent);
  background: var(--sg-color-accent-soft);
  font-weight: 700;
}

.explain-code__line.is-active::before {
  color: var(--sg-color-accent);
  content: "\25B6";
  font-size: 0.7em;
}

@media (forced-colors: active) {
  .explain-code__line.is-active {
    border-inline-start-color: currentColor;
  }

  .steps-legend__swatch {
    border-color: currentColor;
  }
}
