/* ==========================================================================================
   BarcoderX website: free tools and GS1 explainer pages.
   Linked ONLY from the GS1 check digit calculator and the GS1-128 / SSCC-18 explainer (English and Spanish).
   Loaded after tokens.css, site.css, inner.css and zpl.css, so it only adds what those do not have:
   a calculator card, the "working" list, a wider reading measure, plain lists and two small figures.
   Tokens only: every colour, space, radius and type size comes from /brand/tokens.css through site.css.
   Light theme only. Mobile first. Breakpoints: 40rem (640), 48rem (768), 64rem (1024).
   Spanish runs ~30% longer than English, so nothing here relies on short labels: everything wraps.
   ========================================================================================== */

/* The HTML `hidden` attribute must win over the display values set below (a class selector beats the user-agent rule). */
.ft-work[hidden] { display: none; }

/* ============================== READING MEASURE ============================== */
/* The ZPL guide measures prose at 54ch, which suits short fact lines. These pages are explanations, so they read at about 72 to 78
   characters per line (Inter at 16px is roughly 1.0 character per 0.5em, so 40rem lands in that range). */
.ft-article .prose p, .ft-article .prose li, .ft-article .prose .ft-list li { max-width: 40rem; }
.ft-article .prose { gap: var(--bx-space-5); }
.ft-article .zsec { gap: var(--bx-space-6); }
.ft-article .zsec > h2 { max-width: 24ch; }
.ft-article .prose h3 { font-size: var(--bx-text-lg); margin-top: var(--bx-space-3); }
/* Section references: grey mono, like the page references in the ZPL guides, but allowed to wrap on a phone. */
.ft-article .pg, .ft-ref { white-space: normal; }
.ft-ref { font: 500 var(--bx-text-xs)/1.4 var(--bx-font-mono); color: var(--bx-gray-600); }

/* ============================== PLAIN LISTS ============================== */
/* The base stylesheet removes list markers, so lists get an explicit marker. A dash for unordered lists (as .mini-list) and a counter for ordered ones. */
.ft-list { display: grid; gap: var(--bx-space-3); }
.ft-list li { position: relative; padding-left: var(--bx-space-6); color: var(--bx-ink); }
.ft-list li::before { content: ""; position: absolute; left: 0; top: 0.85em; width: 0.625rem; height: 2px; background: var(--bx-ink); }
.ft-list b { font-weight: 650; }
.ft-steps { counter-reset: ft; display: grid; gap: var(--bx-space-4); }
.ft-steps li { counter-increment: ft; position: relative; padding-left: var(--bx-space-10); color: var(--bx-ink); }
.ft-steps li::before { content: counter(ft); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border: 1px solid var(--bx-ink); border-radius: var(--bx-radius-sm); font: 600 var(--bx-text-sm)/1 var(--bx-font-mono); }
.ft-steps li p { max-width: 40rem; }

/* ============================== CALCULATOR CARD ============================== */
.ft-card { display: grid; gap: var(--bx-space-6); padding: var(--bx-space-5); background: var(--bx-surface); border: 1px solid var(--bx-border-strong); border-top: var(--rule); max-width: 46rem; min-width: 0; }
@media (min-width: 40rem) { .ft-card { padding: var(--bx-space-8); } }
.ft-card-h { font-size: var(--bx-text-2xl); max-width: 28ch; }
.ft-form { display: grid; gap: var(--bx-space-6); min-width: 0; }
.ft-field { display: grid; gap: var(--bx-space-2); min-width: 0; }
.ft-label, .ft-legend { padding: 0; font: 600 var(--bx-text-xs)/1.5 var(--bx-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-gray-700); }
fieldset.ft-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.ft-legend { margin-bottom: var(--bx-space-2); }

/* The type choice: six radio buttons drawn as chips. The real radio stays in the page (visually hidden, still focusable and still
   arrow-key navigable) so keyboard and screen reader behaviour is the browser's own. */
.ft-types { display: flex; flex-wrap: wrap; gap: var(--bx-space-2); }
.ft-type { position: relative; }
.ft-type input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.ft-type span { display: inline-flex; align-items: center; justify-content: center; min-height: var(--bx-touch-target); min-width: var(--bx-touch-target); padding: 0 var(--bx-space-4); border: 1px solid var(--bx-border-strong); border-radius: var(--bx-radius-md); background: var(--bx-surface); color: var(--bx-ink); font: 600 var(--bx-text-sm)/1 var(--bx-font-mono); white-space: nowrap; }
.ft-type:hover span { border-color: var(--bx-ink); }
.ft-type input:checked + span { background: var(--bx-ink); border-color: var(--bx-ink); color: var(--bx-white); }
/* Focus lands on the hidden radio, so the ring is drawn on the visible chip next to it. */
.ft-type input:focus-visible + span { outline: 3px solid var(--bx-focus-ring); outline-offset: 3px; }

