/* ── Design tokens (CLAUDE.md 32): the only place colours, spacing, type, radius, z-index and motion are defined ── */
/* Theme: no data-theme = follow the system (PrefTheme 0); data-theme="light" (1) or "dark" (2) forces one. */
/* Tenant branding overrides only --color-accent, from ajax/getTenantStyle.php (spec m05 D4). */
/* UX-1 (2026-10-14): enterprise scale; every earlier token name kept. Guide: docs/standards/ui_enhancements.md */

:root {
  /* native controls (file button, scrollbars, autofill) follow the theme */
  color-scheme: light;

  /* brand: government blue, with a deep navy for the shell and the sign-in panel */
  --color-primary: #1F4E9A;
  --color-primary-hover: #183E7B;
  --color-primary-active: #12315F;
  --color-primary-soft: #EBF1FB;
  --color-primary-soft-strong: #D3E1F6;
  --color-on-primary: #FFFFFF;
  /* text on the accent; an Authority's own accent sets white or dark ink */
  --color-on-accent: var(--color-on-primary);
  --color-accent: #1F4E9A;
  --color-brand-deep: #0E2340;
  --color-brand-deep-2: #17386A;
  --color-brand-glow: rgba(96, 165, 250, 0.22);
  --color-brand-dot: rgba(255, 255, 255, 0.07);
  --color-brand-line: rgba(255, 255, 255, 0.14);

  /* surfaces and text */
  --color-bg: #F3F5F8;
  --color-surface: #FFFFFF;
  --color-surface-2: #F7F9FB;
  --color-surface-3: #EEF2F6;
  --color-border: #E2E7EE;
  --color-border-strong: #C9D2DD;
  --color-border-hover: #9DAABB;
  --color-border-input: #7C8899; /* a field's edge: at least 3:1 on surface and surface-2 (WCAG 1.4.11) */
  --color-border-input-hover: #5F6B7C;
  --color-text: #16202C;
  --color-text-muted: #556172;
  --color-text-subtle: #626E80;
  --color-link: #1F4E9A;
  --color-focus: #1F4E9A;
  --color-focus-ring: rgba(31, 78, 154, 0.28);
  --color-overlay: rgba(14, 24, 38, 0.55);
  --color-skeleton: #E4E8EE;

  /* app shell: navy side menu in both themes */
  --color-nav-bg: #0E2340;
  --color-nav-text: #C3D0E2;
  --color-nav-title: #7F93B0;
  --color-nav-hover: rgba(255, 255, 255, 0.06);
  --color-nav-active: rgba(255, 255, 255, 0.11);
  --color-nav-active-text: #FFFFFF;
  --color-nav-indicator: #60A5FA;
  --color-nav-line: rgba(255, 255, 255, 0.08);
  --color-topbar-bg: rgba(255, 255, 255, 0.85); /* translucent surface: the page shows blurred under the sticky top bar */
  --color-topbar-solid: #FFFFFF; /* the same surface, opaque: no backdrop-filter, reduced transparency, print */
  --glass-blur: saturate(180%) blur(10px);
  --glass-blur-soft: blur(3px); /* popup backdrop */

  /* semantic (text on its own background meets WCAG AA) */
  --color-success: #1B6E3A;
  --color-success-bg: #E7F5EC;
  --color-warning: #8A5300;
  --color-warning-bg: #FFF5E1;
  --color-danger: #B42318;
  --color-danger-bg: #FDEDEB;
  --color-info: #1F4E9A;
  --color-info-bg: #EBF1FB;
  --color-neutral: #46505D;
  --color-neutral-bg: #EDF0F4;
  --color-on-danger: #FFFFFF;
  --color-danger-strong: #912018;

  /* lists and disabled controls */
  --color-table-head: #F1F4F8;
  /* header row text, line, sort arrows and focus: the page's own colours unless the tenant style sets them */
  --color-table-head-text: var(--color-text-muted);
  --color-table-head-hover: var(--color-text);
  --color-table-head-line: var(--color-border-strong);
  --color-table-head-sort: var(--color-link);
  --color-table-head-sort-idle: var(--color-text-subtle);
  --color-table-head-focus: var(--color-focus);
  --color-row-hover: #F5F8FC;
  --color-disabled-bg: #EEF2F6;
  --color-disabled-border: #E2E7EE;
  --color-disabled-text: #8A95A5;

  /* spacing: 4px base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* type */
  --font-sans: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  --fs-3xl: 36px;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --lh-base: 1.5;
  --lh-tight: 1.25;
  --lh-devanagari: 1.6;
  --ls-tight: -0.011em;
  --ls-caps: 0.04em;

  /* elevation: soft, layered */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 4px 10px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-3: 0 20px 40px -8px rgba(16, 24, 40, 0.20), 0 8px 16px -6px rgba(16, 24, 40, 0.10);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-btn: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-btn-hover: 0 2px 4px -1px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
  --color-scroll-edge: rgba(16, 24, 40, 0.22); /* shadow on a table edge with columns beyond it */
  --color-print-ink: #111827; /* print is always dark text on white, whatever the theme (not set in the dark blocks) */
  --color-print-paper: #FFFFFF;
  --color-print-line: #C9D1DC;

  /* z-index */
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-nav: 1150;
  --z-overlay: 1200;
  --z-popup: 1300;
  --z-toast: 1400;

  /* motion (switched off under prefers-reduced-motion in base.css) */
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --toast-ms: 5000; /* read by common.js: how long a toast stays */

  /* sizes and density (comfortable) */
  --control-h: 40px; /* base controls at least 40px (docs/standards/ux_principles.md §3) */
  --control-h-lg: 44px;
  --control-h-sm: 30px;
  --control-px: 12px;
  --cell-py: 12px;
  --cell-px: 16px;
  --card-p: var(--space-5);
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --content-max-w: 1600px;
  --focus-ring: 0 0 0 3px var(--color-focus-ring);
  --popup-small-w: 460px;
  --popup-medium-w: 720px;
  --card-narrow-w: 680px;
  --form-max-w: 960px;
  --form-index-w: 220px;
  --table-max-h: max(320px, calc(100vh - var(--topbar-h) - 96px)); /* list table box: scrolls inside, header stays on top */
  --auth-card-w: 440px;
}

