/* GHOST MODE — styles.css
   Retro-arcade / CRT-era, modern-polished. Dark only. */

/* ---------- fonts (self-hosted, shared with the lab root) ---------- */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

/* ---------- tokens ---------- */

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);
  --checker: repeating-conic-gradient(#1c1c2c 0% 25%, #14141f 0% 50%);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(69, 240, 255, 0.05), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }
a { color: var(--cyan); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}

/* ---------- header ---------- */

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }

.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}

.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 3px 3px 0 var(--magenta);
}

.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.cursor { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px var(--space-gutter) 72px;
}

.upload-stage { margin-bottom: 20px; }

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: clamp(34px, 7vw, 74px) 20px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, var(--surface), rgba(18, 18, 29, 0.3));
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s var(--ease-out);
}
.drop-zone:hover, .drop-zone.is-over {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(69, 240, 255, 0.12), inset 0 0 48px rgba(69, 240, 255, 0.04);
}
.drop-zone.is-over { transform: scale(1.01); }

.drop-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 28px;
  color: var(--dim);
  font-size: 14px;
}
.ghost-block { width: 22px; height: 22px; display: inline-block; }
.block-cyan { background: var(--cyan); }
.block-magenta { background: var(--magenta); clip-path: polygon(50% 0, 100% 34%, 82% 100%, 18% 100%, 0 34%); }
.block-empty { border: 2px solid var(--gold); box-shadow: inset 0 0 0 5px rgba(255, 200, 87, 0.08); }
.drop-zone:hover .ghost-block { animation: bob 1.2s ease-in-out infinite; }
.drop-zone:hover .block-magenta { animation-delay: 0.15s; }
.drop-zone:hover .block-empty { animation-delay: 0.3s; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.drop-title {
  margin: 0 0 14px;
  font-family: var(--pixel);
  font-size: clamp(11px, 2.6vw, 15px);
  color: var(--text);
  letter-spacing: 1px;
}
.drop-sub { margin: 0 0 18px; color: var(--dim); font-size: 14px; }
.drop-formats {
  margin: 22px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
.privacy-note {
  margin: 18px auto 0;
  max-width: 520px;
  text-align: center;
  font-size: 12.5px;
  color: var(--dim);
}

.workspace { display: grid; gap: 16px; }
.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}
.src-info {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  word-break: break-word;
}

.tool-grid, .result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(69, 240, 255, 0.4);
}
.note { margin: 0; font-size: 12px; color: var(--dim); line-height: 1.5; }
.note-gold { color: var(--gold); }
.model-credit { color: var(--green); }

/* ---------- previews ---------- */

.preview-box, .compare-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  background: var(--checker) 0 0 / 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.preview-box canvas {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 520px);
}
.empty-preview {
  margin: 0;
  position: absolute;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
.preview-box.has-image .empty-preview { display: none; }

.model-status {
  margin: 0;
  font-family: var(--mono);
  color: var(--text);
}
progress {
  width: 100%;
  height: 14px;
  accent-color: var(--cyan);
}
.run-actions, .result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.is-busy .preview-box::after,
.is-busy .compare-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0, rgba(69, 240, 255, 0.13) 50%, transparent 100%);
  animation: scanline 1.1s linear infinite;
}
@keyframes scanline {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

/* ---------- buttons & fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.btn-primary:hover { box-shadow: 0 0 18px rgba(69, 240, 255, 0.5); }
.btn-ghost { background: transparent; }
.btn-big { font-family: var(--pixel); font-size: 11px; padding: 14px 20px; }

.background-options {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.background-options legend {
  width: 100%;
  margin-bottom: 2px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
.background-options label {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  cursor: pointer;
}
.background-options input { accent-color: var(--cyan); }

.field-row { display: flex; align-items: center; gap: 10px; }
.field-row > label {
  flex: 0 0 82px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
input[type="color"] {
  width: 46px; height: 36px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
select {
  width: 100%;
  min-height: 40px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
}

/* ---------- result ---------- */

.result-stage { margin-top: 22px; }
.result-heading {
  margin: 8px 0 22px;
  text-align: center;
  font-family: var(--pixel);
  font-size: clamp(12px, 2.6vw, 16px);
  color: var(--green);
  text-shadow: 0 0 12px rgba(65, 255, 139, 0.5);
}
.compare-wrap { min-width: 0; }
.compare-stage {
  aspect-ratio: 1 / 1;
  min-height: 0;
}
.compare-stage canvas,
.after-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.compare-stage canvas {
  display: block;
  object-fit: contain;
}
.after-layer {
  overflow: hidden;
  width: 55%;
  border-right: 2px solid var(--cyan);
}
.after-layer canvas { width: calc(100% / var(--wipe, 0.55)); max-width: none; }
.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: 55%;
  width: 2px;
  background: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.compare-labels {
  display: flex;
  justify-content: space-between;
  margin: 8px 2px 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
}
.wipe-control {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}
.wipe-control input { width: 100%; accent-color: var(--cyan); }
.wipe-control output { color: var(--gold); text-align: right; }
.result-dims {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-info { border-left-color: var(--cyan); }
.toast-success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

/* ---------- responsive ---------- */

@media (min-width: 768px) {
  .tool-grid { grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr); }
  .result-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

@media (pointer: coarse) {
  .btn, .background-options label, select { min-height: 44px; }
}

@media (max-width: 480px) {
  .wordmark { letter-spacing: 1px; }
  .workspace-head { display: block; }
  .field-row { flex-wrap: wrap; }
  .field-row > label { flex-basis: 100%; }
  .run-actions .btn, .result-actions .btn { width: 100%; }
  .wipe-control { grid-template-columns: 1fr; }
  .wipe-control output { text-align: left; }
}

/* ---------- reduced motion: kill all looping/auto animation ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor, .drop-zone:hover .ghost-block, .is-busy .preview-box::after, .is-busy .compare-stage::after {
    animation: none !important;
  }
}
