/* =============================================================
   Manta X - Global CSS
   Design tokens, reset, typography, layout grid.
   Source of truth: .claude/memory/designer/DESIGN.md
   ============================================================= */

/* --- Fonts (self-hosted Inter) --- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter/inter-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter/inter-500-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter/inter-700-latin.woff2') format('woff2');
}

/* --- Design tokens --- */
:root {
  /* Colour */
  --mx-black: #000000;
  --mx-surface-1: #1A1A1A;
  --mx-surface-2: #222222;
  --mx-white: #FFFFFF;
  --mx-text-muted: #AAAAAA;
  --mx-red: #D11E3E;
  --mx-red-hover: #B2162F;
  --mx-offwhite: #F5F5F0;
  --mx-border: rgba(255, 255, 255, 0.06);
  --mx-border-strong: rgba(255, 255, 255, 0.1);
  --mx-hairline: #2A2A2A;

  /* Type scale */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-display: clamp(44px, 7vw, 96px);
  --fs-h1: clamp(36px, 5vw, 56px);
  --fs-h2: clamp(28px, 3.4vw, 40px);
  --fs-h3: clamp(22px, 2.2vw, 28px);
  --fs-h4: 20px;
  --fs-body-lg: 18px;
  --fs-body: 16px;
  --fs-caption: 13px;
  --fs-eyebrow: 12px;

  /* Spacing - 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Layout */
  --content-max: 1280px;
  --content-narrow: 1040px;
  --nav-height: 72px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 300ms;
  --dur-slow: 600ms;
}

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

html { -webkit-text-size-adjust: 100%; }

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol { list-style: none; padding: 0; margin: 0; }

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

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

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

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--mx-white);
  outline-offset: 2px;
}

/* --- Base typography --- */
html, body {
  background: var(--mx-black);
  color: var(--mx-white);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body { min-height: 100vh; }

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--mx-white);
}

h1 { font-size: var(--fs-h1); line-height: 1.1; }
h2 { font-size: var(--fs-h2); line-height: 1.2; }
h3 { font-size: var(--fs-h3); line-height: 1.25; font-weight: 600; }
h4 { font-size: var(--fs-h4); line-height: 1.3; font-weight: 600; }

p { line-height: 1.6; }

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

.accent { color: var(--mx-red); }

/* Eyebrow label */
.eyebrow {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mx-red);
  line-height: 1;
}

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

/* Display (hero) */
.display {
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.02em;
}

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

.container-narrow {
  width: 100%;
  max-width: var(--content-narrow);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

main { display: block; }

section {
  padding-block: var(--space-10);
  position: relative;
}

.section-compact { padding-block: var(--space-8); }

.grid {
  display: grid;
  gap: var(--space-5);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

/* Hairline rule */
.rule {
  border: 0;
  border-top: 1px solid var(--mx-surface-1);
  margin: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--mx-red);
  color: var(--mx-white);
  z-index: 9999;
  transition: top var(--dur-fast);
}
.skip-link:focus { top: 0; }

/* --- Responsive breakpoints --- */
@media (max-width: 1024px) {
  section { padding-block: var(--space-8); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  section { padding-block: var(--space-7); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: var(--space-5); }
  .container, .container-narrow { padding-inline: var(--space-4); }
}

@media (max-width: 480px) {
  :root {
    --fs-display: clamp(32px, 9vw, 48px);
  }
  section { padding-block: var(--space-6); }
  .container, .container-narrow { padding-inline: var(--space-4); }
  /* Inline grids that ignore .grid utilities also collapse */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Reduce oversized inline gaps */
  [style*="--space-9"][style*="gap"] {
    gap: var(--space-6) !important;
  }
}

@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;
  }
}
