/*
 * AgentMagic design tokens (v2)
 * White, near-black and one blue. One typeface. Hairlines and whitespace instead of boxes.
 * Components use the semantic tokens (--color-*, --text-*, --space-*), never the raw palette.
 * Light is the default. Dark applies with [data-theme="dark"] on any element (a page or one section),
 * or from the system setting when <html> has no data-theme.
 * Every text/background pair is 4.5:1 or better (see DESIGN.md; the style guide re-measures them live).
 */

@font-face {
  font-family: 'Instrument Sans';
  /* Root path with the site's cache key: it must match the <link rel="preload"> on every page exactly. */
  src: url('/design-system/fonts/instrument-sans-latin-var.woff2?v=20261128') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---------- Raw palette (do not use directly in components) ---------- */
  --am-white: #ffffff;
  --am-ink-950: #0b0c0e; /* near-black: text, dark sections */
  --am-ink-900: #111316;
  --am-ink-850: #16181c;
  --am-ink-800: #1f2227;
  --am-ink-700: #24272d;
  --am-grey-600: #5b616b; /* secondary text on white */
  --am-grey-500: #6b727d;
  --am-grey-450: #8a9099;
  --am-grey-400: #a1a7b0; /* secondary text on near-black */
  --am-grey-200: #e6e8eb; /* hairline */
  --am-grey-100: #eef0f2;
  --am-grey-50: #f6f7f8;
  --am-blue-600: #156deb; /* AgentMagic blue: the centre of the logo ribbon. Actions only. */
  --am-blue-700: #0f56c4;
  --am-blue-text: #1259d9; /* the same blue, a touch deeper, for link text on white and grey */
  --am-blue-300: #7fa9ff; /* link and focus on near-black */
  --am-green-700: #157347;
  --am-green-300: #5fd398;
  --am-red-700: #b42318;
  --am-red-300: #ff8a7a;

  /* ---------- Type: one family; size and weight carry the hierarchy ---------- */
  --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --text-xs: 0.8125rem; /* 13 */
  --text-sm: 0.9375rem; /* 15 */
  --text-base: 1.0625rem; /* 17 */
  --text-lg: 1.25rem; /* 20 */
  --text-xl: 1.5rem; /* 24 */
  --text-2xl: clamp(1.75rem, 1.45rem + 1.2vw, 2.25rem); /* 28 to 36 */
  --text-3xl: clamp(2rem, 1.4rem + 2.4vw, 3.25rem); /* 32 to 52 */
  --text-4xl: clamp(2.5rem, 1.4rem + 4.4vw, 4.75rem); /* 40 to 76 */

  --leading-tight: 1.03;
  --leading-snug: 1.2;
  --leading-normal: 1.55;
  --tracking-tight: -0.035em; /* 3xl and up */
  --tracking-snug: -0.02em; /* xl and 2xl */
  --tracking-label: 0.01em;
  --measure: 60ch;

  /* ---------- Space (4pt grid) ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;
  --space-section: clamp(4rem, 2rem + 5.5vw, 7rem); /* the one vertical rhythm for sections */
  --space-head: clamp(2.5rem, 1.5rem + 3vw, 4.5rem); /* heading block to content */

  /* ---------- Grid: 12 columns ---------- */
  --container: 76rem; /* 1216px */
  --gutter: clamp(1.25rem, 0.25rem + 4vw, 3rem); /* page side padding */
  --grid-gap: clamp(1rem, 0.5rem + 1.6vw, 2rem);
  --tap: 2.75rem; /* 44px minimum touch target */

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

  /* ---------- Motion ---------- */
  --dur-instant: 90ms;
  --dur-fast: 160ms;
  --dur-base: 260ms;
  --dur-slow: 520ms;
  --dur-scene: 900ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.9, 0.3);
  --ease-in-out: cubic-bezier(0.6, 0, 0.3, 1);
  --stagger: 60ms;

  --z-raised: 10;
  --z-sticky: 40;
  --z-overlay: 100;
}

