/* NightKillerYT — Image Recolor (.rcl-*). Loaded after site.css, tools.css and tools-image.css on /tools/image-recolor
   only: it uses the image tools' shared bits (the drop area, the before / after line, the quick colors, the labels on
   the picture) and adds the toolbar, the stage, the list of recolors and its settings, in the same language:
   see-through glass, one pink accent, numbers in mono, dark fills only where the picture is shown.
   Sections: toolbar, stage, under the stage, the list of recolors, the selected recolor, small screens, touch,
   motion. */

.rcl .panel-title {
  color: var(--text);
  font: 650 15px/1.25 var(--font-display);
  letter-spacing: -0.02em;
  text-transform: none;
}

/* ---------- toolbar ---------- */
.rcl-toolbar {
  gap: 8px 10px;
}

.rcl-toolbar .segmented span {
  min-height: 38px;
  padding: 0 14px;
}

.rcl-tool-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.rcl-tool-buttons .btn-ghost[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.rcl-zoom {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}

.rcl-zoom .btn {
  border: 0;
}

.rcl-zoom-value {
  min-width: 56px;
  height: 36px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--text-2);
  font: 600 12.5px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  cursor: var(--nc-hand, pointer);
}

.rcl-zoom-value:hover {
  color: var(--text);
}

.rcl-zoom-value:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.rcl-brushbar {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 2px 6px 2px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.rcl-brushbar-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
}

.rcl-brushbar .range {
  flex: 1;
  min-width: 0;
}

.rcl-brushbar output {
  min-width: 56px;
  color: var(--text);
  font: 600 12.5px/1 var(--font-mono);
  text-align: right;
}

/* ---------- stage ---------- */
.rcl-stage {
  display: block;
  height: var(--rcl-stage-h, 460px);
  min-height: 0;
  background: rgba(8, 7, 11, 0.72);
  user-select: none;
  -webkit-user-select: none;
}

.stage .rcl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  cursor: crosshair;
  touch-action: pan-y;
}

.rcl-stage[data-mode="move"] .rcl-canvas {
  cursor: grab;
}

.rcl-stage.is-panning .rcl-canvas {
  cursor: grabbing;
}

@media (hover: hover) and (pointer: fine) {
  .rcl-stage[data-mode="add"] .rcl-canvas,
  .rcl-stage[data-mode="remove"] .rcl-canvas {
    cursor: none;
  }
}

/* The brush outline that follows the pointer (pink: add, white: remove). */
.rcl-brush {
  --size: 36px;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--size);
  height: var(--size);
  border: 1.5px solid var(--accent-ink);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease-out);
  will-change: transform;
}

.rcl-brush[data-mode="remove"] {
  border-color: #fff;
  border-style: dashed;
}

.rcl-brush.is-visible {
  opacity: 1;
}

.rcl-hint {
  top: 12px;
  left: 50%;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  white-space: nowrap;
}

.rcl-hint .icon {
  flex: none;
  color: var(--accent-ink);
}

.rcl-peek {
  top: 12px;
  left: 12px;
}

.rcl-working {
  right: 12px;
  bottom: 12px;
}

.rcl-ripple {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 3px solid var(--c);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
}

.rcl-editor.is-dragover .rcl-stage {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}

/* ---------- under the stage ---------- */
.rcl-under {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px 16px;
  margin-top: 10px;
}

.rcl-status {
  min-height: 1.5em;
  color: var(--text-3);
  font: 500 12.5px/1.6 var(--font-mono);
  overflow-wrap: anywhere;
}

.rcl-keys summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  cursor: var(--nc-hand, pointer);
}

.rcl-keys summary::-webkit-details-marker {
  display: none;
}

.rcl-keys summary:hover,
.rcl-keys[open] summary {
  color: var(--text);
}

.rcl-keys dl {
  display: grid;
  gap: 8px;
  min-width: 270px;
  margin: 6px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.rcl-keys dl > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
}

.rcl-keys dt {
  display: flex;
  gap: 4px;
}

.rcl-keys dd {
  margin: 0;
  color: var(--text-2);
}

.rcl-keys .kbd {
  min-width: 24px;
  height: 24px;
  font-size: 11.5px;
}

.rcl-actions {
  margin-top: 12px;
}

/* One download button under the picture on wide screens, one under the settings on phones (where the settings come
   after the picture). */
.rcl-actions.is-narrow {
  display: none;
  margin-top: 2px;
}

