/*
  ambient.css: the "Ambient lighting" control (js/ui/ambient-control.js), in the Interior and
  Lighting tabs. Phone first: every target is 44px, the sliders run the panel's width with
  44px thumbs, nothing needs a hover. The live colour arrives as --amb (a hex) and --amb-level
  (0.35..1, from the brightness), so the lamp, the thumb and the brightness track glow with it.
  Siblings: panel.css (rows, chips, swatches), base.css (tokens).
*/

.row--light { --amb: #ffcd94; --amb-level: .9; padding-bottom: 4px; }

.amb { padding: 6px var(--gutter) 0; }

/* ---------- The switch: lamp, state, price, track ---------- */

.amb__switch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  color: var(--text-2);
  font-size: 14px;
  transition: border-color .2s, background-color .2s;
}
.amb__switch[aria-checked="true"] { border-color: color-mix(in srgb, var(--amb) 45%, var(--line-2)); color: var(--text); }
.amb__lamp {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1d1d1c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  transition: background-color .25s, box-shadow .25s;
}
.row--light[data-on="true"] .amb__lamp {
  background: radial-gradient(circle at 50% 50%, var(--amb) 0 42%, color-mix(in srgb, var(--amb) 30%, #161615) 100%);
  box-shadow: 0 0 calc(18px * var(--amb-level)) color-mix(in srgb, var(--amb) 55%, transparent), inset 0 0 0 1px rgba(255, 255, 255, .2);
}
.amb__state { font-weight: 560; }
.amb__price { margin-left: auto; font-size: 12.5px; color: var(--text-3); }
.amb__track {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: rgba(236, 231, 222, .14);
  transition: background-color .2s;
}
.amb__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform .22s var(--ease), background-color .2s;
}
.amb__switch[aria-checked="true"] .amb__track { background: color-mix(in srgb, var(--brass) 70%, #000); }
.amb__switch[aria-checked="true"] .amb__knob { transform: translateX(18px); background: var(--text); }

/* ---------- Sliders ---------- */

/* Off, the controls stay live (using one switches the light on) but sit back a step. */
.amb__body { transition: opacity .25s; }
.row--light[data-on="false"] .amb__body { opacity: .62; }

.amb__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
  font-size: 13px;
}
.amb__label { color: var(--text-2); }
.amb__read { color: var(--text-3); font-variant-numeric: tabular-nums; }

.amb__slider {
  --track: linear-gradient(to right, #333, #999);
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-y;
  cursor: pointer;
}
.amb__slider--glow {
  --fill: 80%;
  --track: linear-gradient(to right, #222120, var(--amb));
}
.amb__slider::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: var(--track); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.amb__slider::-moz-range-track { height: 12px; border-radius: 6px; background: var(--track); }
/* A 44px thumb: a 28px disc of the live colour with a bone ring, inside a clear 8px margin. */
.amb__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 44px;
  height: 44px;
  margin-top: -16px;
  border: 8px solid transparent;
  border-radius: 50%;
  background: var(--amb) padding-box;
  box-shadow: inset 0 0 0 3px var(--text), 0 2px 10px rgba(0, 0, 0, .5);
}
.amb__slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 3px solid var(--text);
  border-radius: 50%;
  background: var(--amb);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}
.amb__slider:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 8px; }

/* ---------- Presets ---------- */

.amb__presets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 10px;
}
.amb__preset {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 64px;
  padding: 6px 0 4px;
  border-radius: 12px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}
.amb__dot {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--dot) 0 40%, color-mix(in srgb, var(--dot) 35%, #161615) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.amb__dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color .2s;
}
.amb__preset[aria-pressed="true"] { color: var(--text); }
.amb__preset[aria-pressed="true"] .amb__dot::after { border-color: var(--brass); }
.amb__name { max-width: 100%; overflow-wrap: anywhere; }

@media (hover: hover) {
  .amb__switch:hover { border-color: rgba(236, 231, 222, .4); }
  .amb__preset:hover:not([aria-pressed="true"]) { color: var(--text-2); }
}
@media (prefers-reduced-motion: reduce) {
  .amb__knob, .amb__switch, .amb__lamp, .amb__body { transition: none; }
}
