/* ==========================================================================
   Binayti design tokens
   - Deep teal brand, concrete-grey neutrals, 8px spacing grid, 16px cards.
   - Light theme by default, dark theme via [data-theme="dark"] or the
     system preference when no explicit theme is chosen.
   ========================================================================== */

:root {
  /* ---- Brand: deep teal ---- */
  --teal-25: #f2faf9;
  --teal-50: #e3f3f1;
  --teal-100: #c2e5e0;
  --teal-200: #92d0c8;
  --teal-300: #5bb4aa;
  --teal-400: #2f968c;
  --teal-500: #137b73;
  --teal-600: #0b6660;
  --teal-700: #08534f;
  --teal-800: #06403d;
  --teal-900: #042e2c;
  --mint-400: #3fe0c5; /* scan line / AI overlay accent */

  /* ---- Neutrals: concrete grey (slightly warm) ---- */
  --grey-0: #ffffff;
  --grey-25: #fafaf8;
  --grey-50: #f3f4f2;
  --grey-100: #e8e9e6;
  --grey-200: #d6d8d4;
  --grey-300: #b8bcb6;
  --grey-400: #8e938d;
  --grey-500: #62675f;
  --grey-600: #51564f;
  --grey-700: #3b3f3a;
  --grey-800: #272a26;
  --grey-900: #181a17;
  --grey-950: #0f110f;

  /* ---- Status (always paired with an icon + text label) ---- */
  --green-600: #1c7f45;
  --green-700: #156536;
  --green-50: #e6f5eb;
  --green-100: #c9ebd5;
  --yellow-500: #e0a100;
  --yellow-700: #8a5a00;
  --yellow-50: #fff6dc;
  --yellow-100: #ffe9a8;
  --red-600: #c42b2b;
  --red-700: #a11f1f;
  --red-50: #fdecec;
  --red-100: #f8cfcf;
  --blue-600: #2459c7;
  --blue-50: #e9f0fd;

  /* ---- Semantic colors (light) ---- */
  --bg: var(--grey-50);
  --bg-elevated: var(--grey-0);
  --bg-sunken: var(--grey-100);
  --surface: var(--grey-0);
  --surface-2: var(--grey-25);
  --surface-hover: var(--grey-50);
  --border: var(--grey-200);
  --border-strong: var(--grey-300);
  --text: var(--grey-900);
  --text-2: var(--grey-600);
  --text-3: var(--grey-500);
  --text-on-brand: #ffffff;
  --brand: var(--teal-600);
  --brand-hover: var(--teal-700);
  --brand-press: var(--teal-800);
  --brand-soft: var(--teal-50);
  --brand-soft-2: var(--teal-100);
  --brand-text: var(--teal-700);
  --focus: var(--teal-500);
  --overlay: rgba(15, 17, 15, 0.48);

  --ok: var(--green-600);
  --ok-text: var(--green-700);
  --ok-soft: var(--green-50);
  --ok-border: var(--green-100);
  --warn: var(--yellow-500);
  --warn-text: var(--yellow-700);
  --warn-soft: var(--yellow-50);
  --warn-border: var(--yellow-100);
  --danger: var(--red-600);
  --danger-text: var(--red-700);
  --danger-soft: var(--red-50);
  --danger-border: var(--red-100);
  --info: var(--blue-600);
  --info-soft: var(--blue-50);

  /* ---- Typography ---- */
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, Tahoma, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-md: 0.9375rem; /* 15 */
  --fs-lg: 1.0625rem; /* 17 */
  --fs-xl: 1.25rem;   /* 20 */
  --fs-2xl: 1.5rem;   /* 24 */
  --fs-3xl: 2rem;     /* 32 */
  --fs-4xl: 2.5rem;   /* 40 */
  --lh-tight: 1.25;
  --lh: 1.55;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ---- 8px spacing grid ---- */
  --sp-0: 4px;  /* half step, for tight icon gaps only */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;
  --sp-6: 48px;
  --sp-8: 64px;
  --sp-10: 80px;

  /* ---- Radius ---- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-card: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* ---- Elevation (soft) ---- */
  --shadow-xs: 0 1px 2px rgba(24, 26, 23, 0.06);
  --shadow-sm: 0 1px 2px rgba(24, 26, 23, 0.05), 0 2px 8px rgba(24, 26, 23, 0.05);
  --shadow-md: 0 2px 4px rgba(24, 26, 23, 0.04), 0 8px 24px rgba(24, 26, 23, 0.08);
  --shadow-lg: 0 8px 16px rgba(24, 26, 23, 0.06), 0 24px 48px rgba(24, 26, 23, 0.14);
  --shadow-brand: 0 6px 20px rgba(11, 102, 96, 0.35);

  /* ---- Layout ---- */
  --header-h: 56px;
  --tabbar-h: 64px;
  --rail-w: 240px;
  --content-max: 640px;
  --wide-max: 1120px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ---- Motion ---- */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 480ms;

  /* ---- Z layers ---- */
  --z-header: 20;
  --z-tabbar: 30;
  --z-banner: 35;
  --z-sheet: 60;
  --z-toast: 80;
  --z-splash: 100;

  color-scheme: light;
}

