/* ───────────────────────────────────────────────────────────────
   Hello World — consignment direction
   Swiss International Style: strict grid, flush-left, flat ink.
   Tokens are semantic roles, not a colour list.
   ─────────────────────────────────────────────────────────────── */

:root {
  /* Palette roles */
  --field:      #ffcc00;   /* Post yellow — a field, never an accent */
  --field-ink:  #141414;   /* type on yellow */
  --paper:      #ffffff;
  --ink:        #141414;
  --ink-soft:   #5c5c5c;
  --rule:       #141414;
  --rule-faint: #dcdcdc;
  --ok:         #0a7d3f;
  --fail:       #c8102e;

  /* Type roles */
  --display: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", system-ui, sans-serif;
  --utility: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", system-ui, sans-serif;
  --mono:    ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  /* Rhythm — 8px base */
  --s1: .5rem;  --s2: 1rem;   --s3: 1.5rem;
  --s4: 2rem;   --s6: 3rem;   --s8: 4rem;   --s12: 6rem;

  --shell: 78rem;
  --tempo: 180ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--utility);
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
p  { margin: 0; }
ol { margin: 0; padding: 0; list-style: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(var(--s2), 4vw, var(--s6));
}

/* Focus: one visible system everywhere */
:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.field :where(a, button, input):focus-visible { outline-color: var(--field-ink); }

.skip {
  position: absolute; left: var(--s2); top: -4rem;
  z-index: 10; padding: var(--s1) var(--s2);
  background: var(--ink); color: var(--field);
  font-weight: 700; text-decoration: none;
  transition: top var(--tempo) var(--ease);
}
.skip:focus { top: var(--s2); }

/* ── Masthead ─────────────────────────────────────────────────── */
.masthead {
  background: var(--paper);
  border-bottom: 2px solid var(--rule);
}
.masthead__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2);
  min-height: 4.25rem;
}

.wordmark {
  display: inline-flex; align-items: center; gap: .625rem;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 1.125rem; letter-spacing: -.03em;
  hyphens: auto;
}
/* Abstract mark: a franked square. Deliberately not a third-party logo. */
.wordmark__mark {
  width: 1.5rem; height: 1.5rem; flex: none;
  background: var(--field);
  border: 2px solid var(--ink);
}

.langs { display: flex; }
.langs__btn {
  appearance: none;
  border: 0; border-left: 1px solid var(--rule-faint);
  padding: .4rem .7rem;
  background: transparent;
  font: inherit; font-size: .8125rem; font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color var(--tempo) var(--ease), background var(--tempo) var(--ease);
}
.langs__btn:first-child { border-left: 0; }
.langs__btn:hover { color: var(--ink); }
.langs__btn[aria-pressed="true"] { background: var(--ink); color: var(--field); }

/* ── Yellow field + label card ────────────────────────────────── */
.field {
  background: var(--field);
  color: var(--field-ink);
  padding-block: clamp(var(--s6), 8vw, var(--s12)) var(--s12);
}
.field__grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(var(--s4), 5vw, var(--s8));
  align-items: start;
}

/* min-width:0 lets the oversized greeting wrap instead of blowing out the column */
.lede { min-width: 0; }

.eyebrow {
  font-size: .75rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--field-ink);
  margin-bottom: var(--s3);
}

.greeting {
  font-family: var(--display);
  font-size: clamp(2.5rem, 9.5vw, 7rem);
  line-height: .92;
  letter-spacing: -.045em;
  text-wrap: balance;
  overflow-wrap: break-word;   /* localisation safety: "Bonjour le monde" */
  hyphens: none;
}

.sub {
  max-width: 34ch;
  margin-top: var(--s3);
  font-size: clamp(1.0625rem, 1rem + .35vw, 1.3125rem);
  line-height: 1.4;
}

.controls { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }

.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: 0 var(--s3);
  border: 2px solid var(--field-ink);
  border-radius: 0;
  font: inherit; font-weight: 700;
  cursor: pointer;
  transition: background var(--tempo) var(--ease), color var(--tempo) var(--ease),
              transform var(--tempo) var(--ease);
}
.btn--primary { background: var(--field-ink); color: var(--field); }
.btn--primary:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--field-ink); }
.btn--ghost:hover { background: var(--field-ink); color: var(--field); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: progress; }

.switch {
  display: inline-flex; align-items: center; gap: .6rem;
  margin-top: var(--s3);
  font-size: .875rem; font-weight: 500;
  cursor: pointer;
}
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--field-ink); cursor: pointer; }

