/* Reset, document defaults, and the shared section grid. */

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

* {
  margin: 0;
}

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

body {
  background: var(--base);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

img {
  height: auto;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.04;
  text-wrap: balance;
}

h1 {
  font-size: var(--t-display-1);
}

h2 {
  font-size: var(--t-display-2);
}

h3 {
  font-family: var(--body);
  font-size: var(--t-display-3);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
}

code,
pre {
  font-family: var(--mono);
}

/* Focus: an accent ring with a dark separator, so it reads on any surface.
   Deliberately not the browser default, and never removed. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--accent);
  color: var(--base);
}

/* ---- Layout ---- */

.shell {
  padding-left: var(--rail);
}

.wrap {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--s4);
}

.section {
  position: relative;
  border-top: 1px solid var(--hairline);
  padding-block: var(--s8) var(--s8);
  /* Clears the sticky header, so a hash link never parks a heading underneath
     it — which would also strand a keyboard user who followed the link. */
  scroll-margin-top: 72px;
}

/* The eyebrow that opens every section: rule, index, name. It encodes the
   signal path — each section is a stage the reader passes through. */
.section-mark {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin-bottom: var(--s5);
}

.section-mark::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--hairline), transparent);
}

.lede {
  font-size: var(--t-lead);
  line-height: 1.55;
  color: var(--text-dim);
  max-width: var(--measure);
}

.lede strong {
  color: var(--text);
  font-weight: 500;
}

/* ---- Utility ---- */

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

.skip-link {
  position: absolute;
  top: var(--s1);
  left: var(--s1);
  z-index: 100;
  padding: var(--s1) var(--s2);
  background: var(--raised);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: var(--t-small);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--attack);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---- Motion ---- */

.rise {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--attack),
    transform var(--attack);
}

.rise.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .rise {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  :root {
    --rail: 0px;
  }

  .section {
    padding-block: var(--s7);
  }

  .wrap {
    padding-inline: var(--s3);
  }
}

@media (max-width: 480px) {
  .wrap {
    padding-inline: var(--s2);
  }
}
