/* ==========================================================================
   Hagavia design tokens — the single source of every color, type size,
   radius, shadow, spacing and motion value in the platform.

   Language: Apple-inspired, shared with Finwiz (same rules and scales, own
   --hg-* names and values). One accent, a neutral gray ramp, quiet surfaces,
   depth from soft shadows and translucent materials, never from heavy
   borders. Rules for use live in design/DESIGN_LANGUAGE.md.

   Load this file FIRST on every page. Component and feature stylesheets
   reference var(--hg-*) only; a new hard-coded hex value is a defect.
   ========================================================================== */
:root {
    /* ---- Typography -------------------------------------------------------
       The platform font: SF on Apple devices, Segoe UI on Windows — both
       ship Hebrew glyphs, optical sizing and tuned tracking. No web font. */
    --hg-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
               "Segoe UI", system-ui, "Heebo", Arial, sans-serif;
    --hg-font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display",
               "Segoe UI", system-ui, "Heebo", Arial, sans-serif;
    --hg-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    /* Type scale (rem, so the user's text-size setting scales the UI). */
    --hg-fs-2xs: 0.6875rem;  /* 11 — badge, caption 2 */
    --hg-fs-xs: 0.75rem;     /* 12 — caption, table meta */
    --hg-fs-sm: 0.8125rem;   /* 13 — footnote, dense tables */
    --hg-fs-md: 0.875rem;    /* 14 — controls, body in dense panels */
    --hg-fs-base: 0.9375rem; /* 15 — body */
    --hg-fs-lg: 1.0625rem;   /* 17 — headline */
    --hg-fs-xl: 1.25rem;     /* 20 — title 3 */
    --hg-fs-2xl: 1.375rem;   /* 22 — title 2, section title */
    --hg-fs-3xl: 1.75rem;    /* 28 — title 1 */
    --hg-fs-4xl: 2.125rem;   /* 34 — large title */

    --hg-fw-regular: 400;
    --hg-fw-medium: 500;
    --hg-fw-semibold: 600;
    --hg-fw-bold: 700;

    --hg-lh-tight: 1.15;   /* titles */
    --hg-lh-snug: 1.35;    /* controls */
    --hg-lh-body: 1.5;     /* reading text */

    --hg-tracking-display: -0.022em; /* 20px and up */
    --hg-tracking-title: -0.012em;   /* 17px */
    --hg-tracking-caption: 0.01em;   /* 12px and down */

    /* ---- Neutral ramp (Apple system grays, warm-neutral) ----------------- */
    --hg-white: #ffffff;
    --hg-gray-50: #f5f5f7;
    --hg-gray-100: #efeff2;
    --hg-gray-200: #e5e5ea;
    --hg-gray-300: #d2d2d7;
    --hg-gray-400: #b0b0b6;
    --hg-gray-500: #86868b;
    --hg-gray-600: #6e6e73;
    --hg-gray-700: #48484a;
    --hg-gray-800: #2c2c2e;
    --hg-gray-900: #1d1d1f;

    /* ---- Brand + accent ---------------------------------------------------
       --hg-brand* are the logo colours (crimson badge, gold frame): decoration
       only. Crimson must never fill a button — red already means danger.
       --hg-accent is the one interactive colour: primary buttons, links,
       focus, selection, the open tool. 5.39:1 on white, 4.95:1 on
       --hg-gray-50 (the old #008fd6 measured 3.56:1 and failed). */
    --hg-brand: #ac2b35;
    --hg-brand-deep: #932133;
    --hg-brand-gold: #e3d2b1;
    --hg-accent: #006dba;
    --hg-accent-hover: #005fa3;
    --hg-accent-pressed: #00528e;
    --hg-accent-border: #9ccbea;
    --hg-accent-tint: #e5f1fa;
    --hg-accent-tint-subtle: #f3f8fc;
    --hg-on-accent: #ffffff;

    /* ---- Status: only ever means status ---------------------------------- */
    --hg-success: #1f7a3a;
    --hg-success-fill: #34a853;
    --hg-success-border: #a9dbb8;
    --hg-success-tint: #eaf6ed;
    --hg-warning: #a85300;
    --hg-warning-fill: #f5a524;
    --hg-warning-border: #f3d29a;
    --hg-warning-tint: #fff6e6;
    --hg-danger: #d1242f;
    --hg-danger-hover: #b51f29;
    --hg-danger-border: #f3b8bc;
    --hg-danger-tint: #fdeeef;

    /* ---- Categorical hues: things told apart by colour (board lists,
       product lines, layers). Each holds white semibold text at 4.5:1. ---- */
    --hg-cat-1: #1f6fd1;  /* blue */
    --hg-cat-2: #8e44c9;  /* purple */
    --hg-cat-3: #b85a00;  /* orange */
    --hg-cat-4: #00788a;  /* teal */
    --hg-cat-5: #c8283d;  /* red */
    --hg-cat-6: #5b4dd6;  /* violet */
    --hg-cat-7: #c2307a;  /* pink */
    --hg-cat-8: #00845a;  /* green */

    /* ---- Semantic roles (what components should reach for) --------------- */
    --hg-bg: var(--hg-gray-50);              /* the canvas behind cards */
    --hg-surface: var(--hg-white);           /* cards, sheets, inputs */
    --hg-surface-raised: var(--hg-white);
    --hg-fill: var(--hg-gray-100);           /* quiet fills: hover, segmented track */
    --hg-fill-strong: var(--hg-gray-200);
    --hg-separator: rgba(0, 0, 0, 0.08);     /* hairlines inside a surface */
    --hg-border: var(--hg-gray-300);         /* control outlines */
    --hg-text: var(--hg-gray-900);
    --hg-text-secondary: var(--hg-gray-600);
    /* #707075: 4.93:1 on white, 4.52:1 on the canvas. The ramp's gray-500
       (#86868b) measured 3.62:1 — the UI audit flagged every caption. */
    --hg-text-tertiary: #707075;
    --hg-text-disabled: var(--hg-gray-400);
    --hg-link: var(--hg-accent);
    --hg-focus-ring: 0 0 0 3px rgba(0, 109, 186, 0.28);
    --hg-selection: rgba(0, 109, 186, 0.18);

    /* Materials: translucent chrome over scrolling content. */
    --hg-material-bar: rgba(255, 255, 255, 0.72);
    --hg-material-thin: rgba(255, 255, 255, 0.82);
    --hg-material-blur: saturate(180%) blur(20px);
    --hg-scrim: rgba(0, 0, 0, 0.32);

    /* ---- Shape ------------------------------------------------------------ */
    --hg-radius-xs: 6px;     /* chips, small controls */
    --hg-radius-sm: 8px;     /* buttons, inputs */
    --hg-radius-md: 12px;    /* cards, menus */
    --hg-radius-lg: 16px;    /* panels, large cards */
    --hg-radius-xl: 22px;    /* sheets, dialogs */
    --hg-radius-pill: 999px;

    /* ---- Elevation: soft, layered, never a hard outline ------------------ */
    --hg-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
    --hg-shadow-2: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
    --hg-shadow-3: 0 8px 24px rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
    --hg-shadow-4: 0 20px 48px rgba(0, 0, 0, 0.16), 0 0 0 0.5px rgba(0, 0, 0, 0.06);

    /* ---- Spacing (4pt grid) ---------------------------------------------- */
    --hg-space-1: 4px;
    --hg-space-2: 8px;
    --hg-space-3: 12px;
    --hg-space-4: 16px;
    --hg-space-5: 20px;
    --hg-space-6: 24px;
    --hg-space-8: 32px;
    --hg-space-10: 40px;

    /* Control heights: one size per density step. */
    --hg-control-sm: 28px;
    --hg-control-md: 34px;
    --hg-control-lg: 44px;

    /* ---- Motion ------------------------------------------------------------
       Critically damped feel: fast out, gentle settle, no overshoot. */
    --hg-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --hg-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --hg-dur-press: 100ms;
    --hg-dur-fast: 160ms;
    --hg-dur-base: 240ms;
    --hg-dur-slow: 360ms;

    /* ======================================================================
       Legacy aliases. Older token sets grew up section by section (theme.css,
       the data table's --dt-*, raw data's --rd-*, page-local roots). They now
       resolve to the tokens above, so every older rule follows the one
       language. New code uses --hg-* directly.
       ====================================================================== */
    --primary-text-color: var(--hg-text);
    --secondary-text-color: var(--hg-accent);
    --muted-text-color: var(--hg-text-secondary);
    --background-color: var(--hg-bg);
    --border-color: var(--hg-gray-200);
    --box-shadow-color: rgba(0, 0, 0, 0.08);
    --header-background: var(--hg-accent-tint-subtle);
    --title-color: var(--hg-surface);
    --emphasis-color: var(--hg-danger);
    --error-color: var(--hg-danger);

    --brand-blue: var(--hg-accent);
    --brand-indigo: var(--hg-text);
    --accent-color: var(--hg-accent);
    --surface-color: var(--hg-surface);
    --card-bg: var(--hg-surface);
    --text-muted: var(--hg-text-secondary);

    --dt-primary: var(--hg-accent);
    --dt-primary-dark: var(--hg-accent-hover);
    --dt-primary-light: var(--hg-accent-tint);
    --dt-surface: var(--hg-surface);
    --dt-text: var(--hg-text);
    --dt-text-secondary: var(--hg-text-secondary);
    --dt-border: var(--hg-gray-200);
    --dt-success: var(--hg-success-fill);
    --dt-danger: var(--hg-danger);
    --dt-radius-md: var(--hg-radius-md);
    --dt-shadow-sm: var(--hg-shadow-1);

    --rd-primary: var(--hg-accent);
    --rd-primary-dark: var(--hg-accent-hover);
    --rd-primary-light: var(--hg-accent-tint);
    --rd-bg: var(--hg-bg);
    --rd-surface: var(--hg-surface);
    --rd-text: var(--hg-text);
    --rd-text-secondary: var(--hg-text-secondary);
    --rd-border: var(--hg-gray-200);
    --rd-success: var(--hg-success-fill);
    --rd-danger: var(--hg-danger);
    --rd-radius-sm: var(--hg-radius-xs);
    --rd-radius-md: var(--hg-radius-md);
    --rd-shadow-sm: var(--hg-shadow-1);

    color-scheme: light;
}

@media (prefers-reduced-transparency: reduce) {
    :root {
        --hg-material-bar: rgba(255, 255, 255, 0.98);
        --hg-material-thin: rgba(255, 255, 255, 0.98);
        --hg-material-blur: none;
    }
}

@media (prefers-contrast: more) {
    :root {
        --hg-separator: rgba(0, 0, 0, 0.22);
        --hg-border: var(--hg-gray-500);
        --hg-text-secondary: var(--hg-gray-700);
        --hg-text-tertiary: var(--hg-gray-600);
    }
}
