:root {
  --page-pad-x: clamp(0.75rem, 3vw, 1.5rem);
  --measure: 68ch;
  --surface: #fff;
  --ink: #222;
  --muted: #555;
  --rule: #e6e6e6;
  font-size: clamp(1rem, 0.92rem + 0.45vw, 1.125rem);
}

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

body {
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem) var(--page-pad-x) 3rem;
  max-width: min(100%, var(--measure) + var(--page-pad-x) * 2);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  color: var(--ink);
  background: var(--surface);
  overflow-x: clip;
}

header {
  margin-bottom: clamp(1rem, 2.5vw, 2rem);
}

header nav a {
  display: inline-block;
  padding-block: 0.25rem;
  color: var(--muted);
  text-decoration: none;
}

header nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
}

h2 {
  margin: 2rem 0 0.65rem;
  font-size: clamp(1.3rem, 1.15rem + 0.9vw, 1.75rem);
  line-height: 1.25;
}

p {
  margin: 0 0 1.15rem;
}

/* Home page index list */
nav[aria-label="Pages"] ul {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

nav[aria-label="Pages"] li {
  border-bottom: 1px solid var(--rule);
}

nav[aria-label="Pages"] a {
  display: block;
  padding: 0.65rem 0;
  color: inherit;
  text-decoration: none;
}

nav[aria-label="Pages"] a:hover {
  text-decoration: underline;
}

/* Inline 800px Hugo-resized images: scale down on small screens, never upscale past natural size */
main img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 1.25rem 0;
  cursor: zoom-in;
}

/* Lightbox dialog */
dialog {
  border: 0;
  padding: 0;
  margin: auto;
  background: transparent;
  width: 100dvw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  overflow: auto;
  display: none;
  align-items: center;
  justify-content: center;
}

dialog[open] {
  display: flex;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.92);
}

dialog img {
  display: block;
  border: 0;
  width: auto;
  height: auto;
  max-width: 100dvw;
  max-height: 100dvh;
  object-fit: contain;
  cursor: zoom-in;
}

dialog img.zoomed {
  max-width: none;
  max-height: none;
  margin: auto;
  cursor: zoom-out;
}

dialog button {
  position: fixed;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 0;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  line-height: 1;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  z-index: 1;
}

dialog [data-prev] {
  left: clamp(0.5rem, 2vw, 1.25rem);
  top: 50%;
  transform: translateY(-50%);
}

dialog [data-next] {
  right: clamp(0.5rem, 2vw, 1.25rem);
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 600px) {
  dialog button {
    padding: 0.45rem 0.65rem;
  }
}
