:root {
  /* Typography */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
 
  /* Fluid base size: ~17px on phones, ~19px on wide screens */
  --text-base: clamp(1.0625rem, 0.95rem + 0.4vw, 1.1875rem);
  --text-small: 0.875em;
  --leading: 1.6;            /* body line-height */
  --leading-tight: 1.2;      /* headings */
 
  /* Modular type scale (ratio ~1.25) */
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: clamp(1.75rem, 1.4rem + 1.5vw, 2.441rem);
 
  /* Layout */
  --measure: 68ch;           /* comfortable line length: 45–75 characters */
  --gutter: 1rem;            /* side padding on small screens */
  --space: 1.5rem;           /* vertical rhythm unit */
 
  /* Motion */
  --duration: 150ms;
  --ease: ease-out;
}
 
 
/* --------------------------------------------------------------------------
   2. Light reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}


html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;   /* disabled under reduced motion, see §8 */
}
 
body {
  margin: 0;
}
 
img,
svg,
video {
  max-width: 100%;
  height: auto;
}
 
 
/* --------------------------------------------------------------------------
   3. Base typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading);
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;       /* long URLs don't break the layout */
}
 
h1, h2, h3, h4 {
  line-height: var(--leading-tight);
  text-wrap: balance;              /* evens out ragged headings */
  margin: calc(var(--space) * 1.5) 0 calc(var(--space) * 0.5);
}
 
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
h4 { font-size: 1rem; }
 
p,
ul,
ol,
blockquote,
pre,
figure {
  margin: 0 0 var(--space);
}
 
p {
  text-wrap: pretty;               /* avoids single-word last lines */
}
 
li + li {
  margin-top: 0.25em;
}
 
code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
 
pre {
  overflow-x: auto;
  padding: 1em;
  line-height: 1.45;
  tab-size: 2;
}
 
blockquote {
  margin-inline: 0;
  padding-inline-start: 1em;
  border-inline-start: 0.25em solid currentColor;
}
 
hr {
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.3;
  margin: calc(var(--space) * 2) 0;
}
 
 
/* --------------------------------------------------------------------------
   4. Links & focus
   -------------------------------------------------------------------------- */
a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness var(--duration) var(--ease),
              text-underline-offset var(--duration) var(--ease);
}
 
a:hover {
  text-decoration-thickness: 0.15em;
  text-underline-offset: 0.25em;
}
 
/* Keyboard focus only — clearly visible, uses currentColor so no palette needed */
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 2px;
}
 
 
/* --------------------------------------------------------------------------
   5. Page layout
   header and nav share the top row; main and footer span the full width.
   -------------------------------------------------------------------------- */
body {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "header nav"
    "main   main"
    "footer footer";
  grid-template-rows: auto 1fr auto;   /* footer sticks to bottom on short pages */
  column-gap: var(--space);
  min-height: 100vh;
  min-height: 100dvh;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
 
header { grid-area: header; }
nav    { grid-area: nav; }
main   { grid-area: main; }
footer { grid-area: footer; }
 
 
/* --------------------------------------------------------------------------
   6. Header & navigation
   -------------------------------------------------------------------------- */
header,
nav {
  display: flex;
  align-items: center;
  padding-block: var(--space);
}
 
header p {
  margin: 0;
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -0.01em;
}
 
nav {
  flex-wrap: wrap;
  gap: 0.5em 1.25em;
  justify-content: flex-end;
}
 
nav a {
  text-decoration: none;
  padding-block: 0.25em;           /* bigger tap target */
}
 
nav a:hover,
nav a[aria-current="page"] {
  text-decoration: underline;
}
 
 
/* --------------------------------------------------------------------------
   7. Main content
   The h1 and .description are optional, so nothing depends on them existing.
   -------------------------------------------------------------------------- */
main {
  padding-block: var(--space) calc(var(--space) * 2);
}
 
/* Whatever comes first in <main> shouldn't add extra space on top */
main > :first-child {
  margin-top: 0;
}
 
.description {
  font-size: var(--step-1);
  line-height: 1.45;
  opacity: 0.8;                    /* de-emphasis without choosing a colour */
  margin-top: calc(var(--space) * -0.25);
}
 
/* Offset for in-page anchors so headings aren't flush with the viewport top */
:target {
  scroll-margin-top: var(--space);
}
 
 
/* --------------------------------------------------------------------------
   8. Footer
   "Proudly generated by" on the left, licence on the right;
   stacks on narrow screens.
   -------------------------------------------------------------------------- */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5em var(--space);
  padding-block: var(--space);
  border-top: 1px solid currentColor;
  border-top-color: color-mix(in srgb, currentColor 20%, transparent);
  font-size: var(--text-small);
}
 
footer p {
  margin: 0;
}
 
.license {
  margin-inline-start: auto;       /* stays right-aligned even when wrapped */
  text-align: end;
}
 
/* Inline SVG icons: sized like the CC press-kit snippet */
.icon {
  width: 1em;
  height: 1em;
  max-width: 1em;
  max-height: 1em;
  margin-inline-start: 0.2em;
  vertical-align: -0.125em;        /* sit on the text baseline */
  fill: currentColor;              /* follows link colour; remove if icons have their own */
}
 
.builder .icon {
  margin-inline: 0 0.2em;          /* OCaml logo precedes its text */
}
 
.license a {
  white-space: nowrap;             /* keep "CC0 1.0" + icons together */
}
 
 
/* --------------------------------------------------------------------------
   9. Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 30rem) {
  footer {
    flex-direction: column;
    align-items: flex-start;
  }
 
  .license {
    margin-inline-start: 0;
    text-align: start;
  }
}
 
 
/* --------------------------------------------------------------------------
   10. User preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
 
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
 
@media print {
  nav,
  footer {
    display: none;
  }
 
  body {
    display: block;
    max-width: none;
    font-size: 12pt;
  }
 
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: var(--text-small);
  }
}
