/* ─────────────────────────────────────────────
   PixShift — styles.css
   Theme: Deep cobalt on ink · light & dark modes
───────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #175fb8;
  --accent-dark:  #0e4483;
  --accent-soft:  #e5f0fb;
  --ink:          #0b1220;
  --bg:           #eef3f8;
  --surface:      #ffffff;
  --rule:         #d8e6f0;
  --muted:        #5b7186;
  --success:      #16966b;
  --success-soft: #dff5ec;
  --error:        #d4373f;
  --error-soft:   #fbe6e7;
  --warn:         #b8770e;
  --warn-soft:    #fbf0d9;

  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

[data-theme="dark"] {
  --accent:       #4f9fff;
  --accent-dark:  #77b6ff;
  --accent-soft:  #17263a;
  --ink:          #e8eef4;
  --bg:           #0a0e15;
  --surface:      #121826;
  --rule:         #232f42;
  --muted:        #8296ab;
  --success:      #33c48c;
  --success-soft: #123326;
  --error:        #ff6b6b;
  --error-soft:   #3a1a1c;
  --warn:         #e0a83a;
  --warn-soft:    #3a2c0f;

  color-scheme: dark;
}

html { font-size: 16px; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.2s ease, color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.mono { font-family: var(--font-mono); }

.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;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ─── HEADER ─── */
header {
  background: var(--ink);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

[data-theme="dark"] header { background: #05070b; }

.masthead-left { display: flex; flex-direction: column; gap: 0.1rem; }

.masthead-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.masthead-brand:hover { opacity: 0.82; }
.masthead-brand span { color: var(--accent-dark); }

.masthead-tagline {
  font-size: 0.7rem;
  color: #7d8ea0;
  letter-spacing: 0.03em;
  display: none;
}

.masthead-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pill {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.32rem 0.7rem;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 600;
}

.pill.green {
  background: rgba(51,196,140,0.16);
  border-color: rgba(51,196,140,0.32);
  color: #5fe0ab;
}

.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.theme-toggle:hover { background: rgba(255,255,255,0.14); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

@media (min-width: 640px) {
  .masthead-tagline { display: block; }
}

/* ─── PAGE LAYOUT ───
   Single focused column — no sidebar. The page shows either the upload
   hero (no files yet) or the workspace card stack (files queued), never
   both at full size at once. */
.page-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1rem 3rem;
  width: 100%;
  flex: 1 0 auto;
}

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.card-header {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--rule);
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.card-header-title {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.card-body { padding: 1.2rem; }

/* ─── SECTION LABEL ─── */
.section-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  text-align: center;
  transition: opacity 0.2s ease, margin 0.2s ease;
}

/* ─── UPLOAD SECTION ───
   Two visual states driven by JS toggling `.compact` once files exist:
   a full hero when empty, a slim "add more" bar once the workspace is showing. */
.upload-section {
  transition: margin 0.25s ease;
}

.upload-section.compact { margin-bottom: 0; }
.upload-section.compact .section-label { display: none; }

.drop-zone {
  border: 2px dashed #a9cdec;
  border-radius: 14px;
  padding: 3.4rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
}

[data-theme="dark"] .drop-zone { border-color: #2d4d72; }

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 140%);
}

.drop-zone.drag-over { transform: scale(1.006); box-shadow: 0 8px 28px rgba(23,95,184,0.16); }

.drop-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

.drop-icon {
  width: 56px; height: 56px;
  margin: 0 auto 1.1rem;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(23,95,184,0.28);
  transition: all 0.2s ease;
}

.drop-icon svg {
  width: 25px; height: 25px;
  stroke: #ffffff;
  transition: all 0.2s ease;
}

.drop-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
  transition: all 0.2s ease;
}

.drop-sub {
  font-size: 0.7rem;
  color: var(--muted);
  transition: opacity 0.2s ease;
}

/* Compact "add more" bar — same element, restyled */
.upload-section.compact .drop-zone {
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  border-style: dashed;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  text-align: left;
  background: var(--surface);
}

.upload-section.compact .drop-icon {
  width: 32px; height: 32px;
  margin: 0;
  box-shadow: none;
  flex-shrink: 0;
}

.upload-section.compact .drop-icon svg { width: 15px; height: 15px; }
.upload-section.compact .drop-title { font-size: 0.82rem; margin-bottom: 0; }
.upload-section.compact .drop-sub { display: none; }

/* ─── UPLOAD TOAST ─── */
.upload-msg {
  margin-top: 0.6rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(184,119,14,0.25);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.18s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── WORKSPACE ─── */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-top: 1.4rem;
  animation: workspaceIn 0.3s ease;
}

.workspace.hidden { display: none; }
.workspace.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.18s ease, transform 0.18s ease; }

@keyframes workspaceIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── PREVIEW CARD ─── */
.preview-card-body {
  display: flex;
  gap: 1.1rem;
  padding: 1.2rem;
  align-items: stretch;
}

.preview-canvas {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  border-radius: 8px;
  background: repeating-conic-gradient(var(--rule) 0% 25%, var(--surface) 0% 50%) 0 0 / 14px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.preview-canvas img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  display: none;
}

.preview-canvas img.visible { display: block; }

.preview-placeholder {
  color: var(--rule);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.5rem;
}

.preview-placeholder svg {
  width: 28px; height: 28px;
  stroke: var(--rule);
  margin: 0 auto 0.4rem;
  display: block;
}

.preview-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.55rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
}

.meta-key { color: var(--muted); }
.meta-val { font-weight: 600; color: var(--ink); }

@media (max-width: 480px) {
  .preview-card-body { flex-direction: column; }
  .preview-canvas { width: 100%; height: auto; aspect-ratio: 4/3; }
}

