/* WALLPAPER WARP — level styles */

@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%; }

: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);
}

*, *::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); }

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

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

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

.warp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preview-column, .controls {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.preview-frame {
  --preview-aspect: 16 / 9;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: var(--preview-aspect);
  min-height: 220px;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(69, 240, 255, 0.08), transparent 42%),
    linear-gradient(315deg, rgba(255, 61, 139, 0.08), transparent 48%),
    #05050d;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.32);
}

#previewCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(233, 233, 242, 0.05);
  font-family: var(--pixel);
  font-size: clamp(38px, 14vw, 112px);
  letter-spacing: 6px;
  pointer-events: none;
}
.preview-frame.has-render .preview-empty { display: none; }

.render-strip, .action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}

.action-row { justify-content: flex-start; }
.action-row .btn { flex: 1 1 120px; }

progress {
  flex: 1 1 180px;
  min-width: 160px;
  height: 12px;
  accent-color: var(--cyan);
}

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

.status-line {
  margin: 6px 0 0;
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--green);
  line-height: 1.8;
}

.note, .privacy-note {
  margin: 0;
  color: var(--dim);
  font-size: 12.5px;
}

.btn, .icon-btn, .chip, .algo-card, .palette-btn {
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s, background 0.12s;
}

.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: 700;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-decoration: none;
}
.btn-big { font-family: var(--pixel); font-size: 11px; padding: 14px 20px; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }

.icon-btn {
  width: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled), .chip:hover:not(:disabled),
.algo-card:hover, .palette-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:active, .icon-btn:active, .chip:active, .algo-card:active, .palette-btn:active { transform: translateY(1px); }
.btn:disabled, .icon-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.algo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.algo-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  letter-spacing: 0.5px;
}
.algo-card.is-active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(69, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(69, 240, 255, 0.35);
}

.algo-preview {
  display: block;
  width: 92px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid rgba(233, 233, 242, 0.12);
  background: #05050d;
}
.preview-flow { background: repeating-radial-gradient(ellipse at 70% 20%, transparent 0 10px, rgba(69, 240, 255, 0.5) 11px 12px), #05050d; }
.preview-peaks { background: linear-gradient(160deg, transparent 48%, rgba(255, 200, 87, 0.75) 49% 58%, transparent 59%), linear-gradient(22deg, transparent 54%, rgba(69, 240, 255, 0.45) 55% 64%, transparent 65%), #090914; }
.preview-circuit { background: linear-gradient(90deg, transparent 20%, #45f0ff 21% 23%, transparent 24% 66%, #ff3d8b 67% 69%, transparent 70%), linear-gradient(0deg, transparent 34%, #ffc857 35% 37%, transparent 38%), #05050d; }
.preview-stars { background: radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 2px), radial-gradient(circle at 70% 65%, #45f0ff 0 1px, transparent 2px), radial-gradient(circle at 45% 40%, rgba(255, 61, 139, 0.6), transparent 28px), #05050d; }
.preview-bauhaus { background: linear-gradient(90deg, #45f0ff 0 26%, #0a0a12 26% 36%, #ffc857 36% 66%, #ff3d8b 66% 100%); }

.seed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  min-width: 0;
  background: var(--bg);
  border: 1px solid #5e5e80;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 13px;
}

.palette-grid, .size-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.palette-btn, .chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 8px 10px;
}

.palette-btn {
  display: grid;
  gap: 6px;
  min-width: 104px;
  text-align: left;
}
.palette-btn.is-active, .chip.is-active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(69, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(69, 240, 255, 0.35);
}

.palette-swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.palette-swatches span {
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(233, 233, 242, 0.12);
}

.custom-palette, .custom-size {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.custom-size { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.custom-palette label, .custom-size label {
  display: grid;
  gap: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
}

input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.toggle-line {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.toggle-line input { accent-color: var(--cyan); }

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

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

@media (min-width: 768px) {
  .algo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .warp-layout { grid-template-columns: minmax(0, 1fr) 420px; gap: 22px; }
  .algo-grid { grid-template-columns: 1fr; }
  .preview-column { position: sticky; top: 18px; }
}

@media (max-width: 480px) {
  .wordmark { letter-spacing: 1px; }
  .render-strip, .action-row { align-items: stretch; }
  .render-strip > *, .action-row .btn, progress { flex-basis: 100%; }
  .algo-card { grid-template-columns: 72px minmax(0, 1fr); }
  .algo-preview { width: 72px; }
  .custom-palette { grid-template-columns: 1fr; }
}

@media (pointer: coarse) {
  .btn, .icon-btn, .chip, .algo-card, .palette-btn, .toggle-line { min-height: 44px; }
}

@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 { animation: none; }
}
