/* Step card (docs/design-system.md, Step cards): one step of composing a
   carousel as an open section in a panel. The heading holds the number and
   the title at text size 600; the body is 16px under it. The heading stays
   smaller than the step's value. */

.step-card__heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--color-text);
}

/* A step with nothing to choose: the whole card at half strength. */
.step-card--dimmed {
  opacity: 0.5;
}

/* A step that keeps Generate off until the user chooses in it: the card's
   outline in the warning color, so the user sees which step is missing. */
.step-card--needs-action {
  border-radius: var(--border-radius);
  outline: 2px solid var(--color-warning);
}

.step-card__number {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.step-card__body {
  min-width: 0;
  margin-top: var(--space-4);
}

/* The two columns of a step: the list up to 320px, the detail up to 640px.
   Both start with a title on one line, so the first row of the list and
   the top edge of the detail are on one line too. */
.step-columns {
  display: grid;
  grid-template-columns: minmax(240px, var(--step-list-width)) minmax(0, var(--step-detail-width));
  gap: var(--space-8);
  align-items: start;
}

/* A detail of images takes the rest of the card. */
.step-columns--wide {
  grid-template-columns: minmax(240px, var(--step-list-width)) minmax(0, 1fr);
}

.step-columns__column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.step-columns__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* What the detail column shows for the chosen row. */
.step-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* A list as tall as the step picture. It scrolls inside and fades to the
   surface over its last 48px, the sign that it scrolls (macOS shows no bar
   at rest); the padding under the rows lets the last one scroll out of the
   fade. The inset keeps the focus ring of a row inside the scroll box. */
.step-list {
  position: relative;
  box-sizing: border-box;
  height: var(--step-list-height);
  overflow-y: auto;
  padding: var(--space-1) var(--space-2) var(--step-list-fade) var(--space-1);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--step-list-fade)), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--step-list-fade)), transparent);
}

/* A short list takes the height of its rows: nothing to scroll, no fade. */
.step-list--fit {
  height: auto;
  overflow-y: visible;
  padding-bottom: var(--space-1);
  -webkit-mask-image: none;
  mask-image: none;
}

.step-list__rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.step-list .choice-row {
  align-items: center;
  padding: var(--space-2) var(--space-3);
}

.step-list .choice-row--chosen,
.step-list .choice-row--chosen:hover:not(.choice-row--disabled) {
  padding: calc(var(--space-2) - var(--border-width)) calc(var(--space-3) - var(--border-width));
}

.step-list .choice-row__radio,
.step-list .choice-row .choice-row__box {
  margin-top: 0;
}

.step-list__separator {
  height: var(--border-width);
  margin: var(--space-2) 0;
  background: var(--color-border);
}

/* "+ Write your own": the last row, dashed and muted, the size of a row, its
   text on the line of the rows' text past their ring. */
.step-list__write-own {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) calc(var(--space-3) * 2 + var(--choice-mark-size));
  font: inherit;
  font-size: var(--text-body);
  line-height: var(--leading-snug);
  text-align: left;
  color: var(--color-text-muted);
  background: transparent;
  border: var(--border-width) dashed var(--color-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.step-list__write-own:hover {
  border-color: var(--color-text-muted);
}

.step-list__write-own:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Motion (docs/design-system.md, Motion). Rows that appear because the
   other column changed rise 6px into place, one after another from the top;
   a row just added flashes from the control fill to the surface once. */
@keyframes step-row-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes step-row-flash {
  from {
    background: var(--color-bg-control);
  }

  to {
    background: var(--color-bg-surface);
  }
}

.step-list__rows--entering > * {
  animation: step-row-enter var(--duration-row-enter) var(--ease-default) both;
  /* --row-index is the row's place in the list, set on the row itself */
  animation-delay: calc(var(--row-index, 0) * var(--duration-row-stagger)); /* ds-lint-allow */
}

.step-row-added {
  animation: step-row-flash var(--duration-row-flash) var(--ease-default);
}

/* An added row that enters too flashes once it shows, not while it waits. */
.step-list__rows--entering > .step-row-added {
  animation:
    step-row-enter var(--duration-row-enter) var(--ease-default) both,
    step-row-flash var(--duration-row-flash) var(--ease-default);
  animation-delay: calc(var(--row-index, 0) * var(--duration-row-stagger)); /* ds-lint-allow */
}

.step-row-rise {
  animation: step-row-enter var(--duration-row-enter) var(--ease-default) both;
  /* --row-index is the place among the rows that rise together, set on the row */
  animation-delay: calc(var(--row-index, 0) * var(--duration-row-stagger)); /* ds-lint-allow */
}

@media (prefers-reduced-motion: reduce) {
  .step-list__rows--entering > *,
  .step-list__rows--entering > .step-row-added,
  .step-row-added,
  .step-row-rise {
    animation: none;
  }
}

/* On a phone the columns stack and a list keeps a bounded height. */
@media (max-width: 860px) {
  .step-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .step-list {
    height: 240px;
  }

  .step-list--fit {
    height: auto;
  }
}
