/* ============================================
   Pixia - Image Resizer studio (resize-image.html)
   Complements css/ai-tool.css (.at-* primitives)
   Scope: body.at-resize
   ============================================ */

body.at-resize {
  --rs-accent: #ff9800;
  --rs-accent-2: #ffc947;
  --rs-accent-ink: #241701;
  --rs-shadow: 0 16px 34px -18px rgba(255, 152, 0, .7);
  --rs-ease: var(--at-ease, cubic-bezier(.22, .61, .36, 1));
}

body.at-resize [hidden] { display: none !important; }

/* Orange accent replaces the shared purple identity. */
body.at-resize .at-kicker {
  background: linear-gradient(135deg, #ff9800, #ffc947);
  color: #241701;
}
body.at-resize .at-btn {
  background: linear-gradient(135deg, #ff9800, #ffc947);
  color: #241701;
  box-shadow: var(--rs-shadow);
}
body.at-resize .at-btn-alt {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.at-resize .at-progress-fill { background: linear-gradient(90deg, #ff9800, #ffc947); }
body.at-resize .at-drop-icon {
  background: linear-gradient(135deg, rgba(255, 152, 0, .18), rgba(255, 201, 71, .18));
  color: #e07d00;
}

/* ---------- Layout ---------- */
body.at-resize .rs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: start;
}
.rs-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.rs-side {
  min-width: 0;
  position: sticky;
  inset-block-start: 84px;
  display: grid;
  gap: 16px;
}
@media (max-width: 1060px) {
  body.at-resize .rs-layout { grid-template-columns: 1fr; }
  .rs-side { position: static; }
}

body.at-resize .rs-side .at-panel + .at-panel { margin-block-start: 0; }
body.at-resize .at-panel {min-height: 0;min-width: 0;}

.rs-panel h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-block-end: 4px;
}
.rs-source-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 598px;
  overflow: auto;
}
.rs-source-panel .rs-source {
  min-height: 0;
  overflow: auto;
}
.rs-count {
  margin-inline-start: auto;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- Source ---------- */
.rs-source { display: grid; gap: 12px; }

.rs-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 30px 20px;
  border: 1.6px dashed var(--glass-border-hover);
  border-radius: var(--at-radius-lg);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color .2s var(--rs-ease), background .2s var(--rs-ease), transform .2s var(--rs-ease);
}
.rs-drop:hover { border-color: var(--rs-accent); }
.rs-drop:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: 3px; }
.rs-drop.drag {
  border-color: var(--rs-accent);
  background: color-mix(in srgb, var(--rs-accent) 10%, var(--glass-bg));
  transform: scale(1.006);
}
.rs-drop input { display: none; }
.rs-drop-icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: color-mix(in srgb, var(--rs-accent) 16%, transparent);
  color: var(--rs-accent);
  margin-block-end: 2px;
}
.rs-drop-icon svg { width: 26px; height: 26px; }
.rs-drop-title { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; color: var(--text-primary); }
.rs-drop-sub { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.55; }
.rs-drop-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-block-start: 4px; }
.rs-drop-meta span {
  font-size: 11px; font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px 10px;
}

.rs-files { display: none; gap: 10px; }
.rs-files[data-has="1"] { display: grid; }