/* ---------- the list of recolors ---------- */
.rcl .panel .segmented label {
  flex: 1 1 auto;
}

.rcl .panel .segmented span {
  padding: 0 8px;
}

.rcl .switch + .field-hint {
  margin-top: -8px;
}

.rcl-palette-wrap {
  display: grid;
  gap: 10px;
}

/* The picture's main colors: plain round swatches; tapping one recolors that color everywhere. */
.rcl-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rcl-palette:empty {
  display: none;
}

.rcl-swatch {
  display: block;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: var(--nc-hand, pointer);
  transition:
    transform var(--medium) var(--ease-out),
    box-shadow var(--medium) var(--ease-out);
}

.rcl-swatch:hover {
  transform: scale(1.08);
}

.rcl-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.rcl-rows {
  display: grid;
  gap: 6px;
}

/* A recolor: old color → new color, its new color's code and where it works, then show / hide and remove. */
.rcl-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  transition:
    border-color var(--medium) var(--ease-out),
    background-color var(--medium) var(--ease-out);
}

.rcl-row:hover {
  border-color: var(--glass-border-hover);
}

.rcl-row.is-selected {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.rcl-row-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px 0 6px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: var(--nc-hand, pointer);
}

.rcl-row-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.rcl-chip {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.rcl-row-arrow {
  display: grid;
  flex: none;
  color: var(--text-3);
}

.rcl-row-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin-left: 4px;
}

.rcl-row-text strong {
  color: var(--text);
  font: 600 13px/1.2 var(--font-mono);
}

.rcl-row-text span {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rcl-row .btn-icon {
  flex: none;
  color: var(--text-3);
}

.rcl-row .btn-icon:hover {
  color: var(--text);
}

.rcl-row-remove:hover {
  color: #ff8a8a;
}

.rcl-row.is-off .rcl-row-main {
  opacity: 0.5;
}

/* ---------- the selected recolor ---------- */
.rcl-editor-box {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: rgba(8, 7, 11, 0.35);
}

.rcl-editor-box[hidden] {
  display: none;
}

.rcl-swatches {
  margin-top: 4px;
}

.rcl-from {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.rcl-from .field-label {
  flex: 1 0 auto;
}

.rcl-from-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rcl-from-value code {
  color: var(--text-2);
  font: 600 12.5px/1 var(--font-mono);
}

.rcl-from .btn[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.rcl-brush-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-3);
  font-size: 13px;
}

.rcl-brush-note[hidden] {
  display: none;
}

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .rcl-keys {
    display: none;
  }

  .rcl-actions.is-wide {
    display: none;
  }

  .rcl-actions.is-narrow {
    display: flex;
  }
}

@media (max-width: 600px) {
  .rcl-toolbar > .segmented {
    flex: 1 1 100%;
  }

  .rcl-toolbar > .segmented label {
    flex: 1 1 0;
  }

  .rcl-toolbar .segmented span {
    padding: 0 6px;
  }

  .rcl-tool-buttons {
    flex: 1 1 100%;
  }

  .rcl-zoom {
    margin-left: auto;
  }

  .rcl-actions .btn-lg {
    flex: 1 1 100%;
  }

  .rcl-hint {
    top: 8px;
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .rcl-tool-buttons {
    gap: 2px;
  }

  .rcl-tool-buttons [data-rcl-selection] {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .rcl-tool-buttons [data-rcl-selection] span {
    display: none;
  }

  .rcl-tool-buttons [data-rcl-compare] {
    padding-inline: 8px;
  }

  .rcl-zoom-value {
    min-width: 40px;
  }
}

/* Touch screens: every button and slider here is at least 40 px tall to hit. */
@media (pointer: coarse) {
  .rcl .btn-sm {
    min-height: 40px;
  }

  .rcl .range {
    height: 40px;
  }

  .rcl .btn-sm.btn-icon {
    width: 40px;
  }

  .rcl-zoom-value {
    height: 40px;
  }

  .rcl-swatch {
    width: 40px;
    height: 40px;
  }
}

/* ---------- motion ---------- */
@keyframes rcl-ripple {
  from {
    opacity: 1;
    transform: scale(0.4);
  }
  to {
    opacity: 0;
    transform: scale(1.4);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .rcl-ripple {
    animation: rcl-ripple 650ms var(--ease-out) forwards;
  }

  .rcl-editor-box:not([hidden]) {
    animation: img-rise var(--slow) var(--ease-out);
  }
}