.ft-input { width: 100%; min-height: 3.5rem; padding: var(--bx-space-3) var(--bx-space-4); border: 1px solid var(--bx-gray-500); border-radius: var(--bx-radius-md); background: var(--bx-surface); color: var(--bx-ink); font: 500 var(--bx-text-xl)/1.3 var(--bx-font-mono); letter-spacing: 0.04em; }
.ft-input:focus-visible { outline: 3px solid var(--bx-focus-ring); outline-offset: 2px; border-color: var(--bx-ink); }
.ft-input[aria-invalid="true"] { border-color: var(--bx-danger); }
.ft-hint { font-size: var(--bx-text-sm); color: var(--bx-text-muted); max-width: none; }
.ft-actions { display: flex; flex-wrap: wrap; gap: var(--bx-space-3); }
.ft-actions .btn { flex: 1 1 10rem; }
@media (min-width: 40rem) { .ft-actions .btn { flex: 0 0 auto; min-width: 10rem; } }

/* ============================== RESULT (the aria-live region) ============================== */
/* Reserved space: the region is empty at load, so it takes a fixed minimum height and the page does not jump when a result arrives. */
.ft-status { min-height: 4.5rem; padding: var(--bx-space-4) var(--bx-space-5); border-left: 4px solid transparent; background: var(--bx-gray-50); font: 600 var(--bx-text-lg)/1.4 var(--bx-font-display); color: var(--bx-ink); max-width: none; }
.ft-status:empty { background: transparent; }
.ft-status[data-state="ok"] { background: var(--bx-green-50); border-left-color: var(--bx-green-500); }
.ft-status[data-state="bad"], .ft-status[data-state="error"] { background: var(--bx-danger-100); border-left-color: var(--bx-danger); color: var(--bx-ink); }

/* ============================== THE WORKING ============================== */
.ft-work { display: grid; gap: var(--bx-space-4); padding-top: var(--bx-space-5); border-top: var(--hair); }
.ft-work h2, .ft-work-h { font: 650 var(--bx-text-lg)/1.3 var(--bx-font-display); letter-spacing: -0.01em; }
.ft-terms { display: flex; flex-wrap: wrap; gap: var(--bx-space-2); }
.ft-terms li { padding: var(--bx-space-1) var(--bx-space-2); border: 1px solid var(--bx-border-strong); border-radius: var(--bx-radius-sm); background: var(--bx-gray-50); font: 500 var(--bx-text-sm)/1.4 var(--bx-font-mono); white-space: nowrap; }
.ft-sums { display: grid; gap: var(--bx-space-2); }
.ft-sums p { max-width: none; font: 500 var(--bx-text-sm)/1.5 var(--bx-font-mono); color: var(--bx-ink); }
.ft-sums p:last-child { font-weight: 700; }

