/*
 * EncodeLabel: the Barcode types pages (barcodes.php, assets/js/page-barcodes.js).
 * Only what these two pages need on top of site.css: "Which barcode do I need?"
 * and the gallery of cards at /barcodes, and the "Make your own" box (with its
 * "Many at once" pop-up), the check-digit box and the fact table on a type's
 * own page (/barcode/upc-a). Every colour is one of site.css's names, so light and
 * dark both work. The barcode samples are always black on white, like a
 * printed label, on the same grey "desk" the tools use.
 */

/* ==========================================================================
   1. The gallery (/barcodes)
   ========================================================================== */

/* ---- "Which barcode do I need?" ------------------------------------------ */
.bc-choose { max-width: 56rem; margin: 0 0 32px; }
.bc-choose > h2 { margin: 0 0 12px; }
.bc-choose-table {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  border-collapse: separate; border-spacing: 0; overflow: hidden;
}
.bc-choose-table thead th { background: color-mix(in srgb, var(--ink) 3%, var(--card)); }
.bc-choose-table tbody th {
  width: 34%; color: var(--ink); font-size: .95rem; font-weight: 650; letter-spacing: 0; text-transform: none; white-space: normal;
}
.bc-choose-table th, .bc-choose-table td { padding: 4px 14px; vertical-align: middle; }
.bc-choose-table thead th { padding-top: 9px; padding-bottom: 9px; }
.bc-choose-types { font-weight: 650; }
/* Links in the table are 44 px tall targets. */
.bc-choose-types > a { display: inline-flex; align-items: center; min-height: 44px; }
.bc-choose-or { color: var(--muted); font-weight: 400; }
.bc-choose-why { display: block; margin: -6px 0 8px; color: var(--muted); font-size: .9rem; }
@media (max-width: 560px) {
  /* One job per block on a phone: the job, then the types and why. */
  .bc-choose-table thead { display: none; }
  .bc-choose-table, .bc-choose-table tbody, .bc-choose-table tr, .bc-choose-table th, .bc-choose-table td { display: block; width: auto; }
  .bc-choose-table tbody th { width: auto; padding: 12px 14px 0; border-bottom: 0; }
  .bc-choose-table td { padding: 0 14px 10px; }
  .bc-choose-table tbody tr:not(:last-child) { border-bottom: 1px solid var(--line); }
  .bc-choose-table tbody tr:not(:last-child) > td { border-bottom: 0; }
}

