/*
 * ThaiNS CVE design tokens.
 * Three layers: primitive (raw values) → semantic (meaning) → component (per component).
 * Components in app.css only use semantic/component tokens, never primitives or raw hex.
 *
 * Palette: navy (brand), white/black neutrals, gold as a rare accent.
 * Gold is reserved for: brand mark, active navigation indicator, KEV badge, auth page accent.
 */

/* ---------- Fonts (self-hosted, SIL OFL — see fonts/OFL-IBM-Plex.txt) ---------- */
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-thai-thai-400-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-thai-thai-500-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-thai-thai-600-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-thai-thai-700-normal.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-thai-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-thai-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-thai-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans Thai"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-thai-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

/* ========== Layer 1: primitives ========== */
:root {
  /* Navy — brand */
  --navy-50: #f2f5fa;
  --navy-100: #e3e9f4;
  --navy-200: #c4d0e7;
  --navy-300: #95a9d0;
  --navy-400: #6481b8;
  --navy-500: #3d5f9e;
  --navy-600: #284a86;
  --navy-700: #1b386c;
  --navy-800: #132a54;
  --navy-900: #0c1d3c;
  --navy-950: #070f22;

  /* Neutrals — white to black */
  --white: #ffffff;
  --ink-25: #fbfbfc;
  --ink-50: #f5f6f8;
  --ink-100: #eceef2;
  --ink-200: #dfe2e8;
  --ink-300: #c6cad3;
  --ink-400: #9aa0ad;
  --ink-500: #6c7280;
  --ink-600: #4c5260;
  --ink-700: #353a45;
  --ink-800: #21252d;
  --ink-850: #181b21;
  --ink-900: #111317;
  --ink-950: #0a0b0d;
  --black: #000000;

  /* Gold — accent, use sparingly */
  --gold-200: #ecdcb2;
  --gold-300: #ddc283;
  --gold-400: #cda85a;
  --gold-500: #b8913d;
  --gold-600: #96742c;

  /* Status */
  --red-50: #fdf0f0;
  --red-300: #f19b9b;
  --red-500: #d93a3a;
  --red-600: #b42323;
  --red-700: #921a1a;
  --amber-50: #fdf5ea;
  --amber-300: #f2b46b;
  --amber-500: #d97a10;
  --amber-600: #b4600a;
  --green-50: #edf7f0;
  --green-300: #86cfa0;
  --green-600: #1d7d3e;
  --blue-50: #eef3fd;
  --blue-300: #9dbaf2;
  --blue-600: #2456c7;

  /* Type */
  --font-sans: "IBM Plex Sans Thai", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --leading-tight: 1.25;
  --leading-normal: 1.6;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --tracking-wide: 0.06em;

  /* Spacing (4px grid) */
  --space-0-5: 0.125rem;
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

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

  /* Elevation */
  --shadow-xs: 0 1px 2px rgb(10 11 13 / 0.05);
  --shadow-sm: 0 1px 3px rgb(10 11 13 / 0.07), 0 1px 2px rgb(10 11 13 / 0.04);
  --shadow-md: 0 6px 16px rgb(10 11 13 / 0.08), 0 2px 4px rgb(10 11 13 / 0.04);
  --shadow-lg: 0 18px 40px rgb(7 15 34 / 0.18);

  /* Motion */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Layout */
  --sidebar-width: 248px;
  --content-max: 1240px;
  --control-height: 38px;
  --control-height-sm: 30px;
  --size-icon-button: 34px;
  --size-checkbox: 16px;
  --width-auth: 440px;
  --width-auth-wide: 520px;
  --width-form: 560px;
  --width-settings: 760px;
  --width-test-input: 280px;
  --width-sub-text: 160px;
  --height-suggest: 340px;
  --offset-suggest: 68px;
  /* Breakpoints (documented here; media queries must use literals): tablet 960px, phone 560px */
}

/* ========== Layer 2: semantic (light) ========== */
:root {
  color-scheme: light;

  --color-bg: var(--ink-50);
  --color-surface: var(--white);
  --color-surface-muted: var(--ink-25);
  --color-surface-sunken: var(--ink-100);
  --color-border: var(--ink-200);
  --color-border-strong: var(--ink-300);

  --color-text: var(--ink-950);
  --color-text-secondary: var(--ink-600);
  --color-text-muted: var(--ink-500);
  --color-text-inverse: var(--white);

  --color-primary: var(--navy-800);
  --color-primary-hover: var(--navy-700);
  --color-primary-active: var(--navy-900);
  --color-primary-soft: var(--navy-50);
  --color-primary-soft-border: var(--navy-200);
  --color-primary-text: var(--white);
  --color-link: var(--navy-600);
  --color-link-hover: var(--navy-800);
  --color-focus-ring: rgb(40 74 134 / 0.35);

  --color-accent: var(--gold-500);
  --color-accent-strong: var(--gold-600);
  --color-accent-soft: var(--gold-300);

  --color-critical: var(--red-600);
  --color-critical-soft: var(--red-50);
  --color-high: var(--amber-600);
  --color-high-soft: var(--amber-50);
  --color-info: var(--ink-500);
  --color-info-soft: var(--ink-100);
  --color-success: var(--green-600);
  --color-success-soft: var(--green-50);
  --color-notice: var(--blue-600);
  --color-notice-soft: var(--blue-50);

  --color-chrome-bg: var(--navy-900);
  --color-chrome-bg-raised: var(--navy-800);
  --color-chrome-border: rgb(255 255 255 / 0.08);
  --color-chrome-text: var(--navy-100);
  --color-chrome-text-muted: var(--navy-300);
  --color-chrome-text-active: var(--white);
}

