/* ══════════════════════════════════════════════════════════════════════════════
   APP STYLES — app.html
   Complements style.css (shared design system). Never duplicate tokens here.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── App bar ──────────────────────────────────────────────────────────────── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-base);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.app-bar-end {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
}

/* ── Screen override for app (full viewport minus app bar) ────────────────── */
#app {
  display: contents;
}

.screen {
  min-height: calc(100vh - 52px);
}

/* ── Accessibility utility ────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 0.5px solid var(--accent-tint-border);
  font-size: 13px;
  font-family: monospace;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
  white-space: normal;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Drop zone screen ─────────────────────────────────────────────────────── */
.drop-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
}

.drop-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.drop-sub {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  min-height: 240px;
  justify-content: center;
  border: 1.5px dashed var(--bg-card);
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  padding: 36px 28px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.drop-icon { opacity: 0.7; }

.drop-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.drop-formats {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Loading state */
.drop-spinner {
  display: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.drop-loading-label {
  display: none;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes spin { to { transform: rotate(360deg); } }

.drop-zone.loading .drop-icon,
.drop-zone.loading .drop-label,
.drop-zone.loading .drop-formats,
.drop-zone.loading .btn-secondary  { display: none; }
.drop-zone.loading .drop-spinner,
.drop-zone.loading .drop-loading-label { display: block; }

/* PDF tip — collapsible */
.pdf-tip {
  max-width: 440px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12px;
}

.pdf-tip-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  cursor: pointer;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.pdf-tip-header::-webkit-details-marker { display: none; }

.pdf-tip-header:hover {
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.pdf-tip[open] .pdf-tip-header {
  color: var(--danger);
  border-bottom: 0.5px solid var(--border);
}

.pdf-tip-header svg { flex-shrink: 0; }

.pdf-tip-body {
  padding: 14px 16px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdf-tip-body p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.pdf-tip-body strong {
  color: var(--text-primary);
  font-weight: 500;
}

.pdf-tip-steps-label {
  font-size: 11px !important;
  font-weight: 600;
  color: var(--text-primary) !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pdf-tip-steps {
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.pdf-tip-steps strong {
  color: var(--text-primary);
}

.pdf-tip-try {
  align-self: flex-start;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.pdf-tip-try:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

/* Guarantee line */
.drop-guarantee {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: monospace;
  font-size: 12px;
  color: var(--accent);
}

/* Mobile */
@media (max-width: 600px) {
  .drop-zone { padding: 28px 16px; }
  .drop-title { font-size: 22px; }
}

/* ── Editor screen ────────────────────────────────────────────────────────── */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

.zone-count {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
}

/* Mode selector */
.mode-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.mode-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.mode-btn.active {
  background: var(--accent-tint);
  border-color: var(--accent-tint-border);
  color: var(--accent);
  font-weight: 500;
}

/* Mode icon swatches */
.mode-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.mode-icon--noise {
  background:
    repeating-linear-gradient(45deg,
      #555 0px, #333 1px, #666 2px, #444 3px, #555 4px);
}

.mode-icon--blur {
  background: linear-gradient(135deg, #1e3a26, #2e5438, #163020);
  filter: blur(1.5px);
}

.mode-icon--pixel {
  background-color: #1e4a28;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255,255,255,0.15) 3px, rgba(255,255,255,0.15) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(255,255,255,0.15) 3px, rgba(255,255,255,0.15) 4px);
}

.mode-icon--solid { background: #111; }

/* Color picker inside solid mode button */
.mode-btn input[type="color"] {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

/* Before/After toggle */
.preview-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 16px;
  background: var(--bg-base);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.toggle-btn {
  padding: 5px 18px;
  font-size: 13px;
  border: 0.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.toggle-btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; border-inline-start: none; }

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Canvas area */
.canvas-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  background: var(--bg-surface);
}

.canvas-inner {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#redactCanvas {
  display: block;
  cursor: crosshair;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

#ghostCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 4px;
}

/* Editor footer */
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

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

/* Editor mobile */
@media (max-width: 600px) {
  .editor-footer {
    flex-direction: column;
    gap: 10px;
  }
  .editor-footer .btn-primary { width: 100%; }
  .editor-hint { text-align: center; }
}

/* ── Small phone fixes (375px) ────────────────────────────────────────────── */
@media (max-width: 420px) {
  /* App bar: hide badge text, keep pulsing dot only */
  .app-bar .badge-text { display: none; }

  /* Review stats: tighten */
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 10px; }

  /* PDF nav */
  .pdf-indicator { font-size: 12px; }

  /* Export / Done */
  .export-center,
  .done-center { padding: 24px 16px; gap: 16px; }
  .export-title,
  .done-title  { font-size: 20px; }

  /* Drop zone */
  .drop-title { font-size: 20px; }
  .drop-zone  { min-height: 200px; padding: 24px 14px; }
}

/* ── PDF nav ──────────────────────────────────────────────────────────────── */
.pdf-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 0.5px solid var(--border);
  background: var(--accent-tint);
  flex-shrink: 0;
}

.pdf-indicator {
  font-family: monospace;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ── Review screen ────────────────────────────────────────────────────────── */
.review-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

.review-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.review-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.review-stats {
  display: flex;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

.stat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 12px;
  border-inline-end: 0.5px solid var(--border);
}

.stat-card:last-child { border-inline-end: none; }

.stat-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.review-guarantee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 20px;
  font-family: monospace;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-tint);
  border-bottom: 0.5px solid var(--accent-tint-border);
  flex-shrink: 0;
}

.review-image-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  background: var(--bg-surface);
}

.review-image-wrap img {
  display: block;
  max-width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 0.5px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .review-footer {
    flex-direction: column;
    gap: 10px;
  }
  .review-footer .btn-primary,
  .review-footer .btn-secondary { width: 100%; }
}

/* ── Export screen ────────────────────────────────────────────────────────── */
.export-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
  text-align: center;
}

.export-icon { margin-bottom: 4px; }

.export-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.export-filename {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  word-break: break-all;
}

.export-guarantee {
  font-family: monospace;
  font-size: 12px;
  color: var(--accent);
  max-width: 360px;
  line-height: 1.6;
}

/* ── Export loading state (PDF can take several seconds) ─────────────────── */
.btn-exporting {
  opacity: 0.65;
  cursor: wait;
  pointer-events: none;
}

/* ── Done screen ──────────────────────────────────────────────────────────── */
.done-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
  text-align: center;
}

.done-icon { margin-bottom: 4px; }

.done-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.done-sub {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.7;
}
