/* Base: reset, typography, scrollbar, page scaffolding and motion. */

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

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + var(--space-lg));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.nav-open {
  overflow-y: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--text-main);
  text-wrap: balance;
  overflow-wrap: break-word;
  min-width: 0;
}

h1 {
  font-size: var(--text-display);
  line-height: 1;
}

h2 {
  font-size: var(--text-section);
}

h3 {
  font-size: var(--text-title);
  line-height: 1.15;
}

p {
  margin: 0;
  text-wrap: pretty;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

dl,
dd,
dt,
figure,
blockquote {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

img {
  height: auto;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

::selection {
  background: var(--red-primary);
  color: var(--text-main);
}

html {
  scrollbar-width: thin;
  scrollbar-color: var(--red-primary) var(--bg-card);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid var(--bg-card);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--red-primary);
}

:focus-visible {
  outline: 2px solid var(--red-glow);
  outline-offset: 3px;
}

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

/* Page scaffolding */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.section--tight {
  padding-block: var(--section-gap-s);
}

.section--alt {
  background: var(--bg-card);
  border-block: var(--border-width) solid var(--border);
}

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

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

.section-head__text {
  max-width: 54ch;
}

.section-head h2 {
  max-width: 22ch;
}

.section-head .lead {
  margin-top: var(--space-md);
}

.lead {
  max-width: 58ch;
  color: var(--text-muted);
  font-size: var(--text-lead);
  line-height: 1.55;
}

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

.dim {
  color: var(--text-dim);
}

.text-red {
  color: var(--red-glow);
}

.text-balance {
  text-wrap: balance;
}

.flow > * + * {
  margin-top: var(--space-md);
}

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

.skip-link {
  position: fixed;
  inset-block-start: var(--space-sm);
  inset-inline-start: var(--space-sm);
  z-index: var(--z-toast);
  padding: var(--space-sm) var(--space-md);
  background: var(--red-primary);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  transform: translateY(-180%);
  transition: transform var(--dur-short) var(--ease-out);
}

.skip-link:focus {
  transform: none;
}

/* Subpage hero */

.page-hero {
  position: relative;
  isolation: isolate;
  overflow: clip;
  padding-block: calc(var(--nav-height) + var(--space-4xl)) var(--space-3xl);
  background: var(--bg-card);
  border-bottom: var(--border-width) solid var(--border);
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: var(--page-image);
  background-size: cover;
  background-position: center;
  filter: grayscale(1) contrast(1.08) brightness(0.55);
  opacity: 0.34;
}

.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--scrim-page);
}

.page-hero h1 {
  max-width: 15ch;
  font-size: var(--text-display-s);
}

.page-hero .lead {
  margin-top: var(--space-lg);
}

.page-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

/* Footer credit disclosure */

.credits {
  color: var(--text-dim);
  font-size: var(--text-xs);
}

.credits summary {
  cursor: pointer;
  color: var(--text-muted);
}

.credits summary:hover {
  color: var(--text-main);
}

.credits p {
  margin-top: var(--space-xs);
  max-width: 90ch;
  line-height: 1.6;
}

.credits a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.credits a:hover {
  color: var(--text-main);
}

/* Motion */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero__content > * {
    animation: rise var(--dur-long) var(--ease-out) both;
  }

  .hero__content > *:nth-child(2) {
    animation-delay: 80ms;
  }

  .hero__content > *:nth-child(3) {
    animation-delay: 150ms;
  }

  .hero__content > *:nth-child(4) {
    animation-delay: 220ms;
  }

  .page-hero > .container {
    animation: rise var(--dur-long) var(--ease-out) both;
  }
}

@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;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 900px) {
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
  }

  .page-hero {
    padding-block: calc(var(--nav-height) + var(--space-3xl)) var(--space-2xl);
  }
}

@media (max-width: 600px) {
  .section {
    padding-block: var(--section-gap-s);
  }

  .page-hero {
    padding-block: calc(var(--nav-height) + var(--space-2xl)) var(--space-2xl);
  }

  .page-hero h1 {
    max-width: 12ch;
  }
}