/* ---- The top: the filter box and the popular dozen ------------------------ */
.bc-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 0 0 12px; }
.bc-find { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.bc-find-box { position: relative; flex: 1 1 280px; max-width: 460px; }
.bc-find-box > input { width: 100%; padding-left: 42px; }
.bc-find-icon {
  position: absolute; top: 0; bottom: 0; left: 12px; display: flex; align-items: center;
  color: var(--muted); pointer-events: none;
}
.bc-find-count { flex: 0 1 auto; min-height: 0; margin: 0; }
.bc-find-count::before { display: none; } /* a plain count, not a message: no marker */

.bc-popular { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.bc-popular-label {
  margin: 0; color: var(--muted); font: 600 .75rem/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase;
}
.bc-popular > .chip-list { margin: 0; }

/* ---- A group and its cards ------------------------------------------------- */
.bc-group { margin: 40px 0; }
.bc-group > .section-head { margin-bottom: 6px; }
.bc-group-blurb { max-width: 46rem; margin: 0 0 18px; color: var(--muted); }
.bc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 16px;
  margin: 0; padding: 0; list-style: none;
}
.bc-card {
  display: flex; flex-direction: column; min-width: 0; margin: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); overflow: hidden;
}
.bc-card[hidden] { display: none; }
/* The sample sits on a small desk, as a white label does in the tools. */
.bc-card-desk { flex: none; padding: 12px; border-bottom: 1px solid var(--line); background: var(--desk); }
.bc-sample {
  position: relative; display: block; height: 104px; padding: 10px;
  border-radius: 2px; background: var(--sheet); color: var(--sheet-ink); color-scheme: light;
  box-shadow: 0 0 0 1px var(--desk-line);
  overflow: hidden;
}
.bc-sample > svg, .bc-sample > img { display: block; width: 100%; height: 100%; }
.bc-sample > img { object-fit: contain; } /* the picture file keeps its own shape inside the card */
/* Until the sample is drawn (and if it never can be): a faint ghost of a barcode. */
.bc-sample:not([data-bc-state="drawn"])::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: 52%; height: 50%; transform: translate(-50%, -50%);
  --ghost: color-mix(in srgb, var(--sheet-ink) 9%, var(--sheet));
  background: repeating-linear-gradient(90deg, var(--ghost) 0 3px, transparent 3px 5px, var(--ghost) 5px 6px, transparent 6px 9px, var(--ghost) 9px 11px, transparent 11px 12px);
}
.bc-sample[data-bc-dims="2d"]:not([data-bc-state="drawn"])::before {
  width: auto; height: 60%; aspect-ratio: 1;
  background:
    repeating-linear-gradient(90deg, var(--ghost) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(0deg, var(--ghost) 0 4px, transparent 4px 8px);
}

.bc-card-body { flex: 1 1 auto; min-width: 0; padding: 14px 16px 4px; }
.bc-card-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 6px; font-size: 1.05rem; line-height: 1.25; }
.bc-card-name > a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
/* A 44 px tall target, without making the title line any taller. */
.bc-card-name > a { display: inline-block; padding: 11px 0; margin: -11px 0; }
.bc-card-name > a:hover { text-decoration: underline; }
.bc-card-name > .badge { vertical-align: 0; }
.bc-card-uses { margin: 0 0 8px; font-size: .92rem; line-height: 1.45; }
.bc-card-takes { margin: 0 0 8px; color: var(--muted); font-size: .85rem; line-height: 1.45; overflow-wrap: anywhere; }
.bc-card-label {
  margin-right: 4px; color: var(--muted); font: 700 .68rem/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.bc-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; padding: 4px 16px 14px; }
.bc-card-actions > .btn { margin: 0; }
.bc-card-more { display: inline-flex; align-items: center; min-height: 36px; font-size: .875rem; }

/* ---- "Not sure which one?" ----------------------------------------------- */
.bc-close-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; margin: 0; }
.bc-close-card > div { flex: 1 1 22rem; max-width: 44rem; }
.bc-close-card > div > :last-child { margin-bottom: 0; }
.bc-close-card h2 { margin-top: 0; }
.bc-close-card > .button-row { margin: 0; }

@media (max-width: 560px) {
  /* The popular dozen become one line that scrolls sideways inside its own box. */
  .bc-popular { display: block; }
  .bc-popular-label { margin-bottom: 8px; }
  .bc-popular > .chip-list {
    flex-wrap: nowrap; margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter);
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .bc-popular > .chip-list::-webkit-scrollbar { display: none; }
  .bc-popular > .chip-list > li { flex: none; }
  .bc-popular .chip { white-space: nowrap; }

  /* On a phone a card is a row: the sample on the left, the words beside it, the buttons underneath. */
  .bc-group { margin: 32px 0; }
  .bc-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .bc-card { display: grid; grid-template-columns: 116px minmax(0, 1fr); }
  .bc-card[hidden] { display: none; }
  .bc-card-desk { display: flex; align-items: center; padding: 8px; border-bottom: 0; border-right: 1px solid var(--line); }
  .bc-sample { width: 100%; height: 80px; padding: 6px; }
  .bc-card-body { padding: 12px 14px 6px; }
  .bc-card-body > :last-child { margin-bottom: 4px; }
  .bc-card-actions { grid-column: 1 / -1; justify-content: space-between; padding: 6px 14px 6px 8px; border-top: 1px solid var(--line); }
  .bc-card-actions > .btn { min-height: 40px; }
  .bc-card-more { min-height: 44px; }
}

