/* ==========================================================================
   base.css — reset, elements, typography, layout primitives, utilities.
   Reads tokens.css. Holds no colour values and no form values of its own.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--wt-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;   /* every number in this system aligns */
}
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; }
li { list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-strong); }
hr { border: 0; border-top: var(--rule); margin: var(--s-5) 0; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ---- Focus: visible everywhere, never removed ---- */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: var(--r-ctl);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: var(--s-2); top: -100px; z-index: var(--z-tour);
  background: var(--primary); color: var(--on-primary);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-ctl);
  font-size: var(--t-14); font-weight: 600; text-decoration: none;
  transition: top var(--dur-1) var(--ease);
}
.skip-link:focus { top: var(--s-2); color: var(--on-primary); }

/* ==========================================================================
   Typography — two registers.
   .brand-*  the marketing/identity register: fluid, expressive
   default   the product register: fixed rem, dense, quiet
   ========================================================================== */

.brand-display, .brand-h1, .brand-h2, .brand-h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.brand-display { font-size: var(--fs-display); }
.brand-h1 { font-size: var(--fs-h1); }
.brand-h2 { font-size: var(--fs-h2); line-height: var(--lh-snug); }
.brand-h3 { font-size: var(--fs-h3); line-height: var(--lh-snug); letter-spacing: var(--tracking-heading); }
.brand-lead {
  font-size: var(--fs-lead); line-height: var(--lh-relaxed);
  color: var(--ink-2); max-width: var(--measure); text-wrap: pretty;
}

/* Product register. Page titles stay sentence case — uppercase is confined to
   the document-label treatment below. */
h1, .p-h1 {
  font-family: var(--font-display); font-size: var(--t-28); font-weight: 600;
  line-height: var(--lh-snug); letter-spacing: var(--tracking-heading); text-wrap: balance;
}
h2, .p-h2 {
  font-family: var(--font-display); font-size: var(--t-22); font-weight: 600;
  line-height: var(--lh-snug); letter-spacing: var(--tracking-heading);
}
h3, .p-h3 {
  font-family: var(--font-display); font-size: var(--t-18); font-weight: 600;
  line-height: var(--lh-snug);
}

/* The document label — the BMR / GRN / packing-list convention.
   This is where --case-head lives. Labels and <th>, never page headings. */
.label, .panel-hd h2, .panel-hd h3, th {
  font-family: var(--font-display);
  font-size: var(--t-12);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: var(--case-head);
  color: var(--muted);
  line-height: 1.3;
}
.label-ink { color: var(--ink-2); }

.body-sm { font-size: var(--t-14); }
.body-xs { font-size: var(--t-13); }
.muted   { color: var(--muted); }
.ink-2   { color: var(--ink-2); }
.strong  { font-weight: 600; }
.num     { font-variant-numeric: tabular-nums; }
/* Batch codes, lot numbers, GRN references. The body face already
   disambiguates I/l/1 and 0/O — that is why it was chosen. */
.code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  font-weight: 500;
  white-space: nowrap;
}
.prose { max-width: var(--measure); text-wrap: pretty; }
.prose p + p { margin-top: var(--s-4); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }

/* ==========================================================================
   Layout primitives
   ========================================================================== */
.wrap  { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-wide   { max-width: var(--container-wide); }
.wrap-narrow { max-width: var(--container-narrow); }

.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-lg > * + * { margin-top: var(--s-6); }

.row { display: flex; align-items: center; gap: var(--s-3); }
.row-top { align-items: flex-start; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.push { margin-left: auto; }
.grow { flex: 1 1 auto; min-width: 0; }

.grid { display: grid; gap: var(--gap-grid); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g-auto-lg { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}

/* Wide content scrolls inside itself. The body never scrolls sideways. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body { overflow-x: hidden; }

.section { padding-block: var(--section); }
.section-tight { padding-block: var(--section-tight); }

/* ---- Utilities ---- */
.hide { display: none; }
@media (max-width: 900px) { .hide-sm { display: none !important; } }
@media (min-width: 901px) { .only-sm { display: none !important; } }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.tr { text-align: right; } .tc { text-align: center; }
.w-full { width: 100%; }

/* Reveal — markup renders VISIBLE; JS opts into hiding. See prototype.js. */
.rv.pre { opacity: 0; transform: translateY(10px); }
.rv.in  { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }

/* Room for the prototype bar so nothing is covered. */
body.has-pocbar { padding-bottom: var(--pocbar-h); }
