/*
 * Design tokens for Abacus One Group Integration Services.
 *
 * This file is the single source of every colour, size and timing on the site. It has three tiers:
 *
 *   1. Primitives: the raw palette and scales. Never used by a component directly.
 *   2. Semantic tokens: what a value is for (background, foreground, border, primary).
 *      Components use these, and only these change between the light and dark themes.
 *   3. Component tokens: live with the component, in components.css, and point at tier 2.
 *
 * The file knows nothing about the docs theme, so the operations console can take the same
 * values. See docs/design-system.md for the rules and for how the console maps them.
 *
 * Every token is prefixed --ao- (Abacus One). The docs theme and its search dialog define
 * unprefixed names of their own (--color-background, --space-1), so a prefix is what keeps the
 * two apart.
 */

:root {
  /*
   * One design rem is 16px at the browser's default text size. The docs theme sets the root
   * font size to 125%, so theme.css sets --ao-rem to 0.8rem there. Everywhere else it is 1rem.
   * Sizes stay relative to the reader's own text size either way.
   */
  --ao-rem: 1rem;

  /* ---- 1. Primitives ------------------------------------------------------------------- */

  /* Navy and red are taken from the Abacus One Group logo (600 is the logo's own colour). */
  --ao-navy-50: #f1f6f9;
  --ao-navy-100: #e0ebf2;
  --ao-navy-200: #bfd6e3;
  --ao-navy-300: #8cc0de;
  --ao-navy-400: #6fb0d3;
  --ao-navy-500: #256a90;
  --ao-navy-600: #08476b;
  --ao-navy-700: #063a58;
  --ao-navy-800: #12303f;
  --ao-navy-900: #0b2331;

  --ao-red-50: #fdf1f1;
  --ao-red-300: #f4a3a9;
  --ao-red-400: #f0818a;
  --ao-red-600: #c6303b;
  --ao-red-700: #a3232d;
  --ao-red-900: #2c1517;

  /* Neutrals lean slightly towards the navy, so greys and brand colour sit together. */
  --ao-slate-0: #ffffff;
  --ao-slate-50: #f6f8fa;
  --ao-slate-100: #edf1f4;
  --ao-slate-200: #dde4ea;
  --ao-slate-300: #c5cfd8;
  --ao-slate-400: #8593a0;
  --ao-slate-500: #5f6e7c;
  --ao-slate-600: #4d5b68;
  --ao-slate-700: #2b3843;
  --ao-slate-800: #1a252e;
  --ao-slate-850: #151e26;
  --ao-slate-900: #141b22;
  --ao-slate-950: #0e151b;

  --ao-green-50: #edf7f1;
  --ao-green-300: #7fd1a6;
  --ao-green-700: #1c6b45;
  --ao-green-900: #10261c;

  --ao-amber-50: #fdf5e3;
  --ao-amber-300: #f0c36a;
  --ao-amber-700: #7a4a00;
  --ao-amber-900: #2a2110;

  /* Type. System fonts only: the site loads nothing from other hosts, and text renders at once. */
  --ao-font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ao-font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;

  /* The type scale. Each size has its own line height: tighter as the text gets larger. */
  --ao-text-xs: calc(0.75 * var(--ao-rem)); /* 12px */
  --ao-text-sm: calc(0.875 * var(--ao-rem)); /* 14px */
  --ao-text-base: var(--ao-rem); /* 16px */
  --ao-text-lg: calc(1.125 * var(--ao-rem)); /* 18px */
  --ao-text-xl: calc(1.25 * var(--ao-rem)); /* 20px */
  --ao-text-2xl: calc(1.5 * var(--ao-rem)); /* 24px */
  --ao-text-3xl: calc(1.875 * var(--ao-rem)); /* 30px */
  --ao-text-4xl: calc(2.25 * var(--ao-rem)); /* 36px */

  --ao-leading-tight: 1.2;
  --ao-leading-snug: 1.35;
  --ao-leading-normal: 1.5;
  --ao-leading-relaxed: 1.65;

  --ao-weight-regular: 400;
  --ao-weight-medium: 500;
  --ao-weight-semibold: 600;
  --ao-weight-bold: 700;

  --ao-tracking-tight: -0.015em;
  --ao-tracking-normal: 0;
  --ao-tracking-wide: 0.06em;

  /* Spacing. A 4px grid: the number is a multiple of 4px. Nothing is spaced off the grid. */
  --ao-space-1: calc(0.25 * var(--ao-rem)); /* 4px */
  --ao-space-2: calc(0.5 * var(--ao-rem)); /* 8px */
  --ao-space-3: calc(0.75 * var(--ao-rem)); /* 12px */
  --ao-space-4: var(--ao-rem); /* 16px */
  --ao-space-5: calc(1.25 * var(--ao-rem)); /* 20px */
  --ao-space-6: calc(1.5 * var(--ao-rem)); /* 24px */
  --ao-space-8: calc(2 * var(--ao-rem)); /* 32px */
  --ao-space-10: calc(2.5 * var(--ao-rem)); /* 40px */
  --ao-space-12: calc(3 * var(--ao-rem)); /* 48px */
  --ao-space-16: calc(4 * var(--ao-rem)); /* 64px */

  --ao-radius-sm: calc(0.25 * var(--ao-rem)); /* 4px: checkboxes, inline code */
  --ao-radius-md: calc(0.375 * var(--ao-rem)); /* 6px: buttons, nav items, inputs */
  --ao-radius-lg: calc(0.625 * var(--ao-rem)); /* 10px: cards, tables, callouts */
  --ao-radius-full: 9999px;

  --ao-border-width: 1px;

  /* Motion. Short, and off entirely for readers who ask for reduced motion (see below). */
  --ao-duration-fast: 120ms;
  --ao-duration: 200ms;
  --ao-ease: cubic-bezier(0.2, 0, 0, 1);

  /* Layout. */
  --ao-measure: calc(46 * var(--ao-rem)); /* the widest a column of prose gets: about 75 characters */
  --ao-target-min: calc(2.75 * var(--ao-rem)); /* 44px: the smallest touch target */
  --ao-focus-width: 2px;
  --ao-focus-offset: 2px;

  /* ---- 2. Semantic tokens: light theme ------------------------------------------------- */

  color-scheme: light dark;

  --ao-color-background: var(--ao-slate-0); /* the page */
  --ao-color-surface: var(--ao-slate-50); /* a quieter area on the page: table headers, footer */
  --ao-color-card: var(--ao-slate-0); /* a raised container: cards, the checklist */
  --ao-color-overlay: rgb(20 27 34 / 0.45); /* behind a drawer or dialog */

  --ao-color-foreground: var(--ao-slate-900); /* body text and headings */
  --ao-color-muted-foreground: var(--ao-slate-600); /* supporting text */
  --ao-color-subtle-foreground: var(--ao-slate-500); /* labels and captions: the lightest text */

  --ao-color-border: var(--ao-slate-200); /* dividers and container edges */
  --ao-color-border-strong: var(--ao-slate-400); /* edges that mark a control, 3:1 on the page */

  --ao-color-primary: var(--ao-navy-600); /* links, the active item, filled controls */
  --ao-color-primary-hover: var(--ao-navy-700);
  --ao-color-primary-foreground: var(--ao-slate-0); /* text on a primary fill */
  --ao-color-primary-subtle: var(--ao-navy-50); /* a tinted surface: active nav, callouts */
  --ao-color-primary-border: var(--ao-navy-200);
  --ao-color-ring: var(--ao-navy-500); /* the focus ring */

  --ao-color-accent: var(--ao-red-600); /* the logo's red. Decoration only, and sparingly. */

  --ao-color-success: var(--ao-green-700);
  --ao-color-success-subtle: var(--ao-green-50);
  --ao-color-warning: var(--ao-amber-700);
  --ao-color-warning-subtle: var(--ao-amber-50);
  --ao-color-danger: var(--ao-red-700);
  --ao-color-danger-subtle: var(--ao-red-50);

  --ao-color-code: var(--ao-slate-700);
  --ao-color-code-surface: var(--ao-slate-100);

  --ao-shadow-sm: 0 1px 2px rgb(20 27 34 / 0.06);
  --ao-shadow-md: 0 4px 12px rgb(20 27 34 / 0.08), 0 1px 2px rgb(20 27 34 / 0.06);
}

