/* ==========================================================================
   Demo Analytics: design tokens
   --------------------------------------------------------------------------
   Every color, space, radius, shadow, type size and motion value used by the
   demo lives here as a CSS custom property. Components never hardcode raw
   values; they reference these tokens.

   Breakpoints (media queries cannot read custom properties, so they are
   documented here and repeated in views.css):
     mobile   < 720px   bottom navigation
     tablet   720px to 1099px   icon rail
     desktop  >= 1100px  full sidebar

   JavaScript reads the motion tokens at runtime (see motionMs() in
   js/charts.js), so the mobile and reduced-motion overrides at the bottom of
   this file also shorten or disable the scripted animations.
   ========================================================================== */

:root {
    /* ---------- Color: neutrals (warm gray) ---------- */
    --color-bg: #f6f5f2;
    --color-surface: #ffffff;
    --color-surface-subtle: #faf9f7;
    --color-surface-sunken: #f0eeea;
    --color-surface-hover: #f3f1ed;
    --color-border: #e6e3dd;
    --color-border-strong: #d5d1c9;

    --color-text: #1d1c1a;
    --color-text-muted: #5e5a53;
    --color-text-subtle: #736e66;
    --color-text-inverse: #ffffff;

    /* ---------- Color: the single accent (cobalt) ---------- */
    --color-accent: #2f5bea;
    --color-accent-strong: #2449c4;
    --color-accent-soft: #ebf0fe;
    --color-accent-softer: #f4f7ff;
    --color-accent-contrast: #ffffff;

    /* ---------- Color: status (functional only, used sparingly) ---------- */
    --color-positive: #0f7a4d;
    --color-positive-soft: #e6f4ec;
    --color-negative: #b4362a;
    --color-negative-soft: #fbeae7;
    --color-warning: #8a5a00;
    --color-warning-soft: #fbf1dc;
    --color-neutral-soft: #f0eeea;

    /* ---------- Color: data visualisation ---------- */
    --color-chart-store: var(--color-accent);
    --color-chart-store-area: rgba(47, 91, 234, 0.16);
    --color-chart-store-area-end: rgba(47, 91, 234, 0);
    --color-chart-compare: #948e84;
    --color-chart-grid: #ece9e4;
    --color-chart-axis: var(--color-text-subtle);
    --color-chart-track: var(--color-surface-sunken);

    /* ---------- Color: interaction ---------- */
    --color-focus: var(--color-accent);
    --color-selection: rgba(47, 91, 234, 0.18);
    --color-skeleton: #ecebe7;
    --color-skeleton-shine: rgba(255, 255, 255, 0.65);
    --state-layer-hover: 0.06;
    --state-layer-press: 0.1;

    /* ---------- Typography ---------- */
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.8125rem;   /* 13px */
    --text-base: 0.875rem;  /* 14px */
    --text-md: 1rem;        /* 16px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.375rem;    /* 22px */
    --text-2xl: 1.75rem;    /* 28px */
    --text-3xl: 2.25rem;    /* 36px */

    --leading-tight: 1.2;
    --leading-snug: 1.35;
    --leading-normal: 1.5;

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

    --tracking-tight: -0.018em;
    --tracking-normal: 0;
    --tracking-wide: 0.06em;

    /* ---------- Spacing (4px base) ---------- */
    --space-0-5: 0.125rem;  /* 2px */
    --space-1: 0.25rem;     /* 4px */
    --space-1-5: 0.375rem;  /* 6px */
    --space-2: 0.5rem;      /* 8px */
    --space-2-5: 0.625rem;  /* 10px */
    --space-3: 0.75rem;     /* 12px */
    --space-4: 1rem;        /* 16px */
    --space-5: 1.25rem;     /* 20px */
    --space-6: 1.5rem;      /* 24px */
    --space-7: 1.75rem;     /* 28px */
    --space-8: 2rem;        /* 32px */
    --space-10: 2.5rem;     /* 40px */
    --space-12: 3rem;       /* 48px */
    --space-16: 4rem;       /* 64px */

    /* ---------- Radius ---------- */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 999px;

    /* ---------- Shadows (warm tinted) ---------- */
    --shadow-xs: 0 1px 1px rgba(29, 27, 22, 0.04);
    --shadow-sm: 0 1px 2px rgba(29, 27, 22, 0.05), 0 1px 1px rgba(29, 27, 22, 0.03);
    --shadow-md: 0 6px 16px -4px rgba(29, 27, 22, 0.1), 0 2px 4px -2px rgba(29, 27, 22, 0.05);
    --shadow-lg: 0 16px 32px -8px rgba(29, 27, 22, 0.16), 0 4px 10px -4px rgba(29, 27, 22, 0.06);
    --shadow-nav: 0 -1px 0 var(--color-border), 0 -8px 24px -12px rgba(29, 27, 22, 0.12);

    /* ---------- Motion ----------
       Animations only ever change transform and opacity. Durations shrink on
       small screens and drop to zero with prefers-reduced-motion. */
    --motion-duration-instant: 90ms;
    --motion-duration-fast: 150ms;
    --motion-duration-base: 240ms;
    --motion-duration-slow: 420ms;
    --motion-duration-reveal: 560ms;
    --motion-duration-view: 320ms;
    --motion-duration-chart: 1100ms;
    --motion-duration-count: 1200ms;
    --motion-duration-shimmer: 1500ms;
    --motion-duration-spin: 900ms;
    --motion-stagger: 70ms;

    --motion-distance-reveal: 14px;
    --motion-distance-view: 8px;
    --motion-lift: -2px;
    --motion-press-scale: 0.97;

    --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --motion-ease-in: cubic-bezier(0.5, 0, 0.75, 0);
    --motion-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --motion-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ---------- Layout ---------- */
    --sidebar-width: 248px;
    --rail-width: 88px;
    --topbar-height: 60px;
    --bottom-nav-height: 64px;
    --content-max-width: 1240px;
    --page-gutter: var(--space-8);
    --card-padding: var(--space-5);

    /* ---------- Layers ---------- */
    --z-raised: 1;
    --z-sticky: 20;
    --z-nav: 30;
    --z-tooltip: 40;
    --z-toast: 50;
    --z-skip: 60;
}

/* Tablet: tighter gutters. */
@media (max-width: 1099px) {
    :root {
        --page-gutter: var(--space-6);
    }
}

/* Mobile: lighter, shorter motion and tighter spacing. */
@media (max-width: 719px) {
    :root {
        --page-gutter: var(--space-4);
        --card-padding: var(--space-4);

        --motion-duration-base: 200ms;
        --motion-duration-slow: 300ms;
        --motion-duration-reveal: 380ms;
        --motion-duration-view: 220ms;
        --motion-duration-chart: 760ms;
        --motion-duration-count: 850ms;
        --motion-stagger: 35ms;
        --motion-distance-reveal: 8px;
        --motion-distance-view: 4px;
        --motion-lift: 0px;
    }
}

/* Reduced motion: every duration and distance collapses to zero. The
   scripted animations read these values and render their final state. */
@media (prefers-reduced-motion: reduce) {
    :root {
        --motion-duration-instant: 0ms;
        --motion-duration-fast: 0ms;
        --motion-duration-base: 0ms;
        --motion-duration-slow: 0ms;
        --motion-duration-reveal: 0ms;
        --motion-duration-view: 0ms;
        --motion-duration-chart: 0ms;
        --motion-duration-count: 0ms;
        --motion-stagger: 0ms;
        --motion-distance-reveal: 0px;
        --motion-distance-view: 0px;
        --motion-lift: 0px;
        --motion-press-scale: 1;
    }
}
