@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

:root {
  --bg:       #08080f;
  --grid:     #1a1a3a;
  --cyan:     #00f5ff;
  --magenta:  #ff00cc;
  --purple:   #7700ff;
  --text:     #c8d0ff;
  --text-dim: #6672aa;
  --card-bg:  #0d0d20;
  --glow-c:   0 0 8px #00f5ff, 0 0 20px #00f5ff44;
  --glow-m:   0 0 8px #ff00cc, 0 0 20px #ff00cc44;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 15px;
  overflow-x: hidden;
}

/* Perspective grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 40%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* CRT scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 4px
  );
  pointer-events: none;
  z-index: 999;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.8rem 0 1.2rem;
  border-bottom: 1px solid var(--grid);
  min-height: 5rem;
}

.logo {
  font-family: 'VT323', monospace;
  font-size: 3rem;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: logopulse 4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px var(--cyan));
}

@keyframes logopulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--cyan)); }
  50%       { filter: drop-shadow(0 0 18px var(--magenta)); }
}

.credit {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--cyan);
  box-shadow: var(--glow-c);
  border-radius: 4px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.4rem;
}

.card-title {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-bottom: 0.8rem;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  gap: 0;
  margin: 1.4rem 0 0;
  justify-content: center;
}

.mode-btn {
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  padding: 0.5rem 1.8rem;
  cursor: pointer;
  border: 1px solid var(--grid);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s;
}

.mode-btn:first-child {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.mode-btn:last-child {
  border-radius: 0 4px 4px 0;
}

.mode-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,245,255,0.1);
  box-shadow: var(--glow-c);
}

.mode-btn:hover:not(.active) {
  border-color: var(--cyan);
  color: var(--text);
}

[data-theme="minimal"] .mode-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

[data-theme="minimal"] .mode-btn.active {
  background: #0a0a0a;
  color: #ffffff;
  border-color: #0a0a0a;
  box-shadow: none;
}

/* Studio layout */
.studio {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.2rem;
  align-items: start;
  margin-top: 1.8rem;
}

@media (max-width: 680px) {
  .studio { grid-template-columns: 1fr; }
}

/* Style list */
.style-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 40px;
}

.no-styles {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  padding: 0.6rem 0;
  line-height: 1.5;
}

/* Style card (generated by studio.js) */
.style-card {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--grid);
  border-radius: 3px;
  transition: border-color 0.15s, background 0.15s;
  background: transparent;
}

.style-card-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.style-card:hover {
  border-color: var(--cyan);
  background: rgba(0,245,255,0.06);
}

.style-preview {
  width: 100%;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border-radius: 2px;
  display: block;
  margin-bottom: 0.3rem;
}

.style-name {
  flex: 1;
  font-size: 0.85rem;
  outline: none;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-delete-style {
  background: none;
  border: none;
  color: var(--magenta);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0.2rem;
  opacity: 0.5;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.btn-delete-style:hover { opacity: 1; }

/* Inline rename input */
.rename-input {
  flex: 1;
  background: #050510;
  border: 1px solid var(--cyan);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  outline: none;
}

/* Canvas */
#draw-canvas {
  width: 100%;
  height: 160px;
  background: #050510;
  border: 1px solid var(--cyan);
  box-shadow: var(--glow-c);
  border-radius: 3px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Inputs */
input[type="text"], .text-input {
  background: #050510;
  border: 1px solid var(--grid);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  padding: 0.5rem 0.7rem;
  border-radius: 3px;
  width: 100%;
  transition: border-color 0.15s;
  font-size: 0.95rem;
}

input[type="text"]:focus, .text-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: var(--glow-c);
}

input[type="range"] {
  accent-color: var(--cyan);
  cursor: pointer;
  flex: 1;
}

/* Buttons */
.btn {
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  padding: 0.4rem 1.2rem;
  min-height: 2.2rem;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
}

.btn:hover {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: var(--glow-c);
}

.btn-cyan {
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-cyan:hover {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: var(--glow-c);
}

.btn-magenta {
  border-color: var(--magenta);
  color: var(--magenta);
}

.btn-magenta:hover {
  background: var(--magenta);
  color: var(--bg);
  box-shadow: var(--glow-m);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent !important;
  box-shadow: none !important;
}

/* Style pills */
.style-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.style-pill {
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--grid);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: 'Share Tech Mono', monospace;
  transition: all 0.15s;
  color: var(--text-dim);
  background: transparent;
}

.style-pill.active,
.style-pill.selected {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,245,255,0.08);
  box-shadow: 0 0 6px rgba(0,245,255,0.3);
}

/* Bias row */
.bias-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.6rem 0;
}

.bias-row label { color: var(--text-dim); min-width: 3rem; }
.bias-row span   { min-width: 2.5rem; text-align: right; color: var(--cyan); }