.rs-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color .2s var(--rs-ease), background .2s var(--rs-ease);
  margin-top: 10px;
}
.rs-file-row:hover { border-color: var(--glass-border-hover); }
.rs-file-row.is-active {
  border-color: var(--rs-accent);
  background: color-mix(in srgb, var(--rs-accent) 9%, var(--glass-bg));
}
.rs-file-row.is-error { border-color: color-mix(in srgb, #ef4444 55%, var(--glass-border)); }
.rs-file-thumb {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 9px;
  object-fit: contain;
  background-color: var(--bg-secondary);
  background-image:
    linear-gradient(45deg, var(--glass-border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--glass-border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--glass-border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--glass-border) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.rs-file-info { min-width: 0; display: grid; gap: 2px; }
.rs-file-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rs-file-meta {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.rs-file-row.is-error .rs-file-meta { color: #ef4444; }
.rs-file-rm {
  flex: 0 0 auto;
  border: 0; background: none;
  color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: inline-flex;
  transition: color .2s var(--rs-ease), background .2s var(--rs-ease);
}
.rs-file-rm:hover { color: #ef4444; background: color-mix(in srgb, #ef4444 12%, transparent); }
.rs-file-rm svg { width: 15px; height: 15px; }

.rs-files-actions { display: flex; gap: 8px; }
.rs-mini {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-bg);
  color: var(--text-secondary);
  font: 600 12.5px/1 var(--font-primary);
  cursor: pointer;
  transition: color .2s var(--rs-ease), border-color .2s var(--rs-ease);
}
.rs-mini svg { width: 14px; height: 14px; }
.rs-mini:hover { color: var(--text-primary); border-color: var(--glass-border-hover); }
.rs-mini-danger:hover { color: #ef4444; border-color: color-mix(in srgb, #ef4444 45%, transparent); }

/* ---------- Settings ---------- */
.rs-modes {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-block: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}
.rs-mode {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: 600 13px/1 var(--font-primary);
  cursor: pointer;
  transition: background .2s var(--rs-ease), color .2s var(--rs-ease);
}
.rs-mode:hover { color: var(--text-primary); }
.rs-mode.is-active {
  background: linear-gradient(135deg, #ff9800, #ffc947);
  color: #241701;
}

.rs-field { margin-block-start: 16px; }
.rs-field:first-of-type { margin-block-start: 0; }
.rs-legend {
  display: block;
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--text-secondary); margin-block-end: 9px;
}
.rs-hint {margin: 8px 0 0;font-size: 11.5px;line-height: 1.5;color: var(--text-muted);min-height: 35px;}
.rs-keys { text-align: center; margin-block-start: 12px; }

.rs-num-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
}
.rs-num-cell { display: grid; gap: 6px; }
.rs-num-cell span {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.rs-num {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--at-radius-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: inherit; font-size: 14px;
  outline: 0;
}
.rs-num:focus { border-color: var(--rs-accent); }
.rs-num-sm { padding: 8px 10px; width: 74px; }
.rs-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  margin-block-end: 5px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color .2s var(--rs-ease), border-color .2s var(--rs-ease), background .2s var(--rs-ease);
}
.rs-link svg { width: 17px; height: 17px; }
.rs-link.is-on { color: var(--rs-accent); border-color: var(--rs-accent); background: color-mix(in srgb, var(--rs-accent) 10%, transparent); }
.rs-link:hover { color: var(--text-primary); }

.rs-switch {
  display: flex; align-items: center; gap: 11px;
  margin-block-start: 12px;
  padding: 11px 13px;
  border-radius: var(--at-radius-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.rs-switch input { position: absolute; opacity: 0; pointer-events: none; }
.rs-switch i {
  position: relative; width: 38px; height: 22px; flex: 0 0 auto;
  border-radius: 999px; background: var(--bg-secondary);
  transition: background .22s var(--rs-ease);
}
.rs-switch i::after {
  content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .22s var(--rs-ease);
}
.rs-switch input:checked + i { background: var(--rs-accent); }
.rs-switch input:checked + i::after { transform: translateX(16px); }
[dir="rtl"] .rs-switch i::after { transform: translateX(0); }
[dir="rtl"] .rs-switch input:checked + i::after { transform: translateX(-16px); }

.rs-range { width: 100%; accent-color: var(--rs-accent); }
.rs-range-row { display: flex; align-items: center; gap: 12px; }
.rs-range-out {
  min-width: 34px; text-align: end;
  font-size: 13px; color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.rs-range-num { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-tertiary); }

.rs-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 12px; }
.rs-quick button {
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-bg);
  color: var(--text-secondary);
  font: 600 12px/1 var(--font-primary);
  cursor: pointer;
  transition: color .2s var(--rs-ease), border-color .2s var(--rs-ease);
}
.rs-quick button:hover { color: var(--text-primary); border-color: var(--rs-accent); }

.rs-select, .rs-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--at-radius-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: inherit; font-size: 14px;
  outline: 0;
  color-scheme: light dark;
}
.rs-select option { color: var(--text-primary); background-color: var(--bg-secondary); }
.rs-select:focus, .rs-input:focus { border-color: var(--rs-accent); }

.rs-bg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rs-bg-swatch {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  background: var(--sw);
  transition: box-shadow .2s var(--rs-ease), border-color .2s var(--rs-ease);
}
.rs-bg-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.rs-bg-swatch i {
  position: absolute; inset: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.rs-bg-swatch:has(input:checked) { border-color: var(--rs-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--rs-accent) 45%, transparent); }
.rs-bg-custom { background: conic-gradient(#ff9800, #ffc947, #ff9800); }
.rs-bg-custom:has(input:checked) { background: var(--bg-secondary); }
.rs-bg-custom::after {
  content: ""; position: absolute; inset: 8px; border-radius: 6px;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35);
}
.rs-bg-swatch:not(.rs-bg-custom)::after { content: none; }
#rsBgColor {
  width: 40px; height: 40px;
  padding: 0; border: 1px solid var(--glass-border);
  border-radius: 10px; background: none; cursor: pointer;
}
.ce-cp-wrap { display:inline-flex; align-items:center; }
.ce-cp-native { position:absolute; opacity:0; pointer-events:none; width:1px; height:1px; border:0; padding:0; margin:0; }
.ce-cp-swatch:disabled { opacity:.5; cursor:default; }

/* ---------- Stage / preview ---------- */
.rs-stage-panel { display: flex; flex-direction: column; }
.rs-stage-head { display: flex; align-items: center; gap: 12px; margin-block-end: 12px; }
.rs-stage-head h2 { margin: 0; }
.rs-zoom { margin-inline-start: auto; display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass-bg); }
.rs-zoom-btn {
  min-width: 30px; height: 28px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--text-secondary); font: 600 12px/1 var(--font-primary); cursor: pointer;
  transition: color .2s var(--rs-ease), background .2s var(--rs-ease);
}
.rs-zoom-btn:hover { color: var(--text-primary); }
.rs-zoom-btn.is-active { background: var(--bg-card-hover); color: var(--text-primary); }
.rs-zoom-btn svg { width: 15px; height: 15px; }

.rs-stage {
  position: relative;
  flex: 1;
  min-height: 380px;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: var(--at-radius-lg);
  border: 1px solid var(--glass-border);
  background:
    repeating-conic-gradient(rgba(128, 128, 128, .16) 0% 25%, transparent 0% 50%) 50% / 22px 22px;
  overflow: auto;
}
.rs-stage-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 34ch;
}
.rs-stage-empty svg { width: 44px; height: 44px; color: var(--text-muted); }
.rs-stage-empty strong { font-size: 15px; color: var(--text-secondary); font-weight: 600; }

.rs-canvas-wrap {
  position: relative;
  transform-origin: center center;
  transition: transform .12s var(--rs-ease);
}
.rs-canvas-wrap img {
  display: block;
  max-width: 100%;
  max-height: 738px;
  border-radius: 8px;
  box-shadow: 0 10px 30px -16px rgba(0, 0, 0, .5);
}

/* Before/after compare (clip-path reveal) */
.rs-compare {
  position: relative;
  display: inline-block;
  line-height: 0;
  user-select: none;
  touch-action: none;
  border-radius: 8px;
  box-shadow: 0 10px 30px -16px rgba(0, 0, 0, .5);
}
.rs-compare .rs-cmp-base,
.rs-compare .rs-cmp-top {
  display: block;
  max-width: 100%;
  max-height: 738px;
  border-radius: 8px;
}
.rs-compare .rs-cmp-top {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}
.rs-compare-handle {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
  transform: translateX(-1px);
  cursor: ew-resize;
}
.rs-compare-handle::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  width: 38px; height: 38px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .5);
}
.rs-compare-handle::before {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  width: 16px; height: 16px;
  transform: translate(-50%, -50%);
  z-index: 1;
  background:
    linear-gradient(currentColor, currentColor) left 1px top 50% / 2px 9px no-repeat,
    linear-gradient(currentColor, currentColor) right 1px top 50% / 2px 9px no-repeat;
  color: #64748b;
}
.rs-compare-tag {
  position: absolute;
  inset-block-start: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: rgba(20, 20, 20, .68); color: #fff;
  pointer-events: none;
}
.rs-compare-tag.is-before { inset-inline-start: 8px; }
.rs-compare-tag.is-after { inset-inline-end: 8px; }

