/* Topics (docs/design-system.md, Topics): the search over every idea, one
   panel listing the topics - each a row that opens and closes, with rename
   and delete, and under an open row its ideas with the add-ideas form
   last - then the add-a-topic panel and the panel of the paid write of
   topics. */

.topics {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.empty-state + .topics__add-panel {
  margin-top: var(--space-4);
}

/* The Onboarding's empty and failed lists stand in a white panel. */
.topics .card > .empty-state {
  padding: var(--space-12) var(--space-6);
}

.topics__search {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.topics__search-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topics__search-input {
  flex: 1;
  min-width: 0;
  max-width: 480px;
}

.topics__expand {
  margin-left: auto;
  white-space: nowrap;
}

.topics__search-count {
  margin: 0;
  font-size: var(--text-body);
  color: var(--color-text-muted);
}

/* A search holds every shown topic open. */
.topics__toggle:disabled {
  cursor: default;
}

.topics__placeholder {
  display: flex;
  justify-content: center;
  padding: var(--space-12);
}

.topics__add-topic-row {
  display: flex;
  gap: var(--space-2);
  max-width: 480px;
}

.topics__add-topic-row .input {
  flex: 1;
  min-width: 0;
}

.topics__topic + .topics__topic {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: var(--border-width) solid var(--color-border-subtle);
}

.topics__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Three columns: the name, the count, the buttons. The count's column has
   one width on every row, wide enough for "999 ideas", so the counts stand
   in one column down the list. */
.topics__header:not(.topics__header--renaming) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem auto;
}

.topics__name {
  margin: 0;
  min-width: 0;
  font-size: var(--text-section);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--color-text);
}

/* The chevron and the name are one button; its gap plus the 16px chevron
   is the indent of the open topic's ideas. */
.topics__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.topics__chevron {
  display: inline-flex;
  flex-shrink: 0;
}

.topics__name-text {
  overflow-wrap: anywhere;
}

.topics__count {
  font-size: var(--text-body);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.topics__header .button--toolbar:last-child {
  margin-right: calc(-1 * var(--space-2));
}

/* The field that renames a topic stands where its name was, the chevron
   kept beside it. */
.topics__heading-field {
  flex: 1;
  max-width: 480px;
}

.topics__ideas {
  padding: var(--space-2) 0 var(--space-4) var(--space-6);
}

/* The count goes under the name; the buttons stay at the row's end. */
@media (max-width: 600px) {
  .topics__header:not(.topics__header--renaming) {
    grid-template-columns: 1fr auto;
    column-gap: var(--space-3);
    padding: var(--space-1) 0;
  }

  .topics__name {
    grid-column: 1;
    grid-row: 1;
  }

  .topics__toggle {
    min-height: 0;
  }

  .topics__count {
    grid-column: 1;
    grid-row: 2;
    padding-left: var(--space-6);
  }

  .topics__header .topics__actions {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

/* The name keeps its section size while it is renamed. */
.topics__heading-input {
  font-size: var(--text-section);
  font-weight: var(--weight-semibold);
}

.topics__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height);
}

.topics__row .input {
  flex: 1;
}

.topics__text {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.topics__actions {
  display: flex;
  flex-shrink: 0;
}

/* The row controls sit flush with the panel's padding. */
.topics__row .button--toolbar {
  margin: calc(-1 * var(--space-2)) 0;
}

.topics__row .button--toolbar:last-child {
  margin-right: calc(-1 * var(--space-2));
}

.topics__add-ideas {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.card__row + .topics__add-ideas {
  margin-top: var(--space-6);
}

.topics__add-actions {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.topics__add-panel,
.topics__write-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
