/*
 * Design tokens — the single source of truth for theme values.
 *
 * All colors, type sizes, spacing, radii and shadows are defined here as CSS
 * custom properties. Components MUST reference these variables instead of
 * hard-coded values so themes stay switchable.
 *
 * The light palette follows FeedMob's brand guidelines. Dark mode uses
 * neutral charcoal/graphite surfaces; teal is reserved for primary actions
 * and brand artwork. Semantic accents remain distinct and readable.
 *
 * The root palette is light by default. Stored Light/Dark choices pin their
 * palette; without an override, prefers-color-scheme selects and live-updates
 * the palette to match the operating system.
 */

:root {
  color-scheme: light;

  /* Color: surfaces & text — warm near-white canvas, white content
     surfaces, ink headings over #444444 guideline body text. Selection is a
     very pale low-saturation teal with ink text: clearly selection, never
     status, and most of the page stays uncolored. */
  --color-bg: #f4f6f5; /* derived: white warmed 1% toward #f7bd63 */
  --color-surface: #ffffff;
  --color-raised: #ffffff; /* cards, the message box, menus: white on white in light */
  --color-surface-sunken: #edf1f0; /* derived: warm canvas one step deeper */
  --color-selected-bg: #edf7f5; /* derived: 8% #00b5ad on white */
  --color-selected-text: #252a2a;
  --color-text: #444444;
  --color-text-muted: #4c5864;
  --color-border: #dfe6e3;
  --color-border-strong: #b2b7bd;

  /* Primary-action brand color; theme-specific aliases separate controls. */
  --color-primary: #12968f; /* lightened brand teal; white text 3.6:1 */
  --color-primary-hover: #0a8782; /* one step deeper than primary */
  --color-primary-contrast: #ffffff;
  --color-focus: var(--color-primary);
  /* Headings use neutral ink; brand teal stays off titles. */
  --color-heading: #252a2a; /* ink */
  --color-danger: #ee6969;
  --color-danger-hover: #dd6464; /* derived: #ee6969 mixed 8% toward #1d262f */
  --color-danger-contrast: #1d262f;
  --color-primary-subtle: #e0f5f4; /* derived: 10% #00b5ad on white */

  /* Color: semantic tones (flash/status foreground + subtle background).
     Foregrounds are derived shades of the brand accents; backgrounds are 12%
     tints of the same accent on white. */
  --color-neutral-fg: #4c5864;
  --color-neutral-bg: #e5e7e9;
  --color-info-fg: #1c6680; /* derived: #1b9bc2 mixed 45% toward #1d262f */
  --color-info-bg: #e4f3f8; /* derived: 12% #1b9bc2 on white */
  --color-success-fg: #047876; /* derived: #008682 mixed 15% toward #1d262f */
  --color-success-bg: #e0f0f0; /* derived: 12% #008682 on white */
  --color-warning-fg: #705f43; /* derived: #f7bd63 mixed 62% toward #1d262f */
  --color-warning-bg: #fef7ec; /* derived: 12% #f7bd63 on white */
  --color-danger-fg: #9f5053; /* derived: #ee6969 mixed 38% toward #1d262f */
  --color-danger-bg: #fdeded; /* derived: 12% #ee6969 on white */

  /* Opaque brand-primary ring: 4.9:1 on white surfaces (the previous 40%
     teal composited to 1.48:1, below the 3:1 focus-appearance benchmark). */
  --color-focus-ring: #027e7b;

  /* Typography: the platform's UI typeface (SF Pro on macOS, Segoe UI on
     Windows) with its matching CJK face, so Latin and Chinese text share one
     weight and rhythm. The scale is compact: 13px controls and lists, 14px
     body, 15px for the agent's replies. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  --text-2xl: 1.375rem;
  --text-3xl: 1.625rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(29, 38, 47, 0.08);
  --shadow-md: 0 4px 12px rgba(29, 38, 47, 0.12);

  /* Layout */
  --container-max: 84rem;
}

/* Dark theme (owner decision, 2026-10-10): CircleCI-style navy. The main
   area is the deepest navy, the sidebar and cards a step lighter, borders
   blue-grey; blue marks what is selected, running or actionable, green what
   is done. The FeedMob logo keeps its teal. */
[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: #172033;
  --color-surface: #0d1422;
  --color-raised: #1c2639;
  --color-surface-sunken: #212c42;
  --color-selected-bg: #0b2559;
  --color-selected-text: #e8eefa;
  --color-text: #d5deec;
  --color-text-muted: #8e9bb2;
  --color-border: #26324a;
  --color-border-strong: #3e4b60;

  --color-primary: #2f6df6;
  --color-primary-hover: #4c84f8;
  --color-primary-contrast: #ffffff;
  --color-focus: #6f9bff;
  --color-heading: #eef3fa;
  --color-danger: #ee6969;
  --color-danger-hover: #f18080;
  --color-danger-contrast: #10131c;
  --color-primary-subtle: #0f2550;

  /* Semantic colors stay distinct from the blue accent. */
  --color-neutral-fg: #c9d2e0;
  --color-neutral-bg: #26324a;
  --color-info-fg: #8db4ff;
  --color-info-bg: #12264a;
  --color-success-fg: #8fd6a7;
  --color-success-bg: #13302a;
  --color-warning-fg: #f4cc84;
  --color-warning-bg: #33291a;
  --color-danger-fg: #f28f96;
  --color-danger-bg: #3a1f2a;

  --color-focus-ring: rgba(79, 135, 255, 0.6);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* System mode uses the same palette when the OS prefers dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --color-bg: #172033;
    --color-surface: #0d1422;
    --color-raised: #1c2639;
    --color-surface-sunken: #212c42;
    --color-selected-bg: #0b2559;
    --color-selected-text: #e8eefa;
    --color-text: #d5deec;
    --color-text-muted: #8e9bb2;
    --color-border: #26324a;
    --color-border-strong: #3e4b60;

    --color-primary: #2f6df6;
    --color-primary-hover: #4c84f8;
    --color-primary-contrast: #ffffff;
    --color-focus: #6f9bff;
    --color-heading: #eef3fa;
    --color-danger: #ee6969;
    --color-danger-hover: #f18080;
    --color-danger-contrast: #10131c;
    --color-primary-subtle: #0f2550;

    /* Semantic colors stay distinct from the blue accent. */
    --color-neutral-fg: #c9d2e0;
    --color-neutral-bg: #26324a;
    --color-info-fg: #8db4ff;
    --color-info-bg: #12264a;
    --color-success-fg: #8fd6a7;
    --color-success-bg: #13302a;
    --color-warning-fg: #f4cc84;
    --color-warning-bg: #33291a;
    --color-danger-fg: #f28f96;
    --color-danger-bg: #3a1f2a;

    --color-focus-ring: rgba(79, 135, 255, 0.6);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  }
}
