/* Fabric Analytics — shared tokens, type, controls. Light is the default; night mode via [data-theme="dark"]. */

:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #eceef2;
  --line: #e3e5ea;
  --line-strong: #cfd3db;
  --ink: #121620;
  --ink-2: #4c5363;
  --muted: #7d8492;
  --accent: #2952cc;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefc;
  --focus: #2952cc;
  --good: #0a7a2f;
  --bad: #c42b2b;
  --warn-bg: #fff6e0;
  --warn-ink: #7a5300;
  --danger-bg: #fdeceb;
  --shadow-pop: 0 12px 32px rgba(18, 22, 32, 0.12), 0 2px 6px rgba(18, 22, 32, 0.06);

  /* Chart chrome + categorical series (validated palette, light steps) */
  --grid: #e8e9ee;
  --axis: #c7cad2;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;

  --font-ui: "Raleway", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Montserrat", "Raleway", system-ui, sans-serif;
  --brand: #fda700;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1218;
  --surface: #161a22;
  --surface-2: #1c212b;
  --surface-3: #252b37;
  --line: #262c37;
  --line-strong: #353c4a;
  --ink: #eef0f4;
  --ink-2: #b5bac6;
  --muted: #858c99;
  --accent: #7b96f5;
  --accent-ink: #0f1218;
  --accent-soft: #1e2742;
  --focus: #9fb2ff;
  --good: #3fbf63;
  --bad: #f07171;
  --warn-bg: #3a2e10;
  --warn-ink: #f3cf73;
  --danger-bg: #3a1c1c;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);

  --grid: #242a34;
  --axis: #3a414e;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Raleway defaults to old-style figures; analytics needs even, aligned numbers. */
  font-variant-numeric: lining-nums;
  font-feature-settings: "lnum" 1;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.num { font-variant-numeric: lining-nums tabular-nums; font-feature-settings: "lnum" 1, "tnum" 1; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Buttons ---- */
.btn {
  --h: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1 var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--page); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { --h: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme toggle shows the icon for the mode you'd switch to */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---- Forms ---- */
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input, textarea.input, select.input {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: 15px/1.4 var(--font-ui);
}
textarea.input { resize: vertical; min-height: 120px; }
.input::placeholder { color: var(--muted); }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }

.notice {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.notice.error { background: var(--danger-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.ok { background: color-mix(in srgb, var(--good) 12%, var(--surface)); color: var(--good); }
.notice:empty { display: none; }

/* ---- Logo: fabric mark + "Fabric." wordmark ---- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 44px; height: 30px; flex: none;
  background: currentColor;
  -webkit-mask: url("../brand/mark.png") center / contain no-repeat;
  mask: url("../brand/mark.png") center / contain no-repeat;
}
.logo-word { font: 700 22px/1 var(--font-display); letter-spacing: -0.035em; }
.logo-word i { font-style: normal; color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
