/* eIDASscan base and components. Uses only tokens.css custom properties.
   Order: base, type, layout, wordmark, scale motif, buttons, fields, typeahead, code input,
   status block, notice, step meter, header, footer. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-ground);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
  font-weight: var(--type-body-weight);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  /* Long German and Dutch compounds: hyphenate by language, break as a last resort. */
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 12 5 5; /* only long words (German compounds) get hyphenated */
  overflow-wrap: break-word;
}
h1, h2, h3, .display { hyphens: manual; overflow-wrap: break-word; text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }
a { color: var(--color-accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--color-accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: var(--line-focus) solid var(--color-focus); outline-offset: 2px; }
.band :focus-visible, .footer :focus-visible { outline-color: var(--color-accent-on-band); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.figures { font-feature-settings: var(--font-figures); }
.brand { white-space: nowrap; hyphens: none; } /* eIDASscan in running text: never split, never re-cased */

/* ---------- Type ---------- */
.display {
  font-size: var(--type-display-size); line-height: var(--type-display-line);
  font-weight: var(--type-display-weight); letter-spacing: var(--type-display-tracking);
  margin: 0;
}
h1, .h1 { font-size: var(--type-h1-size); line-height: var(--type-h1-line); font-weight: var(--type-h1-weight); letter-spacing: var(--type-h1-tracking); margin: 0; }
h2, .h2 { font-size: var(--type-h2-size); line-height: var(--type-h2-line); font-weight: var(--type-h2-weight); letter-spacing: var(--type-h2-tracking); margin: 0; }
h3, .h3 { font-size: var(--type-h3-size); line-height: var(--type-h3-line); font-weight: var(--type-h3-weight); margin: 0; }
.lead { font-size: var(--type-lead-size); line-height: var(--type-lead-line); font-weight: var(--type-lead-weight); margin: 0; max-width: var(--measure); }
.small { font-size: var(--type-small-size); line-height: var(--type-small-line); }
.muted { color: var(--color-text-secondary); }
p { margin: 0 0 var(--space-4); max-width: var(--measure); }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: calc(var(--max-wide) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--text { max-width: calc(var(--max-text) + 2 * var(--gutter)); }
.stack > * + * { margin-top: var(--stack, var(--space-4)); }

/* ---------- Wordmark ---------- */
.wordmark { display: inline-block; line-height: 0; color: inherit; }
.wordmark img { height: 1.375rem; width: auto; }           /* nav: 22px tall */
.wordmark--footer img { height: 1.25rem; }

/* ---------- Scale motif ----------
   <div class="scale" style="--reading: 62%"><span class="scale__reading"></span></div>
   A 2px rule, 8 equal divisions, taller end ticks, one accent reading. */
.scale {
  --ink: var(--color-text);
  --mark: var(--color-accent);
  position: relative;
  height: var(--scale-reading-height);
  background:
    linear-gradient(var(--ink), var(--ink)) 0 5px / 100% var(--scale-rule) no-repeat,
    repeating-linear-gradient(90deg, var(--ink) 0 var(--scale-rule), transparent var(--scale-rule) 12.5%) 0 5px / 100% var(--scale-tick-minor) no-repeat;
}
.scale::before, .scale::after {
  content: ""; position: absolute; top: 5px; width: var(--scale-rule); height: var(--scale-tick-major); background: var(--ink);
}
.scale::before { left: 0; }
.scale::after { right: 0; }
.scale__reading {
  position: absolute; top: 0; left: var(--reading, 62%);
  width: var(--scale-reading-width); height: var(--scale-reading-height);
  margin-left: calc(var(--scale-reading-width) / -2);
  background: var(--mark);
  transition: left 600ms var(--motion-easing);
}
.band .scale, .footer .scale { --ink: var(--color-on-band); --mark: var(--color-accent-on-band); }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--target-min);
  padding: 0.8125rem var(--space-5);
  border: var(--line-control) solid transparent;
  border-radius: var(--radius-control);
  font: inherit; font-size: var(--type-button-size); line-height: var(--type-button-line);
  font-weight: var(--type-button-weight); letter-spacing: var(--type-button-tracking);
  text-decoration: none; cursor: pointer;
  transition: background-color var(--motion-duration) var(--motion-easing), color var(--motion-duration) var(--motion-easing);
}
.button--primary { background: var(--color-accent); color: var(--color-on-accent); }
.button--primary:hover { background: var(--color-accent-hover); color: var(--color-on-accent); text-decoration: none; }
.button--primary:active { transform: translateY(1px); }
.button--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-line-strong); }
.button--secondary:hover { border-color: var(--color-text); color: var(--color-text); text-decoration: none; }
.button--block { width: 100%; }
.button[aria-disabled="true"], .button:disabled { background: var(--color-sunken); color: var(--color-text-secondary); cursor: not-allowed; }
.button--link { font: inherit; font-size: var(--type-small-size); cursor: pointer; background: none; border: 0; padding: 0; min-height: var(--target-min); color: var(--color-accent); font-weight: 540; text-decoration: underline; text-underline-offset: 0.18em; }
.button--block-mobile { width: 100%; }
@media (min-width: 48rem) { .button--block-mobile { width: auto; } }

