@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --bg-base:        #0b0d0c;
  --bg-surface:     #111412;
  --bg-raised:      #181c1a;
  --bg-input:       #0e1210;
  --border-subtle:  #1e2520;
  --border-active:  #00e0a0;
  --accent:         #00e0a0;
  --accent-dim:     #00a876;
  --accent-glow:    rgba(0, 224, 160, 0.15);
  --accent-glow-sm: rgba(0, 224, 160, 0.08);
  --text-primary:   #e2ede9;
  --text-secondary: #7a9a8e;
  --text-muted:     #4a6358;
  --text-code:      #6affc0;
  --error:          #ff5a5a;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --transition:     160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  /* subtle dot-grid texture */
  background-image: radial-gradient(circle, #1a2a22 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── Layout ─────────────────────────────────────────────── */
.wrapper {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  width: min(960px, 100%);
  padding: 0 20px 60px;
  gap: 0;
}

/* ── Header / H1 ────────────────────────────────────────── */
h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--bg-base);
  background: var(--accent);
  padding: 18px 28px;
  margin: 0 -20px;
  position: relative;
  overflow: hidden;
}

h1::before {
  content: '$ ';
  opacity: 0.45;
}

h1::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(255,255,255,0.08) 100%);
  pointer-events: none;
}

h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}

/* ── Sections ───────────────────────────────────────────── */
.section {
  width: 100%;
  padding: 28px 0 0;
}

.bottom-divider {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 32px;
  margin-bottom: 4px;
}

.sub-section {
  clear: both;
  margin-bottom: 2px;
}

/* ── Intro Text ─────────────────────────────────────────── */
p {
  margin: 14px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}

p strong {
  color: var(--text-primary);
  font-weight: 600;
}

p a,
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  transition: color var(--transition), border-color var(--transition);
}

p a:hover,
a:hover {
  color: #fff;
  border-color: #fff;
}

/* ── Sponsor block ──────────────────────────────────────── */
.sp-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 10px;
}

.sp-block img {
  height: 28px;
  width: auto;
  border-radius: 4px;
  opacity: 0.9;
  transition: opacity var(--transition);
}

.sp-block img:hover { opacity: 1; }

/* ── Column Layout (step 1) ─────────────────────────────── */
.column { float: left; }

