/* SkyyCast Smart Image Compressor (/tools/image-compressor).
 *
 * Loaded by that page only, after assets/sc-public.css AND
 * assets/sc-image-checker.css: this file reuses the checker's shared `ic-*`
 * shell (drop zone, buttons, card list, detail panel, facts grid, badges)
 * and only adds the compressor-specific `cm-*` pieces (mode tabs, preset /
 * target controls, resize fields, progress bar, before/after compare
 * slider). All scoped under `.pub-site` and built from the `--pub-*`
 * tokens: no new colours, no new fonts, nothing on :root/html/body. Motion
 * is limited to short state transitions and is switched off under
 * prefers-reduced-motion. */

/* ---- Mode tabs ---- */
.pub-site .cm-modes {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.pub-site .cm-mode {
  appearance: none;
  border: 1px solid var(--pub-border-strong);
  border-radius: var(--pub-radius-pill);
  background: var(--pub-surface);
  color: var(--pub-text-secondary);
  font: inherit;
  font-weight: 700;
  font-size: .9375rem;
  min-height: 44px;
  padding: .5rem 1.1rem;
  cursor: pointer;
  transition: background var(--pub-dur-fast) var(--pub-ease), border-color var(--pub-dur-fast) var(--pub-ease), color var(--pub-dur-fast) var(--pub-ease);
}
.pub-site .cm-mode:hover { border-color: var(--pub-accent); }
.pub-site .cm-mode:focus-visible { outline: none; box-shadow: var(--pub-ring); }
.pub-site .cm-mode.is-active { background: var(--pub-accent); border-color: var(--pub-accent); color: #fff; }

/* ---- Field rows / controls ---- */
.pub-site .cm-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  margin-bottom: .85rem;
}
.pub-site .cm-field-row[hidden] { display: none; }
.pub-site .cm-label {
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--pub-text-muted);
}
.pub-site .cm-select,
.pub-site .cm-input {
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  min-height: 44px;
  padding: .4rem .7rem;
  border: 1px solid var(--pub-border-strong);
  border-radius: var(--pub-radius-md);
  background: var(--pub-surface);
  color: var(--pub-text);
}
.pub-site .cm-select:focus-visible,
.pub-site .cm-input:focus-visible { outline: none; box-shadow: var(--pub-ring); border-color: var(--pub-accent); }
.pub-site .cm-input-sm { width: 90px; }
.pub-site .cm-input[type="number"] { -moz-appearance: textfield; }

.pub-site .cm-advanced {
  flex-direction: column;
  align-items: flex-start;
  border-top: 1px solid var(--pub-border);
  padding-top: .85rem;
}
.pub-site .cm-adv-group { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pub-site .cm-resize-custom { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .6rem; }
.pub-site .cm-resize-custom[hidden] { display: none; }
.pub-site .cm-lock { display: inline-flex; align-items: center; gap: .4rem; font-size: .875rem; font-weight: 600; color: var(--pub-text-secondary); }
.pub-site .cm-advanced-toggle-row { display: inline-flex; align-items: center; gap: .5rem; font-size: .9375rem; font-weight: 600; color: var(--pub-text-secondary); }
.pub-site .cm-advanced-toggle { margin-bottom: 1rem; }

/* ---- Drop zone reused from ic-drop; just needs top margin here ---- */
.pub-site .cm-tool .ic-drop { margin-top: .25rem; }

/* ---- Progress ---- */
.pub-site .cm-progress { margin: .9rem 0 0; }
.pub-site .cm-progress[hidden] { display: none; }
.pub-site .cm-progress-label { margin: 0 0 .4rem; font-size: .875rem; font-weight: 700; color: var(--pub-text-secondary); }
.pub-site .cm-progress-track {
  height: 8px;
  border-radius: var(--pub-radius-pill);
  background: var(--pub-bg-soft);
  border: 1px solid var(--pub-border);
  overflow: hidden;
}
.pub-site .cm-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--pub-accent);
  transition: width .2s ease;
}

/* ---- Batch actions ---- */
.pub-site .cm-batch-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }
.pub-site .cm-batch-actions[hidden] { display: none; }

/* ---- Before / after compare ---- */
.pub-site .cm-compare {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 420px;
  margin: 0 0 1rem;
  border-radius: var(--pub-radius-md);
  overflow: hidden;
  border: 1px solid var(--pub-border);
  background: var(--pub-bg-soft);
  touch-action: none;
  user-select: none;
}
.pub-site .cm-compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.pub-site .cm-compare-after { clip-path: inset(0 0 0 50%); }
.pub-site .cm-compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
}
.pub-site .cm-compare-handle::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -1px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--pub-border);
}
.pub-site .cm-compare-grip {
  position: relative;
  z-index: 1;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--pub-border);
  display: grid;
  place-items: center;
  color: var(--pub-text);
  box-shadow: var(--pub-shadow-sm);
}
.pub-site .cm-compare-handle:focus-visible .cm-compare-grip { outline: none; box-shadow: var(--pub-ring); }
.pub-site .cm-compare-tag {
  position: absolute;
  bottom: .6rem;
  padding: .2rem .55rem;
  border-radius: var(--pub-radius-pill);
  background: rgba(15, 23, 42, .72);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.pub-site .cm-compare-tag-before { left: .6rem; }
.pub-site .cm-compare-tag-after { right: .6rem; }
.pub-site .cm-compare-toggle {
  display: flex;
  gap: .5rem;
  margin: 0 0 1rem;
}

/* ---- Decision note (kept original / target missed) ---- */
.pub-site .cm-decision {
  margin: 0 0 1rem;
  padding: .7rem .9rem;
  border: 1px solid var(--pub-border);
  border-left: 4px solid var(--pub-accent);
  border-radius: var(--pub-radius-md);
  background: var(--pub-accent-soft);
  color: var(--pub-text);
  font-size: .9375rem;
  line-height: 1.5;
}
.pub-site .cm-decision[data-tone="warn"] { border-left-color: var(--pub-warning); background: #FFF7E8; }
.pub-site .cm-decision[data-tone="success"] { border-left-color: var(--pub-success); background: #ECFDF5; }

@media (max-width: 640px) {
  .pub-site .cm-modes { flex-direction: column; }
  .pub-site .cm-mode { width: 100%; justify-content: center; text-align: center; }
  .pub-site .cm-field-row { flex-direction: column; align-items: flex-start; }
  .pub-site .cm-select, .pub-site .cm-input { width: 100%; }
  .pub-site .cm-input-sm { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .pub-site .cm-mode,
  .pub-site .cm-progress-bar { transition: none; }
}
