/* Element defaults. No classes here; components and layout build on top. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Hidden stays hidden, also on elements whose component sets a display value. */
[hidden] {
  display: none !important;
}

html {
  /* Set on the root as well: WebKit sometimes reports the body background as transparent on long pages. */
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchored sections land below the sticky header. */
  scroll-padding-top: calc(4.25rem + var(--space-5));
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  /* Entrances that travel sideways must never cause a horizontal scrollbar; clip keeps sticky working. */
  overflow-x: clip;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-3);
  line-height: var(--leading-tight);
  font-weight: 750;
  letter-spacing: -0.015em;
  text-wrap: balance;
  /* Long German compounds ("Benutzerverwaltung") hyphenate on narrow screens instead of overflowing. */
  overflow-wrap: break-word;
  hyphens: auto;
}

h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
}

h2 {
  font-size: var(--text-lg);
}

h3 {
  font-size: var(--text-md);
}

p,
ul,
ol,
dl {
  margin: 0 0 var(--space-4);
}

p {
  text-wrap: pretty;
}

p:last-child,
ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition:
    color var(--duration-fast) ease,
    text-decoration-thickness var(--duration-fast) ease;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration-thickness: 2px;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
}

/* Taps react at once instead of waiting for a possible double-tap zoom. */
a,
button,
input,
select,
label {
  touch-action: manipulation;
}

img,
svg {
  max-width: 100%;
}

::selection {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

/* WCAG 2.4.7: every interactive element shows a clearly visible keyboard focus. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Also used by the motion layer: with reduced motion everything is shown in its final state. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
