/*
  remove-background/remove-background.css
  =========================================
  Self-contained styles for the Remove Background tool.

  NOTE: unlike a first assumption made earlier, these generic
  .mea-drop-zone / .mea-controls / .mea-field / .mea-quality-group /
  .mea-btn-primary / .mea-status / .mea-download-btn rules are NOT in
  the shared/tools.css file — each existing tool (e.g. img-compress/
  compressor.css) defines its own copy of them. This file follows that
  same pattern: it duplicates the generic component rules (copied from
  shared/img-compress/compressor.css for visual consistency) and adds
  what's specific to this tool (progress bar, checkerboard preview,
  compare panels, field hint).
*/

.mea-tool-header {
  margin-bottom: 32px;
}

.mea-back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mea-text-muted);
  margin-bottom: 20px;
}

.mea-back-link:hover {
  color: var(--mea-accent-text);
}

.mea-tool-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: 0.02em;
  margin: 8px 0 8px;
  color: var(--mea-text-primary);
}

.mea-tool-header p {
  font-size: 14.5px;
  color: var(--mea-text-secondary);
  margin: 0;
  max-width: 50ch;
}

.mea-tool-page {
  max-width: 640px;
  padding-top: 40px;
  padding-bottom: 64px;
}

/* Global safety net: [hidden] must always win over any class-based
   display rule below, regardless of CSS source order or specificity.
   Without this, any element that both uses [hidden] AND has a custom
   "display: flex/block/..." rule for its class can end up visible
   even while [hidden] is set (this is a real bug that happened with
   .mea-selected-file and .mea-download-btn in this file — see below). */
[hidden] {
  display: none !important;
}

/* ---------- Drop zone ---------- */

.mea-drop-zone {
  border: 1px dashed var(--mea-border-strong);
  border-radius: var(--mea-radius-lg);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mea-drop-zone:hover,
.mea-drop-zone.drag-active {
  border-color: var(--mea-accent);
  background: var(--mea-accent-muted);
}

.mea-drop-zone p {
  margin: 0;
  color: var(--mea-text-secondary);
  font-size: 14px;
}

.mea-drop-zone .dz-sub {
  font-size: 12px;
  color: var(--mea-text-muted);
  margin-top: 6px;
}

.mea-drop-zone span {
  color: var(--mea-accent-text);
  font-weight: 600;
}

/* ---------- Selected file bar ---------- */

.mea-selected-file {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--mea-border);
  border-radius: var(--mea-radius-md);
  background: var(--mea-surface);
}

.mea-selected-thumb {
  width: 40px;
  height: 40px;
  min-width: 40px;
  object-fit: cover;
  border-radius: var(--mea-radius-sm);
  border: 1px solid var(--mea-border);
  flex-shrink: 0;
  background: var(--mea-surface);
  color: transparent; /* hide alt text if image hasn't loaded yet */
  overflow: hidden;
}

.mea-selected-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mea-selected-name {
  font-size: 13.5px;
  color: var(--mea-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mea-selected-size {
  font-size: 12px;
  color: var(--mea-text-muted);
}

.mea-selected-remove {
  background: transparent;
  border: none;
  color: var(--mea-text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: var(--mea-radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.mea-selected-remove:hover {
  color: var(--mea-danger-text);
  background: var(--mea-danger-bg);
}

/* ---------- Controls ---------- */

.mea-controls {
  margin-top: 32px;
  border-top: 1px solid var(--mea-border);
  padding-top: 24px;
}

.mea-field {
  margin-bottom: 20px;
}

.mea-field label {
  display: block;
  font-size: 13px;
  color: var(--mea-text-secondary);
  margin-bottom: 8px;
}

.mea-field-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--mea-text-muted);
}

.mea-quality-group {
  display: flex;
  gap: 8px;
}

.mea-quality-btn {
  flex: 1;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--mea-border);
  border-radius: var(--mea-radius-sm);
  color: var(--mea-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mea-quality-btn:hover {
  border-color: var(--mea-border-strong);
}

.mea-quality-btn.active {
  border-color: var(--mea-accent);
  background: var(--mea-accent-muted);
  color: var(--mea-accent-text);
}

.mea-btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--mea-accent);
  color: #061121;
  border: none;
  border-radius: var(--mea-radius-md);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.mea-btn-primary:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.mea-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.mea-status {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

/* ---------- Before/after preview ---------- */

.mea-bgremove-preview {
  margin-top: 32px;
  border-top: 1px solid var(--mea-border);
  padding-top: 24px;
}

.mea-compare-wrap {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.mea-compare-panel {
  flex: 1;
  min-width: 0;
}

.mea-compare-panel .label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--mea-text-secondary);
  margin-bottom: 8px;
}

.mea-compare-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--mea-radius-md);
  border: 1px solid var(--mea-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mea-surface);
}

.mea-compare-img-wrap img,
.mea-compare-img-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Checkerboard background so a transparent PNG result is visibly
   distinguishable from a plain white/dark background. */
.mea-checkerboard {
  background-image:
    linear-gradient(45deg, #808080 25%, transparent 25%),
    linear-gradient(-45deg, #808080 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #808080 75%),
    linear-gradient(-45deg, transparent 75%, #808080 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #b0b0b0;
}

.mea-download-btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 13px;
  background: var(--mea-success);
  color: #061121;
  border-radius: var(--mea-radius-md);
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: transform 0.15s ease;
}

.mea-download-btn:hover {
  transform: translateY(-1px);
}

/* ---------- FAQ (SEO) ---------- */

.mea-faq {
  margin-top: 48px;
  border-top: 1px solid var(--mea-border);
  padding-top: 24px;
}

.mea-faq h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--mea-text-primary);
}

.mea-faq-item {
  margin-bottom: 4px;
  border-bottom: 1px solid var(--mea-border);
}

.mea-faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--mea-text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mea-faq-item summary::-webkit-details-marker {
  display: none;
}

.mea-faq-item summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--mea-text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 12px;
}

.mea-faq-item[open] summary::after {
  transform: rotate(45deg);
}

.mea-faq-item summary:hover {
  color: var(--mea-accent-text);
}

.mea-faq-item p {
  font-size: 13.5px;
  color: var(--mea-text-secondary);
  margin: 0 4px 16px;
}

@media (max-width: 480px) {
  .mea-compare-wrap {
    flex-direction: column;
  }
}
