/* Quick-pie horizontal bar — performance-optimised for C4D HTML viewer.
   All animations use transform + opacity only (GPU-composited layers).
   No backdrop-filter, no animated box-shadow, no layout thrash. */

:root {
  --qp-bg:     #0b0b0e;
  --qp-bar:    #111114;
  --qp-bdr:    rgba(255,255,255,0.06);
  --qp-accent: #2979FF;
  --qp-acc-l:  #5ea3ff;
  --qp-text:   #e0e0e3;
  --qp-sec:    #808088;
  --qp-dim:    #4a4a52;
  --qp-track:  rgba(255,255,255,0.07);
  --qp-fill:   rgba(41,121,255,0.50);
  --qp-on-bg:  rgba(41,121,255,0.10);
  --qp-on-bdr: rgba(41,121,255,0.40);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--qp-bg);
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  color: var(--qp-text);
  user-select: none;
}

/* ── Entrance / exit (transform+opacity only) ────────── */
@keyframes qp-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes qp-leave {
  to { opacity: 0; transform: translateY(3px); }
}

/* ── Bar ─────────────────────────────────────────────── */
.qp {
  position: relative;
  display: flex;
  align-items: center;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  margin: 2px;
  padding: 0 6px;
  gap: 5px;
  background: var(--qp-bar);
  border: 1px solid var(--qp-bdr);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  will-change: transform, opacity;
  animation: qp-enter 0.15s ease-out both;
}
.qp.qp-exit {
  animation: qp-leave 0.12s ease-in forwards;
  pointer-events: none;
}

/* thin top accent — static, no animation */
.qp::before {
  content: '';
  position: absolute;
  top: -1px; left: 18%; right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--qp-acc-l), transparent);
  opacity: 0.3;
  pointer-events: none;
}

/* ── Countdown bar ───────────────────────────────────── */
.qp-timer {
  position: absolute;
  bottom: 2px; left: 12px; right: 12px;
  height: 2px;
  background: linear-gradient(90deg, var(--qp-accent), var(--qp-acc-l));
  border-radius: 1px;
  opacity: 0.25;
  pointer-events: none;
  transform-origin: left;
  will-change: transform;
}

/* ── Drag grip ───────────────────────────────────────── */
.qp-grip {
  flex: 0 0 8px;
  width: 8px; height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  opacity: 0.15;
  transition: opacity 0.12s;
}
.qp-grip:hover { opacity: 0.5; }
.qp-grip:active { cursor: grabbing; opacity: 0.65; }
.qp-grip svg { width: 6px; height: 14px; color: var(--qp-sec); }

/* ── Action buttons ──────────────────────────────────── */
.qp-btn {
  flex: 0 0 24px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--qp-dim);
  cursor: pointer;
  padding: 0;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.qp-btn svg { width: 15px; height: 15px; }
.qp-btn:hover {
  background: rgba(255,255,255,0.04);
  color: var(--qp-acc-l);
  border-color: rgba(255,255,255,0.04);
}
.qp-btn:active { opacity: 0.7; }

.qp-btn.qp-on {
  background: var(--qp-on-bg);
  border-color: var(--qp-on-bdr);
  color: var(--qp-acc-l);
}
.qp-btn.qp-pick.qp-on {
  background: rgba(41,121,255,0.18);
  border-color: rgba(94,163,255,0.55);
  color: #5ea3ff;
}
.qp.qp-picking .qp-timer { opacity: 0.1; }
.qp-pick-scope { display:flex; flex:0 0 auto; border:1px solid var(--qp-bdr); border-radius:4px; overflow:hidden; }
.qp-pick-scope[hidden] { display:none; }
.qp-pick-scope button { padding:0 4px; height:20px; border:0; border-right:1px solid var(--qp-bdr); background:transparent; color:var(--qp-sec); font:500 7px system-ui; cursor:pointer; }
.qp-pick-scope button:last-child { border-right:0; }
.qp-pick-scope button.on { color:var(--qp-acc-l); background:var(--qp-on-bg); }
.qp.qp-picking:not(.qp-vertical) { gap:2px; }
.qp-picking:not(.qp-vertical) .qp-btn, .qp-picking:not(.qp-vertical) .qp-power { flex-basis:22px; width:22px; }
.qp-picking:not(.qp-vertical) .qp-number { flex-basis:29px; }
.qp-picking:not(.qp-vertical) .qp-paint-mode { flex-basis:64px; gap:2px; }
.qp-picking:not(.qp-vertical) .qp-slc { min-width:16px; }

