/* Minecraft Banner Maker. The layout and every card, heading, input and button come from the shared tool cards
   (styles/tool-cards.css), as on the tag generator and the chibi maker; this file only adds what a banner needs:
   the stage, the color dots, the pattern tiles, the layer rows, the segmented toggles and the loom steps. */

.bm-px {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---- preview ---- */
/* The header is the title alone, as on the chibi maker; the view toggle and undo / redo sit in the card's top
   corners, out of the flow, so they add no height above the stage. */
.bm-preview-header {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bm-preview-header h3 {
  margin: 0;
}

/* exactly as tall as the round undo / redo / pin buttons beside it (32px; 28px on a phone); .bm-seg.bm-view so
   its 2px padding beats the general .bm-seg rule below */
.bm-seg.bm-view {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  height: 32px;
  box-sizing: border-box;
  padding: 2px;
  flex-wrap: nowrap;
}

.bm-view .bm-seg-btn {
  min-height: 0;
  height: 28px;
  padding: 0 12px;
  font-size: 13px;
}

.bm-history {
  position: absolute;
  right: 52px;
  top: 12px;
  z-index: 2;
  display: flex;
  gap: 6px;
}

.bm-round-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: #fff;
  color: #666;
  cursor: pointer;
}

.bm-round-btn:hover:not(:disabled) {
  border-color: #3984a7;
  background: #f0f8ff;
  color: #3984a7;
}

.bm-round-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* The preview fills its card from the header down (the actions card beside it can be the taller one), the banner
   and its shield centered on the see-through checkerboard the chibi maker's preview uses. */
.bm-preview-card {
  justify-content: flex-start;
}

.bm-stage {
  flex: 1;
  width: 100%;
  min-height: 300px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 18px 12px;
  border-radius: 14px;
  background-color: #4a4a4a;
  background-image:
    linear-gradient(45deg, #555 25%, transparent 25%),
    linear-gradient(-45deg, #555 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #555 75%),
    linear-gradient(-45deg, transparent 75%, #555 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

/* 3D: the flat pictures make way for the model */
.bm-stage.is-3d {
  padding: 0;
}

/* the flat pictures fill the stage without sizing it (the stage's size comes from the layout: the script then
   fits the pictures to it) */
.bm-flat {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
}

.bm-stage.is-3d .bm-flat {
  display: none;
}

/* (!important: three.js writes display: block onto its canvas itself, which beat this rule and left the 3D view
   over the 2D pictures after switching back) */
.bm-stage:not(.is-3d) > .bm-3d {
  display: none !important;
}

.bm-3d {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.bm-3d:active {
  cursor: grabbing;
}

/* (the banner and shield are sized by the script: whole multiples of their pixels that fit the stage) */

.bm-status {
  min-height: 20px;
  text-align: center;
  font-size: 13px;
  color: #666;
}

.bm-status[data-kind="warn"] {
  color: #8a5a00;
}

.bm-status[data-kind="ok"] {
  color: #2b6a2f;
}

/* ---- the options cards ---- */
/* a field's label, as .input-group label in the shared cards */
.bm-sub {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  text-align: center;
}

.bm-colors {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  justify-items: center;
}

/* From 711px the panels sit side by side and a half-width card has no room for 8 circles in a row (they went down
   to 22px at 730): rows of four keep each at its 44px, as the chibi maker does on a phone, until a row of eight
   holds 36px again (960px). */
@media (min-width: 711px) and (max-width: 959px) {
  .bm-colors {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* the color circles, exactly the chibi maker's background swatches */
.bm-swatch {
  width: 100%;
  max-width: 44px;
  min-width: 0;
  aspect-ratio: 1;
  height: auto;
  padding: 0;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  cursor: pointer;
}

.bm-swatch:hover {
  border-color: #3984a7;
}

.bm-swatch[aria-pressed="true"] {
  border-color: #3984a7;
  box-shadow: 0 0 0 2px rgba(57, 132, 167, 0.3);
}

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

.bm-pattern {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bm-pattern:hover {
  border-color: #3984a7;
  background: #f0f8ff;
}

.bm-pattern canvas {
  width: 24px;
  height: 48px;
}

/* a layer: the tag generator's color entry, with the pattern's picture and two dropdowns */
.bm-layers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bm-layer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-layer-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bm-layer-selects {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bm-layer-selects .input-group {
  flex: 1;
  min-width: 0;
}

/* a layer's color: the shared round color box, filled with its dye, opening the 16 under the layer */
.bm-layer .color-box[aria-expanded="true"] {
  border-color: #3984a7;
  box-shadow: 0 0 0 2px rgba(57, 132, 167, 0.3);
}

.bm-layer-selects select {
  width: 100%;
  min-width: 0;
}

/* a layer Bedrock doesn't show (past its 6): dimmed, its note says why */
.bm-layer.is-unshown .bm-layer-body {
  opacity: 0.5;
}

.bm-layer-item {
  margin: 0;
  font-size: 12px;
  color: #666;
}

.bm-empty {
  margin: 0;
  font-size: 14px;
  color: #666;
  text-align: center;
}

/* segmented toggles, as the chibi maker's Style and Body type */
.bm-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #eef2f4;
  border-radius: 24px;
}

.bm-seg-btn {
  flex: 1 1 auto;
  min-width: max-content;
  min-height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 20px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #667;
  white-space: nowrap;
  cursor: pointer;
}

.bm-seg-btn:hover {
  color: #3984a7;
}

.bm-seg-btn[aria-pressed="true"] {
  background: #fff;
  color: #3984a7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* the command: the site's code box, as the config dialogs' (.config-export-text), not a one-line field stretched
   (a block: an inline box sits on a text line and leaves the line's descender gap under it) */
.input-group textarea.bm-command {
  display: block;
  min-height: 96px;
  padding: 10px;
  border-radius: 12px;
  background: #fafafa;
  color: #333;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.input-group textarea.bm-command::-webkit-scrollbar-track {
  margin: 14px 0;
}

.bm-note {
  margin: 0;
  font-size: 13px;
  color: #8a5a00;
  text-align: center;
}

.bm-edition {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* the Bedrock downloads, one under the other, full width like the Actions buttons */
.bm-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-stack .json-button-secondary {
  width: 100%;
}

/* (below 300px "Download .mcstructure" no longer fits on its line: the download icon says it, the word goes) */
@media (max-width: 299px) {
  .bm-btn-verb {
    display: none;
  }
}

.bm-hint {
  margin: 0;
  font-size: 13px;
  color: #555;
  text-align: center;
  line-height: 1.5;
}

.bm-hint code {
  font-size: 12px;
  overflow-wrap: anywhere;
}


/* ---- loom steps ---- */
.tool-card ol.bm-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-card ol.bm-steps > li {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
  counter-increment: step;
}

.tool-card ol.bm-steps > li::before {
  content: counter(step);
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d1d5db;
  box-sizing: border-box;
  color: #333;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-card ol.bm-steps > li.bm-step-note {
  counter-increment: none;
  color: #8a5a00;
  font-size: 13px;
}

.tool-card ol.bm-steps > li.bm-step-note::before {
  content: none;
}

.tool-card ol.bm-steps > li.bm-over {
  opacity: 0.5;
}

.bm-dot {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

#minecraft-banner-maker-tool [hidden] {
  display: none !important;
}

/* the keyboard's ring on a button, as the tag generator's own buttons (2px accent, 2px off); text boxes get none, only
   their blue border, as in every tool (the dropdown's open list shows its row instead) */
#minecraft-banner-maker-tool button:focus-visible {
  outline: 2px solid #3984a7;
  outline-offset: 2px;
}

#minecraft-banner-maker-tool .bm-select-list:focus {
  outline: none;
}

@media (max-width: 480px) {
  /* rows of four, as the chibi maker's swatches: every circle keeps its 44px */
  .bm-colors {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .bm-flat {
    gap: 24px;
  }
  /* a phone's preview: a banner is tall (unlike the tag generator's wide tags), so it keeps the height its 4x picture
     needs (176 px with the padding) and no more */
  .bm-stage {
    min-height: 212px;
  }
}

.bm-command-card .input-group label {
  display: block;
  text-align: center;
}

.bm-layer .bm-colors {
  padding-top: 2px;
}


/* ---- the config dialog and its gear, as the tag generator's ---- */
.config-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  height: 32px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.config-btn:hover { background: #f0f8ff; border-color: #3984a7; color: #3984a7; }
.config-btn { padding: 0; }
.config-btn svg { width: 18px; height: 18px; display: block; }
.actions-card { position: relative; }

.config-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.config-modal-overlay[hidden] { display: none; }

.config-modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.config-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
}

.config-modal-header h3 { margin: 0; font-size: 17px; color: #333; }

.config-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.config-modal-close:hover { background: #e5e7eb; color: #2c3e50; }
.config-modal-close svg { width: 20px; height: 20px; }

.config-modal-body {
  padding: 14px 20px 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
  row-gap: 16px;
}

.config-modal-body > * { min-width: 0; }
.config-section { display: flex; flex-direction: column; gap: 10px; }

.config-section-label {
  font-weight: bold;
  font-size: 13px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-drop-zone {
  width: 100%;
  min-height: 200px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-drop-zone:hover { border-color: #3984a7; background: #f0f8ff; }
.icon-drop-zone.drag-over { border-color: #3984a7; background: #e6f3ff; border-style: solid; }
.drop-zone-content { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-icon { width: 24px; height: 24px; color: #666; }
.bm-drop-text { color: #666; font-size: 14px; font-weight: 500; }

.config-status { font-size: 13px; min-height: 18px; color: #666; }
.config-status:empty { display: none; }
.config-status.error { color: #b02e26; }
.config-status.success { color: #2b6a2f; }

.config-export-text {
  width: 100%;
  min-width: 0;
  min-height: 200px;
  box-sizing: border-box;
  padding: 10px;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  background: #fafafa;
  color: #333;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}

.config-modal-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.config-modal-actions .json-button-secondary { height: 40px; font-size: 14px; width: auto; flex: 1 1 140px; white-space: nowrap; }

@media (max-width: 600px) {
  .config-modal-body { grid-template-columns: minmax(0, 1fr); }
  .icon-drop-zone, .config-export-text { min-height: 100px; }
}

/* ---- pinning: the preview floats while you scroll, as the tag generator's ---- */
/* The pin: the shared sheet sizes and places it at every width (32px in the 12px corner, the 8px corner from 480,
   28px in the 6px corner from 360, 24px in the 4px corner from 270). As in the chibi maker, no padding and a fixed
   icon: the padding crushed the icon width-first (18 tall but 16, then 12 wide). */
.bm-preview-card .pin-preview-btn {
  z-index: 2;
  padding: 0;
}

.bm-preview-card .pin-preview-btn .pin-icon,
.bm-round-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.bm-preview-card.pinned {
  display: flex;
  flex-direction: column;
}

/* pinned: the tag generator's plain grip dots, centered on the header's line (the switch's 32px), their dots 12px in
   from the edge like the pin on the right, then the 2D / 3D switch a clear gap after them */
#minecraft-banner-maker-tool .bm-preview-card.pinned .preview-drag-handle {
  top: 12px;
  left: 6px;
  width: 20px;
  height: 32px;
}

.bm-preview-card.pinned .bm-seg.bm-view {
  left: 30px;
}

/* pinned, the picture shrinks with the pane (a pane resized smaller than the in-place preview kept its 300px and
   spilled out under the pane's bottom) */
.bm-preview-card.pinned .bm-stage {
  min-height: 0;
}

@media (max-width: 480px) {
  #minecraft-banner-maker-tool .bm-preview-card.pinned .preview-drag-handle {
    top: 8px;
    left: 2px;
    height: 28px;
  }
  .bm-preview-card.pinned .bm-seg.bm-view {
    left: 25px;
  }
}

/* a narrow phone has no room for the title between the switch and the round buttons: it goes invisible (still read
   out, still holding the header's height so the picture stays put) */
@media (max-width: 340px) {
  .bm-preview-card .bm-preview-header h3 {
    opacity: 0;
    user-select: none;
  }
}

/* (set by the script where the title would touch the switch or undo / redo: a pinned pane resized narrow) */
.bm-preview-card.bm-no-title .bm-preview-header h3 {
  opacity: 0;
  user-select: none;
}

/* ---- a layer's pattern: the shared dropdown pill (.input-group select), with each pattern's picture ---- */
.bm-select {
  flex: 1;
  min-width: 0;
}

.bm-select-btn {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 8px;
  border: 2px solid #d1d5db;
  border-radius: 24px;
  background: #fff;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  line-height: normal;
  color: #000;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.bm-select-btn:hover,
.bm-select-btn[aria-expanded="true"] {
  border-color: #3984a7;
}

.bm-select-btn .bm-opt-thumb {
  width: 12px;
  height: 24px;
}

.bm-select-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bm-select-btn > svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  stroke: #555;
}

/* (.tool-card ul: the site's list rule indents lists 30px and gives them bullets; this one is a menu) */
.tool-card ul.bm-select-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 2px solid #d1d5db;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

/* the site's slim scrollbar (as its text boxes): a 6px rounded thumb, no arrows */
.bm-select-list::-webkit-scrollbar {
  width: 6px;
}

.bm-select-list::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

.bm-select-list::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 3px;
}

.bm-select-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

@supports not selector(::-webkit-scrollbar) {
  .bm-select-list {
    scrollbar-width: thin;
    scrollbar-color: #c0c0c0 transparent;
  }
}

.tool-card .bm-select-list > li {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 3px 10px 3px 8px;
  border-radius: 12px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.3;
  color: #333;
  cursor: pointer;
  list-style: none;
}

.tool-card .bm-select-list > li::before {
  content: none;
}

/* hover / keyboard: a light gray; the current pattern: the site's blue tint, its blue text and a check */
.tool-card .bm-select-list > li.is-active {
  background: #f3f4f6;
}

.tool-card .bm-select-list > li[aria-selected="true"] {
  background: #e8f3f8;
  color: #1f5470;
  font-weight: 600;
}

.tool-card .bm-select-list > li[aria-selected="true"].is-active {
  background: #dcedf5;
}

.bm-opt-name {
  flex: 1 1 auto;
  min-width: 0;
}

.bm-opt-check {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: #3984a7;
}

.bm-select-list .bm-opt-thumb {
  width: 14px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.bm-opt-item {
  margin-left: auto;
  font-size: 12px;
  font-weight: 400;
  color: #777;
  white-space: nowrap;
}

/* ---- the corner ladder: the pin's steps (tool-cards.css), with the 2D / 3D switch, undo / redo, the gear and the
   pinned grip riding along, and their icons held at the desktop 18 / 32 ratio (as the chibi maker's) ---- */
@media (max-width: 480px) {
  .bm-seg.bm-view { top: 8px; left: 8px; }
  .bm-history { top: 8px; right: 48px; }
  .config-btn { top: 8px; right: 8px; }
  #minecraft-banner-maker-tool .bm-preview-card.pinned .preview-drag-handle { top: 8px; left: 2px; height: 32px; }
  .bm-preview-card.pinned .bm-seg.bm-view { left: 25px; }
}

@media (max-width: 360px) {
  .bm-seg.bm-view { top: 6px; left: 6px; height: 28px; }
  .bm-view .bm-seg-btn { height: 24px; padding: 0 9px; font-size: 12px; }
  .bm-history { top: 6px; right: 40px; }
  .bm-round-btn { width: 28px; height: 28px; }
  .bm-preview-card .pin-preview-btn .pin-icon,
  .bm-round-btn svg { width: 16px; height: 16px; }
  .config-btn { top: 6px; right: 6px; width: 28px; height: 28px; }
  #minecraft-banner-maker-tool .bm-preview-card.pinned .preview-drag-handle { top: 6px; left: 0; height: 28px; }
  .bm-preview-card.pinned .bm-seg.bm-view { left: 22px; }
}

@media (max-width: 270px) {
  .bm-seg.bm-view { top: 4px; left: 4px; height: 24px; }
  .bm-view .bm-seg-btn { height: 20px; padding: 0 7px; font-size: 11px; }
  .bm-history { top: 4px; right: 34px; }
  .bm-round-btn { width: 24px; height: 24px; }
  .bm-preview-card .pin-preview-btn .pin-icon,
  .bm-round-btn svg { width: 14px; height: 14px; }
  .config-btn { top: 4px; right: 4px; width: 24px; height: 24px; }
  #minecraft-banner-maker-tool .bm-preview-card.pinned .preview-drag-handle { top: 4px; left: 0; height: 24px; }
  .bm-preview-card.pinned .bm-seg.bm-view { left: 22px; }
}

/* ---- the pattern dropdown: the site's dropdown height at every width (40px, 36px from 710, 30px from 270) ---- */
@media (max-width: 710px) {
  .bm-select-btn { height: 36px; }
}

@media (max-width: 270px) {
  .bm-select-btn { height: 30px; font-size: 12px; }
  .bm-select-btn .bm-opt-thumb { width: 10px; height: 20px; }
}
