/*
  AppTrace design tokens, v1.1 (22 Nov 2026, APT-0213; v1.0 was 21 Nov 2026, APT-0178).
  The single source for color, type, spacing, radius, shadow and motion.
  v1.1 adds, and changes no v1.0 value: the tile on a soft surface, tile sizes,
  icon sizes and stroke, stat sizes, card padding, the phone header height, the
  phone rhythm limit and table cell padding (guide 4.5, 5.5, 6.4, 6.5, 6.10,
  6.13, 6.14, 8.2). No new color: every pair these tokens make is already in guide 3.2.
  The site keeps a copy at public/tokens.css in apptrace-site: change this file first, then copy it.
  Rules for using each token: business/brand/brand-guide.md. Contrast ratios
  quoted below are WCAG 2.x, computed (truncated to two places) with
  .cache/scratch/APT-0178/contrast.mjs.

  Fonts: self-hosted variable woff2, both SIL Open Font License 1.1.
    fonts/space-grotesk-latin-wght-normal.woff2  from @fontsource-variable/space-grotesk (weights 300-700)
    fonts/inter-latin-wght-normal.woff2          from @fontsource-variable/inter (weights 100-900)
  The url() paths are relative to this file: serve the fonts/ folder next to it.
  Preload both files in <head> (rel="preload" as="font" type="font/woff2" crossorigin).
*/

