body {
  padding: 0 12px;
  margin: 1rem auto 3rem;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  font-size: 1.1rem;
  max-width: 40em;
  -webkit-font-smoothing: antialiased;
  color: #111;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  line-height: 1.2;
  font-weight: 600;
}

h2,
h3 {
  margin-top: 1.5em;
}

h1 {
  margin: 0.5rem 0 0.75rem;
  font-size: 2rem;
}

strong {
  font-weight: 600;
}

a {
  color: currentColor;
  text-underline-offset: 0.1lh;
}

a:hover {
  text-underline-offset: 0.15lh;
}

/* :visited colors are forced opaque by browsers for privacy, so we can't
   use `transparent` to hide the underline — match the background instead. */
a:visited {
  text-decoration-color: white;
}

h1 a {
  text-decoration: none;
}

h1 a:hover {
  text-decoration: underline;
}

/* External link icon on article titles */
article h1 a::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.35em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
  transition: opacity 0.2s;
}

article h1 a:hover::after {
  opacity: 0.7;
}

@media (prefers-color-scheme: dark) {
  article h1 a::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
  }
}

/* Section label */
.section {
  text-transform: uppercase;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
}

/* Authors */
.authors {
  font-size: 0.95rem;
  margin: 0 0 2rem;
}

/* Dateline (publisert / oppdatert) */
.dateline {
  font-size: 0.85rem;
  margin: 0 0 2rem;
}

/* Pull the dateline tight under the byline when an author paragraph
   precedes it. Without this rule on bulletins (no .authors) the dateline
   would overlap the h1. */
.authors + .dateline {
  margin-top: -1.5rem;
}

.dateline::first-letter {
  text-transform: uppercase;
}

/* Lead paragraph */
.lead {
  font-size: 1.3rem;
  margin: 0 0 2rem;
}

/* Dim text */
.dim {
  color: #666;
}

/* Repel layout */
.repel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: var(--repel-vertical-alignment, center);
  gap: var(--gutter, 1rem);
}

/* Page count */
.page-count {
  min-width: 6ch;
  text-align: right;
}

/* Header navigation */
header nav {
  --repel-vertical-alignment: baseline;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 2.5rem;
}

nav a {
  text-decoration: underline;
}

/* Override the global a:visited that hides body-link underlines —
   nav links should always look clickable, regardless of visit state. */
nav a:visited {
  text-decoration-color: currentColor;
}

/* Active section in header nav: drop the underline and bump weight so
   the actionable inactive link is the underlined one and the current
   page reads as "you are here". */
header nav a[aria-current="page"] {
  text-decoration: none;
  font-weight: 600;
}

/* Primary nav cluster (Dagleg / Live) and the right-side context slot. */
.nav-primary {
  display: flex;
  gap: 1.25rem;
}

.nav-context {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.nav-context a {
  color: inherit;
}

/* Footer navigation */
footer nav {
  margin: 3rem 0 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid #e0e0e0;
}

footer nav a {
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-weight: 600;
  transition: background-color 0.2s;
  background-color: #f5f5f5;
  color: #333;
}

footer nav a:hover {
  background-color: #e0e0e0;
  text-decoration: none;
}

/* List pages */
ul[role="list"] {
  list-style: none;
  margin-block: 0;
  padding: 0;
}

ul[role="list"] li + li {
  margin-top: 1em;
}

li:empty {
  display: none;
}

/* Keyboard shortcuts overlay */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.shortcuts-dialog {
  background: #fff;
  color: #111;
  padding: 1.5rem 2rem;
  border-radius: 8px;
  max-width: 400px;
  position: relative;
}

.shortcuts-dialog h2 {
  margin: 0 2rem 1rem 0;
}

.shortcuts-dialog dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.shortcuts-dialog dt {
  font-family: monospace;
  background: #eee;
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

.shortcuts-dialog dd {
  margin: 0;
}

.shortcuts-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2em 0.4em;
  line-height: 1;
}

.shortcuts-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  body {
    color: unset;
  }

  a:visited {
    text-decoration-color: black;
  }

  .dim {
    color: #999;
  }

  header nav,
  footer nav {
    border-color: #333;
  }

  footer nav a {
    background-color: #2a2a2a;
    color: #e0e0e0;
  }

  footer nav a:hover {
    background-color: #333;
  }

  .shortcuts-dialog {
    background: #222;
    color: #eee;
  }

  .shortcuts-dialog dt {
    background: #444;
  }

  .shortcuts-close:hover {
    background: rgba(255, 255, 255, 0.15);
  }
}
