/* ================================================================
   CUSTOM TINTS - styles for the custom tint builder modal
   and the custom tints section in the grid.
   ================================================================ */

/* ── Custom Tint button in meta actions strip — tertiary text style ── */
.btn-custom {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 8px 10px;
  cursor: pointer;
  transition: color .15s;
}
.btn-custom:hover    { color: var(--text); }
.btn-custom:disabled { opacity: .18; cursor: default; }

/* ── Custom builder modal (wider than multitint modal) ── */
#customModal .modal-box {
  width: 520px;
  max-width: calc(100vw - 32px);
  gap: 14px;
}

/* ── Two-column layout inside modal ── */
.ctb-cols {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.ctb-col-left  { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.ctb-col-right { width: 130px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }

/* ── Section label (small caps) ── */
.ctb-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ── Form rows ── */
.ctb-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctb-input {
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  padding: 7px 10px;
  width: 100%;
  transition: border-color .15s;
}
.ctb-input:focus {
  outline: none;
  border-color: var(--bd-hi);
}

.ctb-select {
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  padding: 7px 10px;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s;
}
.ctb-select:focus { outline: none; border-color: var(--bd-hi); }

/* ── Inline row (e.g. label + toggle) ── */
.ctb-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctb-inline .ctb-label { margin-bottom: 0; }

/* ── Toggle switch ── */
.ctb-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.ctb-toggle input { opacity: 0; width: 0; height: 0; }
.ctb-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 18px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.ctb-toggle input:checked + .ctb-toggle-track {
  background: rgba(128,238,192,.2);
  border-color: var(--ice);
}
.ctb-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}
.ctb-toggle input:checked + .ctb-toggle-track::after {
  transform: translateX(14px);
  background: var(--ice);
}

/* ── Hex colour text input ── */
.ctb-hex-input {
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 8px;
  width: 80px;
  letter-spacing: .04em;
  transition: border-color .15s, color .15s;
}
.ctb-hex-input:focus { outline: none; border-color: var(--bd-hi); }
.ctb-hex-input.invalid { border-color: var(--err); color: var(--err); }

/* ── Number input ── */
.ctb-num {
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  padding: 7px 8px;
  width: 64px;
  transition: border-color .15s;
}
.ctb-num:focus { outline: none; border-color: var(--bd-hi); }

/* ── Gradient stop editor ── */
.ctb-stops {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 2px;
}

.ctb-stop-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctb-stop-color {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.ctb-stop-color::-webkit-color-swatch-wrapper { padding: 0; }
.ctb-stop-color::-webkit-color-swatch { border: 1.5px solid rgba(128,238,192,.25); border-radius: 3px; }

.ctb-stop-pos {
  width: 52px;
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  padding: 5px 7px;
  transition: border-color .15s;
}
.ctb-stop-pos:focus { outline: none; border-color: var(--bd-hi); }

.ctb-stop-del {
  background: none;
  border: 1px solid rgba(128,238,192,.12);
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  padding: 4px 7px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  line-height: 1;
}
.ctb-stop-del:hover { border-color: #ff5555; color: #ff5555; }

.ctb-add-stop {
  align-self: flex-start;
  background: none;
  border: 1px solid rgba(128,238,192,.15);
  border-radius: 4px;
  color: var(--muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ctb-add-stop:hover { border-color: var(--ice); color: var(--ice); }

/* ── Live preview thumbnail (in modal right column) ── */
.ctb-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ctb-preview-canvas-wrap {
  width: 120px;
  height: 120px;
  background: repeating-conic-gradient(#0a1a2a 0% 25%, #071525 0% 50%) 0 0 / 12px 12px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.ctb-preview-canvas-wrap canvas {
  max-width: 120px;
  max-height: 120px;
  display: block;
}
.ctb-preview-hint {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ── Load from baseline ── */
.ctb-baseline-wrap {
  display: flex;
  gap: 5px;
  align-items: center;
}
.ctb-baseline-select {
  flex: 1;
  background: var(--dim);
  border: 1px solid var(--bd);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  padding: 6px 8px;
  cursor: pointer;
}
.ctb-baseline-select:focus { outline: none; border-color: var(--bd-hi); }

.ctb-baseline-btn {
  background: none;
  border: 1px solid rgba(128,238,192,.2);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.ctb-baseline-btn:hover { border-color: rgba(128,238,192,.45); color: var(--ice); }

/* ── Custom grid section cells: edit/delete overlay ── */
.tcell.custom-cell .tcell-inner {
  position: relative;
}
.tcell.custom-cell .tcell-inner:hover .tcell-custom-actions {
  opacity: 1;
}
.tcell-custom-actions {
  position: absolute;
  inset: 0;
  background: rgba(0,8,18,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0;
  transition: opacity .15s;
  border-radius: 4px;
}
.tcell-custom-action-btn {
  background: none;
  border: 1px dashed rgba(128,238,192,.3);
  border-radius: 3px;
  color: var(--text);
  font-size: 9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  padding: 4px 7px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  line-height: 1;
}
.tcell-custom-action-btn:hover     { border-color: var(--ice); color: var(--ice); }
.tcell-custom-action-btn.del:hover { border-color: #ff5555;    color: #ff5555;    }

.tcell-del-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tcell-del-prompt {
  font-size: 9px;
  font-weight: 700;
  color: #ff5555;
  white-space: nowrap;
  letter-spacing: .03em;
}

/* ── Deletion confirmation modal overlay ── */
.ctb-delete-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,8,18,.72);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}
.ctb-delete-overlay.active {
  display: flex;
}
.ctb-delete-dialog {
  background: #020f1e;
  border: 1px dashed rgba(128,238,192,.18);
  border-radius: 10px;
  padding: 28px 32px 24px;
  min-width: 260px;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.ctb-delete-msg {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
  text-transform: none;
  letter-spacing: 0;
}
.ctb-delete-msg span {
  color: #ff5555;
  text-transform: none;
  letter-spacing: normal;
}
.ctb-delete-sub {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 22px;
}
.ctb-delete-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.ctb-delete-btn {
  background: none;
  border: 1px dashed rgba(128,238,192,.3);
  border-radius: 3px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 7px 20px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ctb-delete-btn.cancel:hover  { border-color: var(--ice); color: var(--ice); }
.ctb-delete-btn.confirm       { border-color: rgba(255,85,85,.5); color: #ff5555; }
.ctb-delete-btn.confirm:hover { border-color: #ff5555; color: #ff5555; }

/* ── Export / Import row in modal footer ── */
.ctb-io-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ctb-io-btn {
  background: none;
  border: 1px solid rgba(128,238,192,.14);
  border-radius: 4px;
  color: var(--muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ctb-io-btn:hover { border-color: rgba(128,238,192,.4); color: var(--ice); }

/* ── Conditional show/hide driven by tint type ── */
.ctb-solid-only, .ctb-grad-only, .ctb-anim-only { display: none; }

/* ── Divider ── */
.ctb-divider {
  border: none;
  border-top: 1px solid var(--bd);
  margin: 2px 0;
}

/* ================================================================
   CUSTOM TINTS — additions: wider modal, sliders, help panel,
   mobile layout, touch-active state
   ================================================================ */

/* ── Wider modal ── */
#customModal .modal-box {
  width: 720px;
}

/* ── Range slider ── */
.ctb-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.ctb-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bd-hi);
  outline: none;
  cursor: pointer;
}
.ctb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ice);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px rgba(128,238,192,.2);
  transition: box-shadow .15s;
}
.ctb-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px rgba(128,238,192,.25);
}
.ctb-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ice);
  cursor: pointer;
  border: none;
}

/* Stop rows with slider */
.ctb-stop-row {
  gap: 8px;
}
.ctb-stop-row .ctb-slider {
  width: 80px;
  flex: none;
}

/* ── Help panel ── */
.ctb-help-btn {
  background: none;
  border: 1px solid rgba(128,238,192,.18);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  margin-right: 6px;
}
.ctb-help-btn:hover,
.ctb-help-btn.active { border-color: var(--ice); color: var(--ice); }

.ctb-help-panel {
  background: rgba(128,238,192,.04);
  border: 1px dashed rgba(128,238,192,.14);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ctb-help-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.ctb-help-term {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ice);
  width: 82px;
  flex-shrink: 0;
}
.ctb-help-desc {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Touch-active state for custom cell actions ── */
.tcell.custom-cell.touch-show .tcell-custom-actions {
  opacity: 1;
}

/* ── Mobile: full-width modal, single column ── */
@media (max-width: 600px) {
  #customModal .modal-box {
    width: calc(100vw - 24px);
    padding: 18px 16px 16px;
    max-height: calc(100vh - 32px);
  }

  .ctb-cols {
    flex-direction: column;
  }

  .ctb-col-right {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }

  .ctb-preview-canvas-wrap {
    width: 90px;
    height: 90px;
  }

  /* On small screens, always show custom cell actions (no hover) */
  .tcell.custom-cell .tcell-custom-actions {
    opacity: 1;
    background: rgba(0,8,18,.55);
  }
}

/* ================================================================
   GRADIENT BAR EDITOR - Photoshop-style draggable stop handles
   ================================================================ */

.grad-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* The gradient preview bar */
.grad-bar {
  height: 28px;
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--bd);
  border-bottom: none;
  background: #333;
  cursor: crosshair;
  position: relative;
}

/* Track where handles sit */
.grad-track {
  position: relative;
  height: 20px;
  background: rgba(128,238,192,.04);
  border: 1px solid var(--bd);
  border-top: 2px solid rgba(128,238,192,.12);
  border-radius: 0 0 4px 4px;
  margin-bottom: 6px;
}

/* Individual stop handle: upward-pointing arrow below the bar */
.grad-handle {
  position: absolute;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid rgba(128,238,192,.3);
  transform: translateX(-50%);
  cursor: grab;
  box-sizing: border-box;
  transition: border-color .12s, box-shadow .12s;
  touch-action: none;
}
.grad-handle::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: rgba(128,238,192,.4);
}
.grad-handle:hover   { border-color: var(--ice); }
.grad-handle.sel     {
  border-color: var(--ice);
  box-shadow: 0 0 0 2px rgba(128,238,192,.3);
  z-index: 2;
}
.grad-handle:active  { cursor: grabbing; }

/* Detail row for selected stop */
.grad-detail {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: rgba(128,238,192,.04);
  border: 1px dashed rgba(128,238,192,.14);
  border-radius: 4px;
  margin-bottom: 4px;
}
.grad-detail .ctb-slider { flex: 1; }
.grad-detail .ctb-stop-pos { width: 48px; }

/* Bigger preview canvas wrap */
.ctb-preview-canvas-wrap {
  width: 200px !important;
  height: 200px !important;
}
.ctb-preview-canvas-wrap canvas {
  max-width: 200px !important;
  max-height: 200px !important;
}
.ctb-col-right {
  width: 210px !important;
}

/* ── Direction slider control ── */
.ctb-dir-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ctb-dir-ticks-360 {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}
.ctb-dir-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ice);
  text-align: center;
}

/* ── Save confirmation flash ── */
.ctb-saved-msg {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #5fffb0;
  opacity: 0;
  transition: opacity .25s;
  align-self: center;
}
.ctb-saved-msg.show { opacity: 1; }

/* ── Mobile: custom cell actions as always-visible bottom bar ── */
@media (max-width: 600px) {
  .tcell.custom-cell .tcell-inner {
    position: relative;
    overflow: visible;
  }
  .tcell-custom-actions {
    position: static !important;
    opacity: 1 !important;
    background: transparent !important;
    border-radius: 0;
    gap: 6px;
    padding: 4px 0 0;
  }
  .tcell-custom-action-btn {
    padding: 6px 10px;
    font-size: 10px;
    min-height: 28px;
    border-color: rgba(128,238,192,.25);
    flex: 1;
  }
}

/* ── Save toast (fixed position, outside modal) ── */
.save-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,10,20,.92);
  border: 1px solid rgba(95,255,176,.45);
  color: #5fffb0;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
}
.save-toast.show { opacity: 1; }

/* ── Smooth handle dragging optimisation ── */
.grad-bar   { will-change: background; }
.grad-handle { will-change: left; transition: none !important; }
/* Easter egg toast variant */
.egg-toast {
  border-color: rgba(255, 220, 80, .55);
  color: #ffdc50;
  font-size: 13px;
}
.egg-toast.show { opacity: 1; }
