/* Pixel art patterns. #pxg-scoped.
 *
 * The same two tool-theme.css rules as the editor, answered the same way: material rows are
 * buttons, and `#tool-root button:not(.btn):not([class*="tab"])` (1,2,1) would give them its
 * 28px padding floor, so they are restyled at (2,1,1) with two ids; toggles carry `pxg-tab` to
 * get the site's own active state; and the blueprint canvas is not scaled down to its column by
 * `#tool-root canvas { max-width: 100% }` because it is already sized to fit it. */

#pxg { display: block; }
#pxg [hidden] { display: none !important; }

/* ---- the pattern on its own page -------------------------------------------------------- */

#pxg .pxg-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  grid-template-areas: "main side" "rows rows";
  gap: 18px;
  align-items: start;
  margin-bottom: 30px;
}
#pxg .pxg-dmain { grid-area: main; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#pxg .pxg-dside { grid-area: side; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#pxg .pxg-rowpanel { grid-area: rows; }
@media (max-width: 820px) {
  #pxg .pxg-detail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "side" "rows"; }
}

#pxg .pxg-viewbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
#pxg .pxg-toolgroup { display: inline-flex; flex-wrap: wrap; gap: 4px; }
#pxg .pxg-tab { padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
#pxg .pxg-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

#pxg .pxg-stage {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(127, 127, 127, .1);
  text-align: center;
  line-height: 0;
  overflow-x: auto;
}
#tool-root #pxg .pxg-stage canvas { max-width: none; image-rendering: pixelated; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
#pxg .pxg-size { margin: 0; font-size: 12.5px; opacity: .75; font-variant-numeric: tabular-nums; }

#pxg .pxg-panel { padding: 12px 13px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 9px; min-width: 0; }
#pxg .pxg-h { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
#pxg .pxg-hint { margin: 0; font-size: 12.5px; line-height: 1.5; }
#pxg .pxg-note { margin: 0; min-height: 1.2em; font-size: 12.5px; line-height: 1.5; }

#pxg .pxg-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
#pxg .pxg-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#pxg .pxg-stat strong { font-size: 17px; line-height: 1.2; font-variant-numeric: tabular-nums; }
#pxg .pxg-statlabel { font-size: 11px; opacity: .72; line-height: 1.25; }

/* A mid-grey ring rather than a dark one: black concrete on the dark theme and white wool on the
 * light one both vanish into the page without it — measured in the first screenshot, where
 * every black run in the row guide was an empty-looking box. */
#pxg .pxg-sprite {
  display: inline-block; flex: 0 0 auto; width: 20px; height: 20px;
  background-repeat: no-repeat; image-rendering: pixelated; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, .6);
}
#pxg .pxg-mats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#pxg .pxg-mat { margin: 0; }
#tool-root #pxg button.pxg-matbtn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 4px 6px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; font-size: 12.5px; font-weight: 500; text-align: start; cursor: pointer; color: inherit;
}
#tool-root #pxg button.pxg-matbtn:hover { border-color: var(--line-strong); background: transparent; }
#tool-root #pxg .pxg-mat.pxg-active button.pxg-matbtn { border-color: var(--grass-bright); }
#pxg .pxg-matsym { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; min-width: 2ch; text-align: center; }
#pxg .pxg-matname { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
/* --gold is dark-theme only: 1.86:1 on the light page, measured in the editor. */
#pxg .pxg-matwarn { font-size: 11px; color: var(--gold); }
:root[data-theme="light"] #pxg .pxg-matwarn { color: #7a5200; }
#pxg .pxg-matcount { flex: 0 0 auto; text-align: end; font-variant-numeric: tabular-nums; font-weight: 700; display: flex; flex-direction: column; }
#pxg .pxg-matstacks { font-size: 10.5px; font-weight: 500; opacity: .7; }

#pxg .pxg-open {
  display: block; text-align: center; padding: 9px 12px; font-weight: 700; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--grass-deep);
  text-decoration: none;
}
#pxg .pxg-num { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
#pxg .pxg-num select { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 13px; }
#pxg .pxg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#tool-root #pxg button.pxg-btn { padding: 6px 11px; font-size: 13px; }
#pxg .pxg-code {
  width: 100%; box-sizing: border-box; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; word-break: break-all;
}

#pxg .pxg-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
#pxg .pxg-rowline { display: flex; gap: 10px; align-items: center; margin: 0; }
#pxg .pxg-rownum {
  flex: 0 0 auto; min-width: 3ch; text-align: end; font-size: 12px; font-weight: 700; opacity: .7;
  font-variant-numeric: tabular-nums;
}
#pxg .pxg-runs { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }
#pxg .pxg-run, #pxg .pxg-gap {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 6px 0 2px;
  border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px;
}
#pxg .pxg-gap { padding: 0 7px; border-style: dashed; opacity: .7; }
#pxg .pxg-runtext { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- the gallery ------------------------------------------------------------------------ */

#pxg .pxg-gh { margin: 0 0 12px; font-size: 18px; }
#pxg .pxg-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
#pxg .pxg-cell { margin: 0; min-width: 0; }
#pxg .pxg-item {
  display: flex; flex-direction: column; gap: 5px; height: 100%; box-sizing: border-box;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; background: var(--surface);
}
#pxg .pxg-item:hover, #pxg .pxg-item:focus-visible { border-color: var(--line-strong); }
#pxg .pxg-item[aria-current="page"] { border-color: var(--grass-bright); }
#pxg .pxg-item img {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain;
  image-rendering: pixelated; border-radius: 2px;
}
#pxg .pxg-name { font-weight: 700; font-size: 14px; color: var(--fg); }
#pxg .pxg-meta { font-size: 12px; opacity: .72; font-variant-numeric: tabular-nums; }
#pxg .pxg-more { margin: 16px 0 0; font-size: 14px; }

#pxg .pxg-help { margin-top: 24px; font-size: 14.5px; line-height: 1.65; max-width: 80ch; }
#pxg .pxg-help p { margin: 0; }
