/* fero-design tokens — the shared visual language of the Fero estate.
 * Dark-first. Every app links (or copies) this file and sets ONE accent:
 *   :root { --accent: #f59e0b; }            (see DESIGN.md for the app palette)
 * Everything else comes from these tokens. Do not hardcode colors in app CSS.
 */

:root {
  /* ---- neutral scale (dark theme) ---- */
  --bg:        #0b0e14;   /* page background */
  --surface:   #121722;   /* cards, panels */
  --surface-2: #1a2130;   /* nested surfaces, hovers, table stripes */
  --surface-3: #232c3f;   /* active states, code blocks */
  --border:    #2a3245;   /* hairline borders */
  --border-strong: #3b465e;

  /* ---- text ---- */
  --text:      #e8ecf4;   /* primary */
  --text-dim:  #9aa5b8;   /* secondary, labels */
  --text-faint:#66718a;   /* placeholders, disabled */

  /* ---- accent (each app overrides --accent; derivatives follow) ---- */
  --accent:       #6366f1;
  --accent-hover: color-mix(in srgb, var(--accent) 85%, white);
  --accent-soft:  color-mix(in srgb, var(--accent) 16%, transparent);
  --on-accent:    #0b0e14;

  /* ---- status ---- */
  --ok:     #34d399;
  --warn:   #fbbf24;
  --danger: #f87171;
  --info:   #60a5fa;
  --ok-soft:     color-mix(in srgb, var(--ok) 15%, transparent);
  --warn-soft:   color-mix(in srgb, var(--warn) 15%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 15%, transparent);

  /* ---- typography ---- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;  --fs-sm: 0.875rem;  --fs-md: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.375rem;  --fs-2xl: 1.75rem;
  --lh-tight: 1.25;  --lh-normal: 1.55;

  /* ---- spacing (4px scale) ---- */
  --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;

  /* ---- shape & elevation ---- */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-full: 999px;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 4px 12px rgb(0 0 0 / .35);
  --shadow-3: 0 12px 32px rgb(0 0 0 / .45);

  /* ---- motion ---- */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --t-fast: 120ms; --t-med: 180ms;

  color-scheme: dark;
}

/* Optional light theme — apps may support it via a toggle setting
 * <html data-theme="light">. Accent stays the same. */
[data-theme="light"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f6; --surface-3: #e3e8f0;
  --border: #d6dce7; --border-strong: #b9c2d4;
  --text: #17202e; --text-dim: #55617a; --text-faint: #8b96ab;
  --on-accent: #ffffff;
  --shadow-1: 0 1px 2px rgb(23 32 46 / .08);
  --shadow-2: 0 4px 12px rgb(23 32 46 / .10);
  --shadow-3: 0 12px 32px rgb(23 32 46 / .14);
  color-scheme: light;
}

/* ---- base reset the estate agrees on ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* selection must be clearly visible — a soft 16% tint disappears on dark bg */
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---- optional utility layer (vanilla apps may use these directly) ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
}
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent);
  font: 600 var(--fs-sm)/1 var(--font-sans);
  cursor: pointer; transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #0b0e14; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font: var(--fs-sm) var(--font-sans);
  transition: border-color var(--t-fast) var(--ease);
}
.input:focus { border-color: var(--accent); outline: none; }
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2); border-radius: var(--radius-full);
  font: 600 var(--fs-xs)/1.6 var(--font-sans);
  background: var(--accent-soft); color: var(--accent);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.stat { display: grid; gap: var(--sp-1); }
.stat .stat-value { font-size: var(--fs-2xl); font-weight: 700; line-height: var(--lh-tight); }
.stat .stat-label { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