/* A worked example written out in the HTML, so the method is readable with JavaScript off. */
.ft-example { display: grid; gap: var(--bx-space-4); padding: var(--bx-space-5); background: var(--bx-surface); border: 1px solid var(--bx-border-strong); border-left: 4px solid var(--bx-green-500); max-width: 46rem; min-width: 0; }
.ft-example h3 { font-size: var(--bx-text-lg); }
.ft-example p { max-width: none; font-size: var(--bx-text-sm); color: var(--bx-gray-700); }
.ft-num { font: 600 var(--bx-text-xl)/1.3 var(--bx-font-mono); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.ft-num mark { padding: 0 0.15em; background: var(--bx-lime-500); color: var(--bx-ink); border-radius: var(--bx-radius-sm); }   /* lime is a fill, ink text on it: 13.4:1 */

/* ============================== TABLE (stacked on a phone) ============================== */
.ft-table { width: 100%; border-collapse: collapse; font-size: var(--bx-text-sm); }
.ft-table caption { padding-bottom: var(--bx-space-3); text-align: left; font: 600 var(--bx-text-xs)/1.5 var(--bx-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-gray-700); }
.ft-table th, .ft-table td { padding: var(--bx-space-3) var(--bx-space-4) var(--bx-space-3) 0; text-align: left; vertical-align: top; border-bottom: var(--hair); }
.ft-table thead th { border-bottom: 1px solid var(--bx-border-strong); font: 600 var(--bx-text-xs)/1.4 var(--bx-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--bx-gray-600); }
.ft-table tbody th { font-family: var(--bx-font-mono); font-weight: 700; white-space: nowrap; }
.ft-table td { color: var(--bx-ink); }
@media (max-width: 39.99rem) {
  /* Under 640px each row becomes a small block and the cell labels come from data-label, so nothing scrolls sideways. */
  .ft-table, .ft-table tbody, .ft-table tr, .ft-table th, .ft-table td { display: block; }
  .ft-table caption { display: block; }
  .ft-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ft-table tbody tr { padding: var(--bx-space-3) 0; border-bottom: var(--hair); }
  .ft-table th, .ft-table td { padding: var(--bx-space-1) 0; border: 0; }
  .ft-table td::before { content: attr(data-label) ": "; font: 600 var(--bx-text-xs)/1.5 var(--bx-font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--bx-gray-600); }
}

/* ============================== FIGURES ============================== */
/* Figures are built from HTML boxes (not images or SVG), so they wrap in Spanish and cost no extra request. Each carries its meaning
   in the figcaption and the surrounding text; the boxes themselves are aria-hidden. */
.ft-fig { display: grid; gap: var(--bx-space-3); max-width: 40rem; margin: 0; min-width: 0; }
.ft-fig figcaption { font: 500 var(--bx-text-xs)/1.5 var(--bx-font-mono); color: var(--bx-gray-600); }
.ft-seg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; border: 1px solid var(--bx-ink); background: var(--bx-ink); }
.ft-seg > div { display: grid; gap: var(--bx-space-1); align-content: start; padding: var(--bx-space-3) var(--bx-space-4); background: var(--bx-surface); min-width: 0; }
.ft-seg b { font: 700 var(--bx-text-lg)/1.2 var(--bx-font-mono); }
.ft-seg span { font-size: var(--bx-text-sm); color: var(--bx-gray-700); }
.ft-seg .is-key { background: var(--bx-green-50); }
.ft-seg .is-check { background: var(--bx-lime-500); }
.ft-seg .is-check span { color: var(--bx-ink); }
@media (min-width: 40rem) {
  /* Widths are loosely tied to the digit counts (AI 00: 2, extension: 1, prefix + serial reference: 16, check digit: 1) but the narrow
     cells are widened so a Spanish label such as "Dígito de control" wraps to two lines at most. */
  .ft-seg { grid-template-columns: minmax(0, 2fr) minmax(0, 2.2fr) minmax(0, 6.4fr) minmax(0, 3fr); }
}
.ft-label-fig { display: grid; gap: 2px; padding: 2px; border: 1px solid var(--bx-ink); background: var(--bx-ink); }
.ft-label-fig > div { display: grid; gap: var(--bx-space-1); padding: var(--bx-space-3) var(--bx-space-4); background: var(--bx-surface); }
.ft-label-fig b { font: 600 var(--bx-text-xs)/1.5 var(--bx-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--bx-green-600); }
.ft-label-fig span { font-size: var(--bx-text-sm); color: var(--bx-ink); }
.ft-label-fig .is-bottom { background: var(--bx-green-50); }

/* ============================== SOURCES AND RELATED LINKS ============================== */
.ft-sources { display: grid; gap: var(--bx-space-4); }
.ft-sources li { display: grid; gap: var(--bx-space-1); padding-block: var(--bx-space-3); border-bottom: var(--hair); max-width: 40rem; }
.ft-sources b { font: 600 var(--bx-text-xs)/1.5 var(--bx-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--bx-gray-700); }
.ft-sources a { display: inline-flex; align-items: center; justify-self: start; min-height: var(--bx-touch-target); overflow-wrap: anywhere; }
.ft-sources span { font-size: var(--bx-text-sm); color: var(--bx-gray-700); }
.ft-related { display: grid; gap: var(--bx-space-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 48rem) { .ft-related { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ft-related a { display: grid; gap: var(--bx-space-1); align-content: start; min-height: var(--bx-touch-target); padding: var(--bx-space-4) var(--bx-space-5); background: var(--bx-surface); border: 1px solid var(--bx-border-strong); border-top: var(--rule); color: var(--bx-ink); text-decoration: none; }
.ft-related a:hover { border-color: var(--bx-ink); }
.ft-related a:hover b { text-decoration: underline; text-underline-offset: 0.2em; }
.ft-related b { font: 650 var(--bx-text-md)/1.3 var(--bx-font-display); }
.ft-related span { font-size: var(--bx-text-sm); color: var(--bx-text-muted); }

/* ============================== MOTION AND PRINT ============================== */
@media (prefers-reduced-motion: reduce) { .ft-type span, .ft-input { transition: none; } }
@media print { .ft-form, .ft-actions { display: none; } .ft-card { border: 1px solid var(--bx-ink); } }