/* ---------- Fields ---------- */
.field { display: grid; gap: var(--space-2); }
.field + .field { margin-top: var(--space-5); }
.field__label { font-size: var(--type-label-size); line-height: var(--type-label-line); font-weight: var(--type-label-weight); }
.field__help { font-size: var(--type-small-size); line-height: var(--type-small-line); color: var(--color-text-secondary); margin: 0; }
.field__error {
  display: none; margin: 0;
  font-size: var(--type-small-size); line-height: var(--type-small-line); font-weight: 540; color: var(--color-error);
  padding-left: var(--space-3); border-left: var(--line-strong) solid var(--color-error);
}
.field.is-invalid .field__error { display: block; }
.input {
  width: 100%; min-height: 3rem;
  padding: 0.6875rem var(--space-3);
  background: var(--color-surface);
  border: var(--line-control) solid var(--color-line-strong);
  border-radius: var(--radius-control);
  color: var(--color-text);
  font: inherit; font-size: 1.0625rem; /* >=16px: no zoom on iOS */
  transition: border-color var(--motion-duration) var(--motion-easing), box-shadow var(--motion-duration) var(--motion-easing);
}
.input::placeholder { color: var(--color-text-secondary); opacity: 1; }
.input:hover { border-color: var(--color-text); }
.input:focus-visible { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 var(--line-control) var(--color-accent); }
.field.is-invalid .input { border-color: var(--color-error); box-shadow: 0 0 0 var(--line-control) var(--color-error); }

/* ---------- Organisation typeahead (ARIA combobox + listbox) ---------- */
.typeahead { position: relative; }
.typeahead__list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + var(--space-1));
  margin: 0; padding: var(--space-1) 0; list-style: none;
  background: var(--color-surface);
  border: var(--line-control) solid var(--color-text);
  border-radius: var(--radius-control);
  box-shadow: 0 10px 24px -12px rgb(14 47 51 / 0.35);
  max-height: 20rem; overflow-y: auto;
}
.typeahead__list[hidden] { display: none; }
.typeahead__option {
  display: grid; grid-template-columns: 1fr auto; column-gap: var(--space-3); row-gap: 2px;
  min-height: var(--target-min);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.typeahead__option + .typeahead__option { border-top: 1px solid var(--color-line); }
.typeahead__name { grid-column: 1 / -1; font-weight: 540; line-height: 1.3; }
.typeahead__name mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--color-accent); text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
.typeahead__meta { font-size: var(--type-small-size); color: var(--color-text-secondary); font-feature-settings: var(--font-figures); }
.typeahead__city { font-size: var(--type-small-size); color: var(--color-text-secondary); text-align: right; }
.typeahead__option[aria-selected="true"], .typeahead__option:hover { background: var(--color-sunken); border-left-color: var(--color-accent); }
.typeahead__foot { padding: var(--space-2) var(--space-3) var(--space-1); font-size: 0.8125rem; color: var(--color-text-secondary); border-top: 1px solid var(--color-line); }
.typeahead__chosen {
  display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; flex-wrap: wrap;
  padding: var(--space-3); background: var(--color-surface); border: var(--line-control) solid var(--color-line-strong); border-radius: var(--radius-control);
}

