/* ============================================================
   DESIGN TOKENS
   Single source of truth for all visual decisions.
   Dark theme is the default. Light theme overrides follow.
   ============================================================ */

:root {

  /* ── Colour — Backgrounds ──────────────────────────────────
     Layered surfaces from darkest (body) to lightest (raised).  */
  --color-bg-body:              #080b16;
  --color-bg-page:              #0f1221;
  --color-bg-surface:           #161b30;
  --color-bg-surface-raised:    #1c2240;
  --color-bg-interactive:       #222848;
  --color-bg-interactive-hover: #2a3258;

  /* ── Colour — Borders ─────────────────────────────────────── */
  --color-border-subtle:        #1a2038;
  --color-border-default:       #263050;
  --color-border-strong:        #374070;
  --color-border-focus:         #4a6cf7;

  /* ── Colour — Text ────────────────────────────────────────── */
  --color-text-primary:         #e2e8f5;
  --color-text-secondary:       #8892a8;
  --color-text-tertiary:        #525c78;
  --color-text-on-accent:       #ffffff;

  /* ── Colour — Semantic ────────────────────────────────────── */
  --color-error:                #f87171;
  --color-error-subtle:         rgba(248, 113, 113, 0.12);
  --color-success:              #4ade80;
  --color-success-subtle:       rgba(74, 222, 128, 0.12);
  --color-warning:              #fbbf24;
  --color-warning-subtle:       rgba(251, 191, 36, 0.12);
  --color-info:                 #60a5fa;
  --color-info-subtle:          rgba(96, 165, 250, 0.12);

  /* ── Colour — Accent ──────────────────────────────────────── */
  --color-accent:               #4a6cf7;
  --color-accent-hover:         #3a5ae6;
  --color-accent-subtle:        rgba(74, 108, 247, 0.12);
  --color-accent-glow:          rgba(74, 108, 247, 0.28);

  /* ── Shadows ──────────────────────────────────────────────── */
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.35),  0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.30);
  --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-xl:    0 20px 60px rgba(0, 0, 0, 0.65), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-focus: 0 0 0 3px var(--color-accent-glow);

  /* ── Typography — Families ────────────────────────────────── */
  --font-sans:  system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Georgia', serif;
  --font-mono:  'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* ── Typography — Scale ───────────────────────────────────── */
  --text-xs:   0.6875rem;  /* 11px */
  --text-sm:   0.8125rem;  /* 13px */
  --text-base: 1rem;       /* 16px */
  --text-md:   1.125rem;   /* 18px */
  --text-lg:   1.25rem;    /* 20px */
  --text-xl:   1.5rem;     /* 24px */
  --text-2xl:  1.875rem;   /* 30px */
  --text-3xl:  2.25rem;    /* 36px */

  /* ── Typography — Leading / Tracking / Weight ─────────────── */
  --leading-tight:   1.25;
  --leading-snug:    1.4;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  --tracking-tight:   -0.025em;
  --tracking-normal:   0em;
  --tracking-wide:     0.025em;
  --tracking-wider:    0.06em;
  --tracking-widest:   0.12em;

  --font-normal:   400;
  --font-medium:   500;
  --font-semibold: 600;
  --font-bold:     700;

  /* ── Spacing — 4px base grid ─────────────────────────────── */
  --space-px:  1px;
  --space-1:   0.25rem;   /*  4px */
  --space-2:   0.5rem;    /*  8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */
  --space-24:  6rem;      /* 96px */

  /* ── Border Radius ────────────────────────────────────────── */
  --radius-sm:   0.25rem;  /*  4px */
  --radius-md:   0.5rem;   /*  8px */
  --radius-lg:   0.75rem;  /* 12px */
  --radius-xl:   1rem;     /* 16px */
  --radius-2xl:  1.5rem;   /* 24px */
  --radius-full: 9999px;

  /* ── Animation ────────────────────────────────────────────── */
  --duration-fast:   100ms;
  --duration-normal: 200ms;
  --duration-slow:   350ms;
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Z-index ──────────────────────────────────────────────── */
  --z-base:     0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  500;
  --z-modal:    1000;
  --z-toast:    1100;

  /* ── Layout ───────────────────────────────────────────────── */
  --nav-height:     3.25rem;
  --page-padding:   var(--space-6);

  /* ── List table — mobile scale ────────────────────────────── */
  /* On mobile (≤640px), list table font sizes are multiplied by this factor.
     Tune this value to find the right balance between readability and compactness. */
  --list-mobile-scale: 0.65;
}


