/* ==========================================================================
   Settings

   An accordion of sections, each a native <details>. There is one section today
   and there will be more, so the section is the unit: a heading that opens, and
   a body of cards inside it.
   ========================================================================== */
.settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 1100px;
}

.settings__section {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

/* The default triangle is replaced by the chevron in the markup, which can then
   be turned with the section. */
.settings__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  list-style: none;
}

.settings__summary::-webkit-details-marker {
  display: none;
}

.settings__summary:hover {
  background-color: var(--color-surface-sunken);
  border-radius: var(--radius-md);
}

.settings__summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-md);
}

.settings__summary-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings__summary-title {
  color: var(--color-primary-dark);
  font-size: var(--font-size-large);
  font-family: var(--font-family-bold);
  font-weight: 600;
}

.settings__summary-hint {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.settings__chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-base);
}

.settings__section[open] .settings__chevron {
  transform: rotate(180deg);
}

/* The rule divides the section from its heading, so it belongs to the body and
   spans it — on the note it would stop wherever the note's measure does. */
.settings__section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0 var(--space-5);
  padding: var(--space-4) 0 var(--space-5);
  border-top: 1px solid var(--color-border);
}

.settings__note {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  line-height: 1.6;
  max-width: 70ch;
}

/* ==========================================================================
   One table's card
   ========================================================================== */
.settings-card {
  display: block;
  padding: var(--space-4);
  background-color: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.settings-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.settings-card__title {
  margin: 0;
  color: var(--color-primary-dark);
  font-size: var(--font-size-medium);
  font-weight: 600;
}

.settings-card__where {
  color: var(--color-text-faint);
  font-size: var(--font-size-small);
}

/* Whether this table is currently holding anything, and what just happened to
   it. Both sit in the same corner, because a save answers the same question. */
.settings-card__state,
.settings-card__message {
  flex-shrink: 0;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  font-size: var(--font-size-small);
  white-space: nowrap;
}

.settings-card__state--set {
  background-color: var(--tint-navy-06);
  color: var(--color-text);
}

.settings-card__message {
  background-color: var(--tint-green-16);
  color: var(--color-success-dark);
  font-family: var(--font-family-bold);
  font-weight: 600;
}

.settings-card__scoping {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-yellow-100);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  line-height: 1.5;
  max-width: 70ch;
}

.settings-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.settings-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ==========================================================================
   One control
   ========================================================================== */
.settings-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

/* The products multi-select needs the room its chips take. */
.settings-field--wide {
  grid-column: 1 / -1;
}

.settings-field__label {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  font-family: var(--font-family-bold);
  font-weight: 600;
  letter-spacing: var(--label-letter-spacing);
  text-transform: uppercase;
}

.settings-field__select,
.settings-field__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-family-base);
  font-size: var(--font-size-medium);
}

.settings-field__select:focus,
.settings-field__input:focus {
  outline: none;
  border-color: var(--color-primary-green);
  box-shadow: var(--focus-ring);
}

@media (max-width: 768px) {
  .settings-card__grid {
    grid-template-columns: 1fr;
  }
}