.rs-compare-hint { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Info strip */
.rs-info {
  margin-block-start: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.rs-info-cell {
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--glass-bg);
  padding: 10px 12px;
  min-width: 0;
}
.rs-info-k { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.rs-info-v {
  display: block; margin-block-start: 3px;
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rs-info-v.is-up { color: #ef4444; }
.rs-info-v.is-down { color: #16a34a; }

/* ---------- Results ---------- */
.rs-results { display: grid; gap: 8px; margin-block-start: 12px; }
.rs-result-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--glass-border);
  border-radius: var(--at-radius-md);
  background: var(--glass-bg);
}
.rs-result-thumb {
  width: 44px; height: 44px; border-radius: 9px; object-fit: contain;
  background-color: var(--bg-secondary);
}
.rs-result-info { min-width: 0; display: grid; gap: 2px; }
.rs-result-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-result-meta { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rs-result-meta .is-down { color: #16a34a; font-weight: 600; }
.rs-result-meta .is-up { color: #ef4444; font-weight: 600; }
.rs-result-dl {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font: 600 11.5px/1 var(--font-primary);
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: border-color .2s var(--rs-ease);
}
.rs-result-dl:hover { border-color: var(--rs-accent); }
.rs-result-dl svg { width: 13px; height: 13px; }
.rs-download-all { margin-block-start: 14px; width: 100%; }

/* ---------- Run / progress ---------- */
.rs-run-actions { display: grid; gap: 9px; }
.rs-run-btn { width: 100%; }
.rs-cancel {
  width: 100%;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #ef4444 45%, transparent);
  background: var(--glass-bg);
  color: #ef4444;
  font: 600 13.5px/1 var(--font-primary);
  cursor: pointer;
  transition: background .2s var(--rs-ease);
}
.rs-cancel:hover { background: color-mix(in srgb, #ef4444 10%, var(--glass-bg)); }
.rs-progress { display: grid; gap: 8px; }
.rs-progress-track {
  height: 8px; border-radius: 999px; background: var(--bg-tertiary); overflow: hidden;
  display: block;
}
.rs-progress-fill {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9800, #ffc947);
  transition: width .25s var(--rs-ease);
}
.rs-progress-msg { font-size: 12.5px; color: var(--text-tertiary); }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .rs-stage { min-height: 260px; }
  .rs-canvas-wrap img,
  .rs-compare .rs-cmp-base { max-height: 320px; }
  .rs-info { grid-template-columns: 1fr; }
  .rs-num-row { grid-template-columns: 1fr; }
  .rs-link { display: none; }
}

/* ---------- RTL ---------- */
[dir="rtl"] .rs-link svg { transform: scaleX(-1); }
[dir="rtl"] .rs-file-meta, [dir="rtl"] .rs-result-meta { direction: ltr; text-align: start; }
