/* ==========================================================================
   GameBuddy prototype - design tokens (FOUNDATION owns this file)

   PALETTE SAMPLED FROM reference/fintrack.png (994x722, System.Drawing GetPixel,
   flat-area averages; text colors are the brightest glyph pixel, so real text is a
   little brighter than the sample because the capture is downscaled ~0.69):

     outer backdrop (launcher frame)      #414141
     sidebar surface / kanban column      #0F0F0F   (sunken level)
     main canvas = KPI card = inner card  #131313   (base level)
     active nav pill / user card / search #181818   (raised level)
     active tab pill                      #1E1E1E   (active level)
     keycap                               #292929
     hairline border (peak)               #222222..#262626  (1px, ~rgba(255,255,255,.08))
     subtle border (column, sidebar)      #1C1C1C
     strong divider (search | actions)    #343434
     progress track                       #2A2A2A
     text: title/value #FFFFFF, nav #CCCCCC..#D5D5D5, subtitle/labels #AAAAAA..#BEBEBE,
           muted category/title #858585..#8E8E8E, email #A6A6A6
     primary button gradient              top #667EF6 -> mid #4565F0 -> bottom #2052FC
                                          (top edge highlight #7B9AFD, bottom edge #2645C4)
     sidebar tiles                        blue #205DDF (#516DE0 -> #1B5ACF), orange #EA7120 -> #D96217,
                                          green #1C9C48, white #F3F3F3 -> #E2E2E2
     notification dot / orange KPI icon   #EB5D06
     green solid (progress, tile)         #12AA4C / #19A449
     green delta text                     #4AC87B (brightest pixel, real ~#4ADE80)
     purple progress                      #7539E3
     orange-red progress                  #E94614
     dot-matrix highlight                 orange, off dots ~#555
     chip backgrounds                     ~10-14% alpha tints of the tone color over #131313

   Geometry measured in reference pixels and divided by the capture scale 0.6903 (994px image of a ~1440px screen):
     window radius 14, card radius 12, inner card 10, buttons/inputs 8, nav pill 10,
     sidebar 280 (284 measured), topbar 58 (59 measured), controls 34 (topbar buttons) / 40 (section bar),
     KPI value 36px, page + section title 17px, kanban amount 20px, card title 15px, sidebar items 15px,
     labels / tabs / captions 14px, chips 11px, card footer 11px, base text 14px.
     (Implied font sizes were derived by matching measured text widths with Inter metrics; they cluster at
     11 / 12 / 14 / 15 / 17 / 20 / 36 px.)

   RULES
   - Every color is a custom property. :root holds LIGHT values.
   - The DARK values exist twice (media query + data-theme="dark") and MUST stay identical.
     tools-free check: both blocks are copy-pasted; keep them in sync when editing.
   - Accent colors come from :root[data-accent="blue|violet|green|orange"] (blue is default).
   - Platform classes use the pd- prefix. Do not add module tokens here; module CSS may define
     its own custom properties under its module prefix (--st-*, --pl-* ...).
   ========================================================================== */

