/* ==========================================================================
   Base: reset, typography, accessibility helpers
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* keeps anchored headings clear of the sticky header */
}

body {
  margin: 0;
  background: var(--spray);
  color: var(--tar);
  font-family: var(--font);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
ol,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3 {
  /* Norwegian compounds ("Personvernerklæring") are long: hyphenate on small
     screens rather than overflow. Needs lang="nb" on <html>, which we have. */
  overflow-wrap: break-word;
  -webkit-hyphens: auto; /* Safari before 17 */
  hyphens: auto;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h2 {
  font-size: var(--step-3);
}

h3 {
  font-size: var(--step-1);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

p,
dt,
dd,
li {
  overflow-wrap: break-word;
}

p {
  max-width: var(--measure);
  text-wrap: pretty;
}

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

a {
  color: var(--fjord);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--ochre);
  color: var(--tar);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--tar);
  color: var(--white);
  font-weight: 700;
  border-radius: var(--radius-s);
}

.skip-link:focus {
  top: 1rem;
  color: var(--white);
}

/* Motion off: the visitor's system setting, or the "Stopp animasjoner"
   button (src/js/motion.js). Animations jump straight to their end state. */
html[data-motion="off"] {
  scroll-behavior: auto;
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0ms !important;
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
