:root {
  --header-offset: 32mm;
}

* {
  box-sizing: border-box;
}

body,
html {
  margin: 0 0;
  padding: 0 0;
  width: 100%;
  height: 100%;
}

article:not(article article) {
  max-width: var(--article-w);
  margin-right: 150px;
  margin: 0 auto;
  padding-right: var(--footnote-w);
}

article header {
  padding-right: 0;
  margin-right: calc(var(--footnote-w) * -1);
}

article header {
  min-height: var(--header-offset);
}

aside+section p:first-child {
  margin-top: 0;
}

.media--pcb {
  width: 70mm;
}

dialog {
  max-width: var(--main-w);
  height: 100%;
  max-height: 100%;
  border: none;
  overflow: hidden;
  outline: none;
  background-color: transparent;
  margin: 0 auto;
  padding: 0 0;
}

dialog img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: calc(100svh - 2rem);
}

dialog::backdrop {
  background-color: transparent;
  transition: 0.2s linear;
}

dialog[open]::backdrop {
  background-color: black;
  opacity: 0.5;
}

sup li:before,
li[count]:before {
  display: inline;
  float: left;
  margin-right: 1ch;
  font-weight: bold;
  content: attr("count");
  content: " [" attr(count) "]";
  color: var(--accent);
}

.footnote-back {
  display: none;
}

li[count],
aside:not(.footnotes):not(aside aside) {
  float: right;
  clear: right;
  width: var(--footnote-w);
  margin-right: calc((var(--footnote-w) * -1));
  padding-left: var(--gap);
  margin-bottom: 1em;
}

li[count] {
  margin-top: -1em;
}

.list--frontpage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 1rem;
  list-style-type: none;
  padding: 0 0;
}

article table tr, .csl-entry {
  break-inside: avoid;
}


.grid p {
  display: grid;
  margin-right: -100px;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  break-before: page;
}

figure {
  counter-increment: figure-counter;
}

article figure:has(.img--fullpage), figure:has(.img--fullpage) {
  margin-right: calc(var(--footnote-w) * -1);
  clear: both;
  margin-top: 2rem;
  margin-bottom: 0;
  position: relative;
  width: 100%;
  break-before: page;
  break-after: page;
  height: 100%;
  height: calc(var(--pagedjs-pagebox-height)/2);
  margin-top: calc(var(--pagedjs-margin-top) * -1);
  margin-right: calc(var(--pagedjs-margin-right) * -1);
  margin-bottom: calc(var(--pagedjs-margin-bottom) * -1);
  margin-left: calc(var(--pagedjs-margin-left) * -1);
  width: calc(var(--pagedjs-pagebox-width));
  break-inside: avoid;
}


article figure:has(.img--fullpage) img, figure:has(.img--fullpage) img {
  position: absolute;
  height: 200% !important;
  transform: scale(1.01);
}

article figure:has(.img--fullpage) figcaption, figure:has(.img--fullpage) figcaption {
  position: absolute;
  z-index: 2;
  bottom: calc(var(--pagedjs-pagebox-height)*-0.5 + var(--pagedjs-margin-bottom));
  left: var(--pagedjs-margin-left);
  padding: 1mm 2mm;
  background: white;
  font-size: 8px;
}

article figure img {
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
}

article figure figcaption {
  padding-top: 8px;
  line-height: 1.5;
}

figcaption:before {
  content: "fig " counter(figure-counter) ". ";
  opacity: .5
}

.image-list {
  break-inside: avoid;
  break-before: page;
  width: calc(100% + var(--footnote-w));
  margin-right: calc(var(--footnote-w) * -1);
}

.image-list figure {
  display: flex;
  gap: 2rem;
  margin-top: 0;
  align-items: flex-end;
}

.image-list figcaption {
  max-width: var(--footnote-w);
}

.image-list img {
  height: 50mm;
  object-fit: cover;
}
