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

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
  background: var(--bg);
  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;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
main { flex: 1 0 auto; }
main:focus { outline: none; }

/* Two hairline rails frame the page (the "grid" of the design). They sit under all content. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0;
  z-index: -1;
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
  border-inline: 1px solid var(--line);
  pointer-events: 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: 350;
  line-height: 1.08;
  text-wrap: balance;
  font-optical-sizing: auto;
}
h1 { font-size: var(--step-4); letter-spacing: -0.03em; }
h2 { font-size: var(--step-3); letter-spacing: -0.028em; line-height: 1.1; }
h3 { font-size: var(--step-2); letter-spacing: -0.02em; line-height: 1.18; font-weight: 400; }
h4 { font-size: var(--step-1); letter-spacing: -0.012em; line-height: 1.25; font-weight: 400; }
h1 em, h2 em, h3 em, .serif-em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
  letter-spacing: -0.02em;
}

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: 500; } /* Satoshi has no italic cut loaded; headings use Fraunces italic above */

/* ---------- Links ---------- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }

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

/* ---------- 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-chip);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

/* ---------- Buttons ----------
   Fallback (no JS, or a browser that cannot build the lens): solid ember primary, dark ring secondary.
   liquid-glass.js adds .is-glass and builds the Apple-style glass lens behind the label. */
.btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 3rem;
  padding: 0.625rem 1.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.3s var(--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: linear-gradient(#161616, #060606);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 4px rgba(255, 255, 255, 0.04);
}
.btn-secondary:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.btn-sm { min-height: 2.5rem; padding: 0.375rem 1.2rem; font-size: 0.9375rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Glass mode: the lens, rim light and tint are drawn by liquid-glass.js behind the label. */
.btn.is-glass { background: transparent; border-color: transparent; box-shadow: none; color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35); }
.btn.is-glass:hover { color: #fff; }
.btn-primary.is-glass { box-shadow: 0 12px 40px -12px rgba(var(--ember), 0.6); }
.btn.is-glass:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-chip);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
}

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

/* ---------- Reveal on scroll (js adds .reveal-ready; elements already in view are shown at once) ---------- */
.motion.reveal-ready [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: calc(var(--rd, 0) * 90ms);
}
.motion.reveal-ready [data-reveal].in { opacity: 1; transform: none; }

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