/* Material library (web/js/materials.js): the card's Material button and its picker popover. */

#viewer .sv-selected__actions button[hidden] {
  display: none;
}

.sv-mat__dot {
  width: 16px;
  height: 16px;
  border: 1px solid rgb(23 23 26 / 0.16);
  border-radius: 50%;
  background: conic-gradient(from 200deg, #d9dce0, #8e1218, #c49a62, #85868a, #dcecef, #eceae6, #d9dce0);
}

.has-material > .sv-mat__dot {
  background: var(--c);
}

/* The chosen preset's name can be long: one line, cut short. */
.sv-mat__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The picker: a popover in the top layer, placed by materials.js under the Material button, its
   height fitted above the toolbar. While more is below, a soft shade at the bottom edge: the
   `local` cover scrolls with the content and hides the fixed shade once the end is in view. */
.sv-materials {
  position: fixed;
  inset: auto;
  width: min(312px, calc(100vw - 16px));
  max-height: min(70vh, 520px);
  margin: 0;
  padding: 8px 10px 10px;
  overflow-y: auto;
  border: 1px solid var(--sv-border);
  border-radius: 12px;
  background:
    linear-gradient(rgb(255 255 255 / 0), var(--sv-surface) 50%) center bottom / 100% 32px no-repeat local,
    linear-gradient(rgb(23 23 26 / 0), rgb(23 23 26 / 0.1)) center bottom / 100% 16px no-repeat scroll,
    var(--sv-surface);
  box-shadow: var(--sv-shadow);
}

.sv-materials__section {
  margin: 10px 2px 4px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--sv-muted, rgb(23 23 26 / 0.6));
}

.sv-materials__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

/* A tile: swatch over its name; at least 44 px a side. */
#viewer .sv-mat,
#viewer .sv-mat:hover:not(:disabled) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 44px;
  min-height: 56px;
  padding: 5px 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
}

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

#viewer .sv-mat[aria-pressed="true"] {
  border-color: var(--sv-accent);
  color: var(--sv-accent);
  font-weight: 650;
}

.sv-mat__swatch {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid rgb(23 23 26 / 0.16);
  border-radius: 50%;
  background: var(--c);
}

/* Hints of the look: metals and paint shine, glass shows what's behind, textures have grain. */
.sv-mat[data-section="Metal"] .sv-mat__swatch,
.sv-mat[data-section="Paint"] .sv-mat__swatch {
  background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / 0.75), transparent 45%), linear-gradient(160deg, var(--c), rgb(0 0 0 / 0.35)), var(--c);
}

.sv-mat[data-section="Glass"] .sv-mat__swatch {
  background: linear-gradient(135deg, rgb(255 255 255 / 0.8), transparent 60%), repeating-conic-gradient(rgb(23 23 26 / 0.12) 0 25%, transparent 0 50%) 0 0 / 10px 10px, var(--c);
}

.sv-mat.is-textured .sv-mat__swatch {
  background: repeating-linear-gradient(100deg, rgb(0 0 0 / 0.08) 0 2px, transparent 2px 5px), var(--c);
}

/* Original: the file's own materials. */
.sv-mat[data-material=""] .sv-mat__swatch {
  background: linear-gradient(135deg, transparent 46%, var(--sv-danger) 46% 54%, transparent 54%), var(--sv-surface);
}

.sv-mat__name {
  overflow-wrap: break-word;
  hyphens: auto;
}
