/*!
 * 123PhotoTool — Color Scheme Designer (color-scheme.php).
 *
 * The page uses the shared tool layout (pt-ui.css), the shared colour parts
 * (pt-color.css) and, with a photo on a phone, the full-screen editor
 * (pt-app.css). This file is what the tool adds: the wheel and its circles,
 * the swatches under it, the sliders, the harmony buttons, the scheme rows
 * and the live preview.
 */

/* ── The selected colour ───────────────────────────────────────────────── */
.cs-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  font-size: 0.78rem;
  font-weight: 700;
}
.cs-base-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pt-surface, #f6f8fb);
  color: var(--pt-muted, #6c757d);
  font-size: 0.72rem;
  font-weight: 600;
}
.cs-base-tag[hidden] { display: none; }

/* ── Sliders: each track shows what it does to the colour ──────────────── */
.cs-slider + .cs-slider { margin-top: 10px; }
.cs-slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cs-slider-head output { font: 600 0.8rem/1 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); color: var(--pt-muted, #6c757d); direction: ltr; }
.cs-slider-ends { display: flex; justify-content: space-between; color: var(--pt-muted, #6c757d); margin-top: -2px; }
.cs-range { --cs-track: #e3e7ee; }
.cs-range-hue { --cs-track: linear-gradient(to right, #f00, #ff0 16.67%, #0f0 33.33%, #0ff 50%, #00f 66.67%, #f0f 83.33%, #f00); }
.cs-range-sat { --cs-track: var(--cs-sat-track, linear-gradient(to right, #8c8c8c, #3f78e0)); }
.cs-range-light { --cs-track: var(--cs-light-track, linear-gradient(to right, #000, #3f78e0, #fff)); }
[dir="rtl"] .cs-range { direction: ltr; }
.cs-range::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: var(--cs-track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.cs-range::-moz-range-track { height: 10px; border-radius: 5px; background: var(--cs-track); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.cs-range::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -5px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.cs-range::-moz-range-thumb { width: 20px; height: 20px; background: #fff; border: 2px solid var(--pt-ink, #343f52); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }

/* ── Harmony rules ─────────────────────────────────────────────────────── */
/* Two to a row; a label whose longest word needs more takes the row
   (a fixed two-column grid chopped "Monochromatic" mid-word). */
.cs-harmony { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-hbtn {
  flex: 1 1 calc(50% - 3px);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  color: var(--pt-ink, #343f52);
  font-size: 13.6px;
  font-weight: 600;
  line-height: 1.2;
  text-align: start;
}
.cs-hbtn svg { flex: none; width: 22px; height: 22px; }
.cs-hbtn span { min-width: 0; }
.cs-hbtn:hover { border-color: var(--pt-accent, #0f70e6); }
.cs-hbtn:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 1px; }
.cs-hbtn.active { border-color: var(--pt-accent, #0f70e6); background: var(--pt-accent-soft, rgba(15, 112, 230, 0.1)); color: var(--pt-accent, #0f70e6); }
/* The 320px panel: the icon over the label leaves a half-width tile room
   for "Monochromatic". */
@media (min-width: 768px) and (max-width: 991.98px) {
  .cs-hbtn { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 6px; text-align: center; }
}
.cs-desc { margin-top: 8px; color: var(--pt-muted, #6c757d); font-size: 13.6px; line-height: 1.45; }

/* ── The scheme ────────────────────────────────────────────────────────── */
.cs-scheme-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cs-codes .btn { padding: 2px 10px; font-size: 0.78rem; }
/* [dir="rtl"] too: style.css gives RTL lists padding-right: 2rem at (0,1,1), above a class. */
.cs-list, [dir="rtl"] .cs-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.cs-row {
  display: flex;
  align-items: stretch;
  min-height: 50px;
  border: 1px solid var(--pt-line, #e3e7ee);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.cs-row.cs-active { border-color: var(--pt-accent, #0f70e6); box-shadow: 0 0 0 2px var(--pt-accent-soft, rgba(15, 112, 230, 0.15)); }
.cs-row-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--pt-ink, #343f52);
  text-align: start;
}
.cs-row-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pt-surface, #eef1f5);
  color: var(--pt-muted, #6c757d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1; /* an Arabic line box overflowed the 22px circle */
}
.cs-active .cs-row-num { background: var(--pt-accent, #0f70e6); color: #fff; }
.cs-row-swatch {
  flex: 0 0 48px;
  height: 36px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}
/* The code over its contrast pill. A long code (rgb, hsl) wraps at its
   spaces rather than being cut to "#…". */
.cs-row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.cs-row-code { max-width: 100%; font: 600 13px/1.25 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); direction: ltr; }
.cs-row-ratio {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  direction: ltr;
  cursor: help;
}
.cs-row-ratio.cs-ok { background: rgba(25, 135, 84, 0.12); color: #146c43; }
.cs-row-ratio.cs-large { background: rgba(250, 183, 88, 0.2); color: #8a5a10; }
.cs-row-ratio.cs-low { background: rgba(220, 53, 69, 0.1); color: #b02a37; }
.cs-row .pt-ccopy { flex: 0 0 44px; }
.cs-format-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#cs-copy-all { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* ── The workspace: the wheel (or the photo), the swatches, the upload ─── */
#cs-viewport { display: flex; flex-direction: column; overflow: hidden; }
.cs-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.cs-wheel { position: relative; flex: none; width: 300px; height: 300px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; direction: ltr; }
.cs-disc, .cs-shade { position: absolute; inset: 0; border-radius: 50%; }
/* HSL exactly: the hue round the rim (a conic gradient through the six
   primaries is HSL's hue), mixed towards grey in the middle. */
.cs-disc {
  background: radial-gradient(circle closest-side, #808080, rgba(128, 128, 128, 0)), conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 8px 28px rgba(30, 34, 40, 0.14);
}
.cs-shade { pointer-events: none; }
.cs-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.55)); }
.cs-lines line { stroke: #fff; stroke-width: 2; stroke-linecap: round; opacity: 0.9; }
.cs-handles { position: absolute; inset: 0; }
.cs-handle {
  position: absolute;
  z-index: 1;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}
.cs-handle-base { z-index: 2; width: 40px; height: 40px; margin: -20px 0 0 -20px; font-size: 0.85rem; }
.cs-handle.cs-active { z-index: 3; box-shadow: 0 0 0 2px #1e2228, 0 0 0 5px rgba(255, 255, 255, 0.9), 0 3px 10px rgba(0, 0, 0, 0.4); }
.cs-handle:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 4px; }
.cs-dragging, .cs-dragging .cs-handle { cursor: grabbing; }
@media (pointer: coarse) {
  .cs-handle { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
  .cs-handle-base { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
}
/* The photo instead of the wheel. */
.cs-main.cs-photo-view > .cs-wheel { display: none; }
.cs-main:not(.cs-photo-view) > .pt-pick-box, .cs-main:not(.cs-photo-view) > .pt-pick-loupe { display: none !important; }
.cs-views {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  z-index: 6;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(17, 19, 23, 0.72);
}
.cs-views[hidden] { display: none; }
.cs-views button { border: 0; border-radius: 999px; padding: 5px 12px; background: transparent; color: #fff; font-size: 0.8rem; font-weight: 600; }
.cs-views button[aria-pressed="true"] { background: #fff; color: var(--pt-ink, #343f52); }

.cs-strip { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 4px 12px 12px; }
.cs-chip {
  min-width: 0;
  height: 60px;
  padding: 0 4px;
  border: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.cs-chip-num { font-size: 0.7rem; font-weight: 700; line-height: 1; opacity: 0.75; }
.cs-chip-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 0.8rem/1.2 var(--bs-font-monospace, ui-monospace, Menlo, Consolas, monospace); direction: ltr; }
.cs-chip.cs-active { transform: translateY(-2px); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pt-accent, #0f70e6); }
.cs-chip:focus-visible { outline: 3px solid var(--pt-accent, #0f70e6); outline-offset: 3px; }
.cs-chip.pt-cdone { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #198754; }

.cs-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 12px 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(30, 34, 40, 0.06);
}
.cs-has-photo .cs-foot { display: none; }
.cs-foot .sample-thumbnails { display: flex; justify-content: center; gap: 8px; }
.cs-foot .sample-thumbnail {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}
.cs-foot .sample-thumbnail:hover { border-color: var(--pt-accent, #0f70e6); }
.cs-foot .sample-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 0 !important; }

/* ── Phone page: the wheel's box takes the wheel's size ────────────────── */
@media (max-width: 767.98px) {
  #cs-viewport:not(.cs-has-photo):not(.pt-app-viewport) { height: auto !important; min-height: 0 !important; }
  #cs-viewport:not(.cs-has-photo):not(.pt-app-viewport) .cs-main { flex: none; height: min(88vw, 400px); }
  .cs-chip { height: 52px; padding: 0 2px; }
  .cs-chip-code { font-size: 0.7rem; }
}
/* On the phone page a photo is not a work surface (a tap opens the editor),
   so its own buttons would only be in the way. */
html.pt-phone:not(.pt-app-open) #cs-views, html.pt-phone:not(.pt-app-open) #cs-remove-photo { display: none !important; }

/* ── In the phone editor ───────────────────────────────────────────────── */
#pt-app #cs-views, #pt-app .cs-foot { display: none !important; }
#pt-app .cs-strip { padding: 8px 4px 0; }
#pt-app .cs-chip.cs-active { box-shadow: 0 0 0 2px #15181d, 0 0 0 4px #fff; }
.pt-app-sheet .cs-save { border-top: 0; padding-top: 0; margin-top: 0; }
.pt-app-sheet .cs-save .pt-tool-savebar > .btn { flex: 1 1 auto; }

/* ── Live preview ──────────────────────────────────────────────────────── */
.cs-preview .cs-pv { transition: background-color 0.15s, color 0.15s; }
/* The theme colours headings; in the preview they take the block's text colour. */
.cs-preview .cs-pv h4, .cs-preview .cs-pv p, .cs-preview .cs-pv strong { color: inherit !important; }
.cs-preview .progress-bar { justify-content: center; font-weight: 600; }
.cs-preview .btn.cs-pv { border-width: 1px; border-style: solid; }
.cs-preview .alert.cs-pv { border-width: 1px; border-style: solid; }
