/* ==========================================================================
   rgb.css: RGB Lighting page. Preview first (what's selected, whether it's
   on the keyboard, Live Sync, the keyboard itself), then an effects gallery
   and an Adjust card. Also the app-wide level slider.
   ========================================================================== */

.rgb-layout { display: flex; flex-direction: column; gap: var(--sp-5); }

/* ---------------------------------------------------------------- preview */
.rgb-preview-card { padding: var(--sp-5) var(--sp-5) var(--sp-4); }

.rgb-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.rgb-now { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.rgb-now-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--ink);
  color: var(--lime);
  box-shadow: var(--shadow-sm);
}
.rgb-now-icon.is-bumped svg { animation: pop-in 380ms var(--spring) both; }
.rgb-now-text { display: flex; flex-direction: column; min-width: 0; }
.rgb-now-text .eyebrow { line-height: 1.3; }
.rgb-now-text h3 { font-size: 22px; font-weight: 600; letter-spacing: var(--tracking-tight); line-height: 1.2; }

.lighting-state-bar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-left: var(--sp-2); }
.lighting-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  animation: pop-in var(--t-med) var(--ease-out) both;
}
.lighting-state-badge svg { width: 14px; height: 14px; }
.lighting-state-badge.verified { background: var(--success-soft); border-color: var(--success-border); color: var(--success-ink); }
.lighting-state-badge.pending  { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-ink); }

/* Live Sync switch with a plain explanation */
.live-sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.live-sync-toggle:hover { border-color: var(--line-strong); }
.live-sync-toggle:has(input:checked) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-ink) 35%, var(--line)); }
.live-sync-text { display: flex; flex-direction: column; line-height: 1.3; }
.live-sync-text strong { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); }
.live-sync-text small { font-size: var(--fs-xs); color: var(--muted); }

#tab-backlight .keyboard-stage { margin-inline: auto; }

.rgb-preview-foot {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}
.rgb-desc { font-size: var(--fs-ctl); color: var(--muted); min-height: 1.5em; }
.rgb-preview-foot .reactive-guide-bar { margin-top: 0; }

.preset-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.preset-label { display: inline-flex; align-items: center; gap: 6px; margin-right: var(--sp-1); font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3) 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--text);
  font: 500 var(--fs-sm)/1 var(--font-ui);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.preset-chip:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.preset-chip:active { transform: scale(0.97); }
.preset-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.preset-swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); }
/* preset swatches show the hardware colours they set (user content) */
.preset-swatch.is-rainbow { background: conic-gradient(#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000); }
.preset-swatch.is-cyan    { background: radial-gradient(circle at 35% 35%, #ffffff, #00ffff 55%, #007a7a); }
.preset-swatch.is-pulse   { background: radial-gradient(circle, #00ffff 0 35%, color-mix(in srgb, #00ffff 25%, transparent) 36% 100%); }
.preset-swatch.is-off     { background: var(--well-dark); }

/* ------------------------------------------------------- controls grid */
.rgb-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: var(--sp-5);
  align-items: start;
}

/* effect filters */
.effect-filters {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.effect-filter {
  height: 30px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: 500 var(--fs-sm)/1 var(--font-ui);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.effect-filter:hover { color: var(--text); }
.effect-filter.is-on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.effect-filter:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* effect tiles: every effect visible, no inner scroll box */
#tab-backlight .mode-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-2);
  max-height: none;
  overflow: visible;
  padding: 0;
  border: 0;
  background: none;
}
#tab-backlight .mode-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
  animation: pop-in var(--t-med) var(--ease-out) both;
}
#tab-backlight .mode-tile[hidden] { display: none; }
#tab-backlight .mode-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
#tab-backlight .mode-tile:active { transform: scale(0.98); }
#tab-backlight .mode-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#tab-backlight .mode-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--panel-2);
  color: var(--muted);
  transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out);
}
#tab-backlight .mode-tile-name { flex: 1; min-width: 0; font-size: var(--fs-ctl); font-weight: 500; line-height: 1.3; }
.mode-tile-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 16px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--info-soft);
  color: var(--info-ink);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.02em;
}
#tab-backlight .mode-tile.active {
  border-color: var(--ink);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--ink), var(--shadow-sm);
}
#tab-backlight .mode-tile.active .mode-tile-icon { background: var(--ink); color: var(--lime); }
#tab-backlight .mode-tile.active .mode-tile-name { font-weight: 600; }

/* ----------------------------------------------------------- level slider */
.level-field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.level-field[hidden] { display: none; }
.level-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.level-head label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-ctl); font-weight: 600; color: var(--text); }
.level-head label svg { color: var(--muted); }
.level-value {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  min-width: 44px;
  justify-content: center;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--panel-2);
  font: 600 var(--fs-sm)/26px var(--font-mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.level-max { color: var(--muted); font-weight: 500; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  --pct: 50%;
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--ink) 0 var(--pct), var(--line-soft) var(--pct) 100%);
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: var(--r-pill); background: var(--line-soft); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: var(--r-pill); background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--spring);
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--lime); border: 2px solid var(--ink); }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.1); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(0.95); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--focus); }

.level-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 7px;
  font: 500 var(--fs-2xs)/1 var(--font-mono);
  color: var(--muted);
}

/* colour chips */
#tab-backlight .palette-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.swatch-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  cursor: pointer;
  transition: transform var(--t-fast) var(--spring), box-shadow var(--t-fast) var(--ease-out);
}
.swatch-circle:hover { transform: scale(1.08); }
.swatch-circle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.swatch-circle.selected { box-shadow: 0 0 0 2px var(--ring-gap), 0 0 0 4px var(--ring-edge); transform: scale(1.04); }

.rgb-apply-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-soft);
}
.rgb-apply-hint { font-size: var(--fs-xs); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 1100px) {
  .rgb-controls { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .rgb-preview-card { padding: var(--sp-4); }
  .lighting-state-bar { margin-left: 0; width: 100%; }
  .live-sync-toggle { width: 100%; }
  #tab-backlight .mode-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rgb-apply-row .btn-action-primary { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  #tab-backlight .mode-tile, .lighting-state-badge, .rgb-now-icon.is-bumped svg { animation: none; }
}

/* the state badges sit inline in the preview header (no legacy box) */
#tab-backlight .lighting-state-bar { border: 0; background: none; padding: 0; box-shadow: none; min-height: 0; }