/* Progress bar */
.progress-wrap {
  position: relative;
  height: 6px;
  background: var(--grid);
  border-radius: 3px;
  margin: 0.8rem 0 0.4rem;
  overflow: visible;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 3px;
  box-shadow: 0 0 8px var(--cyan);
}

.progress-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  margin-bottom: 0.6rem;
}

/* Results grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.8rem;
}

/* Result item (generated by generate.js) */
.result-item {
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s;
}

.result-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.result-item:hover {
  border-color: #aaa;
}

.result-item img {
  width: 100%;
  max-height: 160px;
  display: block;
  object-fit: contain;
  padding: 0.5rem;
  background: #fff;
}

.result-download {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--bg);
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
  text-decoration: none;
  opacity: 1;
  box-shadow: var(--glow-c);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border: 1px solid var(--cyan);
  box-shadow: var(--glow-c);
}

/* Flash message */
#flash-msg {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 1px solid var(--cyan);
  color: var(--text);
  padding: 0.6rem 1.4rem;
  border-radius: 4px;
  font-size: 0.9rem;
  z-index: 1001;
  box-shadow: var(--glow-c);
  white-space: nowrap;
}

#flash-msg.error {
  border-color: var(--magenta);
  color: var(--magenta);
  box-shadow: var(--glow-m);
}

#flash-msg.success {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Misc */
.hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.row-btns {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

section { margin-bottom: 0; }

/* ── Smooth theme transitions (colors only, not layout) ──────── */
body, .card, .card-title, .btn, .btn-theme,
input[type="text"], .text-input, #draw-canvas,
.style-pill, .style-card, .style-name, header, .logo, .credit {
  transition: background 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ── Minimal (clean white) theme ──────────────────────────────── */
[data-theme="minimal"] {
  --bg:       #ffffff;
  --grid:     #e5e5e5;
  --cyan:     #0a0a0a;
  --magenta:  #555555;
  --purple:   #333333;
  --text:     #0a0a0a;
  --text-dim: #666666;
  --card-bg:  #f7f7f7;
  --glow-c:   none;
  --glow-m:   none;
}

[data-theme="minimal"] body {
  font-family: 'Inter', sans-serif;
}

/* Kill the grid and scanline pseudo-elements */
[data-theme="minimal"] body::before,
[data-theme="minimal"] body::after {
  display: none;
}

/* Logo: visually matched size, black text, no gradient/glow */
[data-theme="minimal"] .logo {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: #0a0a0a;
  background-clip: unset;
  animation: none;
  filter: none;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}

/* Cards: flat white, thin gray border */
[data-theme="minimal"] .card {
  border-color: #e0e0e0;
  box-shadow: none;
}

[data-theme="minimal"] .card-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0a0a0a;
}

/* Buttons: flat bordered — same min-height as synth to avoid layout shift */
[data-theme="minimal"] .btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

[data-theme="minimal"] .btn:hover {
  background: #0a0a0a;
  color: #ffffff;
  box-shadow: none;
}

/* Inputs */
[data-theme="minimal"] input[type="text"],
[data-theme="minimal"] .text-input {
  font-family: 'Inter', sans-serif;
  background: #ffffff;
  border-color: #d0d0d0;
}

[data-theme="minimal"] input[type="text"]:focus,
[data-theme="minimal"] .text-input:focus {
  box-shadow: none;
  border-color: #0a0a0a;
}

/* Canvas */
[data-theme="minimal"] #draw-canvas {
  background: #ffffff;
  border-color: #cccccc;
  box-shadow: none;
}

/* Style pills */
[data-theme="minimal"] .style-pill.active,
[data-theme="minimal"] .style-pill.selected {
  border-color: #0a0a0a;
  color: #0a0a0a;
  background: rgba(0,0,0,0.05);
  box-shadow: none;
}

/* Accent: range slider */
[data-theme="minimal"] input[type="range"] {
  accent-color: #0a0a0a;
}

/* Flash messages */
[data-theme="minimal"] #flash-msg {
  box-shadow: none;
}

/* ── Scanline wipe overlay ────────────────────────────────────── */
#theme-wipe {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  pointer-events: none;
  display: none;
  background: repeating-linear-gradient(
    to bottom,
    #000 0px,
    #000 2px,
    #111 2px,
    #111 4px
  );
}

#theme-wipe.wipe-down {
  display: block;
  animation: wipeDown 0.3s ease-in forwards;
}

#theme-wipe.wipe-off {
  display: block;
  animation: wipeOff 0.3s ease-out forwards;
}

@keyframes wipeDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0%); }
}

@keyframes wipeOff {
  from { transform: translateY(0%); }
  to   { transform: translateY(100%); }
}

/* ── Theme toggle button ──────────────────────────────────────── */
.btn-theme {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.8rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--cyan);
  background: transparent;
  color: var(--cyan);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-theme:hover {
  background: var(--cyan);
  color: var(--bg);
}

[data-theme="minimal"] .btn-theme {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