/* ---- 2. Semantic tokens: dark theme ------------------------------------------------------ */

/* On screen only: a printed page always uses the light theme. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --ao-color-background: var(--ao-slate-950);
    --ao-color-surface: var(--ao-slate-850);
    --ao-color-card: var(--ao-slate-850);
    --ao-color-overlay: rgb(0 0 0 / 0.6);

    --ao-color-foreground: #e4eaef;
    --ao-color-muted-foreground: #a3b1be;
    --ao-color-subtle-foreground: #8494a3;

    --ao-color-border: var(--ao-slate-700);
    --ao-color-border-strong: var(--ao-slate-500);

    --ao-color-primary: var(--ao-navy-300);
    --ao-color-primary-hover: #b4d6ea;
    --ao-color-primary-foreground: var(--ao-slate-950);
    --ao-color-primary-subtle: var(--ao-navy-800);
    --ao-color-primary-border: #24506a;
    --ao-color-ring: var(--ao-navy-400);

    --ao-color-accent: var(--ao-red-400);

    --ao-color-success: var(--ao-green-300);
    --ao-color-success-subtle: var(--ao-green-900);
    --ao-color-warning: var(--ao-amber-300);
    --ao-color-warning-subtle: var(--ao-amber-900);
    --ao-color-danger: var(--ao-red-300);
    --ao-color-danger-subtle: var(--ao-red-900);

    --ao-color-code: #c9d4de;
    --ao-color-code-surface: var(--ao-slate-800);

    --ao-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --ao-shadow-md: 0 4px 12px rgb(0 0 0 / 0.5), 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --ao-duration-fast: 0ms;
    --ao-duration: 0ms;
  }
}
