/* ---- Configure: the card's variant groups (nothing selected), option tiles with
   server-rendered thumbnails. Its heading folds it (phones start folded). ----------------------- */
.sv-variants {
  padding: 6px 8px 8px;
}

.sv-variants__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 0 6px;
}

.sv-variants__head h2 {
  margin: 0;
  font: inherit;
}

#viewer .sv-variants__fold,
#viewer .sv-variants__fold:hover:not(:disabled) {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 650;
}

.sv-variants__fold::before {
  content: "";
  width: 6px;
  height: 6px;
  margin: 0 2px 3px 1px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 120ms;
}

.sv-variants__fold[aria-expanded="false"]::before {
  margin-bottom: 0;
  transform: rotate(-45deg);
}

.sv-variants__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ---- Group card ---------------------------------------------------------------------------- */
.sv-vcard {
  border: 1px solid var(--sv-border);
  border-radius: 12px;
  background: var(--sv-surface);
  }

.sv-vcard__heading {
  margin: 0;
  font: inherit;
}

#viewer .sv-vcard__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "title count chevron"
    "value value chevron";
  align-items: center;
  column-gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px 8px 14px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-weight: inherit;
  text-align: left;
}

#viewer .sv-vcard__head:hover:not(:disabled) {
  background: var(--sv-hover);
}

#viewer .sv-vcard__head[aria-expanded="true"] {
  border-radius: 12px 12px 0 0;
}

.sv-vcard__name {
  grid-area: title;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sv-vcard__count {
  grid-area: count;
  color: var(--sv-faint);
  font-size: 11px;
  white-space: nowrap;
}

.sv-vcard__value {
  grid-area: value;
  overflow: hidden;
  color: var(--sv-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sv-vcard__chevron {
  grid-area: chevron;
  width: 8px;
  height: 8px;
  margin: 0 4px;
  border-right: 1.6px solid var(--sv-muted);
  border-bottom: 1.6px solid var(--sv-muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms;
}

.sv-vcard__head[aria-expanded="false"] .sv-vcard__chevron {
  transform: rotate(-45deg);
}

/* ---- Option tiles -------------------------------------------------------------------------- */
.sv-vcard__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding: 2px 12px 12px;
}

#viewer .sv-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  padding: 4px 4px 8px;
  border: 1px solid var(--sv-border);
  border-radius: 10px;
  background: var(--sv-surface);
  font-weight: 500;
  text-align: left;
}

#viewer .sv-tile:hover:not(:disabled) {
  border-color: var(--sv-border-strong);
  background: var(--sv-surface);
}

#viewer .sv-tile[aria-pressed="true"] {
  border-color: var(--sv-accent);
  background: var(--sv-accent-soft);
  box-shadow: inset 0 0 0 1px var(--sv-accent);
}

.sv-tile__thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  margin-bottom: 4px;
  border-radius: 7px;
  background: #f5f4f2;
}

/* Skeleton until the thumbnail has loaded. */
.sv-tile__thumb:has(img)::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.7) 50%, transparent 70%) 0 0 / 300% 100%;
  animation: sv-skeleton 1.2s linear infinite;
}

.sv-tile__thumb.is-loaded::before,
.sv-tile__thumb.is-failed::before {
  content: none;
}

.sv-tile__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 180ms;
}

.sv-tile__thumb.is-loaded img {
  opacity: 1;
}

.sv-tile__thumb.is-failed img {
  visibility: hidden;
}

@keyframes sv-skeleton {
  from { background-position: 100% 0; }
  to { background-position: -50% 0; }
}

.sv-tile__name {
  display: -webkit-box;
  overflow: hidden;
  padding: 0 4px;
  font-size: 12px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.sv-tile__code {
  overflow: hidden;
  padding: 0 4px;
  color: var(--sv-faint);
  font-size: 11px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "None": dashed outline and a remove glyph instead of a thumbnail. */
#viewer .sv-tile--none {
  border-style: dashed;
}

.sv-tile--none .sv-tile__thumb {
  background: none;
}

.sv-tile--none .sv-tile__thumb::before,
.sv-tile--none .sv-tile__thumb::after {
  content: "";
  grid-area: 1 / 1;
  width: 22px;
  height: 22px;
  border: 1.6px solid var(--sv-faint);
  border-radius: 50%;
}

.sv-tile--none .sv-tile__thumb::after {
  width: 1.6px;
  border: 0;
  border-radius: 0;
  background: var(--sv-faint);
  transform: rotate(45deg);
}

.sv-tile--none[aria-pressed="true"] .sv-tile__thumb::before {
  border-color: var(--sv-accent);
}

.sv-tile--none[aria-pressed="true"] .sv-tile__thumb::after {
  background: var(--sv-accent);
}

/* Badge corner: a check on the active tile, a spinner on the one waiting for the server. */
.sv-tile[aria-pressed="true"]::after,
.sv-tile.is-pending::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.sv-tile[aria-pressed="true"]::after {
  background: var(--sv-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m2.5 6.2 2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.sv-tile.is-pending::after {
  border: 2px solid var(--sv-accent-soft);
  border-top-color: var(--sv-accent);
  background: var(--sv-surface);
  animation: sv-spin 700ms linear infinite;
}

#viewer .sv-tile.is-pending {
  border-color: var(--sv-accent);
}

@keyframes sv-spin {
  to { transform: rotate(1turn); }
}

/* ---- Compact card (inside the selected card): no fold, smaller tiles ------------------------ */
.sv-vcard--compact {
  border: 0;
  background: none;
}

#viewer .sv-vcard--compact .sv-vcard__head {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title count"
    "value value";
  min-height: 0;
  padding: 0 0 6px;
}

.sv-vcard--compact .sv-vcard__tiles {
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  padding: 0;
}

.sv-vcard--compact .sv-tile__name {
  font-size: 11.5px;
}
