/* ==========================================================================
   Reset, document foundation, layout primitives
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
  background-color: var(--paper);
}

body {
  min-height: 100%;
  background-color: var(--paper);
  color: var(--on-paper);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: var(--lh-body);
  letter-spacing: var(--ls-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

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

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

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

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

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

/* ---- Headings: the serif does the talking --------------------------------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--lh-head);
  letter-spacing: var(--ls-head);
  text-wrap: balance;
  max-width: none;
}

h4,
h5 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: var(--ls-sans);
}

p {
  text-wrap: pretty;
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

::selection {
  background: var(--periwinkle-deep);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

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

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

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

.section {
  position: relative;
  padding-block: var(--section-y);
}

.section--tight {
  padding-block: clamp(48px, 4.6vw, 84px);
}

/* A "room": a near-black chamber inset into the paper with oversized corners. */
.room {
  margin-inline: var(--gutter);
  padding-block: var(--room-y);
  border-radius: var(--r-room);
  background: var(--ink-room);
  color: var(--on-ink);
}

.room h1,
.room h2,
.room h3 {
  color: var(--on-ink);
}

.room .shell {
  padding-inline: clamp(6px, 2vw, 32px);
}

/* ---- Utilities ----------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  top: 12px;
  left: 50%;
  translate: -50% -200%;
  z-index: 200;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  border: var(--stroke);
  background: var(--paper-raised);
  font-size: var(--t-sm);
  font-weight: 600;
  transition: translate var(--d-base) var(--e-out);
}

.skip-link:focus-visible {
  translate: -50% 0;
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Two-tone headlines: the quiet half sets up, the ink half lands. */
.fog {
  color: var(--on-paper-fog);
}

.room .fog {
  color: var(--on-ink-fog);
}

.nowrap {
  white-space: nowrap;
}

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

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

html[data-motion="calm"] * {
  animation-play-state: paused !important;
}

/* Decorative loops (data packets, floating pills, pulsing dots) only run while
   their block is near the viewport. js/modules/anim.js flips the state. */
[data-anim-state="idle"],
[data-anim-state="idle"] *,
[data-anim-state="idle"] *::before,
[data-anim-state="idle"] *::after {
  animation-play-state: paused !important;
}
