/**
 * control-slider.css — eigenständiges Styling für ein Range-Slider-Steuerelement
 * mit optional gekoppeltem Zahlenfeld.
 *
 * Erwartetes Markup (siehe control-slider.js für automatisches Verdrahten der
 * Werte-Synchronisation und der .slider-rail):
 *
 *   <div class="slider-row">
 *     <input type="number" class="slider-number" value="1" min="1" max="10" step="1">
 *     <div class="slider-wrap">
 *       <div class="slider-rail" aria-hidden="true"></div>
 *       <input type="range" min="1" max="10" step="1" value="1">
 *     </div>
 *   </div>
 *
 * Das Zahlenfeld (.slider-row + .slider-number) ist optional — .slider-wrap
 * funktioniert auch ohne umgebende .slider-row, z.B. mehrere Slider in einem
 * eigenen Grid-Layout (RGB-Regler o.ä.).
 *
 * Theming: Die Datei ist eigenständig lauffähig (Fallback-Werte), übernimmt
 * aber automatisch die Farben des Hosts, sofern dort --color-primary,
 * --color-divider, --color-border, --color-surface definiert sind.
 *
 * Geometrie-Hinweis zur .slider-rail: Ein natives <input type="range"> bewegt
 * die Daumen-MITTE nur zwischen thumb-w/2 und (100% - thumb-w/2), nie bis zum
 * Rand. Die Rail ist deshalb um genau diesen Betrag eingerückt und zusätzlich
 * um rail-h/2 auf jeder Seite verlängert, damit ihre abgerundete Kappe an den
 * Endpositionen optisch exakt mit der Daumen-Mitte übereinstimmt.
 */

:root {
  --slider-thumb-w: 40px;
  --slider-thumb-h: 26px;
  --slider-rail-h: 8px;
  --slider-thumb-radius: 5px;
  --slider-control-h: 36px;
  --slider-thumb-grip-color: rgba(255, 255, 255, 1.0);
  --slider-thumb-color: var(--color-primary, #2f6fed);
  --slider-rail-color: var(--color-divider, #dcdcdc);
  --slider-number-border-color: var(--color-border, #d0d0d0);
  --slider-number-bg-color: var(--color-surface, #fff);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  box-sizing: border-box;
}
.slider-row * {
  box-sizing: border-box;
}

.slider-number {
  width: 62px;
  flex-shrink: 0;
  height: var(--slider-control-h);
  text-align: center;
  font-family: inherit;
  font-size: 16px; /* mind. 16px, sonst zoomt iOS Safari beim Fokussieren */
  border: 1.5px solid var(--slider-number-border-color);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--slider-number-bg-color);
  color: inherit;
  -moz-appearance: textfield;
}
.slider-number::-webkit-inner-spin-button,
.slider-number::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.slider-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-height: var(--slider-control-h);
}

.slider-wrap .slider-rail {
  position: absolute;
  left: calc((var(--slider-thumb-w) / 2) - (var(--slider-rail-h) / 2));
  width: calc(100% - var(--slider-thumb-w) + var(--slider-rail-h));
  height: var(--slider-rail-h);
  top: 50%;
  transform: translateY(-50%);
  background: var(--slider-rail-color);
  border-radius: calc(var(--slider-rail-h) / 2);
  pointer-events: none;
  z-index: 2;
}

.slider-wrap input[type="range"] {
  position: relative;
  z-index: 5;
  flex: 1;
  height: var(--slider-control-h);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.slider-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: var(--slider-rail-h);
  background: transparent;
}
.slider-wrap input[type="range"]::-moz-range-track {
  height: var(--slider-rail-h);
  background: transparent;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--slider-thumb-w);
  height: var(--slider-thumb-h);
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
  background-image: repeating-linear-gradient(
    90deg,
    var(--slider-thumb-grip-color) 0,
    var(--slider-thumb-grip-color) 2px,
    transparent 2px,
    transparent 8px
  );
  background-size: 18px 10px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  /* vertikal mittig zur Rail, unabhängig von --slider-rail-h/--slider-thumb-h */
  margin-top: calc((var(--slider-rail-h) - var(--slider-thumb-h)) / 2);
}

.slider-wrap input[type="range"]::-moz-range-thumb {
  width: var(--slider-thumb-w);
  height: var(--slider-thumb-h);
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
  border: none;
  cursor: pointer;
}

.slider-wrap input[type="range"]:disabled {
  opacity: 0.5;
  cursor: default;
}
.slider-wrap input[type="range"]:disabled::-webkit-slider-thumb {
  cursor: default;
}
.slider-wrap input[type="range"]:disabled::-moz-range-thumb {
  cursor: default;
}
