/* Selected part(s), the card's first section (panel/selected.js): thumbnail, breadcrumb, name,
   size; Focus / Isolate / Hide / Colour; the variant groups it belongs to; then, in edit mode, the
   edit section (edit.css). */
.sv-selected {
  padding: 12px 14px 14px;
}

.sv-selected__head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.sv-selected__thumb {
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sv-viewport-bg);
}

.sv-selected__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 150ms;
}

.sv-selected__thumb img.is-loading {
  opacity: 0;
}

.sv-selected__titles {
  min-width: 0;
}

/* The padding (undone by the margin) keeps the crumbs' focus ring inside the clip. */
.sv-crumbs {
  display: flex;
  gap: 0 4px;
  margin: -3px;
  padding: 3px;
  overflow: hidden;
  color: var(--sv-faint);
  font-size: 11px;
  line-height: 24px;
  white-space: nowrap;
}

#viewer .sv-crumb,
#viewer .sv-crumb:hover:not(:disabled) {
  flex: 0 1 auto;
  min-width: 2em;
  max-width: 10em;
  min-height: 24px;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--sv-muted);
  background: none;
  font-weight: 400;
  text-overflow: ellipsis;
}

#viewer .sv-crumb:hover:not(:disabled) {
  color: var(--sv-accent);
  text-decoration: underline;
}

@media (pointer: coarse) {
  #viewer .sv-crumb,
  #viewer .sv-crumb:hover:not(:disabled) {
    min-height: 40px;
  }
}

.sv-crumbs > :not(:last-child)::after {
  content: " ›";
  color: var(--sv-faint);
}

.sv-selected__name {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sv-selected__code,
.sv-selected__meta {
  margin: 0;
  overflow: hidden;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sv-selected__code {
  color: var(--sv-muted);
  font-size: 12px;
}

/* Wraps rather than cut the part count off. */
.sv-selected__meta {
  color: var(--sv-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: normal;
}

#viewer .sv-selected__head .sv-close {
  align-self: start;
  margin: -4px -6px 0 0;
}

/* Equal buttons, three a row, icon above the label, so no label is ever cut. */
.sv-selected__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

#viewer .sv-selected__actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.2;
}

#viewer .sv-selected__actions button[aria-pressed="true"],
#viewer .sv-selected__actions button[aria-expanded="true"] {
  border-color: var(--sv-accent);
  color: var(--sv-accent);
  background: var(--sv-accent-soft);
  font-weight: 650;
}

/* The Colour button's dot: the part's colour, or a colour wheel when it has its own. */
.sv-selected__dot {
  width: 16px;
  height: 16px;
  border: 1px solid rgb(23 23 26 / 0.16);
  border-radius: 50%;
  background: conic-gradient(#c8102e, #f2c400, #2e9d5b, #1f6fd1, #c8102e);
}

.has-color > .sv-selected__dot {
  background: var(--c);
}

/* The swatches are a popover (top layer, placed by selected.js under the Colour button). */
.sv-swatches {
  position: fixed;
  inset: auto;
  max-width: 236px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--sv-border);
  border-radius: 12px;
  background: var(--sv-surface);
  box-shadow: var(--sv-shadow);
}

.sv-swatches:popover-open {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

#viewer .sv-swatch,
#viewer .sv-swatch:hover:not(:disabled) {
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgb(23 23 26 / 0.16);
  border-radius: 50%;
  background: var(--c);
}

#viewer .sv-swatch--reset,
#viewer .sv-swatch--reset:hover:not(:disabled) {
  background: linear-gradient(135deg, transparent 46%, var(--sv-danger) 46% 54%, transparent 54%), var(--sv-surface);
}

#viewer .sv-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--sv-surface), 0 0 0 4px var(--sv-accent);
}

#viewer .sv-color-input {
  width: 34px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--sv-border-strong);
  border-radius: 8px;
  background: var(--sv-surface);
  cursor: pointer;
}

/* The variant groups the part is, sits in or contains, as compact cards. */
.sv-selected__groups {
  display: grid;
  gap: 12px;
}

.sv-selected__groups:not(:empty) {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--sv-border);
}

@media (pointer: coarse) {
  #viewer .sv-swatch,
  #viewer .sv-swatch:hover:not(:disabled) {
    width: 32px;
    height: 32px;
  }

  #viewer .sv-color-input {
    width: 44px;
    height: 44px;
  }
}

/* The phone's sheet (panel.css) at most 40% of the screen, scrolling inside, so the model's centre
   above it stays tappable (labels, attach points). */
@media (pointer: coarse) and (max-width: 760px), (pointer: coarse) and (max-width: 1023px) and (max-height: 520px) and (min-aspect-ratio: 301/200) {
  .sv-card {
    max-height: min(40dvh, calc(60% - var(--sv-above-dock)));
  }
}
