/* Layer Opacity Controls */

.layer-opacity-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.layer-opacity-row > label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.layer-opacity-toggle {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85em;
  opacity: 0.5;
  padding: 0;
  transition: opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
}

.layer-opacity-toggle:hover,
.layer-opacity-toggle:focus-visible {
  opacity: 1;
  background: var(--surface-hover, rgba(0, 0, 0, 0.06));
}

.layer-opacity-control {
  display: none;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 4px 0 4px 24px;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.layer-opacity-control.open { display: flex; }

.layer-opacity-slider {
  flex: 0 1 80px;
  width: 80px;
  max-width: 80px;
  min-width: 0;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-bar-border, #ccc);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.layer-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #3b8bba);
  cursor: pointer;
  border: none;
}

.layer-opacity-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent, #3b8bba);
  cursor: pointer;
  border: none;
}

.layer-opacity-pct {
  font-size: 0.75em;
  min-width: 3ch;
  text-align: right;
  color: var(--text-secondary, #666);
  font-variant-numeric: tabular-nums;
}

.layer-opacity-reset {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8em;
  opacity: 0.4;
  transition: opacity 0.15s ease;
  padding: 2px;
  line-height: 1;
  color: inherit;
}

.layer-opacity-reset:hover,
.layer-opacity-reset:focus-visible { opacity: 1; }

@media (pointer: coarse) {
  .layer-opacity-toggle {
    width: 32px;
    height: 32px;
    font-size: 1em;
  }
  .layer-opacity-reset {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

body.dark-mode .layer-opacity-slider {
  background: var(--surface-bar-border, #555);
}

body.dark-mode .layer-opacity-toggle:hover,
body.dark-mode .layer-opacity-toggle:focus-visible {
  background: var(--surface-hover, rgba(255, 255, 255, 0.1));
}