.column-center {
  min-width: 60px;
  text-align: center;
  padding-top: 38px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

.column-right { float: right; }

/* Step 1 columns */
#file-input-column,
.column-right {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#file-input-column:hover,
.column-right:hover {
  border-color: #2a3d34;
  box-shadow: 0 0 0 3px var(--accent-glow-sm);
}

/* ── File Input List ────────────────────────────────────── */
.file-input-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 8px;
}

.file-info {
  color: var(--text-code);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72em;
  margin-left: 8px;
  max-width: 280px;
  white-space: pre;
  opacity: 0.8;
}

/* ── Buttons ────────────────────────────────────────────── */
button,
input[type="file"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #041a10;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 8px 0 0;
  padding: 7px 14px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

button::after,
input[type="file"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
}

button:hover,
input[type="file"]:hover {
  background: #00ffb3;
  box-shadow: 0 0 16px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.5);
  transform: translateY(-1px);
}

button:active,
input[type="file"]:active {
  transform: translateY(0);
  box-shadow: none;
}

.generate-button {
  margin: 28px 0 12px;
  padding: 10px 22px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.remove-button {
  background: #1e2d26;
  color: var(--accent-dim);
  border: 1px solid #2a3d34;
  margin: 0 0 0 6px;
  padding: 2px 7px;
  font-size: 0.7rem;
}

.remove-button:hover {
  background: #3a1515;
  color: var(--error);
  border-color: var(--error);
  box-shadow: 0 0 8px rgba(255, 90, 90, 0.2);
}

input[type="file"] {
  font-size: 0.82rem;
  padding: 8px 14px;
  cursor: pointer;
}

/* ── Settings Table ─────────────────────────────────────── */
.table {
  display: table;
  margin: 10px 0 0;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-row {
  display: table-row;
  width: 100%;
}

.table-row:nth-child(odd) .table-cell {
  background: rgba(255,255,255,0.012);
}

.table-cell {
  display: table-cell;
  padding: 9px 12px 9px 0;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}

.table-cell:first-child { width: 32%; }
.table-cell:last-child  { width: 68%; }

.table-cell:first-child label {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.87rem;
}

.table-cell:last-child label {
  margin-right: 12px;
  color: var(--text-primary);
  font-size: 0.87rem;
}

.nested-table { margin: 0; }

.nested-table .table-cell {
  color: var(--text-muted);
  font-size: 0.85em;
  width: 200px;
  border-bottom: none;
}

/* ── Inputs (text, number, select) ─────────────────────── */
input[type="number"],
input[type="text"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  padding: 5px 9px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300e0a0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

select option {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* ── Checkboxes & Radio ─────────────────────────────────── */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-active);
  border-radius: 3px;
  background: var(--bg-input);
  cursor: pointer;
  vertical-align: middle;
  margin-right: 4px;
  position: relative;
  transition: background var(--transition), box-shadow var(--transition);
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid #041a10;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #041a10;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

/* ── Size / Glyph Inputs ────────────────────────────────── */
.size-input  { width: 54px; }
.glyph-input { width: 86px; margin-left: 8px; }
.text-input  { width: 140px; }

/* ── Notes & Messages ───────────────────────────────────── */
.note {
  color: var(--text-muted);
  font-size: 0.8em;
  line-height: 1.5em;
  margin: 4px 0;
  font-style: italic;
}

.note i { font-style: normal; }

.upload-note {
  max-width: 340px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent-dim);
  background: var(--accent-glow-sm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.msg { font-size: 1.05em; }

.error-msg {
  color: var(--error);
  display: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 6px 10px;
  border: 1px solid rgba(255,90,90,0.3);
  border-radius: var(--radius-sm);
  background: rgba(255,90,90,0.05);
  margin-top: 6px;
}

/* ── Textarea (byte input & code output) ────────────────── */
.byte-input {
  min-height: 160px;
  min-width: 340px;
  width: 100%;
  resize: vertical;
}

.code-output {
  height: 220px;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-code);
  resize: vertical;
  margin-top: 8px;
  line-height: 1.55;
  tab-size: 4;
}

/* ── Image Size Settings List ───────────────────────────── */
#image-size-settings {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#image-size-settings li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Canvas Container (Step 3) ──────────────────────────── */
#images-canvas-container {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  min-height: 60px;
}

#images-canvas-container canvas {
  border: 2px solid var(--accent-dim);
  border-radius: 2px;
  box-shadow: 0 0 12px var(--accent-glow);
  image-rendering: pixelated;
}

/* ── Format Caption Container ───────────────────────────── */
#format-caption-container div {
  color: var(--text-secondary);
  display: none;
  font-size: 0.85em;
  line-height: 1.6em;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-left: 2px solid var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 8px;
  width: 100%;
}

#format-caption-container div a {
  color: var(--text-code);
}

/* ── Hidden elements (toggled by JS) ────────────────────── */
#arduino-identifier,
#adafruit-gfx-settings,
#all-same-size {
  display: none;
}

/* ── Inline glitched-display image ─────────────────────── */
.inlineImg {
  display: block;
  margin-top: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  opacity: 0.75;
  filter: sepia(0.2) hue-rotate(120deg);
}

/* ── Output section buttons ─────────────────────────────── */
#copy-button,
#download-button {
  background: var(--bg-raised);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  margin-right: 6px;
}

#copy-button:hover,
#download-button:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 12px var(--accent-glow);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── Sub-section title ──────────────────────────────────── */
.sub-section-title {
  margin: 0 0 12px;
}

/* ── Scrollbar (webkit) ─────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
  background: #1e2d26;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Selection ──────────────────────────────────────────── */
::selection {
  background: var(--accent-glow);
  color: #fff;
}

/* ── Section fade-in on load ────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section {
  animation: fadeUp 0.35s ease both;
}

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.12s; }
.section:nth-child(3) { animation-delay: 0.19s; }
.section:nth-child(4) { animation-delay: 0.26s; }
.section:nth-child(5) { animation-delay: 0.33s; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .wrapper { width: 100%; padding: 0 12px 40px; }

  h1 { margin: 0 -12px; font-size: 1.4rem; }

  .column,
  .column-right {
    float: none;
    width: 100% !important;
    margin-bottom: 16px;
  }

  .column-center { padding-top: 0; margin: 8px 0; }

  .table-cell:first-child,
  .table-cell:last-child { width: 100%; display: block; }
}
