/* Record cards (Components::RecordCards): a list of records that each carry
 * several controls, used where a wide table would squeeze them. Every rule
 * is one flat semantic class; shared markup (badges, button_to forms,
 * details/summary/pre) gets its own class at the render site. */

.record-cards {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One column on narrow screens; on wide screens main sits left and aside
 * right, so each card uses the width it has. The meta line always spans. */
.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.2rem 1.25rem;
  padding: 0.45rem 0.25rem 0.55rem;
  border-top: 1px solid var(--border);
}

.record-card:first-child {
  border-top: 0;
}

.record-card-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.record-card-main {
  min-width: 0;
}

.record-card-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  min-width: 0;
}

.record-card-eyebrow {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--medium-gray-dark);
}

/* Status pills on the meta line: quiet tones for fine states, one solid
 * amber pill for anything that needs a person. */
.record-card-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.record-card-badge--neutral:hover {
  color: var(--dark-gray);
}

.record-card-badge--ok {
  background: color-mix(in oklch, var(--badge-ready) 18%, white 82%);
  color: var(--badge-ready);
}

.record-card-badge--good {
  background: color-mix(in oklch, var(--badge-caution) 22%, white 78%);
  color: var(--badge-warning);
}

.record-card-badge--weak,
.record-card-badge--pending {
  background: color-mix(in oklch, var(--badge-warning) 22%, white 78%);
  color: var(--badge-warning);
}

.record-card-badge--attention {
  background: var(--badge-warning);
  color: var(--surface-white);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--badge-warning) 30%, white 70%);
}

.record-card-actions {
  margin-left: auto;
}

/* button_to wraps its button in a form; keep it on the line. */
.record-card-inline-form {
  display: inline;
}

/* A heading in the outline only; the global h4 bar does not apply. */
.record-card-name {
  margin: 0.15rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 600;
}

/* A body disclosure: a one-line excerpt is the summary, the full text
 * sits beneath. Both neutralize the global summary pill, its dark hover
 * invert, and the global pre styling. */
.record-card-summary,
.record-card-summary:hover {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

.record-card-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.85rem;
  white-space: pre-wrap;
  color: var(--dark-gray);
}

.record-card-toggle {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--primary-color);
}

.record-card-full {
  margin: 0.25rem 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.85rem;
  white-space: pre-wrap;
  color: var(--dark-gray);
}

.record-card-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  font-size: 0.8rem;
}

.record-card-fact::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  background: var(--medium-gray);
  vertical-align: middle;
}

.record-card-fact--warning::before {
  background: var(--badge-caution);
}

.record-card-fact--success::before {
  background: var(--badge-ready);
}

.record-card-fact--info::before {
  background: var(--badge-secondary);
}

.record-card-next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  border-left: 4px solid var(--medium-gray);
  border-radius: 0 4px 4px 0;
  background: var(--surface-subtle);
}

.record-card-next--link,
.record-card-next--record {
  border-left-color: var(--badge-ready);
}

.record-card-next--fix {
  border-left-color: var(--badge-caution);
}

.record-card-next--delete {
  border-left-color: var(--danger-color);
}

.record-card-next-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  flex: 1 1 18rem;
}

.record-card-next-detail {
  color: var(--text-muted);
}

.record-card-next-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Secondary choices folded under a next step ("2 more suggestions", "Or
 * assign manually"). The disclosure is a block of its own, so opening it
 * grows the aside downward and never reflows the meta line. */
.record-card-more {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.record-card-more-summary,
.record-card-more-summary:hover {
  display: block;
  cursor: pointer;
  list-style: none;
  background: transparent;
  color: var(--primary-color);
  padding: 0;
  border-radius: 0;
}

/* One folded choice per row: name, a truncated detail that takes what is
 * left, and its control pinned to the right. */
.record-card-more-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-top: 1px solid var(--border);
}

.record-card-more-item-name {
  white-space: nowrap;
}

.record-card-more-item-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

@media (min-width: 900px) {
  .record-card {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

@media (max-width: 640px) {
  .record-card-actions {
    margin-left: 0;
    width: 100%;
  }

  .record-card-next-actions {
    width: 100%;
  }

  .record-card-next-button {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* The list's own sort control, standing in for the sortable headers a card
 * list has no room for. */
.record-cards-sort {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.record-cards-sort-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* A row of count or severity pills standing in for a definition list. */
.warning-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

/* The sentence a group of warnings shares, standing in for a column that
 * would otherwise repeat it on every row. */
.warning-group-heading {
  margin: 0.75rem 0 0.25rem;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* A card whose content is symmetric, so it takes the whole width instead
   of the main/aside split. */
.record-card.record-card--full {
  grid-template-columns: minmax(0, 1fr);
}

/* A duplicate pair: a candidate on each side with the merge controls
   between them, so the arrow points at the name that survives. */
.duplicate-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem 1.25rem;
}

.duplicate-pair-side {
  min-width: 0;
}

.duplicate-pair-name {
  font-weight: 600;
}

.duplicate-pair-facts {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.duplicate-pair-controls {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

@media (max-width: 700px) {
  .duplicate-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .duplicate-pair-controls {
    justify-content: flex-start;
  }
}