:root[data-density="compact"] {
  --control-h: 32px;
  --control-h-sm: 28px;
  --control-px: 10px;
  --cell-py: 7px;
  --cell-px: 12px;
  --card-p: var(--space-4);
}

/* Devanagari matras clip at 12px: the smallest Hindi text is one step up */
:root:lang(hi) {
  --fs-xs: 13px;
}

/* A+ larger text (ux_principles §3; scripts/textsize.js): one type step up and taller controls; layout rules unchanged */
:root[data-text-size="large"] {
  --fs-xs: 14px;
  --fs-sm: 15px;
  --fs-base: 16px;
  --fs-md: 18px;
  --fs-lg: 20px;
  --fs-xl: 27px;
  --fs-2xl: 33px;
  --control-h: 44px;
  --control-h-sm: 34px;
  --control-h-lg: 48px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-primary: #3D6FC4;
    --color-primary-hover: #335FAE;
    --color-primary-active: #2B5299;
    --color-primary-soft: #16294A;
    --color-primary-soft-strong: #1E3863;
    --color-on-primary: #FFFFFF;
    --color-accent: #4C7FD4;
    --color-brand-deep: #0A1A31;
    --color-brand-deep-2: #12305C;
    --color-bg: #0D141D;
    --color-surface: #141D28;
    --color-surface-2: #182230;
    --color-surface-3: #1E2A39;
    --color-border: #263345;
    --color-border-strong: #364659;
    --color-border-hover: #4E6179;
    --color-border-input: #64748B;
    --color-border-input-hover: #7D8DA3;
    --color-text: #E6EAF0;
    --color-text-muted: #9EAABA;
    --color-text-subtle: #8794A5;
    --color-link: #8AB4F8;
    --color-focus: #8AB4F8;
    --color-focus-ring: rgba(138, 180, 248, 0.35);
    --color-overlay: rgba(0, 0, 0, 0.62);
    --color-skeleton: #243140;
    --color-nav-bg: #0A1422;
    --color-nav-text: #B3C1D4;
    --color-nav-title: #6E819C;
    --color-success: #6FCF97;
    --color-success-bg: #12301F;
    --color-warning: #F5B94A;
    --color-warning-bg: #3A2A0C;
    --color-danger: #F28B82;
    --color-danger-bg: #3B1512;
    --color-info: #8AB4F8;
    --color-info-bg: #16294A;
    --color-neutral: #C3CCD8;
    --color-neutral-bg: #243142;
    --color-on-danger: #2A0B08;
    --color-danger-strong: #F5A39C;
    --color-table-head: #1A2432;
    --color-row-hover: #1A2533;
    --color-disabled-bg: #1A2431;
    --color-disabled-border: #263345;
    --color-disabled-text: #6E7B8C;
    --color-topbar-bg: rgba(20, 29, 40, 0.85);
    --color-topbar-solid: #141D28;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-3: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-btn-hover: 0 2px 6px rgba(0, 0, 0, 0.45);
    --color-scroll-edge: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #3D6FC4;
  --color-primary-hover: #335FAE;
  --color-primary-active: #2B5299;
  --color-primary-soft: #16294A;
  --color-primary-soft-strong: #1E3863;
  --color-on-primary: #FFFFFF;
  --color-accent: #4C7FD4;
  --color-brand-deep: #0A1A31;
  --color-brand-deep-2: #12305C;
  --color-bg: #0D141D;
  --color-surface: #141D28;
  --color-surface-2: #182230;
  --color-surface-3: #1E2A39;
  --color-border: #263345;
  --color-border-strong: #364659;
  --color-border-hover: #4E6179;
  --color-border-input: #64748B;
  --color-border-input-hover: #7D8DA3;
  --color-text: #E6EAF0;
  --color-text-muted: #9EAABA;
  --color-text-subtle: #8794A5;
  --color-link: #8AB4F8;
  --color-focus: #8AB4F8;
  --color-focus-ring: rgba(138, 180, 248, 0.35);
  --color-overlay: rgba(0, 0, 0, 0.62);
  --color-skeleton: #243140;
  --color-nav-bg: #0A1422;
  --color-nav-text: #B3C1D4;
  --color-nav-title: #6E819C;
  --color-success: #6FCF97;
  --color-success-bg: #12301F;
  --color-warning: #F5B94A;
  --color-warning-bg: #3A2A0C;
  --color-danger: #F28B82;
  --color-danger-bg: #3B1512;
  --color-info: #8AB4F8;
  --color-info-bg: #16294A;
  --color-neutral: #C3CCD8;
  --color-neutral-bg: #243142;
  --color-on-danger: #2A0B08;
  --color-danger-strong: #F5A39C;
  --color-table-head: #1A2432;
  --color-row-hover: #1A2533;
  --color-disabled-bg: #1A2431;
  --color-disabled-border: #263345;
  --color-disabled-text: #6E7B8C;
  --color-topbar-bg: rgba(20, 29, 40, 0.85);
  --color-topbar-solid: #141D28;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 20px 40px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-btn-hover: 0 2px 6px rgba(0, 0, 0, 0.45);
  --color-scroll-edge: rgba(0, 0, 0, 0.55);
}