/* ---------- One-time code: one real input, six drawn cells ---------- */
.code { position: relative; width: min(100%, 22rem); }
.code__cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-2); }
.code__cell {
  display: grid; place-items: center; aspect-ratio: 5 / 6; min-height: 3.25rem;
  background: var(--color-surface); border: var(--line-control) solid var(--color-line-strong); border-radius: var(--radius-control);
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 1.875rem); font-weight: 600; font-feature-settings: var(--font-figures);
}
.code__cell:nth-child(3) { margin-right: var(--space-2); } /* 3 + 3 grouping, read as 482 913 */
.code__cell.is-active { border-color: var(--color-accent); box-shadow: 0 0 0 var(--line-control) var(--color-accent); }
.code__cell.is-filled { border-color: var(--color-text); }
.code input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.01; font-size: 16px; letter-spacing: 2em; border: 0; background: transparent; color: transparent; caret-color: transparent;
}
.code.is-invalid .code__cell { border-color: var(--color-error); }
.code.is-valid .code__cell { border-color: var(--color-success); background: var(--color-success-bg); }

/* ---------- Status block: the scan as a reading on the scale ---------- */
.status {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-panel);
  padding: var(--space-5);
}
.status__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.status__state {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--type-small-size); font-weight: 600; padding: 2px var(--space-2); border-radius: var(--radius-panel);
}
.status__state::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.status--waiting .status__state { color: var(--color-waiting); background: var(--color-waiting-bg); }
.status--sent .status__state { color: var(--color-success); background: var(--color-success-bg); }
.status--error .status__state { color: var(--color-error); background: var(--color-error-bg); }
.status .scale { --mark: var(--color-waiting); }
.status--sent .scale { --mark: var(--color-success); }
.status--error .scale { --mark: var(--color-error); }
.status--waiting .scale__reading { animation: settle 2.4s var(--motion-easing) infinite alternate; }
@keyframes settle { from { transform: translateX(-6px); } to { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .status--waiting .scale__reading { animation: none; } .scale__reading { transition: none; } }
.status__steps { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.status__steps li { font-size: var(--type-small-size); line-height: 1.35; color: var(--color-text-secondary); }
.status__steps li:nth-child(2) { text-align: center; }
.status__steps li:nth-child(3) { text-align: right; }
.status__steps strong { display: block; color: var(--color-text); font-weight: 600; }
.status__steps li[aria-current="step"] strong { color: var(--color-waiting); }
.status--sent .status__steps li[aria-current="step"] strong { color: var(--color-success); }
.status__steps time { font-feature-settings: var(--font-figures); }

/* ---------- Notice ---------- */
.notice {
  --tone: var(--color-info); --tone-bg: var(--color-info-bg);
  display: grid; gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  background: var(--tone-bg);
  border-left: var(--line-strong) solid var(--tone);
  border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
  font-size: var(--type-small-size); line-height: var(--type-small-line);
}
.notice > * { margin: 0; }
.notice__title { font-weight: 600; color: var(--tone); }
.notice--waiting { --tone: var(--color-waiting); --tone-bg: var(--color-waiting-bg); }
.notice--error   { --tone: var(--color-error);   --tone-bg: var(--color-error-bg); }
.notice--success { --tone: var(--color-success); --tone-bg: var(--color-success-bg); }

/* ---------- Step meter (request flow: step 1 of 3) ---------- */
.steps { display: grid; gap: var(--space-2); }
.steps__bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.steps__bar span { height: 4px; background: var(--color-line); }
.steps__bar span.is-done { background: var(--color-text); }
.steps__bar span.is-current { background: var(--color-accent); }
.steps__label { font-size: var(--type-small-size); color: var(--color-text-secondary); font-feature-settings: var(--font-figures); }

/* ---------- Header ---------- */
.header { padding-block: var(--space-4); }
.header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.header__aside { font-size: var(--type-small-size); color: var(--color-text-secondary); }

/* ---------- Footer ---------- */
.footer { background: var(--color-band); color: var(--color-on-band); padding-block: var(--space-7) var(--space-6); margin-top: var(--space-9); }
.footer a { color: var(--color-on-band); }
.footer a:hover { color: var(--color-accent-on-band); }
.footer__grid { display: grid; gap: var(--space-6); }
.footer__nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); list-style: none; padding: 0; margin: 0; }
.footer__nav a { display: inline-flex; min-height: var(--target-min); align-items: center; }
.footer__note { color: var(--color-on-band-secondary); font-size: var(--type-small-size); max-width: 36em; margin: 0; }
.footer .scale { margin-bottom: var(--space-6); }
@media (min-width: 48rem) {
  .footer__grid { grid-template-columns: 1fr auto; align-items: start; }
}