/* ── Divider ─────────────────────────────────────────── */
.qp-div {
  width: 1px; height: 16px;
  margin: 0 2px;
  background: var(--qp-bdr);
  flex-shrink: 0;
}

/* ── Slider icon ─────────────────────────────────────── */
.qp-ico {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--qp-sec);
}
.qp-ico.qp-off { opacity: 0.2; }

/* ── Range slider ────────────────────────────────────── */
.qp-range {
  flex: 1 1 36px;
  min-width: 24px;
  height: 4px;
  border-radius: 2px;
  appearance: none; -webkit-appearance: none;
  background: var(--qp-track);
  cursor: pointer;
}
.qp-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--qp-fill) 0%,
    var(--qp-fill) var(--fill, 0%),
    var(--qp-track) var(--fill, 0%),
    var(--qp-track) 100%
  );
}
.qp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--qp-accent);
  border: 1.5px solid rgba(255,255,255,0.15);
  box-shadow: 0 0 4px rgba(41,121,255,0.2);
}
.qp-range:disabled { opacity: 0.15; cursor: default; }

/* ── Close button ────────────────────────────────────── */
.qp-x {
  flex: 0 0 16px;
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 4px;
  background: transparent;
  color: var(--qp-dim);
  cursor: pointer;
  padding: 0;
  opacity: 0.25;
  transition: opacity 0.1s, color 0.1s;
}
.qp-x:hover { opacity: 1; color: var(--qp-text); }
.qp-x:active { opacity: 0.6; }
.qp-x svg { width: 8px; height: 8px; }

/* ── 1.5× bar: the dialog is _QP_W × _QP_H in lp/quick_pie_dialog.py ── */
html { zoom: 1.5; }

/* ── Slider + label column ───────────────────────────── */
.qp-slc {
  flex: 1 1 90px;
  min-width: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding-top: 3px;
}
.qp-slc .qp-range { flex: 0 0 auto; width: 100%; }
/* Icon and value sit on the slider's row, so the label row below is free
   under the value too: a short slider still fits "Solo light off". */