/* ==========================================================================
   2. A type's own page (/barcode/upc-a)
   ========================================================================== */
.bc-back { margin: -8px 0 4px; }

/* ---- "Make your own": what goes in on the left, the drawing on the right ------ */
/* Two columns on a wide screen. On a narrow one the pieces of both columns
   become one list in the order a person needs them: the box, the drawing, the
   options, the size advice, the buttons. */
.bc-maker { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; padding: 20px; }
.bc-maker-col { display: contents; }
.bc-maker-in { order: 1; }
.bc-desk { order: 2; }
.bc-maker-opts { order: 3; }
.bc-maker-meter { order: 4; }
.bc-maker-acts { order: 5; }
.bc-maker-in, .bc-maker-opts, .bc-maker-meter, .bc-maker-acts { min-width: 0; }
.bc-maker-opts:not(:has(> :not([hidden]))), .bc-maker-meter:not(:has(> :not([hidden]))) { display: none; } /* nothing in it: no gap either */
.bc-maker-title { margin: 0 0 14px; font-size: 1.15rem; }
.bc-maker .ksym-input { margin-bottom: 0; }
.bc-maker .ksym-meter { margin: 0; }
.bc-switched { margin: 10px 0 0; color: var(--muted); font-size: .9rem; }
.bc-maker-opts > .check { padding-top: 0; }
.bc-size { margin: 0; }
.bc-size-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.bc-size-row > .stepper > input { width: 5em; }
.bc-size-unit { color: var(--muted); }
.bc-presets { display: flex; flex: 1 1 100%; }

/* In one column the desk is only as tall as the drawing needs (a long thin barcode gets a low desk).
   Beside the controls, on a wide screen, it has a height of its own. */
.bc-desk { height: auto; min-height: 150px; container-type: normal; }
.bc-maker .bc-desk { padding: 20px; }
.bc-maker .bc-desk:has(> .sheet-note:not([hidden])) { padding-bottom: 46px; } /* room for the "Sample" note under the drawing */
.bc-desk > .sheet-paper { width: min(100%, 230px * var(--ratio)); }
/* The sample picture the server sends: the same air around it as a live drawing (the padding, set on the
   picture by barcodes.php, is a share of the paper's width), so nothing moves when the script takes over. */
.bc-desk .sheet-paper > .bc-pic { box-sizing: border-box; object-fit: contain; background: var(--sheet); }
.bc-desk-note { max-width: 22rem; margin: 0; padding: 0 12px; color: var(--muted); font-size: .92rem; text-align: center; }
.bc-desk-note[hidden], .bc-desk .sheet-paper[hidden] { display: none; }
.bc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bc-actions .btn { margin: 0; }
/* The two downloads stay together: if there is no room beside the main button, both move to the next line. */
.bc-downloads { display: flex; flex: 1 1 auto; gap: 8px; }
.bc-maker-acts > .status-line { margin: 10px 0 0; }
.bc-maker-acts > .status-line:empty { min-height: 0; margin: 0; }
.bc-fine { margin: 10px 0 0; }

/* ---- "Many at once": the pop-up with a list in, a ZIP of pictures out ------------ */
.bc-many-intro { margin: 0 0 14px; }
.bc-many-field { margin-bottom: 12px; }
/* One value a line, as pasted: long lines scroll inside the box instead of wrapping, so lines stay lines. */
.bc-many-field > textarea { min-height: 168px; font-family: var(--mono); white-space: pre; overflow-wrap: normal; }
.bc-many-kind { margin: 0; }
.bc-many-kind .segmented > label > span { min-width: 64px; }
.bc-many-sum { margin: 14px 0 0; overflow-wrap: anywhere; }
.bc-many-bar { height: 10px; margin: 10px 0 0; border: 1px solid var(--field-line); border-radius: 3px; background: var(--field); overflow: hidden; }
.bc-many-fill { width: 0; height: 100%; background: var(--brand); }
.bc-many-notes { margin: 8px 0 0; }
/* The lines that can't be made, each with its reason: a box of its own that scrolls when the list is long. */
.bc-many-skipped {
  max-height: 10.5em; margin: 10px 0 0; padding: 8px 12px 8px 30px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--paper); font-size: .9rem; overflow-wrap: anywhere;
}
.bc-many-skipped > li + li { margin-top: 4px; }
.bc-many-skipped:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.bc-many > .fine-print { margin: 14px 0 0; }

