/* Minecraft Banner Generator (banner-generator.html). Loaded after tools.css. The pattern drawings are our own canvases. */

.bn canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.bn-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: clamp(14px, 2vw, 22px); }
.bn-hist { display: flex; gap: 8px; }
.bn-hist[hidden] { display: none; }

/* colour swatches */
.bn-swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 34px)); gap: 6px; }
.bn-sw {
  width: 100%; aspect-ratio: 1; min-width: 26px; padding: 0; border: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.bn-sw[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 2px var(--white), 0 0 0 4px var(--on-paper); }
.bn-sw:focus-visible { outline: 2px solid var(--red-400); outline-offset: 3px; }
@media (prefers-color-scheme: dark) { .bn-sw[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 0 2px #1d1718, 0 0 0 4px #f2e9e6; } }

/* pattern tiles */
.bn-pats { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.bn-tile {
  position: relative; display: grid; place-items: center; padding: 4px 0; border: 0; cursor: pointer;
  background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule-paper);
}
.bn-tile canvas { width: 20px; height: 40px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.bn-tile:hover:not(:disabled) { background: var(--rule-paper); }
.bn-tile:focus-visible { outline: 2px solid var(--red-400); outline-offset: 1px; }
.bn-tile:disabled { opacity: 0.45; cursor: default; }
.bn-tile.item::after, .bn-key.item, .bn-tile.cmd::after, .bn-key.cmd { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c98a00; }
.bn-tile.cmd::after, .bn-key.cmd { border-radius: 0; background: var(--red-500); }
.bn-tile::after { position: absolute; right: 3px; top: 3px; }
.bn-key { display: inline-block; vertical-align: middle; margin-right: 2px; }

/* layer list (top layer first) */
.bn-layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bn-layers li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; box-shadow: inset 0 0 0 1px var(--rule-paper); }
.bn-n { flex: none; width: 1.6em; font-family: var(--mono); font-size: 0.78rem; color: var(--on-paper-soft); text-align: right; }
.bn-layers li > canvas { flex: none; width: 15px; height: 30px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.bn-lmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bn-lsel { display: flex; flex-wrap: wrap; gap: 6px; }
.tool .bn-lsel select { width: auto; flex: 1 1 130px; min-width: 0; padding: 6px 8px; font-size: 0.86rem; }
.bn-csel { display: flex; align-items: center; gap: 5px; flex: 1 1 110px; min-width: 0; }
.tool .bn-csel select { flex: 1 1 auto; }
.bn-dot { flex: none; width: 14px; height: 14px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); }
.bn-tag { font-family: var(--mono); font-size: 0.7rem; color: #9a6a00; }
.bn-tag.warn { color: var(--red-500); }
@media (prefers-color-scheme: dark) { .bn-tag { color: #e0b450; } .bn-tag.warn { color: var(--red-300); } }
.bn-lbtns { flex: none; display: grid; grid-template-columns: repeat(2, auto); gap: 4px; }
.bn-lbtns .tbtn { padding: 4px 9px; min-width: 32px; }
@media (min-width: 560px) { .bn-lbtns { grid-template-columns: repeat(4, auto); } }

/* gallery and letter grid */
.bn-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.bn-gtile, .bn-atile {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px 6px; border: 0; cursor: pointer;
  background: var(--paper-2); color: var(--on-paper); font: inherit; font-size: 0.76rem; font-weight: 600; line-height: 1.2; text-align: center;
  box-shadow: inset 0 0 0 1px var(--rule-paper);
}
.bn-gtile canvas { width: 30px; height: 60px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.bn-gtile:hover, .bn-atile:hover { background: var(--rule-paper); }
.bn-gtile:focus-visible, .bn-atile:focus-visible, .bn-rtile:focus-visible { outline: 2px solid var(--red-400); outline-offset: 1px; }
.bn-alpha { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 5px; }
.bn-atile { padding: 5px 2px 3px; font-family: var(--mono); }
.bn-atile canvas { width: 20px; height: 40px; }

/* preview stage: a stone wall, the same in both themes so the banner colours read the same */
.bn-stage {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: clamp(14px, 4vw, 36px);
  padding: 26px 14px 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 100% 22px,
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 1px, transparent 1px) 0 0 / 44px 22px,
    linear-gradient(#4a4d52, #3a3c40);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.bn-stage[hidden], .bn-row[hidden] { display: none; }
.bn-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bn-fig figcaption { font-family: var(--sans); font-variant-numeric: tabular-nums; font-weight: 650; font-stretch: 112%; font-size: 0.8rem; letter-spacing: 0; color: #d8d2d0; }
.bn-pole { position: relative; padding-top: 10px; }
.bn-pole::before { content: ""; position: absolute; left: -10px; right: -10px; top: 0; height: 8px; background: linear-gradient(#8a6440, #5c3f24); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
#cv-banner { display: block; width: clamp(120px, 26vw, 160px); height: auto; aspect-ratio: 1 / 2; box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.3); }
.bn-shield { padding: 7px; background: linear-gradient(#a7a9ad, #6c6f74); border-radius: 3px 3px 40% 40% / 3px 3px 14% 14%; box-shadow: inset 0 0 0 2px #4b3a2a, 4px 6px 0 rgba(0, 0, 0, 0.3); }
#cv-shield { display: block; width: clamp(72px, 15vw, 96px); height: auto; aspect-ratio: 12 / 22; border-radius: 0 0 36% 36% / 0 0 12% 12%; }
.bn-slot { padding: 5px; background: #8b8b8b; box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #fff; }
#cv-item { display: block; width: 48px; height: 48px; }

/* letter row: scrolls inside its own box */
.bn-row {
  display: flex; gap: 6px; align-items: flex-start; overflow-x: auto; padding: 16px 12px 12px; min-height: 120px;
  background: linear-gradient(#4a4d52, #3a3c40); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.bn-rtile { flex: none; padding: 0; border: 0; background: none; cursor: pointer; }
.bn-rtile canvas { display: block; width: 40px; height: 80px; box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.3); }
.bn-rtile:hover canvas { box-shadow: 0 0 0 2px #fff; }
.bn-rgap { flex: none; display: grid; place-items: center; width: 40px; height: 80px; color: #d8d2d0; font-family: var(--mono); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.bn-row .thint { color: #d8d2d0; }

/* outputs */
.bn-opts > .tf:first-child { flex: 0 1 auto; }
.bn-menu { margin: 4px 0 14px; padding: 8px 10px; box-shadow: inset 0 0 0 1px var(--rule-paper); }
.bn-menu summary { cursor: pointer; font-size: 0.86rem; font-weight: 700; }
.bn-menu[open] summary { margin-bottom: 10px; }
.bn-menu .bn-narrow { flex: 0 1 90px; }
.bn-menu[hidden] { display: none; }
#outtab { margin: 4px 0 10px; }
#outtab button { padding: 7px 11px; font-size: 0.84rem; }
#notes .note { margin-top: 8px; }
.bn-outs .out pre { max-height: 300px; }

/* pattern table */
.bn-tablewrap { overflow-x: auto; }
.bn-table code { white-space: nowrap; }

/* phone and tablet: one column, preview first */
@media (max-width: 900px) {
  .bn .tgrid > .tstack { display: contents; }
  #card-preview { order: 1; }
  #card-design, #card-letters { order: 2; }
  #card-add { order: 3; }
  #card-out { order: 4; }
  #card-gallery { order: 5; }
  #card-import { order: 6; }
}
