/* ── LED Scroller · "precision instrument panel" ──────────────────────────
   Gold-on-charcoal control surface matching the watch-go brand system.
   The preview is a glowing display window framed in a machined bezel; the
   controls read as tactile switches on a studio panel. Uses site tokens
   (--color-primary gold, --font-display Playfair) and works in both themes. */

.led-tool {
  --nav-h: 66px;                 /* offset for the fixed-top GNB */
  --panel: var(--color-bg-surface);
  --stroke: var(--color-border);
  --gold: var(--color-primary);
}

/* ── Glowing preview, sticks just below the fixed nav ────────────────── */
.led-stage-wrap {
  position: sticky;
  top: calc(var(--nav-h) + 12px);
  z-index: 20;
  padding: 12px 0;
  margin-bottom: 20px;
  background: var(--color-bg);
}
.led-bezel {
  position: relative;
  padding: 10px;
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.06), rgba(0,0,0,0.35)),
    #16161a;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 -2px 6px rgba(0,0,0,0.6);
}
.led-bezel::after {                /* gold status pip, like a power LED */
  content: "";
  position: absolute;
  top: 18px; right: 20px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px 1px var(--gold);
  animation: led-pip 2.4s ease-in-out infinite;
}
@keyframes led-pip { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
.led-preview {
  height: 128px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
}

/* ── Panel card holding the controls ─────────────────────────────────── */
.led-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 20px;
  padding: var(--wg-space-6);
}
.led-field { min-width: 0; }                 /* prevent grid blowout */
.led-field--wide { grid-column: 1 / -1; }
.led-field > label,
.led-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--color-text);
  margin-bottom: 10px;
}
.led-badge {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 22px; padding: 0 7px;
  margin-left: 4px;
  font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--color-bg); background: var(--gold);
  border-radius: var(--radius-pill);
}

/* Text input — shared field look */
.led-field input[type=text] {
  width: 100%;
  padding: 12px 14px;
  font-size: var(--fs-base);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
.led-field input[type=text]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

/* ── Custom font dropdown (styled listbox + up/down steppers) ─────────── */
.led-fontselect { position: relative; display: flex; gap: 8px; }
.led-fontselect-trigger {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  font-size: var(--fs-base); font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.led-fontselect-trigger:focus-visible,
.led-fontselect:focus-within .led-fontselect-trigger {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}
.led-fontselect-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.led-fontselect-caret {
  flex: none; width: 8px; height: 8px; margin-right: 2px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s;
}
.led-fontselect-trigger[aria-expanded="true"] .led-fontselect-caret {
  transform: translateY(2px) rotate(225deg);
}

/* Up/down stepper buttons — match the trigger's full height (stretch + split evenly) */
.led-fontselect-steppers {
  flex: none; align-self: stretch;
  display: flex; flex-direction: column; gap: 4px;
  width: 38px;
}
.led-fontstep {
  flex: 1 1 0; min-height: 0;
  display: grid; place-items: center;
  width: 100%; padding: 0;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--stroke);
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.led-fontstep:hover { color: var(--color-bg); background: var(--gold); border-color: var(--gold); }
.led-fontstep:active { transform: translateY(1px); }
.led-fontstep:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--color-primary-subtle); }

/* Popup option list */
.led-fontselect-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 50;
  margin: 0; padding: 6px; list-style: none;
  max-height: 320px; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  /* Themed scrollbar (Firefox). */
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-muted) transparent;
}
.led-fontselect-list[hidden] { display: none; }
/* Themed scrollbar (WebKit/Blink). */
.led-fontselect-list::-webkit-scrollbar { width: 10px; }
.led-fontselect-list::-webkit-scrollbar-track { background: transparent; }
.led-fontselect-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border: 3px solid var(--panel);   /* inset look: thumb padded from the edge */
  border-radius: 999px;
}
.led-fontselect-list::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }
.led-fontselect-option {
  padding: 10px 12px;
  font-size: var(--fs-base);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.led-fontselect-option:hover { background: var(--color-bg-tag); }
.led-fontselect-option.active {
  color: var(--color-bg); background: var(--gold);
}

/* ── Segmented control — tactile switch bank ─────────────────────────── */
.led-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--color-bg);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  max-width: 100%;
}
.led-seg button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--wg-button-height);
  padding: var(--wg-space-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--wg-text);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background .15s, box-shadow .15s;
}
.led-seg button:hover { color: var(--color-text); }
.led-seg button.active {
  color: var(--wg-accent);
  background: var(--wg-gold-surface);
}

