/* The palette, reset and page shell live in base.css, which index.html links
   first; this file is the texturer UI on top of it. */

/* The preview column is capped rather than open-ended: the canvas is at most a
   few hundred pixels, so on a wide screen an unbounded 1fr is just a very
   large empty panel. */
main {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 900px);
  gap: 20px;
  align-items: start;
}

@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }
}

fieldset {
  border: 0.1rem solid var(--fg);
  margin: 16px 0 0;
  padding: 12px;
}

legend {
  font-weight: 700;
  padding: 0 8px;
}

/* Every row shares the same columns (label | control | value box | unit) so right
   edges line up whether or not a row has a slider or a unit. */
.row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 64px 24px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.row > span { grid-column: 1; font-weight: 700; }
/* Plain controls fill the control and value columns... */
.row > :nth-child(2) { grid-column: 2 / 4; min-width: 0; }
/* ...while sliders share them with their number box. */
.row > input[type=range] { grid-column: 2; }
.row > input.value { grid-column: 3; text-align: right; font-variant-numeric: tabular-nums; }
.row > em { grid-column: 4; font-style: normal; }
.row > input[type=checkbox] { justify-self: start; }

/* Below roughly a phone's width the 150px label column leaves the control
   column too narrow to use: sliders shrink to their thumb and select text is
   clipped. Give the label its own line and let the control have the width. */
@media (max-width: 560px) {
  .row { grid-template-columns: minmax(0, 1fr) 64px 24px; }
  .row > span { grid-column: 1 / -1; }
  .row > :nth-child(2) { grid-column: 1 / 3; }
  .row > input[type=range] { grid-column: 1; }
  .row > input.value { grid-column: 2; }
  .row > em { grid-column: 3; }
}

input, select, button, .primary {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 0.1rem solid var(--fg);
  border-radius: 0;
  padding: 0.2rem 0.5rem;
}

input[type=email],
input[type=number],
input[type=password],
input[type=search],
input[type=tel],
input[type=text],
input[type=url],
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: none;
  width: 100%;
}

input[type=range],
input[type=checkbox],
progress {
  accent-color: var(--fg);
}

button { cursor: pointer; }
button:not(:disabled):hover { background: var(--fg); color: var(--bg); }

.shapes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.shapes button { padding: 8px 4px; font-size: 0.85rem; }
.shapes button.active { background: var(--fg); border-color: var(--fg); color: var(--bg); }

.drop {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  padding: 10px;
  border: 0.1rem dashed var(--fg);
  cursor: pointer;
}

.drop.over { background: var(--fg); color: var(--bg); }
.drop input { display: none; }
.drop img { max-width: 96px; max-height: 64px; }
.drop img:not([src]) { display: none; }

.preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.stage {
  display: grid;
  place-items: center;
  padding: 12px;
  max-width: 100%;
  overflow: auto;
}

.stage canvas, .stage img {
  display: block;
  image-rendering: pixelated;
}

.buttons { display: flex; gap: 12px; align-items: center; }
.inline { display: flex; gap: 6px; align-items: center; }

.primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  padding: 10px 28px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:disabled, .primary:disabled {
  background: var(--bg);
  color: var(--fg);
  border-style: dashed;
  cursor: not-allowed;
  opacity: 1;
}

progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  height: 0.5rem;
  overflow: hidden;
  padding: 0;
  width: 100%;
  max-width: 360px;
  background: var(--bg);
  color: var(--fg);
  border: 0.1rem solid var(--fg);
  border-radius: 0;
}
progress::-webkit-progress-bar { background-color: var(--bg); }
progress::-webkit-progress-value { background-color: var(--fg); }
progress::-moz-progress-bar { background-color: var(--fg); }

.row input:disabled, .row select:disabled { opacity: 0.45; }

.status { margin: 0; min-height: 1.2em; }
.status.error { font-weight: 700; text-decoration: underline; }

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-top: 0.1rem solid var(--fg);
  padding-top: 12px;
  width: 100%;
}
