/* Tagsu screen editor. No framework, no build step. */

:root {
  --bg: #11151c;
  --panel: #19202b;
  --panel-2: #212a38;
  --line: #2d3848;
  --text: #e7ecf4;
  --muted: #94a3b8;
  --accent: #2158cf;
  --accent-bright: #3f7ae8;
  --lcd: #2158cf;
  --ok: #3fae6b;
  --bad: #e2605a;
  --radius: 8px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

h1 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
}

a {
  color: var(--accent-bright);
}

/* ------------------------------------------------------------------ chrome */

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.home {
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
}

.budget {
  margin-left: auto;
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ----------------------------------------------------------------- widgets */

button,
select,
input {
  font: inherit;
  color: var(--text);
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1.2;
}

button:hover:not(:disabled) {
  border-color: var(--accent-bright);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-bright);
}

button.danger:hover:not(:disabled) {
  border-color: var(--bad);
  color: var(--bad);
}

button.ghost {
  background: transparent;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-bright);
  text-align: left;
  flex: 1;
}

button.link:hover {
  text-decoration: underline;
}

select,
input[type="text"],
input[type="number"] {
  background: #0d1118;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 1px;
}

.segmented {
  display: inline-flex;
}

.segmented .seg {
  border-radius: 0;
  margin-left: -1px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.segmented .seg:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  margin-left: 0;
}

.segmented .seg:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.segmented .seg.selected {
  background: var(--accent);
  border-color: var(--accent);
  z-index: 1;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.indented {
  margin: 0 0 0 112px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.status {
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 10px;
  background: var(--panel-2);
}

.status.bad {
  background: #3a1f20;
  color: #ffd9d6;
}

.status.ok {
  background: #16301f;
  color: #d6ffe4;
}

.status.busy {
  background: var(--panel-2);
  color: var(--muted);
}

.summary:empty {
  display: none;
}

.empty {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

/* ------------------------------------------------------------------- cards */

.screens {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.6s, box-shadow 0.6s;
}

/* The card being moved rides over its neighbours as they slide past. */
.card.moving {
  position: relative;
  z-index: 1;
  border-color: var(--accent-bright);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  transition: none;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.card-tools {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.card-tools button {
  padding: 4px 8px;
  font-size: 0.82rem;
}

.card-body {
  padding: 14px;
  display: grid;
  gap: 10px;
  /* Grid and flex items default to min-width:auto, so a canvas wider than the
     screen would stretch the whole card and clip off the right edge instead of
     being measured and scaled down. */
  min-width: 0;
}

.preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

canvas.lcd {
  border-radius: 4px;
  display: block;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px #00000055;
  /* Belt and braces: if a scale is ever a pixel too wide, shrink rather than
     overflow the card. */
  max-width: 100%;
}

.preview-tools {
  display: flex;
  gap: 4px;
}

.preview-tools button {
  padding: 4px 9px;
  font-size: 0.82rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field .label {
  width: 104px;
  flex: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.text-field input {
  flex: 1;
  min-width: 140px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

input.delay {
  width: 80px;
}

.field select {
  flex: 1;
  min-width: 150px;
}

.problems {
  margin: 0;
  padding: 0 0 0 18px;
  color: #ffb4ae;
  font-size: 0.85rem;
}

.problems.empty {
  display: none;
}

/* ----------------------------------------------------------------- dialogs */

dialog.modal {
  width: min(96vw, 760px);
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  overflow: auto;
}

dialog.modal.narrow {
  width: min(96vw, 440px);
}

dialog.modal::backdrop {
  background: #000a;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.modal-head h2 {
  font-size: 1rem;
  flex: 1;
}

.modal-close {
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 6px;
}

.modal-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 4px;
}

.saves {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.saves li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--panel-2);
}

.legacy h3 {
  margin-top: 8px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.steps li {
  margin-bottom: 4px;
}

.speeds {
  display: grid;
  gap: 6px;
}

.speeds .seg {
  padding: 8px 14px;
  gap: 2px;
}

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent-bright);
}

.timing summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.timing table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
}

.timing th,
.timing td {
  text-align: left;
  padding: 2px 14px 2px 0;
  font-weight: 400;
}

.timing th {
  color: var(--muted);
}

.timing td {
  font-variant-numeric: tabular-nums;
}

dialog.cycle .modal-body {
  justify-items: center;
}

/* ------------------------------------------------------------- logo editor */

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab.selected {
  background: var(--accent);
  border-color: var(--accent);
}

.builtin-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}

.builtin {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 4px;
}

.builtin canvas {
  border-radius: 3px;
}

.builtin span {
  font-size: 0.75rem;
  color: var(--muted);
}

.builtin.selected {
  background: var(--accent);
  border-color: var(--accent);
}

.builtin.selected span {
  color: #fff;
}

.logo-pane {
  display: grid;
  gap: 12px;
}

.logo-pane .tool-row {
  flex-wrap: wrap;
}

/* The same footprint as a 3x logo thumbnail, so the tile lines up with them. */
.new-logo .plus {
  display: grid;
  place-items: center;
  width: 45px;
  height: 48px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  font-size: 1.4rem;
  line-height: 1;
}

.custom-wrap {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.pixel-grid {
  display: grid;
  gap: 1px;
  background: #0d1118;
  padding: 4px;
  border-radius: var(--radius);
  touch-action: none;
  width: min(100%, 300px);
}

.pixel-grid .px {
  aspect-ratio: 1;
  background: #243b63;
  border-radius: 1px;
}

.pixel-grid .px.on {
  background: #f4f8ff;
}

.logo-tools {
  display: grid;
  gap: 12px;
  align-content: start;
}

.logo-preview-wrap {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.tool-row,
.nudge-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nudge {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.nudge button {
  padding: 4px 10px;
}

/* ------------------------------------------------------------- small print */

@media (max-width: 560px) {
  .field .label {
    width: 100%;
  }

  .indented {
    margin-left: 0;
  }

  main {
    padding: 12px;
  }

  .bar,
  .toolbar {
    padding: 10px 12px;
  }
}

/* ----------------------------------------------------- character set page */

.charset-grid {
  display: grid;
  grid-template-columns: repeat(17, minmax(0, 1fr));
  gap: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.62rem;
  overflow-x: auto;
}

.charset-grid .head {
  color: var(--muted);
  text-align: center;
  padding: 3px 0;
  align-self: center;
}

.charset-cell {
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 1px 2px;
  display: grid;
  justify-items: center;
  gap: 2px;
}

.charset-cell canvas {
  image-rendering: pixelated;
}

.charset-cell .code {
  color: var(--muted);
  font-size: 0.92em;
}

.prose-block {
  max-width: 70ch;
}

.prose-block code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--panel-2);
  border-radius: 3px;
  padding: 1px 5px;
}

@media (max-width: 620px) {
  .charset-grid {
    font-size: 0.5rem;
    gap: 2px;
  }
}

.status:empty {
  display: none;
}