@media (min-width: 860px) {
  .bc-maker { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; gap: 20px 28px; padding: 24px; }
  .bc-maker-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
  .bc-maker-stage { position: sticky; top: calc(var(--header-h, 60px) + 16px); }
  .bc-desk { height: clamp(260px, 44vh, 400px); container-type: size; }
  .bc-maker .bc-desk { padding: 28px; }
  .bc-desk > .sheet-paper { width: min(100cqw, 100cqh * var(--ratio)); }
  .bc-downloads { flex: 0 1 auto; }
}
@media (max-width: 560px) {
  .bc-maker { padding: 16px; }
  /* The main button takes the full width; the two downloads share the line under it. */
  .bc-actions > .btn-primary { flex: 1 1 100%; }
  .bc-downloads > .btn { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
  /* "Download SVG" would wrap onto two lines here: the arrow and "SVG" say it; screen readers still hear the word. */
  .bc-dl-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .bc-actions > .bc-many-open { flex: 1 1 100%; }   /* under the two downloads, as wide as the main button */
  .bc-maker .bc-desk { padding: 16px; }
  .bc-desk > .sheet-paper { width: min(100%, 190px * var(--ratio)); }
}
/* Without JavaScript there is nothing to make with: the box steps aside, the words stay. */
@media (scripting: none) {
  .bc-maker { display: none; }
}

/* ---- The check-digit box ---------------------------------------------------- */
.bc-check { max-width: 46rem; margin: 0 0 24px; padding: 20px; }
.bc-check-title { margin: 0 0 12px; font-size: 1.15rem; }
.bc-check-field { margin: 0; }
.bc-check-field > input { width: 100%; max-width: 22rem; font-family: var(--mono); }
.bc-check-out { margin: 10px 0 0; overflow-wrap: anywhere; }
.bc-check-out:empty { min-height: 0; margin: 0; }
.bc-check-use { margin: 12px 0 0; }
.bc-check-use[hidden] { display: none; }
@media (scripting: none) {
  .bc-check { display: none; }
}

/* ---- The words under it ------------------------------------------------------ */
.bc-number { max-width: 46rem; }
.bc-about > .section { margin: 36px 0; }
.bc-about > .section:first-child { margin-top: 28px; }
.bc-about h2 { margin-bottom: 10px; }
.bc-facts {
  margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); overflow: hidden;
}
.bc-facts > div {
  display: grid; grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); gap: 2px 20px; padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.bc-facts > div:first-child { border-top: 0; }
.bc-facts dt { font-weight: 650; }
.bc-facts dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
/* Lists of links with a reason each: good label sizes, related types. */
.bc-links { margin: 12px 0 16px; padding: 0; list-style: none; }
.bc-links > li { padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.bc-links > li:last-child { border-bottom: 0; }
/* The name is a 44 px tall target on its own line; the reason sits under it. */
.bc-links > li > a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.bc-links-why { display: block; margin-top: -6px; color: var(--muted); }
.bc-more > .chip-list { margin-bottom: 0; }
@media (max-width: 560px) {
  .bc-facts > div { grid-template-columns: minmax(0, 1fr); }
}

@media (forced-colors: active) {
  .bc-sample { forced-color-adjust: none; } /* the sample keeps its real black and white */
  .bc-many-fill { forced-color-adjust: none; background: Highlight; } /* as kit-print.css's bar: still seen in high contrast */
}
