/* ==========================================================================
   Base: reset, element defaults, focus, prose
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-5);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-weight: var(--weight-regular);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1 0 auto;
}

/* Components set display values; the hidden attribute must still win. */
[hidden] {
  display: none !important;
}

main:focus {
  outline: none;
}

::selection {
  background: var(--color-selection);
  color: var(--green-dark);
}

/* ---- Headings ---------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink);
  font-weight: var(--weight-heavy);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-4xl);
  line-height: var(--leading-4xl);
  letter-spacing: var(--tracking-4xl);
}

h2 {
  font-size: var(--text-3xl);
  line-height: var(--leading-3xl);
  letter-spacing: var(--tracking-3xl);
}

h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
  font-weight: var(--weight-bold);
}

h4 {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  font-weight: var(--weight-bold);
}

p,
ul,
ol,
dl,
figure,
blockquote {
  margin: 0;
}

p {
  text-wrap: pretty;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

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

img {
  height: auto;
}

strong,
b {
  font-weight: var(--weight-bold);
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

hr {
  border: 0;
  border-top: var(--border-width) solid var(--line);
  margin: var(--space-7) 0;
}

/* ---- Links ------------------------------------------------------------- */

a {
  color: var(--color-link);
  font-weight: var(--weight-medium);
  text-decoration-line: underline;
  text-decoration-color: var(--color-link-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  transition:
    color var(--duration-fast) var(--ease-out),
    text-decoration-color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration-color: var(--color-link-underline-hover);
  text-decoration-thickness: 3px;
}

a:active {
  color: var(--green-dark);
}

/* ---- Focus ------------------------------------------------------------- */

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Form element defaults --------------------------------------------- */

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

/* ---- Prose (legal pages, long-form text) ------------------------------ */

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

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
  letter-spacing: var(--tracking-2xl);
  margin-top: var(--space-7);
}

.prose h3 {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  margin-top: var(--space-6);
}

.prose h2 + *,
.prose h3 + * {
  margin-top: var(--space-3);
}

.prose ul,
.prose ol {
  padding-left: var(--space-5);
}

.prose li + li {
  margin-top: var(--space-2);
}

.prose ul li::marker {
  color: var(--amber-dark);
}

.prose > :first-child {
  margin-top: 0;
}

/* ---- Accessibility helpers --------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--green-dark);
  color: var(--on-dark);
  font-weight: var(--weight-bold);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
  color: var(--on-dark);
  outline-color: var(--amber);
}