/* ========== Layer 2: semantic (dark) ========== */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --color-bg: var(--ink-950);
    --color-surface: var(--ink-900);
    --color-surface-muted: var(--ink-850);
    --color-surface-sunken: var(--ink-850);
    --color-border: var(--ink-800);
    --color-border-strong: var(--ink-700);

    --color-text: var(--ink-50);
    --color-text-secondary: var(--ink-300);
    --color-text-muted: var(--ink-400);
    --color-text-inverse: var(--ink-950);

    --color-primary: var(--navy-500);
    --color-primary-hover: var(--navy-400);
    --color-primary-active: var(--navy-600);
    --color-primary-soft: rgb(61 95 158 / 0.16);
    --color-primary-soft-border: rgb(100 129 184 / 0.35);
    --color-primary-text: var(--white);
    --color-link: var(--navy-300);
    --color-link-hover: var(--navy-200);
    --color-focus-ring: rgb(149 169 208 / 0.4);

    --color-accent: var(--gold-400);
    --color-accent-strong: var(--gold-300);
    --color-accent-soft: var(--gold-600);

    --color-critical: var(--red-500);
    --color-critical-soft: rgb(217 58 58 / 0.14);
    --color-high: var(--amber-500);
    --color-high-soft: rgb(217 122 16 / 0.14);
    --color-info: var(--ink-400);
    --color-info-soft: var(--ink-850);
    --color-success: var(--green-300);
    --color-success-soft: rgb(29 125 62 / 0.18);
    --color-notice: var(--blue-300);
    --color-notice-soft: rgb(36 86 199 / 0.16);

    --color-chrome-bg: var(--navy-950);
    --color-chrome-bg-raised: var(--navy-900);
    --color-chrome-border: rgb(255 255 255 / 0.06);
  }
}

/* ========== Layer 3: component tokens ========== */
:root {
  /* Page */
  --page-bg: var(--color-bg);
  --page-padding-x: var(--space-8);
  --page-padding-y: var(--space-8);

  /* Sidebar / app chrome */
  --sidebar-bg: var(--color-chrome-bg);
  --sidebar-border: var(--color-chrome-border);
  --sidebar-text: var(--color-chrome-text);
  --sidebar-text-muted: var(--color-chrome-text-muted);
  --sidebar-item-hover-bg: rgb(255 255 255 / 0.06);
  --sidebar-item-active-bg: var(--color-chrome-bg-raised);
  --sidebar-item-active-text: var(--color-chrome-text-active);
  --sidebar-item-indicator: var(--color-accent);
  --brand-mark-fill: var(--navy-700);
  --brand-mark-stroke: var(--color-accent);

  /* Card */
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-radius: var(--radius-lg);
  --card-padding: var(--space-6);
  --card-shadow: var(--shadow-xs);

  /* Button */
  --button-height: var(--control-height);
  --button-radius: var(--radius-md);
  --button-padding-x: var(--space-4);
  --button-bg: var(--color-surface);
  --button-border: var(--color-border-strong);
  --button-text: var(--color-text);
  --button-hover-bg: var(--color-surface-sunken);
  --button-primary-bg: var(--color-primary);
  --button-primary-hover-bg: var(--color-primary-hover);
  --button-primary-active-bg: var(--color-primary-active);
  --button-primary-text: var(--color-primary-text);
  --button-danger-text: var(--color-critical);
  --button-danger-border: var(--color-critical);
  --button-danger-hover-bg: var(--color-critical-soft);

  /* Input */
  --input-height: var(--control-height);
  --input-bg: var(--color-surface);
  --input-border: var(--color-border-strong);
  --input-border-hover: var(--color-text-muted);
  --input-border-focus: var(--color-primary);
  --input-radius: var(--radius-md);
  --input-placeholder: var(--color-text-muted);

  /* Table */
  --table-header-text: var(--color-text-muted);
  --table-row-border: var(--color-border);
  --table-row-hover-bg: var(--color-surface-muted);

  /* Badges */
  --badge-radius: var(--radius-full);
  --badge-kev-bg: var(--ink-950);
  --badge-kev-text: var(--gold-300);
  --badge-kev-border: var(--gold-600);

  /* QR code must stay black-on-white to scan */
  --qr-bg: var(--white);

  /* Auth screen */
  --auth-bg: var(--navy-950);
  --auth-bg-glow: rgb(40 74 134 / 0.45);
  --auth-accent: var(--color-accent);
}
