/* ===================================================================
   img2css — terminal styling + phosphor themes
   =================================================================== */

:root {
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "Fira Code",
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --term-pad: 18px;
  --line-h: 1.45;
}

/* ---- phosphor themes ------------------------------------------------ */
/* Each theme sets background, foreground, dim, accent and a glow color. */
.theme-green {
  --bg: #020a02;
  --bg-soft: #041204;
  --fg: #33ff66;
  --dim: #1c8c3c;
  --accent: #aaffaa;
  --warn: #ffd166;
  --err: #ff5f56;
  --glow: rgba(51, 255, 102, 0.45);
  --selection: rgba(51, 255, 102, 0.3);
}
.theme-amber {
  --bg: #0f0700;
  --bg-soft: #1a0e00;
  --fg: #ffb000;
  --dim: #9a6a00;
  --accent: #ffd98a;
  --warn: #ffe08a;
  --err: #ff6b4a;
  --glow: rgba(255, 176, 0, 0.4);
  --selection: rgba(255, 176, 0, 0.3);
}
.theme-white {
  --bg: #0c0c0e;
  --bg-soft: #151518;
  --fg: #e6e6e6;
  --dim: #8a8a90;
  --accent: #ffffff;
  --warn: #ffd166;
  --err: #ff6b6b;
  --glow: rgba(230, 230, 230, 0.18);
  --selection: rgba(230, 230, 230, 0.28);
}
.theme-matrix {
  --bg: #000300;
  --bg-soft: #001100;
  --fg: #00ff41;
  --dim: #0a7a2a;
  --accent: #b9ffb9;
  --warn: #d7ff5e;
  --err: #ff5f56;
  --glow: rgba(0, 255, 65, 0.55);
  --selection: rgba(0, 255, 65, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: var(--font-mono);
  color: var(--fg);
  font-size: 14px;
  line-height: var(--line-h);
  overflow: hidden;
  text-shadow: 0 0 4px var(--glow);
}

::selection { background: var(--selection); }

/* ---- layout --------------------------------------------------------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  gap: 0;
}

.terminal {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--term-pad);
  background:
    radial-gradient(120% 120% at 50% 0%, var(--bg-soft) 0%, var(--bg) 70%);
  overflow: hidden;
  cursor: text;
}

/* faint scanlines for the CRT feel */
.terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}

.output {
  flex: 1 1 auto;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}
.output::-webkit-scrollbar { width: 8px; }
.output::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 4px; }

.line { display: block; }
.line.cmd { color: var(--accent); }
.line.muted { color: var(--dim); }
.line.warn { color: var(--warn); }
.line.err { color: var(--err); }
.line.accent { color: var(--accent); }
.line.banner {
  color: var(--fg);
  filter: drop-shadow(0 0 6px var(--glow));
}

/* command echo prefix */
.line.cmd::before { content: "img2css> "; color: var(--dim); }

/* progress bar line */
.progress-line { color: var(--accent); }

/* ---- input ---------------------------------------------------------- */
.input-line {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 4px;
}
.prompt { color: var(--dim); flex: 0 0 auto; }
.cmdline {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  white-space: pre;
  min-width: 0;
}
.mirror { color: var(--fg); white-space: pre; }
.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.05em;
  margin-left: 1px;
  transform: translateY(0.18em);
  background: var(--fg);
  box-shadow: 0 0 6px var(--glow);
  animation: blink 1.05s steps(1) infinite;
}
.input-line.blurred .cursor { background: transparent; box-shadow: none; outline: 1px solid var(--dim); }
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* the real input sits transparently over the line to capture typing/taps */
.cmd-input {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  padding: 0;
  margin: 0;
}

/* ---- preview pane --------------------------------------------------- */
.preview {
  flex: 0 0 42%;
  max-width: 620px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--dim);
  overflow: hidden;
}
.preview.hidden { display: none; }
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--dim);
  color: var(--dim);
  flex: 0 0 auto;
}
.preview-close {
  background: transparent;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 3px;
}
.preview-close:hover { color: var(--fg); border-color: var(--fg); }
.preview-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}
.preview-col { display: flex; flex-direction: column; gap: 6px; }
.preview-label {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.12em;
}
.preview-stage {
  /* checkerboard so transparency is visible */
  background-color: #3a3a3a;
  background-image:
    linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1px solid var(--dim);
  border-radius: 4px;
  padding: 14px;
  min-height: 90px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
}
.preview-stage img { image-rendering: pixelated; display: block; max-width: 100%; }
.preview-host { position: relative; }

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

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.drop-overlay.hidden { display: none; }
.drop-inner {
  border: 2px dashed var(--fg);
  color: var(--fg);
  padding: 40px 64px;
  border-radius: 8px;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 0 24px var(--glow);
}

/* ---- responsive ----------------------------------------------------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .preview {
    flex: 0 0 45%;
    max-width: none;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--dim);
  }
  .preview-body { flex-direction: column; }
  body { font-size: 13px; }
}
