/**
 * Design tokens, layered: primitive -> semantic -> component.
 * Components (components.css) reference semantic tokens here, never
 * primitives directly. See dfusionfw/docs/css-conventions.md §2.
 *
 * Three tiers, and the rule that makes them worth having: consuming CSS
 * references the semantic tier (or a component token that itself references
 * semantic), never a primitive. A hex or an rgba() in any other stylesheet
 * means a token is missing from this file, not that this one is an exception
 * -- add it here instead.
 *
 * Values are carried over verbatim from superyachtnetwork/charterhub,
 * which translated them from that product's Tailwind prototype. They are
 * YachtCRM's starting palette, not its final one -- re-theming this project is
 * a matter of changing the primitive values below, since nothing outside
 * this file names a colour. Three deliberate departures from what was
 * measured in the original, each one a finding that review raised:
 *
 *  - The `ink` scale is dropped. ink-500/600 were exact duplicates of
 *    brand-600/700 (C-08).
 *  - The eight bespoke one-off shadows become a named elevation scale (C-05).
 *  - Faint text is ui-500, not ui-400. The prototype's slate-400 measures
 *    2.63:1 against white and fails WCAG AA (T8); ui-500 clears it.
 */
@layer tokens {
    :root {
        /* --- Primitive: neutral scale (the prototype's slate ramp) --- */
        --color-ui-0: #ffffff;
        --color-ui-50: #f8fafc;
        --color-ui-100: #f1f5f9;
        --color-ui-200: #e2e8f0;
        --color-ui-300: #cbd5e1;
        --color-ui-400: #90a1b9;
        --color-ui-500: #62748e;
        --color-ui-600: #45556c;
        --color-ui-700: #314158;
        --color-ui-800: #1d293d;
        --color-ui-900: #0f172a;
        --color-ui-950: #020617;
        --color-ui-1000: #000000;

        /* White at low alpha, for a wash over a coloured surface (the brand
           header's own controls). A flat grey cannot do this job -- it has to
           take its hue from whatever it sits on. */
        --color-ui-0-a10: rgba(255, 255, 255, 0.1);
        --color-ui-0-a15: rgba(255, 255, 255, 0.15);
        --color-ui-0-a25: rgba(255, 255, 255, 0.25);

        /* --- Primitive: brand --- */
        --color-brand-50: #eaf1ff;
        --color-brand-100: #d6e4ff;
        --color-brand-200: #adc8ff;
        --color-brand-300: #7aa5ff;
        --color-brand-400: #3b85ff;
        --color-brand-500: #0267ff;
        --color-brand-600: #0150cc;
        --color-brand-700: #013c99;

        /* --- Primitive: accent --- */
        --color-accent-400: #4bdc97;
        --color-accent-500: #35ce86;

        /* --- Primitive: status --- */
        --color-error-50: #fef2f2;
        --color-error-100: #fee2e2;
        --color-error-200: #fecaca;
        --color-error-500: #ef4444;
        --color-error-600: #dc2626;
        --color-error-700: #b91c1c;
        --color-warning-500: #f59e0b;
        --color-warning-600: #d97706;
        --color-success-50: #ecfdf5;
        --color-success-200: #a7f3d0;
        --color-success-500: #10b981;
        --color-success-600: #059669;

        /* --- Semantic: text --- */
        --text-colour-white: var(--color-ui-0);
        --text-colour-faint: var(--color-ui-500);
        --text-colour-light: var(--color-ui-500);
        --text-colour-regular: var(--color-ui-800);
        --text-colour-dark: var(--color-ui-900);
        --text-colour-brand: var(--color-brand-600);
        /* The brand at its most emphatic: the current item in a nav, where the
           label carries the state and must not be mistaken for a link. */
        --text-colour-brand-strong: var(--color-brand-700);
        /* The label on a neutral control -- an outline button, a menu item. A
           step lighter than body copy, so a row of controls does not out-shout
           the content they act on. */
        --text-colour-control: var(--color-ui-700);
        /* Text that is present but not selectable -- a calendar day outside
           the pickable window. Lighter than --text-colour-faint on purpose:
           faint still has to be readable, this has to read as unavailable. */
        --text-colour-disabled: var(--color-ui-400);
        --link-colour: var(--color-brand-600);

        /* --- Semantic: surface / border / overlay --- */
        --surface-colour: var(--color-ui-0);
        --surface-colour-sunken: var(--color-ui-50);
        --surface-colour-raised: var(--color-ui-100);
        --surface-colour-brand: var(--color-brand-500);
        --surface-colour-brand-hover: var(--color-brand-600);
        /* The brand at half strength, for a decorative fill that should read
           as brand without competing with a real brand surface. */
        --surface-colour-brand-mid: var(--color-brand-300);
        --surface-colour-brand-disabled: var(--color-brand-200);
        --surface-colour-brand-soft: var(--color-brand-50);
        --surface-colour-accent: var(--color-accent-500);
        /* Sitting ON a brand surface: the header's own controls, which take
           their hue from the bar behind them rather than naming a grey. */
        --surface-colour-on-brand: var(--color-ui-0-a15);
        --surface-colour-on-brand-soft: var(--color-ui-0-a10);
        --surface-colour-on-brand-strong: var(--color-ui-0-a25);
        --border-colour: var(--color-ui-200);
        --border-colour-strong: var(--color-ui-300);
        --border-colour-soft: var(--color-ui-100);
        --border-colour-brand: var(--color-brand-500);
        --border-colour-brand-hover: var(--color-brand-600);
        --border-colour-brand-disabled: var(--color-brand-200);
        --overlay-colour: rgba(15, 23, 42, 0.4);
        --focus-ring: 0 0 0 3px rgba(2, 103, 255, 0.25);

        /* --- Semantic: status ---
           One set per status, named by the job rather than by the shade, so a
           component says what it means and the ramp above stays the only place
           a red is chosen. `-solid` is a filled swatch (a badge, a destructive
           button) and pairs with `-on-solid`; `-surface`/`-border`/`-text` are
           the tinted panel (a flash, an inline error). */
        --status-error-text: var(--color-error-600);
        /* A hair brighter than -text: a field outline and its message have to
           catch the eye against a page of neutral chrome. */
        --status-error-accent: var(--color-error-500);
        --status-error-surface: var(--color-error-50);
        --status-error-surface-strong: var(--color-error-100);
        --status-error-border: var(--color-error-200);
        --status-error-solid: var(--color-error-600);
        --status-error-solid-hover: var(--color-error-700);
        --status-error-on-solid: var(--text-colour-white);

        --status-success-text: var(--color-success-600);
        --status-success-surface: var(--color-success-50);
        --status-success-border: var(--color-success-200);
        --status-success-solid: var(--color-success-600);
        --status-success-on-solid: var(--text-colour-white);

        /* Amber is too light to carry white text -- 1.9:1, nowhere near AA --
           so this one status reads dark on its own fill. */
        --status-warning-solid: var(--color-warning-500);
        --status-warning-on-solid: var(--text-colour-dark);

        --status-neutral-surface: var(--color-ui-100);
        --status-neutral-text: var(--color-ui-700);
        --status-neutral-solid: var(--color-ui-700);
        /* The quietest fill of the set: a status that is over rather than
           pending, and should recede from the ones still live. */
        --status-neutral-solid-muted: var(--color-ui-400);
        --status-neutral-on-solid: var(--text-colour-white);

        /* --- Spacing: element-level (component-internal), 4px ramp --- */
        --spacing-s0: 0;
        --spacing-s1: 4px;
        --spacing-s2: 8px;
        --spacing-s3: 12px;
        --spacing-s4: 16px;
        --spacing-s5: 20px;
        --spacing-s6: 24px;
        --spacing-s8: 32px;
        --spacing-s10: 40px;

        /* --- Spacing: block-gutter (page/layout level) --- */
        --gutter-s0: 0;
        --gutter-s2: 8px;
        --gutter-s4: 16px;
        --gutter-s5: 20px;
        --gutter-s6: 24px;
        --gutter-s7: 28px;
        --gutter-page: var(--gutter-s4);

        /* --- Typography --- */
        --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

        --font-weight-regular: 400;
        --font-weight-medium: 500;
        --font-weight-semibold: 600;
        --font-weight-bold: 700;
        --font-weight-extrabold: 800;

        --font-size-2xs: 11px;
        --font-size-xs: 12px;
        --font-size-s: 13px;
        --font-size-r: 14px;
        --font-size-m: 16px;
        --font-size-l: 20px;
        --font-size-xl: 24px;

        --line-height-tight: 1.2;
        --line-height-regular: 1.5;

        /* --- Radius --- */
        --radius-s: 4px;
        --radius-m: 8px;
        --radius-l: 12px;
        --radius-xl: 16px;
        --radius-pill: 999px;

        /* --- Elevation (the prototype's eight bespoke shadows, named) --- */
        --elevation-1: 0 1px 2px rgba(15, 23, 42, 0.04);
        --elevation-2: 0 2px 10px -6px rgba(15, 23, 42, 0.25);
        --elevation-3: 0 2px 14px -8px rgba(15, 23, 42, 0.3);
        --elevation-4: 0 8px 40px -24px rgba(15, 23, 42, 0.35);
        --elevation-5: 0 10px 30px -18px rgba(15, 23, 42, 0.55);
        --elevation-6: 0 18px 50px -24px rgba(15, 23, 42, 0.35);
        --elevation-above: 0 -4px 12px rgba(15, 23, 42, 0.06);
        --elevation-left: -8px 0 24px -20px rgba(15, 23, 42, 0.4);
        --shadow-card: var(--elevation-1);

        /* --- Component: the <select> chevron ---
           A data URI cannot read a custom property, so the stroke has to be a
           literal. It lives here rather than in components.css for that
           reason, and must be kept in step with --text-colour-light (ui-500)
           by hand -- which is the whole cost of the one colour in this file
           that cannot be expressed as var(). */
        --field-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2362748e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

        /* --- Motion --- */
        --transition-duration: 0.15s;
        --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);

        /* --- Shell geometry (docs/research/05-app-shell.md §5) --- */
        /* The header's own height, and the height the shell is laid out
           under -- the same unless the impersonation banner is above the
           header (layout.css, "Impersonation banner"). */
        --shell-header-height-base: 68px;
        --shell-header-height: var(--shell-header-height-base);
        --impersonation-banner-height: 44px;
        --shell-sidebar-width: 256px;
        --shell-sidebar-collapsed-width: 68px;
    }

    /* Two breakpoints only -- 640 and 1024 -- matching the prototype's real
       usage (03-design-system.md §10: 97 `sm:` and 59 `lg:` utilities, 1 `md:`,
       0 `2xl:`). */
    @media (min-width: 641px) {
        :root {
            --gutter-page: var(--spacing-s8);
        }
    }
}
