/* Mailferry design tokens · Direction 1b "Ledger" · v0.1, 27 Oct 2026
   Light is the default. Dark applies with [data-theme="dark"], or with
   "Match system" (no data-theme, or data-theme="system") when the OS is dark.
   Status colours always pair with an icon and text, never colour alone. */

/* [data-theme] also works on any element, to show one part of a page in the
   other theme (as in the design export). */
:root, [data-theme="light"] {
  color-scheme: light;

  /* Colour: neutrals */
  --color-bg: oklch(0.98 0.004 250);
  --color-surface: oklch(1 0 0);
  --color-surface-sunken: oklch(0.975 0.004 250);
  --color-surface-code: oklch(0.95 0.006 250);
  --color-border: oklch(0.9 0.008 250);
  --color-border-subtle: oklch(0.93 0.006 250);
  --color-border-strong: oklch(0.64 0.015 250); /* 3:1 on every surface (WCAG 1.4.11): input, toggle and button edges */
  --color-text: oklch(0.21 0.02 255);
  --color-text-muted: oklch(0.46 0.02 255);
  --color-text-disabled: oklch(0.52 0.02 255);
  --color-disabled-bg: oklch(0.93 0.006 250);

  /* Colour: accent (deep teal) */
  --color-accent: oklch(0.45 0.08 185);
  --color-accent-hover: oklch(0.4 0.08 185);
  --color-accent-active: oklch(0.36 0.075 185);
  --color-accent-tint: oklch(0.95 0.025 185);
  --color-on-accent: oklch(1 0 0);
  --color-focus: oklch(0.45 0.08 185);
  --color-focus-inner: oklch(1 0 0);

  /* Colour: semantic (solid = icons/borders/buttons, text = on tint, tint = backgrounds) */
  --color-success: oklch(0.48 0.11 150);
  --color-success-text: oklch(0.38 0.1 150);
  --color-success-tint: oklch(0.95 0.04 150);
  --color-warning: oklch(0.55 0.12 70);
  --color-warning-text: oklch(0.42 0.1 65);
  --color-warning-tint: oklch(0.95 0.05 80);
  --color-danger: oklch(0.52 0.17 25);
  --color-danger-hover: oklch(0.46 0.17 25);
  --color-danger-text: oklch(0.45 0.16 25);
  --color-danger-tint: oklch(0.94 0.04 25);
  --color-info: oklch(0.5 0.09 220);
  --color-info-text: oklch(0.4 0.08 220);
  --color-info-tint: oklch(0.95 0.025 220);
  --color-progress: oklch(0.42 0.14 260);
  --color-progress-tint: oklch(0.94 0.03 260);
  --color-neutral-tint: oklch(0.94 0.006 250);
  --color-admin: oklch(0.8 0.11 75); /* same in both themes */
  --color-on-admin: oklch(0.2 0.02 70);

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --text-display: clamp(2.25rem, 1.5rem + 3vw, 3.25rem);
  --text-h1: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
  --text-h2: 1.5rem;
  --text-h3: 1.25rem;
  --text-body: 1rem;
  --text-small: 0.875rem;
  --text-xs: 0.8125rem;
  --text-mono: 0.875rem;
  --leading-tight: 1.05;
  --leading-heading: 1.2;
  --leading-body: 1.55;
  --weight-regular: 400;
  --weight-medium: 600;
  --weight-bold: 700;
  --weight-heavy: 750;
  --tracking-display: -0.03em;
  --tracking-heading: -0.02em;
  --measure: 68ch;

  /* Space (4px base) */
  --space-0: 0;
  --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;

  /* Radius, borders, shadows: square and mostly flat */
  --radius-0: 0;
  --radius-pill: 0; /* kept square to match the direction */
  --border-width: 1px;
  --border-width-strong: 2px;
  --shadow-1: 0 1px 2px oklch(0.2 0.02 255 / 0.06);
  --shadow-2: 0 4px 16px oklch(0.2 0.02 255 / 0.12);
  --focus-ring: inset 0 0 0 3px var(--color-focus), inset 0 0 0 5px var(--color-focus-inner);
  --focus-ring-plain: inset 0 0 0 2px var(--color-focus);

  /* Layout */
  --width-reading: 44rem;
  --width-marketing: 72rem;
  --width-dashboard: 80rem;
  --gutter: var(--space-4);
  --grid-columns: 12;
  --control-height: 2.75rem; /* 44px touch target */
  --control-height-sm: 2rem;
  /* Breakpoints (mobile first; use in media queries as literals):
     sm 36rem (576px) · md 48rem (768px) · lg 64rem (1024px) · xl 80rem (1280px) */

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (min-width: 48rem) {
  :root { --gutter: var(--space-8); }
}

/* Dark theme (from 1a) */
:root[data-theme="dark"], [data-theme="dark"] {
  color-scheme: dark;
  --color-bg: oklch(0.19 0.008 85);
  --color-surface: oklch(0.23 0.008 85);
  --color-surface-sunken: oklch(0.21 0.008 85);
  --color-surface-code: oklch(0.27 0.008 85);
  --color-border: oklch(0.34 0.01 85);
  --color-border-subtle: oklch(0.29 0.009 85);
  --color-border-strong: oklch(0.55 0.012 85);
  --color-text: oklch(0.94 0.006 85);
  --color-text-muted: oklch(0.74 0.01 85);
  --color-text-disabled: oklch(0.62 0.01 85);
  --color-disabled-bg: oklch(0.28 0.008 85);
  --color-accent: oklch(0.78 0.09 185);
  --color-accent-hover: oklch(0.83 0.08 185);
  --color-accent-active: oklch(0.73 0.09 185);
  --color-accent-tint: oklch(0.3 0.04 185);
  --color-on-accent: oklch(0.19 0.008 85);
  --color-focus: oklch(0.78 0.09 185);
  --color-focus-inner: oklch(0.19 0.008 85);
  --color-success: oklch(0.78 0.11 150);
  --color-success-text: oklch(0.85 0.1 150);
  --color-success-tint: oklch(0.3 0.05 150);
  --color-warning: oklch(0.8 0.11 75);
  --color-warning-text: oklch(0.86 0.1 75);
  --color-warning-tint: oklch(0.32 0.05 75);
  --color-danger: oklch(0.74 0.13 27);
  --color-danger-hover: oklch(0.79 0.12 27);
  --color-danger-text: oklch(0.82 0.11 27);
  --color-danger-tint: oklch(0.31 0.06 27);
  --color-info: oklch(0.78 0.08 220);
  --color-info-text: oklch(0.85 0.07 220);
  --color-info-tint: oklch(0.3 0.04 220);
  --color-progress: oklch(0.8 0.09 260);
  --color-progress-tint: oklch(0.3 0.05 260);
  --color-neutral-tint: oklch(0.29 0.008 85);
  --color-admin: oklch(0.8 0.11 75);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-2: 0 4px 16px oklch(0 0 0 / 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --color-bg: oklch(0.19 0.008 85);
    --color-surface: oklch(0.23 0.008 85);
    --color-surface-sunken: oklch(0.21 0.008 85);
    --color-surface-code: oklch(0.27 0.008 85);
    --color-border: oklch(0.34 0.01 85);
    --color-border-subtle: oklch(0.29 0.009 85);
    --color-border-strong: oklch(0.55 0.012 85);
    --color-text: oklch(0.94 0.006 85);
    --color-text-muted: oklch(0.74 0.01 85);
    --color-text-disabled: oklch(0.62 0.01 85);
    --color-disabled-bg: oklch(0.28 0.008 85);
    --color-accent: oklch(0.78 0.09 185);
    --color-accent-hover: oklch(0.83 0.08 185);
    --color-accent-active: oklch(0.73 0.09 185);
    --color-accent-tint: oklch(0.3 0.04 185);
    --color-on-accent: oklch(0.19 0.008 85);
    --color-focus: oklch(0.78 0.09 185);
    --color-focus-inner: oklch(0.19 0.008 85);
    --color-success: oklch(0.78 0.11 150);
    --color-success-text: oklch(0.85 0.1 150);
    --color-success-tint: oklch(0.3 0.05 150);
    --color-warning: oklch(0.8 0.11 75);
    --color-warning-text: oklch(0.86 0.1 75);
    --color-warning-tint: oklch(0.32 0.05 75);
    --color-danger: oklch(0.74 0.13 27);
    --color-danger-hover: oklch(0.79 0.12 27);
    --color-danger-text: oklch(0.82 0.11 27);
    --color-danger-tint: oklch(0.31 0.06 27);
    --color-info: oklch(0.78 0.08 220);
    --color-info-text: oklch(0.85 0.07 220);
    --color-info-tint: oklch(0.3 0.04 220);
    --color-progress: oklch(0.8 0.09 260);
    --color-progress-tint: oklch(0.3 0.05 260);
    --color-neutral-tint: oklch(0.29 0.008 85);
    --color-admin: oklch(0.8 0.11 75);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-2: 0 4px 16px oklch(0 0 0 / 0.45);
  }
}

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