/* ============================================================
   LIGHT THEME OVERRIDES
   Applied when the OS is set to light mode OR when
   data-theme="light" is set on the <html> element.
   ============================================================ */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --color-bg-body:              #eef0f7;
    --color-bg-page:              #f8f9fc;
    --color-bg-surface:           #ffffff;
    --color-bg-surface-raised:    #ffffff;
    --color-bg-interactive:       #edf0fa;
    --color-bg-interactive-hover: #e2e6f5;

    --color-border-subtle:        #e4e7f2;
    --color-border-default:       #cdd2e8;
    --color-border-strong:        #9aa3c8;
    --color-border-focus:         #4a6cf7;

    --color-text-primary:         #141829;
    --color-text-secondary:       #42506e;
    --color-text-tertiary:        #7a85a8;
    --color-text-on-accent:       #ffffff;

    --color-error:                #dc2626;
    --color-error-subtle:         rgba(220, 38, 38, 0.08);
    --color-success:              #16a34a;
    --color-success-subtle:       rgba(22, 163, 74, 0.08);
    --color-warning:              #d97706;
    --color-warning-subtle:       rgba(217, 119, 6, 0.08);
    --color-info:                 #2563eb;
    --color-info-subtle:          rgba(37, 99, 235, 0.08);

    --color-accent-subtle:        rgba(74, 108, 247, 0.08);
    --color-accent-glow:          rgba(74, 108, 247, 0.2);

    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.08),  0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.07);
    --shadow-xl:    0 20px 60px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(0, 0, 0, 0.08);
  }
}

/* ============================================================
   MOBILE TYPE SCALE OVERRIDES
   Reduce the type scale on small screens so UI chrome stays
   compact and the document content gets the most space.
   ============================================================ */

@media (max-width: 640px) {
  :root {
    --text-xs:   0.625rem;   /* 10px (was 11px) */
    --text-sm:   0.75rem;    /* 12px (was 13px) */
    --text-base: 0.875rem;   /* 14px (was 16px) */
    --text-md:   1rem;       /* 16px (was 18px) */
    --text-lg:   1.125rem;   /* 18px (was 20px) */
  }
}


/* Manual light theme override — add data-theme="light" to <html> */
[data-theme="light"] {
  --color-bg-body:              #eef0f7;
  --color-bg-page:              #f8f9fc;
  --color-bg-surface:           #ffffff;
  --color-bg-surface-raised:    #ffffff;
  --color-bg-interactive:       #edf0fa;
  --color-bg-interactive-hover: #e2e6f5;

  --color-border-subtle:        #e4e7f2;
  --color-border-default:       #cdd2e8;
  --color-border-strong:        #9aa3c8;
  --color-border-focus:         #4a6cf7;

  --color-text-primary:         #141829;
  --color-text-secondary:       #42506e;
  --color-text-tertiary:        #7a85a8;
  --color-text-on-accent:       #ffffff;

  --color-error:                #dc2626;
  --color-error-subtle:         rgba(220, 38, 38, 0.08);
  --color-success:              #16a34a;
  --color-success-subtle:       rgba(22, 163, 74, 0.08);
  --color-warning:              #d97706;
  --color-warning-subtle:       rgba(217, 119, 6, 0.08);
  --color-info:                 #2563eb;
  --color-info-subtle:          rgba(37, 99, 235, 0.08);

  --color-accent-subtle:        rgba(74, 108, 247, 0.08);
  --color-accent-glow:          rgba(74, 108, 247, 0.2);

  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.08),  0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-xl:    0 20px 60px rgba(0, 0, 0, 0.14), 0 8px 24px rgba(0, 0, 0, 0.08);
}
