/* bundled faces, SIL Open Font License - see fonts/OFL-*.txt.
   the browser only fetches one of these when something asks to draw with it */
@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-regular.ttf"); font-display: block; }
@font-face { font-family: "SilkscreenBold"; src: url("fonts/silkscreen-bold.ttf"); font-display: block; }
@font-face { font-family: "PressStart2P"; src: url("fonts/press-start-2p.ttf"); font-display: block; }
@font-face { font-family: "Tiny5"; src: url("fonts/tiny5.ttf"); font-display: block; }
@font-face { font-family: "Micro5"; src: url("fonts/micro5.ttf"); font-display: block; }
@font-face { font-family: "PixelifySans"; src: url("fonts/pixelify-sans.ttf"); font-display: block; }
@font-face { font-family: "Jacquard12"; src: url("fonts/jacquard12.ttf"); font-display: block; }
@font-face { font-family: "Workbench"; src: url("fonts/workbench.ttf"); font-display: block; }
@font-face { font-family: "VT323"; src: url("fonts/vt323.ttf"); font-display: block; }
@font-face { font-family: "ComicNeue"; src: url("fonts/comic-neue.ttf"); font-weight: normal; font-display: block; }
@font-face { font-family: "ComicNeue"; src: url("fonts/comic-neue-bold.ttf"); font-weight: bold; font-display: block; }

.button-tool-page #container {
}

.tool-main {
  order: 0;
  width: 100%;
}

.tool-intro .panel-body {
  margin: 0;
  padding: 5px 9px 6px;
  color: var(--site-ink);
  font-size: 0.85rem;
  line-height: 1.5;
}

#app {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.span-2 {
  grid-column: 1 / -1;
}

.tool-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

/* undo, redo and reset belong to the whole tool rather than to any one panel,
   so they ride along the top instead of sitting at the bottom of a list */
.tool-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid var(--site-ink);
  background: var(--site-surface);
  box-shadow: 2px 2px 0 var(--site-steel);
}

.tool-actions .spacer {
  flex: 1;
}

/* ---------- preset shelf ---------- */

#presetRow {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.button-tool-page .presetChip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 5px 4px;
  border: 1px solid var(--site-ink);
  color: var(--site-red);
  background: var(--site-surface);
  font-family: monospace;
  font-size: 0.66em;
  line-height: 1.1;
  text-align: center;
  box-shadow: 2px 2px 0 var(--site-steel);
}

.presetThumb {
  width: 88px;
  height: 31px;
  max-width: 100%;
  border: 1px solid var(--site-ink);
  image-rendering: pixelated;
}

.extractor-panel {
  min-width: 0;
  margin-bottom: 0;
}

.panel-subtitle {
  margin: 16px 0 8px;
  color: var(--site-red);
  font-family: "Old English Gothic Pixel", Georgia, serif;
  font-size: 18px;
  font-weight: normal;
  line-height: 1;
}

.panel-note {
  margin: 8px 0 0;
  color: var(--site-deep);
  font-size: 0.78em;
}

/* ---------- form fields ---------- */
/* every field label sits on its own line above its field */
.button-tool-page .panel-body label[for] {
  display: block;
  margin: 12px 0 4px;
  color: var(--site-red);
  font-size: 0.78em;
  font-weight: 700;
}

.button-tool-page .panel-body label[for]:first-child {
  margin-top: 0;
}

.button-tool-page input[type="text"],
.button-tool-page input[inputmode="url"] {
  box-sizing: border-box;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--site-ink);
  color: var(--site-ink);
  background: #fffdf6;
  font-family: monospace;
  font-size: 0.85em;
}

.button-tool-page select {
  box-sizing: border-box;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--site-ink);
  color: var(--site-ink);
  background: #fffdf6;
  font-family: monospace;
  font-size: 0.8em;
}

.button-tool-page input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--site-ink);
  background: var(--site-surface);
  cursor: pointer;
}

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

.fieldRow--tight {
  align-items: center;
  margin-top: 12px;
}

.fieldRow--tight input[type="color"] {
  height: 28px;
}

/* a swatch on its own says nothing you can read or type back */
.swatchRow {
  display: flex;
  gap: 6px;
  align-items: center;
}

.swatchRow input[type="color"] {
  flex: 1;
  min-width: 0;
}

/* input.hexField, not .hexField: the generic input[type="text"] rule above is
   more specific than a bare class and would stretch this to the full row */
.button-tool-page input.hexField {
  box-sizing: border-box;
  width: 9ch;
  flex: none;
  padding: 4px 4px;
  border: 1px solid var(--site-ink);
  color: var(--site-ink);
  background: #fffdf6;
  font-family: monospace;
  font-size: 0.72em;
  text-transform: lowercase;
}

#periodPalette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20px, 1fr));
  gap: 3px;
  margin-top: 6px;
}

.button-tool-page .periodChip {
  height: 20px;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--site-ink);
  box-shadow: none;
}

.button-tool-page .periodChip:hover,
.button-tool-page .periodChip:focus-visible {
  outline: 2px solid var(--site-red);
  outline-offset: 1px;
}

