/* SkyyCast Target-Size Image Compressor (/tools/compress-image-to-target-size).
 *
 * 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 `ts-*` pieces specific to this tool -- the target-size
 * chips (the primary, always-visible control), the format override under
 * "More options", the progress bar and the 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. */

/* ---- Target-size chips: the primary control, shown before any image is
   added so the tool's purpose is obvious immediately. ---- */
.pub-site .ts-targets {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: .5rem;
}
.pub-site .ts-chip {
  appearance: none;
  border: 2px solid var(--pub-border-strong);
  border-radius: var(--pub-radius-pill);
  background: var(--pub-surface);
  color: var(--pub-text);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  min-height: 44px;
  padding: .55rem 1.3rem;
  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), transform var(--pub-dur-fast) var(--pub-ease);
}
.pub-site .ts-chip:hover { border-color: var(--pub-accent); }
.pub-site .ts-chip:focus-visible { outline: none; box-shadow: var(--pub-ring); }
.pub-site .ts-chip.is-active {
  background: var(--pub-accent);
  border-color: var(--pub-accent);
  color: #fff;
}
.pub-site .ts-custom-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 1rem;
}
.pub-site .ts-custom-row[hidden] { display: none; }
.pub-site .ts-custom-label {
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--pub-text-muted);
}
.pub-site .ts-input {
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  min-height: 40px;
  width: 110px;
  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 .ts-input:focus-visible { outline: none; box-shadow: var(--pub-ring); border-color: var(--pub-accent); }
.pub-site .ts-input[type="number"] { -moz-appearance: textfield; }

/* ---- Advanced (format override) ---- */
.pub-site .ts-advanced {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--pub-border);
  padding-top: .85rem;
  margin-bottom: .85rem;
}
.pub-site .ts-advanced[hidden] { display: none; }
.pub-site .ts-label {
  font-size: .8125rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--pub-text-muted);
}
.pub-site .ts-select {
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  min-height: 40px;
  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 .ts-select:focus-visible { outline: none; box-shadow: var(--pub-ring); border-color: var(--pub-accent); }
.pub-site .ts-advanced-toggle { margin-bottom: 1rem; }

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

/* ---- Progress ---- */
.pub-site .ts-progress { margin: .9rem 0 0; }
.pub-site .ts-progress[hidden] { display: none; }
.pub-site .ts-progress-label { margin: 0 0 .4rem; font-size: .875rem; font-weight: 700; color: var(--pub-text-secondary); }
.pub-site .ts-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 .ts-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--pub-accent);
  transition: width .2s ease;
}

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

/* ---- Before / after compare ---- */
.pub-site .ts-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 .ts-compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.pub-site .ts-compare-after { clip-path: inset(0 0 0 50%); }
.pub-site .ts-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 .ts-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 .ts-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 .ts-compare-handle:focus-visible .ts-compare-grip { outline: none; box-shadow: var(--pub-ring); }
.pub-site .ts-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 .ts-compare-tag-before { left: .6rem; }
.pub-site .ts-compare-tag-after { right: .6rem; }

/* ---- Decision note (original kept / target missed) ---- */
.pub-site .ts-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 .ts-decision[data-tone="warn"] { border-left-color: var(--pub-warning); background: #FFF7E8; }
.pub-site .ts-decision[data-tone="success"] { border-left-color: var(--pub-success); background: #ECFDF5; }

@media (max-width: 640px) {
  .pub-site .ts-chip { flex: 1 1 calc(50% - .3rem); text-align: center; }
  .pub-site .ts-advanced { flex-direction: column; align-items: flex-start; }
  .pub-site .ts-select { width: 100%; }
  .pub-site .ts-custom-row { width: 100%; }
  .pub-site .ts-input { width: 100%; }
}

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