/* InstantPalette - background generator (/background-generator) only.
   Layer 5: loaded after tokens.css, base.css, site.css and tools.css, and nothing else loads it.
   Only what is specific to this tool: the preview frame and its bar, the text readout, the style tiles and the
   background chips. Buttons, sliders, segmented controls, code blocks and the page shell come from the shared layers. */

/* ================= Preview ================= */
.bg-main { min-width: 0; margin: 0 0 16px; }
/* The frame keeps the chosen proportions and fits the column: full width, or as tall as --max allows */
.bg-stage { display: grid; justify-items: center; border-radius: var(--r-lg); background: var(--sunken); }
.bg-art {
  --ar: 1.7778; --max: min(56vh, 520px);
  width: min(100%, calc(var(--max) * var(--ar)));
  aspect-ratio: var(--ar);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-2);
}
.bg-art svg { display: block; width: 100%; height: 100%; }

.bg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 12px 0 0; }
.bg-bar .btn-o { min-height: 44px; }
.bg-seed { font: 500 13px/1 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 92px; }
.bg-size { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.bg-size label { font: 400 12px/14px var(--f-sans); color: var(--ink-2); }
.bg-size .tselect { width: auto; max-width: 100%; }

/* ================= Text readout ================= */
.bg-read { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 0; }
.bg-aa {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--r); background: var(--sw, var(--sunken)); color: var(--ink, #000);
  font: 600 17px/1 var(--f-sans);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-1) 14%, transparent);
}
.bg-read p { margin: 0; flex: 1 1 200px; min-width: 0; }
.bg-read b { display: block; font: 600 14px/1.35 var(--f-sans); }
.bg-read p span { font: 400 13px/1.4 var(--f-sans); color: var(--ink-2); }
.bg-read .mono { font: 500 13px/1.4 var(--f-mono); color: var(--ink-1); margin-right: 3px; }

/* ================= Style tiles ================= */
.bg-styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bg-styles button {
  display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 4px 4px 6px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--ink-1); text-align: center; font: 500 13px/1.2 var(--f-sans);
}
.bg-th { display: block; height: 36px; border-radius: var(--r-xs); overflow: hidden; background: var(--sunken); }
.bg-th svg { display: block; width: 100%; height: 100%; }
.bg-styles button[aria-checked="true"] { background: var(--sunken); border-color: var(--ink-1); box-shadow: inset 0 0 0 1px var(--ink-1); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .bg-styles button:hover { border-color: var(--ink-1); } }
#seg-dir button { flex: 1 1 auto; text-align: center; }
.bg-sliders > .tslider { flex: 1 1 120px; min-width: 0; }

/* ================= Colors ================= */
.bg-chips { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px; }
.bg-chip {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--ink-3); border-radius: var(--r);
  background: var(--sw, var(--sunken)); color: var(--ink, #000);
}
.bg-chip .i { opacity: 0; stroke-width: 2.4; }
.bg-chip[aria-checked="true"] { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--ink-1); }
.bg-chip[aria-checked="true"] .i { opacity: 1; }
.bg-chip:focus-visible { outline: 2px solid var(--ink-1); outline-offset: 5px; }
@media (hover: hover) and (pointer: fine) { .bg-chip:hover { border-color: var(--ink-1); } }
.bg-cols { justify-content: space-between; }
.bg-cols .btn-o { min-height: 44px; }
.bg-cols .btn-o[aria-pressed="true"] { border-color: var(--ink-1); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--ink-1); }
.bg-order { display: flex; height: 20px; border-radius: var(--r-sm); overflow: hidden; }
.bg-order i { flex: 1 1 0; background: var(--c); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-1) 12%, transparent); }

/* ================= Export ================= */
.bg-exp { align-items: flex-end; margin: 0 0 12px; }
.bg-exp .tprimary { flex: 1 1 auto; }
.bg-files { margin: 12px 0 0; }
.bg-files .btn-o { flex: 1 1 130px; min-height: 44px; }
.codeout pre { max-height: 150px; white-space: pre-wrap; overflow-wrap: anywhere; }
#code-note { text-align: right; }

@media (max-width: 600px) {
  .bg-size { margin-left: 0; flex: 1 1 100%; }
  .bg-size .tselect { flex: 1 1 auto; }
  .bg-bar .btn-o { flex: 1 1 auto; }
}
/* Landscape phones: a shorter frame, so a control is on screen with it */
@media (orientation: landscape) and (max-height: 500px) {
  .bg-art { --max: 46vh; }
}