:root {
  color-scheme: light;

  /* ---------- typography ---------- */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-base: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 20px;
  --fs-3xl: 24px;
  --fs-nav: 15px;
  --fs-title: 17px;
  --fs-kpi: 36px;
  --fs-hero: 40px;
  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-base: 1.5;

  /* ---------- radii ---------- */
  --r-window: 14px;
  --r-card: 12px;
  --r-inner: 10px;
  --r-btn: 8px;
  --r-input: 8px;
  --r-chip: 6px;
  --r-pill: 999px;

  /* ---------- spacing (4px grid) ---------- */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ---------- layout ---------- */
  --sidebar-w: 280px;
  --sidebar-w-rail: 72px;
  --topbar-h: 58px;
  --titlebar-h: 40px;
  --tabbar-h: 60px;
  --page-pad: 24px;
  --control-h-sm: 28px;
  --control-h: 34px;
  --control-h-lg: 40px;

  /* ---------- motion ---------- */
  --dur-1: 100ms;
  --dur-2: 160ms;
  --dur-3: 200ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* ---------- z-index ---------- */
  --z-sticky: 10;
  --z-topbar: 20;
  --z-sidebar: 40;
  --z-scrim: 45;
  --z-overlay: 100;
  --z-modal: 110;
  --z-pop: 130;
  --z-toast: 150;
  --z-tooltip: 160;

  /* ---------- surfaces (LIGHT) ---------- */
  --bg-backdrop: #cdd0d6;
  --bg-sunken: #f2f2f4;
  --bg-canvas: #fafafb;
  --bg-surface: #ffffff;
  --bg-raised: #ffffff;
  --bg-hover: #f0f0f3;
  --bg-active: #ebebef;
  --bg-input: #ffffff;
  --bg-popover: #ffffff;
  --bg-overlay: rgba(14, 14, 20, .46);
  --bg-keycap: #ececf0;
  --bg-seg-active: #ffffff;
  --bg-track: #e7e7ec;
  --bg-skeleton: rgba(14, 14, 20, .07);
  --bg-inverse: #131313;

  /* ---------- borders (LIGHT) ---------- */
  --border: #e2e2e8;
  --border-subtle: #ececf0;
  --border-strong: #c9c9d2;

  /* ---------- text (LIGHT) ---------- */
  --text: #0e0e12;
  --text-2: #33333b;
  --text-3: #5a5a66;
  --text-4: #686874;
  --text-inverse: #ffffff;

  /* ---------- shadows (LIGHT) ---------- */
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .06);
  --shadow-md: 0 4px 14px rgba(16, 16, 24, .08), 0 1px 3px rgba(16, 16, 24, .06);
  --shadow-lg: 0 18px 48px rgba(16, 16, 24, .18), 0 2px 8px rgba(16, 16, 24, .08);
  --shadow-window: 0 24px 64px rgba(16, 16, 24, .22), 0 0 0 1px rgba(16, 16, 24, .06);
  --shadow-key: 0 1px 0 rgba(16, 16, 24, .08);

  /* ---------- status tones (LIGHT): solid = fills/bars, text = chip text, bg = chip tint ---------- */
  --green-solid: #16a34a;   --green-text: #166534;   --green-bg: rgba(22, 163, 74, .12);   --green-border: rgba(22, 163, 74, .26);
  --red-solid: #e5343d;     --red-text: #b91c2c;     --red-bg: rgba(229, 52, 61, .10);     --red-border: rgba(229, 52, 61, .26);
  --amber-solid: #f0a020;   --amber-text: #8a4d00;   --amber-bg: rgba(240, 160, 32, .16);  --amber-border: rgba(200, 120, 0, .30);
  --purple-solid: #7a3cf0;  --purple-text: #6a3fd8;  --purple-bg: rgba(122, 60, 240, .10); --purple-border: rgba(122, 60, 240, .26);
  --blue-solid: #3b63f5;    --blue-text: #2f55d4;    --blue-bg: rgba(59, 99, 245, .10);    --blue-border: rgba(59, 99, 245, .26);
  --orange-solid: #ec5a12;  --orange-text: #a3410a;  --orange-bg: rgba(236, 90, 18, .11);  --orange-border: rgba(236, 90, 18, .28);
  --gray-solid: #8d8d99;    --gray-text: #52525c;    --gray-bg: rgba(60, 60, 80, .08);     --gray-border: rgba(60, 60, 80, .18);

  /* ---------- icon tiles (sidebar / KPI): gradient fills, white glyph ---------- */
  --tile-blue: linear-gradient(180deg, #4a6ee8 0%, #2259dc 55%, #1b52cc 100%);
  --tile-orange: linear-gradient(180deg, #f07f2e 0%, #e26a1c 55%, #d96217 100%);
  --tile-green: linear-gradient(180deg, #2eb25f 0%, #1d9e4a 55%, #178a40 100%);
  --tile-violet: linear-gradient(180deg, #9577f6 0%, #7a55f0 55%, #6a44e0 100%);
  --tile-red: linear-gradient(180deg, #f2646b 0%, #e5343d 60%, #d02832 100%);
  --tile-amber: linear-gradient(180deg, #f7b744 0%, #f0a020 60%, #e08e10 100%);
  --tile-gray: linear-gradient(180deg, #8d8d99 0%, #70707c 100%);
  --tile-white: linear-gradient(180deg, #ffffff 0%, #e6e6ea 100%);
  --tile-white-fg: #1b1b20;

  /* ---------- charts ---------- */
  --dot-off: rgba(14, 14, 20, .24);
  --bar-off: rgba(14, 14, 20, .12);
  --chart-grid: rgba(14, 14, 20, .09);
  --chart-axis: #686874;

  /* ---------- accent: derived (LIGHT) ---------- */
  --accent-text: var(--accent-text-l);
  --accent-soft: rgb(var(--accent-rgb) / .10);
  --accent-soft-2: rgb(var(--accent-rgb) / .18);
  --accent-ring: rgb(var(--accent-rgb) / .35);
  --focus: var(--accent);
  --focus-ring: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--accent);
  --selection: rgb(var(--accent-rgb) / .22);
  --link: var(--accent-text);
}

/* ---------- fixed palettes (theme independent): accent swatches in Settings, window controls of the Launcher frame ---------- */
:root {
  --sw-blue: #3d66fb;
  --sw-violet: #7554f0;
  --sw-green: #22c55e;
  --sw-orange: #f97316;
  --wc-close: #ff5f57;
  --wc-min: #febc2e;
  --wc-max: #28c840;
  /* a QR code is always dark modules on a light tile, in both themes: many scanners fail on inverted codes */
  --qr-bg: #ffffff;
  --qr-fg: #0b0b0c;
}
/* ---------- accent colors (blue is the default; theme independent) ---------- */
:root,
:root[data-accent="blue"] {
  --accent: #3d66fb;
  --accent-top: #4d6cfc;
  --accent-bottom: #2552fb;
  --accent-edge: #2645c4;
  --accent-hi: rgba(255, 255, 255, .34);
  --accent-rgb: 61 102 251;
  --accent-fg: #ffffff;
  --accent-text-d: #8fa6ff;
  --accent-text-l: #2745c5;
}
:root[data-accent="violet"] {
  --accent: #7554f0;
  --accent-top: #7a5af2;
  --accent-bottom: #6240e2;
  --accent-edge: #4d30b8;
  --accent-hi: rgba(255, 255, 255, .34);
  --accent-rgb: 117 84 240;
  --accent-fg: #ffffff;
  --accent-text-d: #b8a0ff;
  --accent-text-l: #5936cf;
}
:root[data-accent="green"] {
  --accent: #22c55e;
  --accent-top: #3ad474;
  --accent-bottom: #17a84c;
  --accent-edge: #0f8a3b;
  --accent-hi: rgba(255, 255, 255, .38);
  --accent-rgb: 34 197 94;
  --accent-fg: #04210f;
  --accent-text-d: #4ade80;
  --accent-text-l: #166534;
}
:root[data-accent="orange"] {
  --accent: #f97316;
  --accent-top: #fb8a3c;
  --accent-bottom: #ea5f0a;
  --accent-edge: #c24a05;
  --accent-hi: rgba(255, 255, 255, .38);
  --accent-rgb: 249 115 22;
  --accent-fg: #1c0b02;
  --accent-text-d: #ffa066;
  --accent-text-l: #9c3a04;
}

/* ==========================================================================
   DARK theme values (first copy: follows the OS when no explicit choice exists)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg-backdrop: #414141;
    --bg-sunken: #0f0f0f;
    --bg-canvas: #131313;
    --bg-surface: #131313;
    --bg-raised: #181818;
    --bg-hover: #1c1c1c;
    --bg-active: #1e1e1e;
    --bg-input: #161616;
    --bg-popover: #181818;
    --bg-overlay: rgba(0, 0, 0, .62);
    --bg-keycap: #292929;
    --bg-seg-active: #1e1e1e;
    --bg-track: #2a2a2a;
    --bg-skeleton: rgba(255, 255, 255, .07);
    --bg-inverse: #f4f4f5;

    --border: #242424;
    --border-subtle: #1c1c1c;
    --border-strong: #343434;

    --text: #ffffff;
    --text-2: #d0d0d0;
    --text-3: #aaaaaa;
    --text-4: #969696;
    --text-inverse: #0e0e12;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 22px 56px rgba(0, 0, 0, .6), 0 2px 10px rgba(0, 0, 0, .5);
    --shadow-window: 0 24px 64px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-key: 0 1px 0 rgba(0, 0, 0, .5);

    --green-solid: #18a84b;   --green-text: #4ade80;   --green-bg: rgba(74, 222, 128, .12);   --green-border: rgba(74, 222, 128, .24);
    --red-solid: #ef4444;     --red-text: #ff6b76;     --red-bg: rgba(255, 90, 100, .14);    --red-border: rgba(255, 90, 100, .28);
    --amber-solid: #f5a524;   --amber-text: #f6b042;   --amber-bg: rgba(245, 165, 36, .13);  --amber-border: rgba(245, 165, 36, .26);
    --purple-solid: #7a3cf0;  --purple-text: #b197fc;  --purple-bg: rgba(139, 92, 246, .16); --purple-border: rgba(139, 92, 246, .30);
    --blue-solid: #3d62f4;    --blue-text: #8aa4ff;    --blue-bg: rgba(80, 112, 237, .16);   --blue-border: rgba(80, 112, 237, .30);
    --orange-solid: #ee5b16;  --orange-text: #ff8a4c;  --orange-bg: rgba(238, 91, 22, .15);  --orange-border: rgba(238, 91, 22, .30);
    --gray-solid: #6a6a6a;    --gray-text: #b0b0b0;    --gray-bg: rgba(255, 255, 255, .07);  --gray-border: rgba(255, 255, 255, .12);

    --tile-blue: linear-gradient(180deg, #4a6ee8 0%, #225ed8 55%, #1b5acf 100%);
    --tile-orange: linear-gradient(180deg, #ee7a2a 0%, #e26a1c 55%, #d96217 100%);
    --tile-green: linear-gradient(180deg, #27a557 0%, #1d9e4a 55%, #178a40 100%);
    --tile-violet: linear-gradient(180deg, #8c6df5 0%, #7554f0 55%, #6240e2 100%);
    --tile-red: linear-gradient(180deg, #f2646b 0%, #e5343d 60%, #cf2631 100%);
    --tile-amber: linear-gradient(180deg, #f7b744 0%, #f0a020 60%, #e08e10 100%);
    --tile-gray: linear-gradient(180deg, #5a5a5a 0%, #444444 100%);
    --tile-white: linear-gradient(180deg, #f6f6f6 0%, #e2e2e2 100%);
    --tile-white-fg: #1b1b1b;

    --dot-off: rgba(255, 255, 255, .28);
    --bar-off: rgba(255, 255, 255, .17);
    --chart-grid: rgba(255, 255, 255, .07);
    --chart-axis: #8a8a8a;

    --accent-text: var(--accent-text-d);
    --accent-soft: rgb(var(--accent-rgb) / .16);
    --accent-soft-2: rgb(var(--accent-rgb) / .26);
    --accent-ring: rgb(var(--accent-rgb) / .45);
    --focus: var(--accent-text);
    --focus-ring: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--accent-text);
    --selection: rgb(var(--accent-rgb) / .35);
    --link: var(--accent-text);
  }
}

/* ==========================================================================
   DARK theme values (second copy: explicit data-theme="dark"; IDENTICAL to the block above)
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-backdrop: #414141;
  --bg-sunken: #0f0f0f;
  --bg-canvas: #131313;
  --bg-surface: #131313;
  --bg-raised: #181818;
  --bg-hover: #1c1c1c;
  --bg-active: #1e1e1e;
  --bg-input: #161616;
  --bg-popover: #181818;
  --bg-overlay: rgba(0, 0, 0, .62);
  --bg-keycap: #292929;
  --bg-seg-active: #1e1e1e;
  --bg-track: #2a2a2a;
  --bg-skeleton: rgba(255, 255, 255, .07);
  --bg-inverse: #f4f4f5;

  --border: #242424;
  --border-subtle: #1c1c1c;
  --border-strong: #343434;

  --text: #ffffff;
  --text-2: #d0d0d0;
  --text-3: #aaaaaa;
  --text-4: #969696;
  --text-inverse: #0e0e12;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 22px 56px rgba(0, 0, 0, .6), 0 2px 10px rgba(0, 0, 0, .5);
  --shadow-window: 0 24px 64px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-key: 0 1px 0 rgba(0, 0, 0, .5);

  --green-solid: #18a84b;   --green-text: #4ade80;   --green-bg: rgba(74, 222, 128, .12);   --green-border: rgba(74, 222, 128, .24);
  --red-solid: #ef4444;     --red-text: #ff6b76;     --red-bg: rgba(255, 90, 100, .14);    --red-border: rgba(255, 90, 100, .28);
  --amber-solid: #f5a524;   --amber-text: #f6b042;   --amber-bg: rgba(245, 165, 36, .13);  --amber-border: rgba(245, 165, 36, .26);
  --purple-solid: #7a3cf0;  --purple-text: #b197fc;  --purple-bg: rgba(139, 92, 246, .16); --purple-border: rgba(139, 92, 246, .30);
  --blue-solid: #3d62f4;    --blue-text: #8aa4ff;    --blue-bg: rgba(80, 112, 237, .16);   --blue-border: rgba(80, 112, 237, .30);
  --orange-solid: #ee5b16;  --orange-text: #ff8a4c;  --orange-bg: rgba(238, 91, 22, .15);  --orange-border: rgba(238, 91, 22, .30);
  --gray-solid: #6a6a6a;    --gray-text: #b0b0b0;    --gray-bg: rgba(255, 255, 255, .07);  --gray-border: rgba(255, 255, 255, .12);

  --tile-blue: linear-gradient(180deg, #4a6ee8 0%, #225ed8 55%, #1b5acf 100%);
  --tile-orange: linear-gradient(180deg, #ee7a2a 0%, #e26a1c 55%, #d96217 100%);
  --tile-green: linear-gradient(180deg, #27a557 0%, #1d9e4a 55%, #178a40 100%);
  --tile-violet: linear-gradient(180deg, #8c6df5 0%, #7554f0 55%, #6240e2 100%);
  --tile-red: linear-gradient(180deg, #f2646b 0%, #e5343d 60%, #cf2631 100%);
  --tile-amber: linear-gradient(180deg, #f7b744 0%, #f0a020 60%, #e08e10 100%);
  --tile-gray: linear-gradient(180deg, #5a5a5a 0%, #444444 100%);
  --tile-white: linear-gradient(180deg, #f6f6f6 0%, #e2e2e2 100%);
  --tile-white-fg: #1b1b1b;

  --dot-off: rgba(255, 255, 255, .28);
  --bar-off: rgba(255, 255, 255, .17);
  --chart-grid: rgba(255, 255, 255, .07);
  --chart-axis: #8a8a8a;

  --accent-text: var(--accent-text-d);
  --accent-soft: rgb(var(--accent-rgb) / .16);
  --accent-soft-2: rgb(var(--accent-rgb) / .26);
  --accent-ring: rgb(var(--accent-rgb) / .45);
  --focus: var(--accent-text);
  --focus-ring: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--accent-text);
  --selection: rgb(var(--accent-rgb) / .35);
  --link: var(--accent-text);
}

/* explicit light (also resets when the OS is dark but the user chose light) */
:root[data-theme="light"] {
  color-scheme: light;
}
