/* Reset + element defaults */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--font-size-m);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* Images keep their own proportions: the width/height attributes give the
   browser the aspect ratio, height: auto keeps it when the width changes. */
img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Images from site/snippets/image.php: the <picture> carries a blurred
   placeholder as its background, assets/js/image-fade.js fades the image in
   over it once loaded. Without JS the image simply covers the placeholder. */
picture {
  background-size: cover;
}

.js picture > img {
  transition: opacity var(--transition-slow);

  &:not(.is-loaded) {
    opacity: 0;
  }
}

/* No bold anywhere on the site */
h1,
h2,
h3,
h4,
h5,
h6,
b,
strong,
th {
  font-weight: inherit;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

address {
  font-style: normal;
}

:focus-visible {
  outline: 1px solid var(--color-fg);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Page transitions between documents (Chrome/Edge 126+, Safari 18.2+; other
   browsers load instantly). The header gets its own snapshot so it stays put;
   the rest fades out, then fades in. */
@view-transition {
  navigation: auto;
}

.site-header {
  view-transition-name: site-header;
}

::view-transition-old(root) {
  animation: page-out var(--transition) both;
}

::view-transition-new(root) {
  animation: page-in var(--transition-slow) both;
  animation-delay: 300ms; /* = --transition: starts once the old page is gone */
}

@keyframes page-out {
  to {
    opacity: 0;
  }
}

@keyframes page-in {
  from {
    opacity: 0;
  }
}

/* Row/grid switch on the homepage (view-toggle.js): a quicker crossfade */
html:active-view-transition-type(view-switch) {
  &::view-transition-old(root) {
    animation: page-out var(--transition) both;
  }

  &::view-transition-new(root) {
    animation: page-in var(--transition) both;
    animation-delay: 0s;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