/* ---------- Semantic colour: light ---------- */
:root,
[data-theme='light'] {
  color-scheme: light;
  --color-bg: var(--am-white);
  --color-bg-alt: var(--am-grey-50);
  --color-surface: var(--am-white);
  --color-surface-2: var(--am-grey-50);
  --color-fill: var(--am-grey-100); /* neutral fill: secondary buttons, badges, bars */
  --color-text: var(--am-ink-950);
  --color-text-muted: var(--am-grey-600);
  --color-border: var(--am-grey-200); /* hairlines only */
  --color-border-strong: var(--am-grey-450); /* form field edges */

  --color-primary: var(--am-blue-600);
  --color-primary-hover: var(--am-blue-700);
  --color-on-primary: var(--am-white);
  --color-link: var(--am-blue-text);
  --color-focus: var(--am-blue-600);

  --color-success: var(--am-green-700);
  --color-danger: var(--am-red-700);

  --color-inverse-bg: var(--am-ink-950);
  --color-inverse-text: var(--am-white);

  /* Shadows are for product screens only. */
  --shadow-1: 0 1px 2px rgb(11 12 14 / 0.05), 0 4px 12px rgb(11 12 14 / 0.05);
  --shadow-2: 0 1px 2px rgb(11 12 14 / 0.05), 0 12px 32px rgb(11 12 14 / 0.09);
  --shadow-3: 0 2px 4px rgb(11 12 14 / 0.04), 0 24px 64px rgb(11 12 14 / 0.14);
}

/* ---------- Semantic colour: dark ---------- */
[data-theme='dark'] {
  color-scheme: dark;
  --color-bg: var(--am-ink-950);
  --color-bg-alt: var(--am-ink-900);
  --color-surface: var(--am-ink-850);
  --color-surface-2: var(--am-ink-800);
  --color-fill: var(--am-ink-800);
  --color-text: #f5f6f7;
  --color-text-muted: var(--am-grey-400);
  --color-border: var(--am-ink-700);
  --color-border-strong: var(--am-grey-500);

  --color-primary: var(--am-blue-600);
  --color-primary-hover: var(--am-blue-700);
  --color-on-primary: var(--am-white);
  --color-link: var(--am-blue-300);
  --color-focus: var(--am-blue-300);

  --color-success: var(--am-green-300);
  --color-danger: var(--am-red-300);

  --color-inverse-bg: var(--am-white);
  --color-inverse-text: var(--am-ink-950);

  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
  --shadow-3: 0 2px 4px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --color-bg: var(--am-ink-950);
    --color-bg-alt: var(--am-ink-900);
    --color-surface: var(--am-ink-850);
    --color-surface-2: var(--am-ink-800);
    --color-fill: var(--am-ink-800);
    --color-text: #f5f6f7;
    --color-text-muted: var(--am-grey-400);
    --color-border: var(--am-ink-700);
    --color-border-strong: var(--am-grey-500);
    --color-primary: var(--am-blue-600);
    --color-primary-hover: var(--am-blue-700);
    --color-on-primary: var(--am-white);
    --color-link: var(--am-blue-300);
    --color-focus: var(--am-blue-300);
    --color-success: var(--am-green-300);
    --color-danger: var(--am-red-300);
    --color-inverse-bg: var(--am-white);
    --color-inverse-text: var(--am-ink-950);
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
    --shadow-3: 0 2px 4px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 1ms;
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
    --dur-scene: 1ms;
    --stagger: 0ms;
  }
}

/* ============================================================
   v3: a calmer system. A soft blue wash, a card system, and a
   small set of tints used for icon tiles only.
   ============================================================ */
:root {
  --am-blue-50: #f3f7fe;
  --am-blue-100: #e6effd;
  --am-blue-150: #d9e7fc;
  --am-blue-200: #c9dcfb;

  /* Cards */
  --card-radius: 20px;
  --card-radius-sm: 14px;
  --card-pad: clamp(1.5rem, 1.1rem + 1vw, 2rem);
  --card-pad-sm: 1rem;
  --card-gap: var(--space-4);
  --radius-btn: 10px;
  --tile: 2.75rem; /* icon tile */

  /* Slow, calm loops for the small product moments inside agent cards */
  --dur-loop: 9s;
}