/* ---- Dark theme (explicit) ---- */
:root[data-theme="dark"] {
  --bg: #0d100f;
  --bg-elevated: #161a19;
  --bg-sunken: #0a0c0b;
  --surface: #161a19;
  --surface-2: #1b201e;
  --surface-hover: #1f2523;
  --border: #2a302e;
  --border-strong: #3a413e;
  --text: #eef0ee;
  --text-2: #b4bab6;
  --text-3: #8d948f;
  --brand: #22a196;
  --brand-hover: #2bb3a7;
  --brand-press: #1a8a80;
  --brand-soft: rgba(34, 161, 150, 0.14);
  --brand-soft-2: rgba(34, 161, 150, 0.24);
  --brand-text: #5fd0c4;
  --focus: #5fd0c4;
  --overlay: rgba(0, 0, 0, 0.62);
  --text-on-brand: #04201e;

  --ok: #3cbf74;
  --ok-text: #6ad898;
  --ok-soft: rgba(60, 191, 116, 0.13);
  --ok-border: rgba(60, 191, 116, 0.3);
  --warn: #f2bb2a;
  --warn-text: #f6cd5f;
  --warn-soft: rgba(242, 187, 42, 0.13);
  --warn-border: rgba(242, 187, 42, 0.3);
  --danger: #ef5b5b;
  --danger-text: #ff8b8b;
  --danger-soft: rgba(239, 91, 91, 0.13);
  --danger-border: rgba(239, 91, 91, 0.32);
  --info: #79a3ff;
  --info-soft: rgba(121, 163, 255, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35), 0 24px 48px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 6px 20px rgba(34, 161, 150, 0.3);

  color-scheme: dark;
}

/* ---- Dark theme (system preference, when no explicit choice) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0d100f;
    --bg-elevated: #161a19;
    --bg-sunken: #0a0c0b;
    --surface: #161a19;
    --surface-2: #1b201e;
    --surface-hover: #1f2523;
    --border: #2a302e;
    --border-strong: #3a413e;
    --text: #eef0ee;
    --text-2: #b4bab6;
    --text-3: #8d948f;
    --brand: #22a196;
    --brand-hover: #2bb3a7;
    --brand-press: #1a8a80;
    --brand-soft: rgba(34, 161, 150, 0.14);
    --brand-soft-2: rgba(34, 161, 150, 0.24);
    --brand-text: #5fd0c4;
    --focus: #5fd0c4;
    --overlay: rgba(0, 0, 0, 0.62);
    --text-on-brand: #04201e;

    --ok: #3cbf74;
    --ok-text: #6ad898;
    --ok-soft: rgba(60, 191, 116, 0.13);
    --ok-border: rgba(60, 191, 116, 0.3);
    --warn: #f2bb2a;
    --warn-text: #f6cd5f;
    --warn-soft: rgba(242, 187, 42, 0.13);
    --warn-border: rgba(242, 187, 42, 0.3);
    --danger: #ef5b5b;
    --danger-text: #ff8b8b;
    --danger-soft: rgba(239, 91, 91, 0.13);
    --danger-border: rgba(239, 91, 91, 0.32);
    --info: #79a3ff;
    --info-soft: rgba(121, 163, 255, 0.14);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.35), 0 24px 48px rgba(0, 0, 0, 0.5);
    --shadow-brand: 0 6px 20px rgba(34, 161, 150, 0.3);

    color-scheme: dark;
  }
}

/* ---- Reduced motion: collapse durations globally ---- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 0ms;
    --dur-2: 0ms;
    --dur-3: 0ms;
    --dur-4: 0ms;
  }
}
