/* ==========================================================================
   Base: reset, typography and global element styles
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

main {
  flex: 1 0 auto;
}

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

img {
  height: auto;
}

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

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

p,
h1,
h2,
h3,
h4,
h5,
h6,
li,
dd,
blockquote {
  overflow-wrap: break-word;
}

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

/* ---------- Headings ---------- */
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.display {
  color: var(--color-heading);
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  font-variation-settings: "SOFT" 50, "WONK" 0;
}

.display {
  font-size: var(--fs-display);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

h1,
.h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
}

h2,
.h2 {
  font-size: var(--fs-h2);
  line-height: 1.15;
}

h3,
.h3 {
  font-size: var(--fs-h3);
}

h4,
.h4 {
  font-size: var(--fs-h4);
}

h5,
h6 {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
}

h1 em,
h2 em,
.display em {
  font-style: italic;
  color: var(--color-primary);
}

p {
  text-wrap: pretty;
}

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

small {
  font-size: var(--fs-sm);
}

/* ---------- Links ---------- */
a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) ease;
}

a:hover {
  color: var(--color-link-hover);
}

/* ---------- Focus: visible for keyboard users only ---------- */
:focus {
  outline: none;
}

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

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

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* ---------- 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-3);
  left: var(--space-3);
  z-index: calc(var(--z-header) + 10);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--duration-base) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--color-text-inverse);
}

/* ---------- Long-form text ---------- */
.prose {
  max-width: 68ch;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose > h2,
.prose > h3 {
  margin-top: 1.8em;
}

.prose > h2 + *,
.prose > h3 + * {
  margin-top: 0.6em;
}

.prose ul,
.prose ol {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: 0.4em;
}

.prose blockquote {
  margin: 1.8em 0;
  padding-left: var(--space-6);
  border-left: 3px solid var(--color-accent);
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-style: italic;
  line-height: 1.5;
  color: var(--color-heading);
}

/* ---------- Text utilities ---------- */
.lead {
  font-size: var(--fs-lg);
  line-height: 1.6;
  color: var(--color-text-muted);
}

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

.text-sm {
  font-size: var(--fs-sm);
}

.text-xs {
  font-size: var(--fs-xs);
}

.text-center {
  text-align: center;
}

.serif {
  font-family: var(--font-serif);
}

/* ---------- Reduced motion ---------- */
@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;
  }
}