:root,
[data-theme='light'] {
  /* The wash: very light tints of the AgentMagic blue, blurred into each other. Never purple. */
  --wash:
    radial-gradient(55% 75% at 12% 8%, var(--am-blue-150) 0%, transparent 62%),
    radial-gradient(50% 70% at 92% 18%, var(--am-blue-200) 0%, transparent 66%),
    radial-gradient(70% 60% at 62% 104%, var(--am-blue-200) 0%, transparent 62%),
    linear-gradient(180deg, var(--am-blue-50), var(--am-blue-100));
  --wash-text-muted: #454b55; /* secondary text on the wash: 5:1 or better on its deepest tint */
  --wash-link: #0f4dbf;

  --card-fill: var(--am-grey-50);
  --card-fill-hover: var(--am-grey-100);
  --card-float: var(--am-white);

  /* Icon tints: for icon tiles and transcript highlights only. Calm, and they sit beside the blue. */
  --tint-blue-bg: #e3edfd;
  --tint-blue-fg: #1259d9;
  --tint-teal-bg: #dcf2f1;
  --tint-teal-fg: #0b6b6f;
  --tint-green-bg: #e0f2e7;
  --tint-green-fg: #157347;
  --tint-amber-bg: #fbeed7;
  --tint-amber-fg: #8a5700;
  --tint-rose-bg: #fbe6ea;
  --tint-rose-fg: #a32c46;
}

[data-theme='dark'] {
  --wash:
    radial-gradient(55% 75% at 12% 8%, #14294d 0%, transparent 62%),
    radial-gradient(50% 70% at 92% 18%, #173563 0%, transparent 66%),
    radial-gradient(70% 60% at 62% 104%, #122a52 0%, transparent 62%),
    linear-gradient(180deg, #0e1524, #101a2e);
  --wash-text-muted: #b4bcc8;
  --wash-link: var(--am-blue-300);
  --card-fill: var(--am-ink-850);
  --card-fill-hover: var(--am-ink-800);
  --card-float: var(--am-ink-800);
  --tint-blue-bg: #14294d;
  --tint-blue-fg: #9dbdff;
  --tint-teal-bg: #0f3336;
  --tint-teal-fg: #6fd3d1;
  --tint-green-bg: #123524;
  --tint-green-fg: #6fd9a0;
  --tint-amber-bg: #3a2c0f;
  --tint-amber-fg: #f1c56a;
  --tint-rose-bg: #3d1a23;
  --tint-rose-fg: #ff9fb3;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --wash:
      radial-gradient(55% 75% at 12% 8%, #14294d 0%, transparent 62%),
      radial-gradient(50% 70% at 92% 18%, #173563 0%, transparent 66%),
      radial-gradient(70% 60% at 62% 104%, #122a52 0%, transparent 62%),
      linear-gradient(180deg, #0e1524, #101a2e);
    --wash-text-muted: #b4bcc8;
    --wash-link: var(--am-blue-300);
    --card-fill: var(--am-ink-850);
    --card-fill-hover: var(--am-ink-800);
    --card-float: var(--am-ink-800);
    --tint-blue-bg: #14294d;
    --tint-blue-fg: #9dbdff;
    --tint-teal-bg: #0f3336;
    --tint-teal-fg: #6fd3d1;
    --tint-green-bg: #123524;
    --tint-green-fg: #6fd9a0;
    --tint-amber-bg: #3a2c0f;
    --tint-amber-fg: #f1c56a;
    --tint-rose-bg: #3d1a23;
    --tint-rose-fg: #ff9fb3;
  }
}

/* The deepest tint the wash reaches. Used to check text contrast on the wash. */
:root,
[data-theme='light'] {
  --wash-deep: var(--am-blue-200);
}
[data-theme='dark'] {
  --wash-deep: #173563;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --wash-deep: #173563;
  }
}
