/* Variants tray (variants_tray.rs). Tokens come from style.css; the thumbnail plate stays white
   like the graph cards' plate.
   Hierarchy per card: the graph, then one line of summary, then two real choices (Use / Open as
   new) as buttons, then the housekeeping verbs (Keep, Discard, Regenerate, More like this) as a
   quiet row of text buttons. The tray's top edge carries a hairline of accent so AI output reads
   as "proposed", not yet part of the graph. */

.vt {
  margin: var(--s-4) var(--s-5) 0;
  padding: var(--s-4);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  position: relative;
  animation: vt-in var(--dur-3) var(--ease-out);
}
.vt::before {
  content: ""; position: absolute; top: -1px; left: var(--r-lg); right: var(--r-lg); height: 2px;
  border-radius: 0 0 2px 2px; background: var(--accent);
}
@keyframes vt-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.vt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.vt-head-text { min-width: 0; }
.vt-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--text); line-height: 1.2; }
.vt-instr {
  margin: 4px 0 0; color: var(--text-2); font-size: var(--fs-sm); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vt-instr::before { content: "\201c"; }
.vt-instr::after { content: "\201d"; }
.vt-instr:empty { display: none; }
.vt-head-actions { display: flex; align-items: center; gap: var(--s-1); flex-shrink: 0; }
.vt-kept-count { color: var(--text-3); font-size: var(--fs-xs); margin-right: var(--s-1); font-variant-numeric: tabular-nums; }

.vt-status { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); color: var(--text-2); font-size: var(--fs-sm); }
.vt-error { margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-sm); }
.vt-error:empty { display: none; }

.vt-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
}

/* While the first variations are on their way the grid is empty: show two skeleton cards the
   shape of the real ones (plate, then two text lines) instead of a blank strip. */
.vt:has(.vt-status) .vt-grid:empty::before, .vt:has(.vt-status) .vt-grid:empty::after {
  content: ""; display: block; min-height: 220px; border-radius: var(--r-md);
  border: 1px solid var(--border);
  background:
    linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--text) 7%, transparent) 50%, transparent 100%) -100% 0 / 60% 100% no-repeat,
    linear-gradient(var(--sunken), var(--sunken)) 12px calc(100% - 40px) / 40% 10px no-repeat,
    linear-gradient(var(--sunken), var(--sunken)) 12px calc(100% - 20px) / 70% 10px no-repeat,
    linear-gradient(var(--plate), var(--plate)) 0 0 / 100% 62% no-repeat,
    var(--surface);
  animation: vt-shimmer 1.5s var(--ease) infinite;
}
@keyframes vt-shimmer { to { background-position: 200% 0, 12px calc(100% - 40px), 12px calc(100% - 20px), 0 0, 0 0; } }

.vt-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden;
  animation: vt-in var(--dur-3) var(--ease-out) both;
  transition: box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.vt-card:nth-child(2) { animation-delay: 50ms; }
.vt-card:nth-child(3) { animation-delay: 100ms; }
.vt-card:nth-child(4) { animation-delay: 150ms; }
.vt-card:nth-child(n+5) { animation-delay: 200ms; }
.vt-card:hover, .vt-card:focus-within { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.vt-card:hover { transform: translateY(-1px); }
.vt-card.vt-regen { opacity: 0.6; }
.vt-card.vt-regen .vt-thumb::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.7) 50%, transparent 70%) -100% 0 / 60% 100% no-repeat;
  animation: vt-sweep 1.3s var(--ease) infinite;
}
@keyframes vt-sweep { to { background-position: 250% 0; } }

.vt-thumb {
  position: relative; aspect-ratio: 3 / 2; width: 100%;
  background: var(--plate); border-bottom: 1px solid var(--plate-edge);
  cursor: pointer; overflow: hidden;
}
.vt-thumb[data-live="true"] { cursor: default; }
.vt-thumb:focus-visible { outline: 2px solid var(--plate-accent); outline-offset: -3px; }
.vt-canvas, .vt-snap { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vt-snap { object-fit: cover; }
.vt-wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--plate-ink-2); font-size: var(--fs-xs); }
.vt-badge {
  position: absolute; top: 6px; right: 6px; padding: 1px 7px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em; background: rgb(255 255 255 / 0.9); color: var(--plate-ink-2);
  box-shadow: 0 0 0 1px var(--plate-line);
}
.vt-thumb[data-live="true"] .vt-badge { color: #1b6535; }

.vt-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-2); padding: var(--s-2) var(--s-3) 0; }
.vt-num { color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.vt-summary { flex-basis: 100%; margin: 0; color: var(--text); font-size: var(--fs-sm); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.vt-kept { background: var(--accent-soft); color: var(--accent-text); }

.vt-actions {
  display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 6px;
  padding: var(--s-2) var(--s-3) var(--s-2); margin-top: auto;
}
.vt-actions .btn { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the two real choices */
.vt-actions > .btn:nth-child(-n+2) { padding-inline: 6px; }
/* housekeeping verbs: quiet text buttons, two per line, aligned with the buttons above */
.vt-actions > .btn:nth-child(n+3) {
  justify-self: start; justify-content: flex-start; max-width: 100%;
  padding: 2px 6px; margin: -2px 0 -2px -6px; min-height: 26px; border: 0; background: transparent; box-shadow: none;
  color: var(--text-2); font-weight: 600;
}
.vt-actions > .btn:nth-child(n+3):hover:not(:disabled) { background: var(--sunken); color: var(--text); }
.vt-actions > .btn:nth-child(4):hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.vt-actions > .btn:nth-child(n+3):disabled { opacity: 0.55; }
.vt-notes { margin: var(--s-3) 0 0; padding: 0; list-style: none; }

.vt-closed {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin: var(--s-3) var(--s-5) 0; padding: var(--s-2) var(--s-3);
  border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-sm);
  animation: vt-in var(--dur-2) var(--ease-out);
}
.vt-closed > span { flex: 1; min-width: 0; }

@media (max-width: 767px) {
  .vt { margin: var(--s-3) var(--s-4) 0; padding: var(--s-3); }
  .vt-closed { margin: var(--s-3) var(--s-4) 0; }
  /* a swipeable strip: one card and a peek of the next */
  .vt-grid {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(230px, 78%);
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: var(--s-2);
    overscroll-behavior-x: contain;
  }
  .vt-card { scroll-snap-align: start; }
  .vt:has(.vt-status) .vt-grid:empty::after { display: none; }
}
@media (pointer: coarse) {
  .vt-actions > .btn:nth-child(n+3) { min-height: var(--touch); padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .vt, .vt-card, .vt-closed { animation: none; transition: none; }
  .vt-card:hover { transform: none; }
}
@media print {
  .vt, .vt-closed { display: none; }
}