/* ─── CONTROLS ─── */
.controls-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.control-group label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

select {
  appearance: none;
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  padding: 0.6rem 2.2rem 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23175fb8' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  transition: border-color 0.15s;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23,95,184,0.14);
}

.quality-val {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.3rem;
  transition: color 0.15s, opacity 0.15s;
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(23,95,184,0.2);
}

#qualityGroup.disabled { opacity: 0.42; }
#qualityGroup.disabled input[type="range"] { cursor: not-allowed; pointer-events: none; }

.quality-note {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.4rem;
  display: none;
}

#qualityGroup.disabled .quality-note { display: block; }

/* ─── CONVERT BUTTON ─── */
.convert-btn {
  grid-column: 1 / -1;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 1.6rem;
  height: 46px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.convert-btn:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(23,95,184,0.35); }
.convert-btn:active { transform: translateY(0); }
.convert-btn:disabled { background: var(--rule); color: var(--muted); cursor: not-allowed; transform: none; box-shadow: none; }
.convert-btn svg { width: 16px; height: 16px; }

/* ─── PROGRESS ─── */
.progress-wrap {
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 2px;
}

.hidden { display: none !important; }

/* ─── FILE QUEUE (nested directly in a .card) ─── */
.queue-header {
  background: var(--ink);
  color: rgba(255,255,255,0.7);
  display: grid;
  grid-template-columns: 1fr 70px 80px 120px 32px;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.55rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
}

[data-theme="dark"] .queue-header { background: #05070b; }

.queue-item {
  display: grid;
  grid-template-columns: 1fr 70px 80px 120px 32px;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  transition: background 0.12s, opacity 0.18s ease, max-height 0.22s ease, padding 0.22s ease;
  animation: slideIn 0.22s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  max-height: 60px;
}

.queue-item.removing {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: var(--accent-soft); }

.row-progress {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

.file-name {
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size, .file-type {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--muted);
}

.file-type {
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── STATUS BADGES ─── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.24rem 0.55rem;
  border-radius: 100px;
  background: var(--rule);
  color: var(--muted);
  width: fit-content;
}

.status-badge.ready      { background: var(--success-soft); color: var(--success); }
.status-badge.converting { background: var(--accent-soft); color: var(--accent); }
.status-badge.done       { background: var(--success-soft); color: var(--success); }
.status-badge.error      { background: var(--error-soft); color: var(--error); }
.status-badge.outdated   { background: var(--warn-soft); color: var(--warn); cursor: pointer; }

.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.converting .status-dot { animation: pulse 0.8s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--rule);
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem;
  transition: color 0.12s;
  display: flex; align-items: center; justify-content: center;
}

.remove-btn:hover { color: var(--error); }

/* ─── STATS STRIP ─── */
.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
}

.stat-cell {
  padding: 1rem 0.75rem;
  text-align: center;
  border-right: 1px solid var(--rule);
}

.stat-cell:last-child { border-right: none; }

.stat-num {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.stat-num.pulse { animation: statPulse 0.5s ease; }

@keyframes statPulse {
  0%   { transform: scale(1); color: var(--success); }
  40%  { transform: scale(1.18); color: var(--success); }
  100% { transform: scale(1); color: var(--accent); }
}

.stat-lbl {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.3rem;
  font-weight: 600;
}

/* ─── ACTION ROW ─── */
.action-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.download-all-btn {
  background: var(--success);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 0.5rem;
}

.download-all-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.download-all-btn:disabled { background: var(--rule); color: var(--muted); cursor: not-allowed; transform: none; }

.clear-btn {
  background: none;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.clear-btn:hover { border-color: var(--error); color: var(--error); }

/* ─── FORMAT GUIDE (collapsible) ─── */
.format-guide-details {
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.format-guide-details summary {
  cursor: pointer;
  padding: 0.7rem 1.2rem;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-dark);
  background: var(--accent-soft);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  text-align: center;
}

.format-guide-details summary::-webkit-details-marker { display: none; }

.format-guide-details summary::after {
  content: '▾';
  font-family: var(--font-body);
  transition: transform 0.15s ease;
  position: absolute;
  right: 1.2rem;
}

.format-guide-details[open] summary::after { transform: rotate(180deg); }

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.65rem;
  line-height: 1.55;
}

.info-text strong { display: block; font-weight: 700; margin-bottom: 0.12rem; font-size: 0.72rem; }
.info-text p { color: var(--muted); }

/* ─── FOOTER ─── */
footer {
  background: var(--ink);
  padding: 0.8rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  flex-wrap: wrap;
  gap: 0.5rem;
}

[data-theme="dark"] footer { background: #05070b; }

footer strong { color: var(--accent-dark); }

.footer-brand { text-transform: none; }

/* ─── RESPONSIVE ─── */
@media (max-width: 560px) {
  .queue-header,
  .queue-item {
    grid-template-columns: 1fr 70px 100px 28px;
  }

  /* hide Type column on mobile */
  .queue-header span:nth-child(3),
  .queue-item .file-type { display: none; }

  header { padding: 0 1rem; }
  .page-wrap { padding: 1.6rem 0.75rem 2.5rem; }
  footer { justify-content: center; text-align: center; }
}

@media (max-width: 480px) {
  .stat-num { font-size: 1.4rem; }
  .controls-bar { grid-template-columns: 1fr; }
  .masthead-right { gap: 0.4rem; }
  .pill { font-size: 0.52rem; padding: 0.25rem 0.5rem; }

  .queue-header,
  .queue-item {
    grid-template-columns: 1fr 65px 100px 28px;
  }
}