.button-tool-page button[disabled] {
  border-color: var(--site-steel);
  color: var(--site-steel);
  background: var(--site-surface);
  cursor: default;
  box-shadow: none;
}

.button-tool-page button[disabled]:hover {
  color: var(--site-steel);
  background: var(--site-surface);
  outline: none;
}

.field label[for] {
  margin-top: 0;
}

/* a colour field whose toggle is off cannot act, so it reads as unavailable
   rather than as a control that quietly does nothing */
.button-tool-page input:disabled,
.button-tool-page input.hexField:disabled {
  border-color: var(--site-steel);
  color: var(--site-steel);
  background: var(--site-surface);
  cursor: not-allowed;
  opacity: 0.55;
}

label.is-disabled {
  color: var(--site-steel);
}

.checkField {
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
}

.checkField input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--site-red);
}

/* ---------- buttons ---------- */
/* filled = the action this panel exists for, outlined = a side action,
   dashed with an arrow = it opens a file picker */
.buttonRow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.button-tool-page button {
  padding: 6px 10px;
  border: 1px solid var(--site-ink);
  color: var(--site-surface);
  background: var(--site-red);
  font-family: monospace;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--site-steel);
}

.button-tool-page button:hover,
.button-tool-page button:focus-visible {
  color: var(--site-red);
  background: var(--site-surface);
  outline: 2px solid var(--site-red);
  outline-offset: 1px;
}

.button-tool-page button:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.button-tool-page .quiet {
  color: var(--site-red);
  background: var(--site-surface);
  box-shadow: none;
}

.button-tool-page .quiet:hover,
.button-tool-page .quiet:focus-visible {
  color: var(--site-surface);
  background: var(--site-red);
  outline-color: var(--site-ink);
}

.button-tool-page .uploadish {
  border: 2px dashed var(--site-red);
  color: var(--site-red);
  background: var(--site-surface);
  box-shadow: none;
}

.button-tool-page .uploadish:hover,
.button-tool-page .uploadish:focus-visible {
  color: var(--site-surface);
  background: var(--site-red);
  outline: 2px solid var(--site-ink);
}

.button-tool-page .infoDot {
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--site-red);
  border-radius: 50%;
  color: var(--site-red);
  background: transparent;
  font-family: monospace;
  font-size: 11px;
  line-height: 1;
  vertical-align: 2px;
  box-shadow: none;
}

.button-tool-page .infoDot:hover,
.button-tool-page .infoDot:focus-visible {
  color: var(--site-surface);
  background: var(--site-red);
}

/* ---------- preview ---------- */
/* the box is always this size, whether or not there's meaningful text in it,
   so nothing jumps as fields fill in */
#previewWrap {
  display: grid;
  place-items: center;
  min-height: 148px;
  padding: 16px;
  border: 3px double var(--site-red);
  background: var(--site-surface);
}

#buttonCanvas {
  width: min(352px, 100%);
  height: auto;
  aspect-ratio: 88 / 31;
  border: 1px solid var(--site-ink);
  image-rendering: pixelated;
  box-shadow: 4px 4px 0 var(--site-steel);
}

/* the 4x preview flatters the art, so the real thing sits next to it */
#actualSizeWrap {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

#actualCanvas {
  width: 88px;
  height: 31px;
  flex: none;
  border: 1px solid var(--site-ink);
  image-rendering: pixelated;
}

#actualSizeWrap .panel-note {
  margin: 0;
}

#embedCode {
  box-sizing: border-box;
  width: 100%;
  height: 76px;
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--site-ink);
  color: var(--site-deep);
  background: var(--site-surface);
  font-family: monospace;
  font-size: 0.76em;
  resize: vertical;
}

@media only screen and (max-width: 800px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
  }

  .fieldRow {
    grid-template-columns: 1fr;
  }

  #buttonCanvas {
    width: min(100%, 352px);
    height: auto;
    aspect-ratio: 88 / 31;
  }

  /* touch: every target 44x44 with at least 8px of clear space around it */
  .button-tool-page input[type="color"],
  .button-tool-page .fieldRow--tight input[type="color"] {
    height: 44px;
  }

  .button-tool-page #app input,
  .button-tool-page #app select,
  .button-tool-page #app textarea,
  .button-tool-page #app button {
    min-height: 44px;
  }

  .button-tool-page #app .infoDot {
    min-height: 24px;
  }

  .trackRow input[type="range"] {
    min-height: 44px;
  }

  .checkField {
    min-height: 44px;
    gap: 10px;
  }

  .checkField input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }

  .fieldRow,
  .fieldRow--tight {
    gap: 12px;
  }

  #periodPalette {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 8px;
  }

  .button-tool-page .periodChip {
    height: 44px;
  }
}

/* letter spacing: slider and its readout are one row, and the readout holds a
   fixed width so nothing shifts as the number changes */
.trackRow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
}

.trackRow label {
  flex: none;
  margin: 0;
}

.trackRow input[type="range"] {
  flex: 1;
  min-width: 0;
}

.trackRow output {
  flex: none;
  min-width: 3.2ch;
  font-family: monospace;
  text-align: right;
}
