/* primitives.css
 * Reset, base typography and the four layout primitives.
 *
 * Every layout in this portfolio is built from exactly four things:
 *   .section    full bleed background band plus vertical rhythm
 *   .container  centered max-width 1120px column with side gutters
 *   .split      two columns that collapse to one at 768px
 *   .grid-3     responsive card grid, 3 up on desktop
 *   .stack      vertical rhythm between siblings (owl selector)
 *
 * If a page needs a layout these do not cover, the page is wrong, not the CSS.
 */

/* ---------- reset ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Fixed headers must not cover a sitelink anchor target. */
  scroll-padding-top: 5rem;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd,
ul,
ol {
  margin: 0;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg,
iframe {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

@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;
  }
}

/* ---------- base typography ---------- */

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
}
h2 {
  font-size: var(--step-3);
}
h3 {
  font-size: var(--step-2);
}
h4 {
  font-size: var(--step-1);
}

p {
  max-width: var(--measure);
}

.lead {
  font-size: var(--step-1);
  color: var(--ink-muted);
}

.small {
  font-size: var(--step--1);
}

.muted {
  color: var(--ink-muted);
}

.center {
  text-align: center;
}

.center p,
.center .lead {
  margin-inline: auto;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-dark);
}

strong,
b {
  font-weight: 600;
}

hr {
  border: 0;
  border-top: var(--border);
  margin-block: var(--space-l);
}

/* Screen reader only, used for form labels and skip links. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- .section ---------- */

.section {
  padding-block: var(--section-y);
  background: var(--bg);
  /* Anchor targets sit on sections. Give the browser room under a sticky nav. */
  scroll-margin-top: 5rem;
}

.section--paper {
  background: var(--surface);
}

.section--warm {
  background: var(--surface-alt);
}

.section--accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.section--accent h1,
.section--accent h2,
.section--accent h3,
.section--accent h4 {
  color: var(--accent-ink);
}

.section--accent .lead,
.section--accent .muted,
.section--accent p {
  color: rgba(255, 255, 255, 0.86);
}

.section--accent a {
  color: #fff;
}

.section--dark {
  background: var(--accent-dark);
  color: var(--accent-ink);
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 {
  color: var(--accent-ink);
}

.section--dark p,
.section--dark .lead,
.section--dark .muted {
  color: rgba(255, 255, 255, 0.84);
}

/* Without this a link on a dark band inherits the green accent colour and is
   unreadable against the dark green background. .section--accent already had
   the equivalent rule. */
.section--dark a {
  color: #fff;
}

.section--tight {
  padding-block: calc(var(--section-y) * 0.55);
}

.section--flush-top {
  padding-top: 0;
}

.section--flush-bottom {
  padding-bottom: 0;
}

/* ---------- .container ---------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* ---------- .split ---------- */

.split {
  display: grid;
  gap: var(--gap);
  align-items: center;
}

@media (min-width: 768px) {
  .split {
    grid-template-columns: 1fr 1fr;
  }

  /* Media on the left, copy on the right, without reordering the HTML.
     Source order stays copy first, which is what a screen reader wants. */
  .split--reverse > :first-child {
    order: 2;
  }

  .split--reverse > :last-child {
    order: 1;
  }

  .split--wide-left {
    grid-template-columns: 1.35fr 1fr;
  }

  .split--wide-right {
    grid-template-columns: 1fr 1.35fr;
  }

  .split--top {
    align-items: start;
  }
}

/* ---------- .grid-3 ---------- */

.grid-3 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
  align-items: stretch;
}

@media (min-width: 640px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grid-3--2up {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid-3--2up {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- .stack ---------- */

.stack > * + * {
  margin-block-start: var(--stack-space, var(--space-s));
}

.stack--xs {
  --stack-space: var(--space-2xs);
}
.stack--s {
  --stack-space: var(--space-xs);
}
.stack--m {
  --stack-space: var(--space-m);
}
.stack--l {
  --stack-space: var(--space-l);
}
.stack--xl {
  --stack-space: var(--space-xl);
}
