/* --- forms -------------------------------------------------------------- */

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stacked-form label {
  font-size: 14px;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input:not([type]),
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 72px;
  line-height: 1.5;
  resize: vertical;
}

.stacked-form button {
  align-self: flex-start;
}

/* In-place editing: the field keeps the text's own size and shows only a
   dashed rule, so a row does not jump when it enters edit mode. The `input`
   prefix is needed to outrank the boxed `input[type=…]` rules above. */
input.inline-input {
  width: 100%;
  min-height: 34px;
  padding: 0;
  background: transparent;
  border: none;
  border-bottom: 1.5px dashed var(--accent);
  border-radius: 0;
  color: var(--ink);
  outline-offset: 4px;
}

input.inline-input.title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

input.inline-input.front {
  font-family: var(--font-display);
  font-size: 17px;
}

input.inline-input.back {
  font-size: 16px;
  color: var(--ink-soft);
}

input.inline-input.note {
  font-size: 14px;
  color: var(--muted);
  border-bottom-style: dotted;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* Kept in the page for `aria-describedby`, but no room taken while empty. */
.field-error:empty {
  display: none;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* --- toolbar (sort, layout) ---------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* The order picker: its label, the choices and, while random, the reshuffle. */
.sort-bar {
  --sort-gap: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sort-gap);
}

/* A choice's words and its arrow are one run of text; the arrow keeps to
   the last word when the label wraps. */
.seg-text .nowrap {
  white-space: nowrap;
}

.seg-text .sort-dir {
  display: inline-block;
  vertical-align: -2px;
}

/* The reshuffle folds open sideways, by its one grid column, like `.fold`
   does downwards; shut, it takes no room — the gap before it given back
   too. The button keeps its own width throughout and is clipped, so its
   label never wraps on the way. */
.sort-shuffle-fold {
  display: grid;
  grid-template-columns: 0fr;
  margin-left: calc(-1 * var(--sort-gap));
  opacity: 0;
  transition:
    grid-template-columns 220ms cubic-bezier(0.2, 0.7, 0.2, 1),
    margin-left 220ms cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 180ms ease;
}

.sort-shuffle-fold.open {
  grid-template-columns: 1fr;
  margin-left: 0;
  opacity: 1;
}

.sort-shuffle-fold > * {
  min-width: 0;
  overflow: clip;
  overflow-clip-margin: 4px;
}

.sort-shuffle-fold button.sort-shuffle {
  width: max-content;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .sort-shuffle-fold {
    transition: none;
  }
}

/* The card search and the layout switch stay on one line: the search gives
   way first, and past its minimum the pair moves to a line of its own. */
.toolbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* The list/grid switch only does something where a stylesheet reads
   `data-layout`, which today is the poster variant alone. */
.layout-switch {
  display: none;
}

[data-variant="poster"] .layout-switch {
  display: inline-flex;
}

/* --- tags ---------------------------------------------------------------- */

/* A toolbar's quiet word before its control ("Sort"). */
.toolbar-label {
  font-size: 14px;
  color: var(--muted);
}

/* The search's tags tab, before anything is typed: every tag, as chips. */
.palette-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px 10px;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

button.tag-chip,
span.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--chip-ink);
  font-size: 13px;
  font-weight: 400;
  box-shadow: none;
}

span.tag-chip {
  background: var(--chip);
  border-color: transparent;
}

button.tag-chip:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
}

button.tag-chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

button.tag-chip.selected:hover:not(:disabled) {
  background: var(--ink);
  color: var(--bg);
}

button.tag-chip.clear {
  border-style: dashed;
  color: var(--muted);
}
