/* FrogImage - tool-specific styles. Header, hero, footer, base resets, and the
   :root palette tokens come from the shared shell (tool-shell.css). The panel /
   field / dropzone / btn / action-row conventions mirror FrogShrink's tool.css
   so the tools look identical; this file adds the mode toggle, the preview grid,
   and the transparency checkerboard. */

/* ─── Panels ──────────────────────────────────────────────────────────── */

.panel__title {
  margin: 0 0 1.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* ─── Dropzone ────────────────────────────────────────────────────────── */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  color: var(--text-light);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone[hidden] { display: none; }
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.dropzone__icon { color: var(--accent); pointer-events: none; }
.dropzone__text { font-size: 0.98rem; pointer-events: none; }
.dropzone__text strong { color: var(--accent); }
.dropzone__hint { font-size: 0.82rem; color: var(--muted); pointer-events: none; }

/* ─── Compact file bar (swaps in once an image is loaded) ─────────────── */

.file-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
}
.file-bar[hidden] { display: none; }
.file-bar__thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #2a2a2a;
}
.file-bar__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
}
.file-bar__x {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(229, 231, 235, 0.35);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-light);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}
.file-bar__x:hover { border-color: #ff8a8a; color: #ff8a8a; }
.file-bar__x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Form fields ─────────────────────────────────────────────────────── */

.field { margin-bottom: 1.25rem; }
.field:last-child { margin-bottom: 0; }
.field--mode { margin-top: 1.25rem; }

.field__val {
  float: right;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border-dark);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

label, .field__sublabel {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
}

select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--bg-deep);
  color: var(--text-light);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  cursor: pointer;
}
select option { background: var(--bg-deep); color: var(--text-light); }
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ─── Mode toggle (segmented control) ─────────────────────────────────── */

.segmented {
  display: flex;
  gap: 0.5rem;
  padding: 0.3rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
}
.segmented__opt {
  flex: 1;
  margin: 0;
  text-align: center;
  cursor: pointer;
}
.segmented__opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented__opt span {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease;
}
.segmented__opt input:checked + span {
  background: var(--accent);
  color: #06281c;
}
.segmented__opt input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.notice {
  margin: 1.5rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--accent-soft);
  border: 1px solid rgba(25, 195, 125, 0.3);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(229, 231, 235, 0.92);
}
.notice strong { color: var(--accent); }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.action-row #processBtn { flex: 1; }
@media (max-width: 380px) {
  .action-row { flex-direction: column; }
}

/* ─── Status ──────────────────────────────────────────────────────────── */

.results-summary {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.9rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-light);
  font-family: var(--mono);
}
.results-summary[hidden] { display: none; }
.results-summary.is-error {
  background: rgba(255, 107, 107, 0.12);
  color: #ff8a8a;
}

/* ─── Preview ─────────────────────────────────────────────────────────── */

.empty-state {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.preview-grid {
  display: flex;
  gap: 1rem;
}
.preview-grid[hidden] { display: none; }
.preview-cell { flex: 1; min-width: 0; }
.preview-cell[hidden] { display: none; }
.preview-cell__label {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
@media (max-width: 560px) {
  .preview-grid { flex-direction: column; }
}

.preview-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 0.75rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  overflow: hidden;
}
/* Checkerboard so transparency in the result reads as transparent. */
.preview-stage--checker {
  background-color: #2a2a2a;
  background-image:
    linear-gradient(45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(-45deg, #3a3a3a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3a3a3a 75%),
    linear-gradient(-45deg, transparent 75%, #3a3a3a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.preview-img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}
.preview-img[hidden] { display: none; }

.preview-svg {
  max-width: 100%;
  max-height: 360px;
  overflow: auto;
}
.preview-svg[hidden] { display: none; }
.preview-svg svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ─── Result hint + progress ──────────────────────────────────────────── */

.result-hint {
  margin: 0;
  padding: 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}
.result-hint[hidden] { display: none; }

/* Progress overlay inside the result stage. Covers the cell while working. */
.progress-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: rgba(7, 9, 11, 0.82);
}
.progress-box[hidden] { display: none; }
.progress-box__label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  font-family: var(--mono);
  text-align: center;
}
.progress-track {
  width: 80%;
  max-width: 260px;
  height: 8px;
  border-radius: 4px;
  background: var(--border-dark);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
  transition: width 200ms ease;
}
/* Indeterminate sweep for the fast (solid/SVG) paths. */
.progress-fill.is-indeterminate {
  width: 40%;
  transition: none;
  animation: progress-sweep 1.1s ease-in-out infinite;
}
@keyframes progress-sweep {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

#downloadBtn { flex: 1; }