.qp-ico, .qp-number { position: relative; top: -5px; }
/* ── Color: fifth action, a swatch of the light's own color ── */
.qp-btn.qp-color b {
  width: 12px; height: 12px;
  border-radius: 3.5px;
  background: var(--qp-color, #ffffff);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.1s;
}
.qp-btn.qp-color:hover b { transform: scale(1.1); }
/* Temperature mode: the RS Color is not what renders */
.qp-btn.qp-color.qp-temp b { box-shadow: inset 0 0 0 2px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1); }
.qp-lbl.say.color { color: var(--qp-text); }
.qp-lbl {
  display: block;
  height: 8px;
  margin-right: -21px;
  overflow: hidden;
  font-size: 6.5px;
  line-height: 8px;
  color: var(--qp-sec);
  letter-spacing: 0.03em;
}
.qp-lbl-t {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: transform, opacity;
}
/* Status messages take the two label slots, so they never cover a control */
.qp-lbl.say      { color: var(--qp-acc-l); font-weight: 500; }
.qp-lbl.say.edit { color: #ffa56b; }
.qp-lbl.say.exc  { color: #ffa56b; }
.qp-lbl.say.solo { color: #f59e0b; }

/* ── Solo: the mixer's star and colours ──────────────── */
.qp-btn.qp-solo svg { width: 11px; height: 11px; }
.qp-btn.qp-solo:hover { color: #f59e0b; border-color: rgba(245,158,11,0.45); background: transparent; }
.qp-btn.qp-solo.qp-on { background: #f59e0b; border-color: #f59e0b; color: #000; }

/* ── Exclude reads orange ────────────────────────────── */
.qp.qp-exc .qp-btn[data-action="exclude"].qp-on {
  background: rgba(255,138,61,0.12);
  border-color: rgba(255,138,61,0.45);
  color: #ffa56b;
}
.qp.qp-exc::before { background: linear-gradient(90deg, transparent, #ffa56b, transparent); }
.qp.qp-exc .qp-timer { background: linear-gradient(90deg, #ff8a3d, #ffa56b); }
.qp.qp-soloing::before { background: linear-gradient(90deg, transparent, #f59e0b, transparent); opacity: 0.6; }

/* ── Pick: the bar's edge pulses (opacity only) ──────── */
.qp::after {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(94,163,255,0.9);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
}
.qp.qp-picking::after { animation: qp-pickpulse 1.6s ease-in-out infinite; }
@keyframes qp-pickpulse {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 1; }
}
/* . */

.qp-timer[hidden] { display: none !important; }
.qp-btn:disabled { opacity: 0.3; cursor: default; }

/* Paint / Edit stays inside the docked or floating viewer. */
.qp-paint-mode { display: flex; align-items: center; justify-content: center; gap: 4px; flex: 0 0 74px; }
.qp-paint-label, .qp-edit-label { color: var(--qp-sec); font-size: 8px; font-weight: 500; }
.qp-paint-mode.qp-paint-known:not(.qp-editing) .qp-paint-label { color: var(--qp-acc-l); }
.qp-paint-mode.qp-paint-known.qp-editing .qp-edit-label { color: #ffa56b; }
.qp-paint-switch { position: relative; width: 28px; height: 16px; flex: 0 0 28px; padding: 0; border-radius: 9px; border: 1px solid var(--qp-on-bdr); background: var(--qp-on-bg); cursor: pointer; }
.qp-paint-switch span { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--qp-acc-l); }
.qp-editing .qp-paint-switch { border-color: rgba(255,138,61,0.40); background: rgba(255,138,61,0.10); }
.qp-editing .qp-paint-switch span { left: 14px; background: #ffa56b; }
.qp-paint-switch:disabled { cursor: default; opacity: 0.5; }
.qp-paint-switch:focus-visible { outline: 1px solid var(--qp-text); outline-offset: 2px; }

/* One persistent DOM / bridge session, two arrangements of the same controls. */
:root { color-scheme: dark; }
.qp-power { flex: 0 0 24px; width: 24px; height: 24px; display:flex; align-items:center; justify-content:center; border:1px solid var(--qp-bdr); border-radius:7px; background:transparent; color:var(--qp-sec); cursor:pointer; }
.qp-power svg { width:15px; height:15px; }
.qp-power:hover { color:var(--qp-text); background:var(--qp-track); }
.qp-power.qp-on { color:var(--qp-acc-l); border-color:var(--qp-on-bdr); background:var(--qp-on-bg); }
.qp-power:disabled { opacity:.3; cursor:default; }
.qp-paint-label, .qp-edit-label { border:0; background:transparent; cursor:pointer; font-family:inherit; padding:2px 0; }
.qp-paint-label:disabled, .qp-edit-label:disabled { cursor:default; }
button:focus-visible, .qp-number input:focus-visible { outline:1px solid var(--qp-acc-l); outline-offset:2px; }
.qp-number { flex:0 0 35px; min-width:0; }
.qp-number > span { display:none; }
body.qp-narrow { overflow-y:auto; scrollbar-width:thin; scrollbar-color:var(--qp-dim) var(--qp-bg); }
.qp.qp-vertical { flex-direction:column; width:48px; max-width:calc(100% - 4px); height:auto; min-height:0; margin:2px; padding:7px 4px; gap:3px; }
.qp-vertical .qp-grip { width:14px; height:4px; flex-basis:4px; margin-bottom:4px; }
.qp-vertical .qp-grip svg { transform:rotate(90deg); }
.qp-vertical .qp-power { margin-bottom:6px; }
.qp-vertical .qp-btn { flex-basis:21px; height:21px; }
.qp-vertical .qp-pick-scope { flex-direction:column; width:34px; margin:1px 0 4px; }
.qp-vertical .qp-pick-scope button { height:18px; border-right:0; border-bottom:1px solid var(--qp-bdr); padding:0 2px; }
.qp-vertical .qp-pick-scope button:last-child { border-bottom:0; }
.qp-vertical .qp-div { width:24px; height:1px; margin:6px 0; }
.qp-vertical .qp-slc { display:contents; }
.qp-vertical .qp-range { display:none; }
.qp-vertical .qp-number { top:0; flex:0 0 auto; display:flex; flex-direction:column; align-items:center; gap:3px; width:100%; font-size:6.5px; color:var(--qp-sec); }
.qp-vertical .qp-number > span { display:block; }
.qp-number input { display:block; width:100%; height:15px; border:1px solid var(--qp-bdr); border-radius:4px; padding:1px; text-align:center; font:500 9px system-ui; font-variant-numeric:tabular-nums; background:#1a1a20; color:var(--qp-text); cursor:text; }
.qp-number input:not(:disabled):hover { border-color:var(--qp-on-bdr); }
.qp-vertical .qp-number input { height:20px; background:linear-gradient(var(--qp-accent),var(--qp-accent)) left bottom / var(--number-fill,0%) 1px no-repeat, #1a1a20; cursor:ns-resize; touch-action:none; }
.qp-number input:not([readonly]) { cursor:text; user-select:text; }
.qp-number input:disabled { opacity:.3; cursor:default; }
.qp-vertical .qp-paint-mode { flex:0 0 auto; flex-direction:column; gap:3px; margin:0 0 6px; }
.qp-vertical .qp-paint-label, .qp-vertical .qp-edit-label { width:32px; min-height:16px; }
.qp-vertical .qp-paint-switch { width:16px; height:26px; flex-basis:26px; }
.qp-vertical .qp-paint-switch span { top:2px; left:2px; }
.qp-vertical .qp-editing .qp-paint-switch span { top:12px; left:2px; }
.qp-vertical .qp-lbl { order:1; width:100%; margin:0; text-align:center; flex:0 0 auto; min-height:9px; height:auto; line-height:9px; letter-spacing:0; }
.qp-vertical .qp-lbl-t { white-space:normal; overflow-wrap:anywhere; }
.qp-vertical .qp-x { order:2; margin-top:4px; }
@media (prefers-reduced-motion:reduce) { .qp, .qp.qp-exit, .qp.qp-picking::after { animation:none; } }

/* Kept windows use Cinema's native docking/title handle, so dragging cannot
   accidentally move the C4D main window or reopen a dock as a popup. */
.qp.qp-kept .qp-grip { display:none; }

/* OFF keeps the remembered values/mode visible, but only Power can activate. */
.qp-inactive .qp-paint-mode, .qp-inactive .qp-number > span { opacity:.3; }
.qp-inactive::before, .qp-inactive::after { opacity:0; animation:none; }
.qp-inactive .qp-lbl { color:var(--qp-sec); }

/* Power confirmation stays legible even while the controls are disabled. */
.qp-inactive .qp-lbl:not(.power) { opacity:.3; }
.qp-lbl.say.power { color:var(--qp-acc-l); opacity:1; }
.qp-vertical .qp-lbl.power { font-size:6px; }

/* Kept/dockable viewer: the component begins at the native client edge.
   The transient popup retains its original entrance/shadow gutter. */
.qp.qp-kept { width:100%; height:32px; margin:0; box-shadow:none; }
/* The bar fills the window (a Windows floating window cannot be narrower than
   ~136px); its controls keep a 40px column in the middle. */
.qp.qp-kept.qp-vertical { width:100%; min-width:40px; height:auto; margin:0; padding:7px 3px; }
.qp.qp-kept.qp-vertical > *, .qp.qp-kept.qp-vertical .qp-slc > * { max-width:34px; }
.qp-kept.qp-vertical .qp-paint-label, .qp-kept.qp-vertical .qp-edit-label { width:100%; }
