/* Mad Funnel Labs: reset, typography, links, buttons, focus, motion. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light dark;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
main:focus { outline: none; }

img, svg, video { max-width: 100%; height: auto; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); letter-spacing: -0.03em; }
h2 { font-size: var(--step-3); letter-spacing: -0.025em; line-height: 1.12; }
h3 { font-size: var(--step-2); letter-spacing: -0.015em; line-height: 1.2; }
h4 { font-size: var(--step-1); letter-spacing: -0.01em; line-height: 1.25; font-weight: 600; }

p, ul, ol, dl { margin: 0 0 var(--space-4); }
p, li { text-wrap: pretty; }
.prose { max-width: 70ch; }
.prose > * + h2 { margin-top: var(--space-7); }
.prose > * + h3 { margin-top: var(--space-6); }
.lead { font-size: var(--step-1); line-height: 1.5; }
.small { font-size: var(--step--1); }
.muted { color: var(--text-muted); }
strong, b { font-weight: 700; }
em, i { font-style: normal; font-weight: 700; } /* no italic cut is loaded; avoid faux italics */

/* ---------- Links ---------- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--link-hover); text-decoration-thickness: 2.5px; }

/* ---------- Focus (always visible for keyboard users) ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Layout helpers ---------- */
.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}
.section { padding-block: clamp(var(--space-7), 8vw, var(--space-9)); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  border-radius: var(--radius-node);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 3rem;
  padding: 0.625rem 1.375rem;
  border: 2px solid transparent;
  border-radius: var(--radius-node);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-bg-hover); color: var(--btn-fg); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--text); }
.btn-secondary:hover { background: var(--surface); color: var(--text); }
.btn-sm { min-height: 2.5rem; padding: 0.375rem 1rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border: 1.5px solid var(--edge);
  border-radius: var(--radius-chip);
  background: var(--surface);
  color: var(--text);
  font-size: var(--step--1);
  font-weight: 700;
  line-height: 1.3;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: var(--space-5);
}

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