/* =============================================================
   base.css — reset, element defaults, focus, layout utilities
   Depends on: fonts.css, tokens.css (linked first)
   ============================================================= */

/* --- Box model reset --------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Document ---------------------------------------------- */
html {
  font-size: 100%;
  scroll-behavior: smooth;

  /* Keeps focused and anchored elements clear of the sticky header (WCAG 2.4.11) */
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
  /* stylelint-disable-next-line property-no-vendor-prefix -- iOS Safari still needs the prefix */
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-text);
  line-height: var(--line-height-body);
  letter-spacing: var(--letter-spacing-body);
  color: var(--color-text);
  background-color: var(--color-bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizelegibility;
}

/* --- Media ------------------------------------------------- */
img,
video,
svg,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* --- Headings ---------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  line-height: var(--line-height-h3);
}

h1 {
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-heading);
  line-height: var(--line-height-h1);
  letter-spacing: var(--letter-spacing-h1);
}

h2 {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-heading);
  line-height: var(--line-height-h2);
  letter-spacing: var(--letter-spacing-h2);
}

h3 {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-subheading);
  line-height: var(--line-height-h3);
  letter-spacing: var(--letter-spacing-h3);
}

h4 {
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-title);
  line-height: var(--line-height-h4);
  letter-spacing: var(--letter-spacing-h3);
}

h5,
h6 {
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  font-weight: var(--font-weight-title);
}

/* Display — a class, not a heading level */
.text-display {
  font-family: var(--font-heading);
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-heading);
  line-height: var(--line-height-display);
  letter-spacing: var(--letter-spacing-display);
}

/* --- Body copy and lists ----------------------------------- */
p {
  max-width: var(--size-measure);
}

p + p {
  margin-top: var(--space-6);
}

ul,
ol {
  list-style: none;
}

.prose ul {
  padding-left: var(--space-8);
  list-style: disc;
}

.prose ol {
  padding-left: var(--space-8);
  list-style: decimal;
}

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

/* --- Links: always underlined, so colour is never the only cue (WCAG 1.4.1) --- */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-border-control);
  text-decoration-thickness: var(--border-width-thin);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentcolor;
  text-decoration-thickness: var(--border-width-thick);
}

blockquote {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-text);
  font-style: normal;
  line-height: var(--line-height-h3);
  letter-spacing: var(--letter-spacing-h3);
}

hr {
  border: none;
  border-top: var(--border-width-thin) solid var(--color-border-divider);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  line-height: var(--line-height-body);
}

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

/* Visible keyboard focus everywhere: 2px ring, 3px offset, ≥3:1 against
   every surface (checked in tokens/contrast.json). Dark surfaces set
   --focus-color to the inverse ring below. */
:focus-visible {
  outline: var(--border-width-thick) solid var(--focus-color, var(--color-focus));
  outline-offset: var(--space-1);
}

.surface-inverse,
.surface-band,
.testimonials,
.contact-band {
  --focus-color: var(--color-focus-on-inverse);
}

/* --- Layout ------------------------------------------------ */
.container {
  width: 100%;
  max-width: var(--size-content);
  margin-inline: auto;
  padding-inline: var(--space-24);
}

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

@media (max-width: 64rem) {
  .container {
    padding-inline: var(--space-12);
  }
}

@media (max-width: 30rem) {
  .container {
    padding-inline: var(--space-6);
  }
}

/* Visually hidden, still announced. 1px is the technique, not a design length. */
/* stylelint-disable declaration-property-value-disallowed-list */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip-path: inset(50%);
}
/* stylelint-enable declaration-property-value-disallowed-list */

/* --- Overline / label -------------------------------------- */
.overline {
  display: block;
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-label);
  line-height: var(--line-height-label);
  letter-spacing: var(--letter-spacing-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* --- Long-form prose --------------------------------------- */
.prose {
  max-width: var(--size-measure);
  font-weight: var(--font-weight-text);
  line-height: var(--line-height-prose);
}

.prose h2 {
  margin-top: var(--space-group);
  margin-bottom: var(--space-heading);
}

.prose h3 {
  margin-top: var(--space-block);
  margin-bottom: var(--space-4);
}

/* --- Reduced motion ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Forced colors (Windows High Contrast) ----------------- */
@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
  }
}
