/* tokens.css — raw values live ONLY here. */
@layer tokens, base, layout, components, motion, pages, utilities;

@layer tokens {
  :root {
    color-scheme: light;

    /* Typography */
    --font-sans: 'Host Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --text-xs: 0.75rem;   --leading-xs: 1rem;      /* 12/16 meta, captions            */
    --text-sm: 0.8125rem; --leading-sm: 1.125rem;  /* 13/18 labels, dense cells       */
    --text-md: 0.875rem;  --leading-md: 1.25rem;   /* 14/20 body (desktop)            */
    --text-lg: 1rem;      --leading-lg: 1.5rem;    /* 16/24 inputs on mobile, emphasis */
    --text-xl: 1.25rem;   --leading-xl: 1.75rem;   /* 20/28 section / mobile page title */
    --text-2xl: 1.5rem;   --leading-2xl: 2rem;     /* 24/32 page title                */
    --text-3xl: 2rem;     --leading-3xl: 2.5rem;   /* 32/40 hero amount (mobile)      */
    --text-4xl: 2.75rem;  --leading-4xl: 3.25rem;  /* 44/52 hero amount (desktop)     */
    --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;

    /* Spacing — 4 px rhythm (0-5 and 1-5 are optical half steps only) */
    --spacing-0-5: 2px; --spacing-1: 4px; --spacing-1-5: 6px; --spacing-2: 8px; --spacing-3: 12px;
    --spacing-4: 16px;  --spacing-6: 24px; --spacing-8: 32px; --spacing-12: 48px; --spacing-16: 64px;

    /* Shape */
    --radius-none: 0;
    --radius-round: 9999px;            /* ONLY avatars, status dots, spinners */
    --border-hairline: 1px;
    --border-strong: 2px;

    /* Sizes */
    --control-height: 44px;            /* minimum interactive target */
    --control-height-lg: 52px;         /* primary actions on mobile */
    --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px;
    --status-dot: 8px;
    --sidenav-width: 248px; --topbar-height: 56px; --bottomnav-height: 64px;
    --content-max: 1200px; --form-max: 720px; --dialog-max: 560px; --auth-form-max: 400px;
    --focus-ring: 2px; --focus-offset: 2px;

    /* Motion (§12.6). --motion is 0 under reduced motion, which zeroes every distance and scale below. */
    --motion: 1;
    --ease-out: cubic-bezier(0.2, 0, 0, 1);              /* entries and state changes */
    --ease-out-strong: cubic-bezier(0.05, 0.7, 0.1, 1);  /* sheets and other large moves */
    --ease-in: cubic-bezier(0.3, 0, 1, 1);               /* exits only, always short */
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);         /* things moving on screen: FLIP, shared elements */
    --duration-instant: 80ms;    /* press-in */
    --duration-fast: 120ms;      /* hover, press-out, exits, tooltips */
    --duration-base: 180ms;      /* dialogs, toasts, menus, fades */
    --duration-moderate: 240ms;  /* page content, FLIP moves, expand and collapse, drawn checks */
    --duration-slow: 320ms;      /* progress fills, bottom sheets */
    --duration-count: 480ms;     /* number count-ups */
    --duration-emphasis: 600ms;  /* the one-shot "just changed" ring */
    --duration-spin: 800ms;      /* one spinner turn */
    --duration-pulse: 1600ms;    /* one skeleton pulse */
    --duration-toast: 5000ms;    /* how long a toast stays (errors stay until closed) */
    --stagger-step: 30ms;        /* list entries; at most 8 items are staggered */
    --motion-distance-sm: calc(4px * var(--motion));
    --motion-distance-md: calc(8px * var(--motion));
    --motion-distance-lg: calc(16px * var(--motion));
    --press-scale: calc(1 - 0.02 * var(--motion));
    --pop-scale: calc(1 - 0.04 * var(--motion));

    /* Layers */
    --z-sticky: 10; --z-nav: 20; --z-overlay: 40; --z-dialog: 50; --z-toast: 60;

    /* Colour: the Stellaria LIGHT palette, the app's theme */
    --color-bg: #F4F6FA;               /* blue-tinted off-white canvas */
    --color-surface-1: #FFFFFF;        /* nav, top bar, panels, cards */
    --color-surface-2: #F0F3F8;        /* inputs, hover, raised rows */
    --color-surface-3: #E6EBF3;        /* pressed, selected */
    --color-border: #D5DCE8;           /* hairlines and dividers */
    --color-border-control: #7F8BA2;   /* input/control outlines (≥ 3:1 against bg and surface-1) */
    --color-text: #0D1524;
    --color-text-muted: #475369;
    --color-text-subtle: #56627A;
    --color-accent: #2F6BF6;           /* = the Stellaria logo blue — fills */
    --color-accent-hover: #2A5FDC;
    --color-accent-pressed: #2453C4;
    --color-accent-text: #1F56D8;      /* links, focus ring, active nav text */
    --color-on-accent: #FFFFFF;
    --color-accent-wash: rgb(47 107 246 / 0.10);  /* active nav / selected row background */
    --color-danger: #C42B2B;
    --color-danger-text: #C42B2B;
    --color-status-pending: #8F5B00;
    --color-status-approved: #0B6E80;
    --color-status-settled: #17743F;
    --color-status-rejected: #C42B2B;
    --color-status-neutral: #56627A;
    --color-scrim: rgb(13 21 36 / 0.48);
    --color-skeleton: #E6EBF3;
    --color-skeleton-sheen: #F0F3F8;
  }

  /* Reduced motion: the device setting, or "Reduce animations" on the Account page (data-motion="reduced"). */
  @media (prefers-reduced-motion: reduce) { :root { --motion: 0; } }
  :root[data-motion='reduced'] { --motion: 0; }

  /* The Stellaria DARK palette, reserved for a later dark mode (§20). Nothing sets data-theme="dark" in v1. */
  :root[data-theme='dark'] {
    color-scheme: dark;
    --color-bg: #070B12;               /* = the near-black of the Stellaria logo tile */
    --color-surface-1: #0D121C;
    --color-surface-2: #131A27;
    --color-surface-3: #1A2333;
    --color-border: #222D42;
    --color-border-control: #56657F;
    --color-text: #E7ECF5;
    --color-text-muted: #A3AEC2;
    --color-text-subtle: #8692A9;
    --color-accent: #2F6BF6;
    --color-accent-hover: #2A5FDC;
    --color-accent-pressed: #2453C4;
    --color-accent-text: #7EA6FF;
    --color-on-accent: #FFFFFF;
    --color-accent-wash: rgb(47 107 246 / 0.16);
    --color-danger: #D23B3B;
    --color-danger-text: #FF6B6B;
    --color-status-pending: #F5B544;
    --color-status-approved: #4CC9E0;
    --color-status-settled: #43D18F;
    --color-status-rejected: #FF6B6B;
    --color-status-neutral: #8B96AC;
    --color-scrim: rgb(3 6 12 / 0.72);
    --color-skeleton: #131A27;
    --color-skeleton-sheen: #1A2333;
  }

  /* ==============================================================================================
     Additions for components (README §12.5, §12.6). NEW tokens only: no value above was changed,
     and no colour is added here (scripts/check-contrast.mjs reads every --color-* in this file).
     ============================================================================================== */
  :root {
    /* Type */
    --text-kpi: 1.75rem;  --leading-kpi: 2.25rem;  /* 28/36 KPI value */
    --hero-symbol-size: 0.65em;                    /* the muted rupee sign of the hero amount */
    --line-clamp: 2;                               /* category tile labels */
    --measure: 60ch;                               /* longest comfortable line of prose */

    /* Viewport units, with a dynamic-viewport upgrade below */
    --viewport-height: 100vh;
    --sheet-max-height: 90vh;                      /* bottom sheets */
    --palette-offset: 12vh;                        /* the command palette sits in the upper part of the screen */
    --palette-list-max: 50vh;
    --lightbox-stage-max: 100vh;

    /* Controls */
    --checkbox-size: 18px;                         /* checkbox and radio box, inside a 44 px target */
    --radio-dot: 8px;                              /* a selected radio's inner square */
    --spinner-size: 16px; --spinner-size-sm: 12px;
    --badge-size: 20px;
    --avatar-md: 32px; --avatar-sm: 24px;
    --tile-min-height: 56px;                       /* category tile */
    --textarea-lines-min: 3; --textarea-lines-max: 8;
    --kbd-size: 24px;

    /* Tables and list rows: fixed columns, so a longer value never moves its neighbours */
    --table-row-height: 52px;
    --list-row-min-height: 64px;
    --col-claim-no: 150px; --col-category: 200px; --col-date: 120px; --col-amount: 140px;
    --col-status: 200px;   --col-updated: 110px;  --col-waiting: 110px; --col-person: 220px;
    --col-count: 88px;     --col-action: 120px;   --col-text-min: 180px;

    /* Component geometry */
    --kpi-fluid-size: 10.5cqi;                     /* KPI value shrinks with its tile, capped at --text-kpi */
    --card-min-width: 280px;
    --icon-box: 32px;                              /* the square behind a file tile's remove icon */
    --rail-node: 12px;
    --empty-frame: 48px;
    --file-tile-min: 132px;
    --ratio-a4: 1 / 1.414;
    --toast-width: 360px;
    --menu-min-width: 208px; --menu-max-width: 320px;
    --tooltip-max-width: 240px;
    --sheet-handle-width: 36px; --sheet-handle-height: 4px;
    --dropzone-min-height: 148px;
    --details-term-width: 144px;
    --aside-width: 384px;                          /* the approver panel beside a claim */
    --panel-max: 480px;                            /* empty states, error panels, 404 */
    --boot-bar-width: 120px;
    --timer-height: 2px;                           /* toast timer line, upload bar, rail track */
    --scrollbar-size: 12px; --scrollbar-inset: 3px; --scrollbar-inset-hover: 2px;
    --lightbox-zoom: 2;

    /* Timing that is not a transition (§12.1 "Instant response", §12.6) */
    --delay-spinner: 150ms;          /* a spinner only appears after this, so fast actions do not flicker */
    --delay-tooltip: 400ms;          /* hover; focus shows a tooltip at once */
    --delay-boot-bar: 400ms;         /* the boot splash line appears only when loading is slow */
    --duration-saved-tick: 1200ms;   /* how long Save keeps its drawn tick */
    --duration-undo: 6000ms;         /* an Undo toast */
    --duration-indeterminate: 1200ms;/* one pass of the boot splash line (a loading loop, like the spinner) */
    --sequence-step: 120ms;          /* the success sequence's beat: 0, 120, 240, 360, 480, 600 ms */
    --sequence-notify-step: 90ms;    /* "Notified" rows, one by one */
    --duration-sequence: 900ms;      /* the whole success sequence */

    /* Layers */
    --z-skip-link: 70;

    /* Added for the views (shared-module fixes) */
    --col-action-lg: 152px;          /* an actions column whose button has an icon and a label ("Retry") */
    --meter-height: 4px;             /* a .meter track (quota and usage bars) */
    --duration-undo-max: 60000ms;    /* the longest an undoable action waits for its toast to close (10 × undo) */

    /* Added for the shell fixes (timing that is not a transition) */
    --delay-page-skeleton: 80ms;     /* a view module still loading by then: its skeleton shows (§12.1 "within 100 ms") */
    --delay-shared-paint: 100ms;     /* the longest a route change waits for a claim's travelling values to paint */
    --delay-announce: 1000ms;        /* the longest the page title's announcement waits for the view to name itself */
    --bottomnav-new-size: 32px;      /* the bottom nav's central New claim square, with its "New" label under it */
  }
  /* Reduced motion for ONE subtree: data-motion="reduced" on any element (the /dev/motion page shows full and
     reduced motion side by side). The distances and scales are declared again here with the same formulas,
     because a custom property is computed where it is declared: the :root values would not follow --motion. */
  [data-motion='reduced'] {
    --motion: 0;
    --motion-distance-sm: calc(4px * var(--motion));
    --motion-distance-md: calc(8px * var(--motion));
    --motion-distance-lg: calc(16px * var(--motion));
    --press-scale: calc(1 - 0.02 * var(--motion));
    --pop-scale: calc(1 - 0.04 * var(--motion));
  }
  @supports (height: 1dvh) {
    :root { --viewport-height: 100dvh; --sheet-max-height: 90dvh; --lightbox-stage-max: 100dvh; }
  }
}