/* Label card — flat offset, printed-paper material */
.label-card {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  padding: var(--s3);
  /* perforated top edge */
  background-image: radial-gradient(circle at 6px 0, transparent 4px, var(--paper) 4px);
  background-size: 14px 100%;
  background-repeat: repeat-x;
}
.label-card__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: var(--s1);
  border-bottom: 2px solid var(--ink);
  font-size: .75rem; font-weight: 700; letter-spacing: .1em;
}
.label-card__weight { font-family: var(--mono); letter-spacing: 0; color: var(--ink-soft); }

.label-card__addr { margin: var(--s3) 0 0; display: grid; gap: var(--s1); }
.label-card__addr dt {
  font-size: .625rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.label-card__addr dd {
  margin: 0 0 var(--s2);
  font-size: .9375rem; line-height: 1.35;
}
.label-card__addr dd:last-of-type { margin-bottom: 0; }

/* Barcode generated from the tracking digits — product-derived, not decoration.
   Bars use flex ratios so the encoding always fills the label width exactly. */
.barcode {
  display: flex; align-items: stretch; gap: 1px;
  height: 3.25rem;
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--rule-faint);
}
.barcode span { background: var(--ink); flex-basis: 0; min-width: 1px; }
.barcode:empty { opacity: .12; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 6px); }

.label-card__code {
  margin-top: var(--s1);
  font-size: .9375rem; font-weight: 700; letter-spacing: .02em;
}
.label-card__demo {
  margin-top: var(--s1);
  font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft);
}
.label-card[data-failed="true"] { box-shadow: 10px 10px 0 var(--fail); }

/* ── Tracking ─────────────────────────────────────────────────── */
.track { padding-block: clamp(var(--s6), 7vw, var(--s8)); }

.track__head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 2px solid var(--rule);
}
.track__head h2 { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.75rem); }

.status {
  font-size: .8125rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .3rem .7rem;
  border: 2px solid currentColor;
  color: var(--ink-soft);
}
.status[data-state="moving"]    { color: var(--ink);  background: var(--field); border-color: var(--ink); }
.status[data-state="delivered"] { color: var(--paper); background: var(--ok);   border-color: var(--ok); }
.status[data-state="failed"]    { color: var(--paper); background: var(--fail); border-color: var(--fail); }

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: var(--s4);
}
.step {
  position: relative;
  padding: var(--s3) var(--s3) var(--s4) 0;
  border-top: 6px solid var(--rule-faint);
  opacity: .4;
  transition: opacity var(--tempo) var(--ease), border-color var(--tempo) var(--ease);
}
.step h3 { font-size: 1rem; margin-bottom: .35rem; }
.step p  { font-size: .875rem; color: var(--ink-soft); max-width: 24ch; }
.step time {
  display: block; margin-top: var(--s2);
  font-size: .8125rem; font-weight: 700;
  min-height: 1.2em;
}
.step[data-done="true"]   { opacity: 1; border-top-color: var(--ink); }
.step[data-active="true"]  { opacity: 1; border-top-color: var(--field); }
.step[data-failed="true"]  { opacity: 1; border-top-color: var(--fail); }
.step[data-failed="true"] h3,
.step[data-failed="true"] time { color: var(--fail); }

.receipt {
  display: block;
  margin-top: var(--s4);
  padding: var(--s3);
  background: var(--ink);
  color: var(--paper);
  border-left: 8px solid var(--field);
}
.receipt__line { font-size: clamp(1rem, .9rem + .5vw, 1.375rem); font-weight: 700; }
.receipt__note { margin-top: var(--s1); font-size: .875rem; color: #a8a8a8; }

/* ── Foot ─────────────────────────────────────────────────────── */
.foot {
  border-top: 2px solid var(--rule);
  padding-block: var(--s3);
  font-size: .75rem;
  color: var(--ink-soft);
}
.foot__inner {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  justify-content: space-between; align-items: center;
}
.foot p { max-width: 68ch; }

/* ── Responsive transformation ────────────────────────────────────
   Not a scale-down: the label card moves below the greeting and the
   4-column timeline becomes a vertical ledger with a spine.          */
@media (max-width: 60rem) {
  .field__grid { grid-template-columns: minmax(0, 1fr); }
  .label-card { max-width: 26rem; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .step {
    padding: var(--s2) 0 var(--s2) var(--s3);
    border-top: 0;
    border-left: 6px solid var(--rule-faint);
  }
  .step[data-done="true"]   { border-left-color: var(--ink); }
  .step[data-active="true"] { border-left-color: var(--field); }
  .step[data-failed="true"] { border-left-color: var(--fail); }
  .step p { max-width: 46ch; }
}

@media (max-width: 30rem) {
  .label-card { box-shadow: 6px 6px 0 var(--ink); }
  .controls .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}

@media print {
  .masthead, .controls, .switch, .skip { display: none; }
  .field { background: #fff; }
  .label-card { box-shadow: none; }
}
