/* ============================================================================
   copyleast — base layer
   Reset, document defaults, typography scale, layout container, entrance motion.
   Depends on tokens.css.
   ========================================================================== */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  background-color: var(--neutral-100);
  color: var(--neutral-950);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img,
picture,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

/* height:auto lets the width/height attributes drive aspect-ratio instead of
   pinning the intrinsic pixel height (mirrors Tailwind Preflight). Without it,
   a CSS width + a height attribute stretches the image to its intrinsic height. */
img,
svg,
video {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: inherit;
  font-size: inherit;
}

/* Visible focus ring on every focusable element (docs/design.md § 7). */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* ── Layout container ─────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-container);
  margin-inline: auto;
  padding-inline: var(--sp-5); /* 20px */
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--sp-10); /* 40px */
  }
}

/* ── Typography scale (mirrors tailwind fontSize tokens) ──────────────────── */
.t-display {
  font-size: clamp(2.75rem, 6vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.t-h1 {
  font-size: clamp(2.25rem, 4.5vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  font-weight: 700;
}
.t-h2 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.t-h3 {
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 600;
}
.t-h4 {
  font-size: 1.25rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.t-body-lg {
  font-size: 1.125rem;
  line-height: 1.6;
}
.t-body {
  font-size: 1rem;
  line-height: 1.6;
}
.t-body-sm {
  font-size: 0.875rem;
  line-height: 1.55;
}
.t-caption {
  font-size: 0.8125rem;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.t-overline {
  font-size: 0.75rem;
  line-height: 1.3;
  letter-spacing: 0.12em;
  font-weight: 600;
  text-transform: uppercase;
}
.t-prose {
  font-size: 1.1875rem;
  line-height: 1.75;
}
.t-data {
  font-size: 0.875rem;
  line-height: 1.5;
  font-weight: 500;
  font-family: var(--font-mono);
}
.t-data-sm {
  font-size: 0.75rem;
  line-height: 1.45;
  font-family: var(--font-mono);
}
.t-figure {
  font-size: clamp(2rem, 3.5vw, 3rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 700;
}

/* ── Small text helpers ───────────────────────────────────────────────────── */
.text-balance {
  text-wrap: balance;
}

/* Visually hidden but available to assistive tech. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hidden on mobile, shown (as a line break) from 640px — mirrors `hidden sm:block`. */
.hide-sm {
  display: none;
}
@media (min-width: 640px) {
  .hide-sm {
    display: block;
  }
}
.muted {
  color: var(--neutral-500);
}
.u-brand {
  color: var(--brand-700);
}

/* The one phrase in brand-500 inside an otherwise near-black heading (§ 3). */
.highlight {
  color: var(--brand-500);
}

/* ── Chamfer utilities — evidence geometry (cut TL + BR corners) ──────────── */
.chamfer {
  clip-path: polygon(
    var(--chamfer) 0,
    100% 0,
    100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%,
    0 100%,
    0 var(--chamfer)
  );
}
.chamfer-lg {
  clip-path: polygon(
    var(--chamfer-lg) 0,
    100% 0,
    100% calc(100% - var(--chamfer-lg)),
    calc(100% - var(--chamfer-lg)) 100%,
    0 100%,
    0 var(--chamfer-lg)
  );
}

/* ── Entrance motion — reveal on scroll (docs/design.md § 2) ──────────────────
   Ease-out only, 550ms, 16px rise, opacity 0→1. JS (main.js) adds .is-visible.
   Hidden state applies ONLY when JS is on (html.js) so no-JS users see content
   immediately — no <noscript> needed. */
html.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 550ms var(--ease-entrance),
    transform 550ms var(--ease-entrance);
}
html.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Above-the-fold, CSS-only rise (hero) — no JS, no LCP penalty. */
@keyframes copyleast-rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.reveal-load {
  animation: copyleast-rise-in 600ms var(--ease-entrance) both;
}

@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;
  }
  html.js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
