/*
 * Shared document primitives. Load after tokens.css and before component styles.
 * Font-family tokens include local fallbacks so content remains visible if web fonts fail.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-block-size: 100%;
  color-scheme: light;
  background-color: var(--color-surface-canvas);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-block-size: 100%;
  margin: 0;
  color: var(--color-text-primary);
  background-color: var(--color-surface-canvas);
  font-family: var(--font-body);
  font-size: var(--text-step-0);
  font-synthesis: weight style;
  line-height: var(--line-body);
  overflow-wrap: break-word;
}

:where(button, input, optgroup, select, textarea) {
  max-inline-size: 100%;
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
}

:where(button, select) {
  text-transform: none;
}

textarea {
  resize: vertical;
}

::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

fieldset {
  min-inline-size: 0;
}

legend {
  max-inline-size: 100%;
  padding: 0;
}

summary {
  cursor: pointer;
}

:where(h1, h2, h3, h4, h5, h6) {
  margin-block: 0 var(--space-3);
  color: var(--color-brand-ink-900);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--line-heading);
  overflow-wrap: break-word;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-step-3);
}

h2 {
  font-size: var(--text-step-2);
}

h3 {
  font-size: var(--text-step-1);
}

:where(h4, h5, h6) {
  font-size: var(--text-step-0);
}

:where(p, blockquote, dl, figure) {
  margin-block: 0 var(--space-4);
}

:where(ul, ol) {
  margin-block: 0 var(--space-4);
  padding-inline-start: var(--space-5);
}

dd {
  margin-inline-start: 0;
}

small,
.text-small {
  font-size: var(--text-step--1);
}

.lead {
  color: var(--color-text-secondary);
  font-size: var(--text-step-1);
  line-height: var(--line-body);
}

hr {
  block-size: 0;
  margin-block: var(--space-5);
  border: 0;
  border-block-start: var(--border-width) solid var(--color-border-subtle);
}

sub,
sup {
  position: relative;
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
}

sub {
  inset-block-end: -0.25em;
}

sup {
  inset-block-start: -0.5em;
}

a {
  color: var(--color-brand-ink-700);
  text-decoration-line: underline;
  text-decoration-skip-ink: auto;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--color-brand-gold-700);
  text-decoration-thickness: 0.12em;
}

a:active {
  color: var(--color-brand-ink-950);
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-offset);
}

:where(img, picture, video, canvas, svg) {
  display: block;
  max-inline-size: 100%;
}

:where(img, video, canvas) {
  block-size: auto;
}

:where(audio, iframe, embed, object) {
  max-inline-size: 100%;
}

figure {
  margin-inline: 0;
}

figcaption {
  margin-block-start: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--text-step--1);
}

/* Preserve inherited type while enabling safe wrapping for German compounds. */
span[lang] {
  font-family: inherit;
}

:where(span, p, li, dd, blockquote, figcaption):lang(de) {
  hyphens: auto;
  overflow-wrap: break-word;
}

q:lang(de) {
  quotes: "„" "“" "‚" "‘";
}

main {
  display: block;
}

:where(header, nav, main, footer, section, article, aside) {
  min-inline-size: 0;
}

:where([id], [tabindex="-1"]) {
  scroll-margin-block-start: calc(var(--header-block-size, 0rem) + var(--space-4));
}

table {
  border-collapse: collapse;
  border-color: inherit;
  text-indent: 0;
}

/* The first keyboard stop becomes a fully visible control when focused. */
.skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: var(--z-status);
  display: inline-flex;
  align-items: center;
  min-block-size: var(--control-min-block);
  max-inline-size: calc(100vw - var(--space-5));
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-brand-gold-300);
  border-radius: var(--radius-control);
  color: var(--color-text-inverse);
  background-color: var(--color-surface-inverse);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.skip-link:not(:focus):not(:active) {
  inline-size: 1px;
  block-size: 1px;
  min-block-size: 0;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus-visible {
  outline-color: var(--color-focus-ring-inverse);
}

/* Hidden visually, available to assistive technology, and never display:none. */
:where(
  .visually-hidden,
  .sr-only,
  .live-region,
  .live-region--polite,
  .live-region--assertive
),
:where(.visually-hidden-focusable, .sr-only-focusable):not(:focus):not(:focus-within) {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