/* ── Color swatches ──────────────────────────────────────────────────── */
.led-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}
.led-swatch {
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  /* No border: a border would leave the swatch's gradient starting inside the padding-box,
     so the left/right edges (under the border) render dark. The ring is drawn entirely
     OUTSIDE the fill via box-shadow, so the colour reaches every edge. */
  border: none;
  box-shadow: 0 0 0 1px var(--color-border);
  transition: transform .12s, box-shadow .12s;
  position: relative;
}
.led-swatch:hover { transform: translateY(-2px); }
.led-swatch.active {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--gold);
}
/* Custom-colour swatch: same size/shape as a preset swatch, sits as the last grid cell.
   The native colour input fills the cell (invisible) so clicking anywhere opens the picker;
   a "+" glyph sits on top to signal "pick your own". */
.led-swatch--custom {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.led-swatch--custom input[type=color] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0; border: none;
  opacity: 0; cursor: pointer;
}
.led-swatch-plus {
  position: relative;
  font-size: 20px; font-weight: 700; line-height: 1;
  color: #fff;
  text-shadow: 0 0 3px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* ── Range slider ────────────────────────────────────────────────────── */
input[type=range]#ls-speed {
  width: 100%; height: 6px; margin: 6px 0;
  -webkit-appearance: none; appearance: none;
  background: linear-gradient(90deg, var(--gold), var(--color-primary-light));
  border-radius: var(--radius-pill);
  cursor: pointer;
}
#ls-speed::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-bg);
  border: 3px solid var(--gold);
  box-shadow: var(--shadow-gold);
  transition: transform .12s;
}
#ls-speed::-webkit-slider-thumb:hover { transform: scale(1.12); }
#ls-speed::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-bg); border: 3px solid var(--gold);
  box-shadow: var(--shadow-gold);
}

/* ── Toggle switches ─────────────────────────────────────────────────── */
.led-switches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 16px;
}
.led-switch {
  position: relative;
  display: inline-flex; align-items: center; gap: 12px;
  cursor: pointer; user-select: none;
}
.led-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.led-switch-track {
  flex: none;
  position: relative;
  width: 42px; height: 24px;
  background: var(--color-bg);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-pill);
  transition: background .2s, border-color .2s;
}
.led-switch-track::before {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--color-text-muted);
  transition: transform .2s, background .2s;
}
.led-switch input:checked + .led-switch-track {
  background: var(--gold); border-color: var(--gold);
}
.led-switch input:checked + .led-switch-track::before {
  transform: translateX(18px); background: var(--color-bg);
}
.led-switch input:focus-visible + .led-switch-track {
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}
.led-switch-label { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text); }

/* ── Actions ─────────────────────────────────────────────────────────── */
.led-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 0; }
/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .led-tool { --nav-h: 60px; }
  .led-stage-wrap { position: static; }
  .led-panel { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .led-preview { height: 100px; }
  .led-actions .wg-button { flex: 1 1 100%; }
}

/* ── Fullscreen playback overlay (JS-created; mirrors led-share) ──────── */
#ledPlaybackOverlay { position: fixed; inset: 0; z-index: 9999; overflow: hidden; }
#ledPlaybackHost { position: absolute; inset: 0; }
#ledPlaybackClose {
  position: absolute; top: 16px; right: 20px; z-index: 10000;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
  transition: background .2s;
}
#ledPlaybackClose:hover { background: rgba(255,255,255,0.3); }
#ledPlaybackHost .led-track { padding: 0 0.2em; }

/* Keyboard focus is independent from the selected fill/ring. */
.led-tool button:focus:not(:focus-visible) { outline: none; }
.led-tool button:focus-visible, .led-tool input:focus-visible,
.led-swatch--custom:has(input:focus-visible) {
  outline: 2px solid var(--wg-accent); outline-offset: 3px;
}
.led-switch:has(input:focus-visible) { outline: 2px solid var(--wg-accent); outline-offset: 3px; }
.led-fontstep { min-height: 44px; }
.led-swatch { height: 44px; }
.led-switch { min-height: 44px; }
.led-actions svg { flex: none; }
@media (prefers-reduced-motion: reduce) { .led-bezel::after { animation: none; } }