@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* ---------- Palette (raw values; use the role tokens further down in components) ---------- */

  /* AppTrace red: the mark's own color. The mark, the tile device, one red block per page.
     Never text below 24px. 3.76:1 on white, 3.36:1 on stone-100 (non-text OK), 2.96:1 on stone-200 (never). */
  --color-red: #EF4445;
  /* Deep red: primary buttons, links, focus ring, error text on light surfaces.
     5.51:1 on white, 4.92:1 on stone-100; white text on it 5.51:1. */
  --color-red-deep: #C8292C;
  --color-red-deep-hover: #A82125;   /* white text 7.21:1 */
  --color-red-deep-pressed: #8E1B1F; /* white text 9.02:1 */
  /* Red tint: text selection and the form's error summary background. Ink on it 15.06:1, deep red 4.51:1. */
  --color-red-tint: #FBE3E3;
  /* Red on night: links, focus ring and error text on dark surfaces. 7.29:1 on night, 6.60:1 on night-2. */
  --color-red-on-night: #FF7A7C;

  /* Stone: warm neutrals from page white to ink. */
  --color-white: #FFFFFF;
  --color-stone-100: #F3F2F0; /* soft surface: alternate sections, cards on white, inner-page title band */
  --color-stone-200: #E6E4E1; /* hairlines and dividers (decorative, no contrast duty) */
  --color-stone-300: #D3D0CB; /* stronger divider; body text on night (11.96:1) */
  --color-stone-500: #8A8782; /* field borders and other non-text UI: 3.57:1 white, 3.19:1 stone-100, 4.65:1 night-2 */
  --color-stone-600: #6B6863; /* muted text: 5.54:1 white, 4.95:1 stone-100 */
  --color-stone-800: #3A3835; /* body text: 11.68:1 white, 10.44:1 stone-100 */
  --color-stone-950: #151413; /* ink: headings, wordmark, strong text; 18.39:1 white */

  /* Night: the dark band (contact and footer). */
  --color-night: #151413;      /* same value as ink */
  --color-night-2: #1F1E1C;    /* raised surface on night: form fields */
  --color-night-muted: #A19D97;/* muted text on night: 6.82:1 night, 6.17:1 night-2 */

  /* States */
  --color-success: #1E7A46;          /* 5.34:1 white, 4.77:1 stone-100 */
  --color-success-on-night: #5CC48A; /* 8.51:1 night */

  /* ---------- Roles (light, the default) ---------- */

  --bg: var(--color-white);                 /* page */
  --surface-soft: var(--color-stone-100);   /* alternate section, card on white, title band */
  --surface-card-on-soft: var(--color-white);
  --text: var(--color-stone-950);           /* headings, display, wordmark, numerals */
  --text-body: var(--color-stone-800);      /* running text */
  --text-muted: var(--color-stone-600);     /* captions, help text, meta, footnotes */
  --line: var(--color-stone-200);           /* hairline borders and dividers */
  --line-strong: var(--color-stone-300);
  --field-bg: var(--color-white);
  --field-border: var(--color-stone-500);
  --field-border-hover: var(--color-stone-600);
  --field-border-focus: var(--color-stone-950);
  --link: var(--color-red-deep);
  --link-hover: var(--color-red-deep-hover);
  --action-bg: var(--color-red-deep);       /* primary button fill */
  --action-bg-hover: var(--color-red-deep-hover);
  --action-bg-pressed: var(--color-red-deep-pressed);
  --action-text: var(--color-white);
  --secondary-border: var(--color-stone-950);
  --secondary-text: var(--color-stone-950);
  --secondary-bg-hover: var(--color-stone-100);
  --disabled-bg: var(--color-stone-100);
  --disabled-border: var(--color-stone-200);
  --disabled-text: var(--color-stone-600);
  --focus-ring: var(--color-red-deep);
  --error: var(--color-red-deep);
  --error-bg: var(--color-red-tint);
  --success: var(--color-success);
  --selection-bg: var(--color-red-tint);
  --selection-text: var(--color-stone-950);
  --mark: var(--color-red);                 /* the logo mark's fill: always AppTrace red unless mono is required */
  --wordmark: var(--color-stone-950);
  --tile: var(--color-stone-100);           /* neutral tiles in the tile device */
  --tile-accent: var(--color-red);          /* the one red tile */
  --tile-on-soft: var(--color-white);       /* tiles on a stone-100 section or a stone-100 card: the other surface, as cards do */
  --tile-text: var(--color-stone-950);      /* step numbers and tile icons: 16.44:1 on stone-100, 18.39:1 on white */
  --band-tile: var(--color-night-2);        /* tiles on the night band */
  /* Tiles in a tile figure (guide 7.4, v1.2): the quiet tile and the strong one. Both read as objects, not as
     empty frames: stone-500 is 3.19:1 on stone-100 and 3.57:1 on white (4.80:1 on the dark soft surface);
     the strong tile is --tile-text (ink, near-white in dark mode). */
  --fig-tile: var(--color-stone-500);
  --fig-tile-strong: var(--tile-text);

  /* Band (the night section: contact and footer) */
  --band-bg: var(--color-night);
  --band-text: var(--color-white);          /* 18.39:1 */
  --band-text-body: var(--color-stone-300); /* 11.96:1 */
  --band-text-muted: var(--color-night-muted);
  --band-line: rgba(255, 255, 255, 0.14);   /* decorative hairline only */
  --band-field-bg: var(--color-night-2);
  --band-field-border: var(--color-stone-500); /* 4.65:1 on night-2, 5.14:1 on night */
  --band-link: var(--color-red-on-night);
  --band-focus-ring: var(--color-red-on-night);
  --band-error: var(--color-red-on-night);
  --band-success: var(--color-success-on-night);
  --band-secondary-border: var(--color-night-muted);
  --band-secondary-bg-hover: var(--color-night-2);
  --band-wordmark: var(--color-white);

  /* ---------- Type ---------- */

  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Inter", "Helvetica Neue", Arial, sans-serif;

  /* Scale: 1.25 (major third) on a 17px body, rounded to whole px:
     14 · 17 · 21 · 26 · 33 · 42 · 52 · 64. Label (15) and button (16) are UI sizes. */
  --fs-display: clamp(2.5rem, 1.5rem + 3.2vw, 4rem);        /* 40 -> 64 */
  --fs-h1: clamp(2.25rem, 1.4rem + 2.4vw, 3.25rem);         /* 36 -> 52; also stat figures */
  --fs-h2: clamp(1.875rem, 1.2rem + 1.8vw, 2.625rem);       /* 30 -> 42 */
  --fs-quote: clamp(1.5rem, 1.1rem + 1.1vw, 2.0625rem);     /* 24 -> 33 */
  --fs-h3: clamp(1.375rem, 1.1rem + 0.6vw, 1.625rem);       /* 22 -> 26 */
  --fs-h4: 1.3125rem;                                       /* 21 */
  --fs-lead: clamp(1.1875rem, 1rem + 0.5vw, 1.3125rem);     /* 19 -> 21 */
  --fs-body: 1.0625rem;                                       /* 17 (16 below 640px) */
  --fs-body-phone: 1rem;                                    /* 16 */
  --fs-button: 1rem;                                        /* 16 */
  --fs-label: 0.9375rem;                                    /* 15 */
  --fs-small: 0.875rem;                                     /* 14: the smallest text anywhere */
  --fs-wordmark: 1.75rem;                                   /* 28 beside a 30px mark (0.93 x mark height) */
  --fs-wordmark-phone: 1.375rem;                            /* 22 beside a 24px mark, below 640px */
  --fs-stat: var(--fs-h1);                                  /* a stat that is a bare figure ("2021"): 36 -> 52 */
  --fs-stat-word: var(--fs-h2);                             /* a stat set in words ("Two weeks", "Thousands of stores"): 30 -> 42 */
  --leading-stat: 1.1;
  --tracking-stat: -0.02em;

  --leading-display: 1.05;
  --leading-h1: 1.1;
  --leading-h2: 1.15;
  --leading-quote: 1.25;
  --leading-h3: 1.25;
  --leading-h4: 1.35;
  --leading-lead: 1.5;
  --leading-body: 1.6;
  --leading-label: 1.4;
  --leading-small: 1.5;

  --tracking-display: -0.025em;
  --tracking-h1: -0.02em;
  --tracking-h2: -0.015em;
  --tracking-h3: -0.01em;
  --tracking-quote: -0.01em;
  --tracking-h4: -0.005em;
  --tracking-text: 0;
  --tracking-wordmark: -0.02em;

  /* One weight per level */
  --weight-display: 500; /* Space Grotesk: display, h1, h2, quote, h3, stat */
  --weight-h4: 600;      /* Inter */
  --weight-body: 400;    /* Inter: lead, body, small */
  --weight-label: 500;   /* Inter: form labels, nav links */
  --weight-button: 600;  /* Inter: buttons, text links with an arrow */
  --weight-wordmark: 400;/* Space Grotesk, as set on the live site */

  --measure-body: 68ch;
  --measure-lead: 60ch;
  --measure-heading: 20ch;
  --measure-display: 18ch;
  --measure-quote: 32ch;

  /* ---------- Layout ---------- */

  --container: 1200px;           /* content width; 12 columns of 78px with 24px gaps */
  --container-wide: 1440px;      /* full-bleed image bands stop here */
  --gutter: clamp(16px, 4vw, 64px); /* page side padding */
  --grid-columns: 12;            /* 8 from 640px, 4 below 640px */
  --grid-gap: 24px;              /* 16px below 640px */
  --bp-sm: 640px;                /* reference only: custom properties can't be used in @media */
  --bp-md: 960px;
  --bp-lg: 1280px;

  /* Spacing: 4px base, 8px rhythm */
  --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;

  --section-y: clamp(64px, 3rem + 5vw, 128px);  /* major section padding top and bottom: 64 phone, 96 tablet, 128 desk */
  --section-y-minor: clamp(48px, 2rem + 2.5vw, 64px);
  --header-height: 72px;                         /* 64px below 640px */
  --header-height-phone: 64px;
  --card-pad: clamp(24px, 1rem + 2vw, 32px);     /* card padding: 24 phone, 32 from about 800px */
  --grid-gap-phone: 16px;
  --phone-break-max: 600px;                      /* reference: at 390 wide, the most text height between two visual breaks (guide 5.5) */

  /* Tiles (the brand device, guide 7.4) and the things built from it */
  --tile-xs: 24px;    /* small tile step beside a line of text */
  --tile-step: 40px;  /* numbered step tile (guide 6.5) */
  --tile-icon: 48px;  /* tile that holds a 24px tile icon (guide 8.2) */
  --tile-md: 48px;
  --tile-lg: 96px;
  --tile-xl: 160px;
  --tile-fig-phone: 32px;                        /* tile figures below 640px: never under 32px (v1.2) */
  --step-gap: var(--space-4);                    /* tile to its text in a phone step row */

  /* Icons (guide 8) */
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --icon-stroke: 1.5;

  /* Tables (guide 6.14) */
  --table-cell-y: var(--space-3);
  --table-cell-x: var(--space-4);

  /* Radius */
  --radius-sm: 4px;    /* small chips, the tooltip, code */
  --radius-md: 8px;    /* buttons, fields, menus */
  --radius-lg: 12px;   /* cards, images, the consent bar */
  --radius-tile: 27%;  /* tile device only: the mark's corner radius as a share of the tile side */

  /* Borders */
  --border-hairline: 1px solid var(--line);
  --border-field: 1px solid var(--field-border);
  --focus-width: 3px;
  --focus-offset: 2px;

  /* Shadows: floating layers only (sticky header after scroll, menu sheet, consent bar). Never on cards. */
  --shadow-1: 0 1px 2px rgba(21, 20, 19, 0.06);
  --shadow-2: 0 1px 2px rgba(21, 20, 19, 0.04), 0 8px 24px rgba(21, 20, 19, 0.08);

  /* ---------- Motion ---------- */

  --duration-fast: 120ms;  /* color, underline, border */
  --duration-base: 200ms;  /* button press, arrow nudge, fade */
  --duration-slow: 320ms;  /* menu sheet, consent bar */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark mode: follows the system unless the page forces light ---------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110;
    --surface-soft: #1C1B19;
    --surface-card-on-soft: #121110;
    --text: #F5F4F2;          /* 17.15:1 on bg */
    --text-body: var(--color-stone-300); /* 12.26:1 on bg, 11.19:1 on soft */
    --text-muted: var(--color-night-muted); /* 6.99:1 on bg, 6.38:1 on soft */
    --line: #3A3835;
    --line-strong: #4A4844;
    --field-bg: #1C1B19;
    --field-border: var(--color-stone-500); /* 4.80:1 on #1C1B19 */
    --field-border-hover: var(--color-stone-300);
    --field-border-focus: #F5F4F2;
    --link: var(--color-red-on-night);      /* 7.47:1 on bg */
    --link-hover: #FF9A9B;
    --action-bg: var(--color-red-deep);     /* boundary 3.42:1 on bg, 3.12:1 on soft; white text 5.51:1 */
    --action-bg-hover: var(--color-red-deep-hover);
    --action-bg-pressed: var(--color-red-deep-pressed);
    --secondary-border: var(--color-night-muted);
    --secondary-text: #F5F4F2;
    --secondary-bg-hover: #1C1B19;
    --disabled-bg: #1C1B19;
    --disabled-border: #3A3835;
    --disabled-text: var(--color-night-muted);
    --focus-ring: var(--color-red-on-night);
    --error: var(--color-red-on-night);
    --error-bg: #2A1516;
    --success: var(--color-success-on-night);
    --selection-bg: #5A1F21;
    --selection-text: #FFFFFF;
    --wordmark: #F5F4F2;
    --tile: #1C1B19;
    --tile-on-soft: #121110;  /* --tile-text on it 17.15:1 */
    --tile-text: #F5F4F2;     /* 15.65:1 on --tile */
    --band-tile: #121110;
    --band-bg: #1C1B19;
    --band-field-bg: #121110;
    --band-line: rgba(255, 255, 255, 0.12);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #121110;
  --surface-soft: #1C1B19;
  --surface-card-on-soft: #121110;
  --text: #F5F4F2;
  --text-body: var(--color-stone-300);
  --text-muted: var(--color-night-muted);
  --line: #3A3835;
  --line-strong: #4A4844;
  --field-bg: #1C1B19;
  --field-border: var(--color-stone-500);
  --field-border-hover: var(--color-stone-300);
  --field-border-focus: #F5F4F2;
  --link: var(--color-red-on-night);
  --link-hover: #FF9A9B;
  --action-bg: var(--color-red-deep);
  --action-bg-hover: var(--color-red-deep-hover);
  --action-bg-pressed: var(--color-red-deep-pressed);
  --secondary-border: var(--color-night-muted);
  --secondary-text: #F5F4F2;
  --secondary-bg-hover: #1C1B19;
  --disabled-bg: #1C1B19;
  --disabled-border: #3A3835;
  --disabled-text: var(--color-night-muted);
  --focus-ring: var(--color-red-on-night);
  --error: var(--color-red-on-night);
  --error-bg: #2A1516;
  --success: var(--color-success-on-night);
  --selection-bg: #5A1F21;
  --selection-text: #FFFFFF;
  --wordmark: #F5F4F2;
  --tile: #1C1B19;
  --tile-on-soft: #121110;
  --tile-text: #F5F4F2;
  --band-tile: #121110;
  --band-bg: #1C1B19;
  --band-field-bg: #121110;
  --band-line: rgba(255, 255, 255, 0.12);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.5);
}
