/* Moss design system (LABS-461): tokens and the styles of the src/ui components. Shared by Moss apps;
   app styles read the roles, never the primitives. See the PRD, "Moss palette" and "Moss components
   and catalog", and /catalog.

   Primitives: the mossutilities.com brand palette (extracted Oct 18, 2026; moss_fuerte/docs/style-dictionary)
   plus tones of it. Tones keep each brand colour's OKLCH hue and chroma and change only lightness, so
   the darker ones meet WCAG contrast where the brand colours do not. The brand values are marked.

   Layers, lowest first. App styles stay outside them, so an app rule always wins over a Moss rule
   without a specificity fight. */
@layer reset, tokens, base, components;

@layer tokens {
  :root {
    /* ---------- Primitives ---------- */
    --moss-white: #ffffff;
    --moss-background: #f9f9f9; /* brand background */
    --moss-foreground: #404040; /* brand foreground */
    --moss-muted: #6d6d6d; /* brand muted */

    --moss-blue-50: #eff6ff;
    --moss-blue-100: #d9eafe;
    --moss-blue-200: #b7d7fe;
    --moss-blue-300: #88beff;
    --moss-blue-400: #54a4ff;
    --moss-blue-500: #008bff; /* brand primary */
    --moss-blue-600: #0368c1;
    --moss-blue-700: #02559f;
    --moss-blue-800: #02427e;
    --moss-blue-900: #012e5a;

    --moss-green-50: #e3ffda;
    --moss-green-100: #b8ff9e;
    --moss-green-200: #7df647;
    --moss-green-300: #62db1f;
    --moss-green-400: #58d100; /* brand secondary */
    --moss-green-500: #48ad03;
    --moss-green-600: #327c04;
    --moss-green-700: #276600;
    --moss-green-800: #1d5001;
    --moss-green-900: #123800;

    --moss-slate-50: #eef6fe;
    --moss-slate-100: #dceeff;
    --moss-slate-200: #c5def7;
    --moss-slate-300: #abc4dc;
    --moss-slate-400: #8da5bc;
    --moss-slate-500: #758ca3;
    --moss-slate-600: #556c81;
    --moss-slate-700: #42586d;
    --moss-slate-800: #2d4256; /* brand blue: headings and body text */
    --moss-slate-900: #1f3142; /* brand footer */

    /* Cool grey on the brand tertiary's hue; chroma eased at the light end so tints stay neutral. */
    --moss-gray-50: #f3f8fa;
    --moss-gray-100: #ebf1f4;
    --moss-gray-200: #d1dde2;
    --moss-gray-300: #b5c1c6; /* brand tertiary */
    --moss-gray-400: #98a4a9;
    --moss-gray-500: #7d888d;
    --moss-gray-600: #606b6f;
    --moss-gray-700: #4d575c;
    --moss-gray-800: #384246;
    --moss-gray-900: #263033;

    /* The website has no red; this one comes from Traction's design. */
    --moss-red-50: #fff2f0;
    --moss-red-100: #ffe4e0;
    --moss-red-600: #af423b;
    --moss-red-700: #952925;

    /* ---------- Roles ---------- */
    /* Contrast is WCAG, against --surface (#f9f9f9) unless the note names another background. */
    --surface: var(--moss-background); /* page and header backgrounds */
    --white: var(--moss-white); /* panels, rows, label backings */
    --ink: var(--moss-slate-800); /* text, 9.85:1 */
    --ink-2: var(--moss-slate-600); /* secondary text, 5.18:1 */
    --ink-3: var(--moss-muted); /* hints and placeholders, 4.91:1 */
    --line: var(--moss-gray-300); /* dividers and grid lines; decoration only */
    --line-strong: var(--moss-slate-500); /* control borders, 3.30:1 */
    --accent: var(--moss-blue-600); /* actions, links, focus, proposed changes; white on it 5.59:1 */
    --accent-strong: var(--moss-blue-700); /* hover on --accent, 7.49:1 with white */
    --accent-weak: var(--moss-blue-50); /* selected and proposed fills; --accent on it 5.14:1 */
    --accent-glow: rgba(3, 104, 193, 0.16); /* focus halo around the outline */
    --positive: var(--moss-green-700); /* confirmed and done; white on it 7.03:1 */
    --positive-weak: var(--moss-green-50); /* --positive on it 6.56:1 */
    --brand-highlight: var(--moss-green-400); /* fills only: never text, never under white text (1.99:1) */
    --danger: var(--moss-red-600); /* hard rule checks and errors, 5.44:1 */
    --danger-weak: var(--moss-red-50); /* --danger on it 5.24:1 */
    --shell: var(--moss-slate-900); /* app shell bar, tooltips and toasts; white on it 13.32:1 */
    --shell-ink-2: var(--moss-slate-200); /* secondary text on --shell, 9.62:1 */
    --shadow-pop: 0 4px 12px rgba(31, 49, 66, 0.13); /* popovers and tooltips */
    --shadow-lift: 0 4px 12px rgba(31, 49, 66, 0.2); /* something being dragged; toasts */
    --shadow-up: 0 -4px 12px rgba(31, 49, 66, 0.06); /* a tray raised from the bottom edge */
    --scrim: rgba(31, 49, 66, 0.5); /* dims the page behind a dialog or a tour step */

    /* Type: Inter for all app text. Montserrat is for the product name and page titles only, once
       its font file is self-hosted (SIL Open Font License). The website's type scale is for marketing pages. */
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Montserrat", "Inter", system-ui, sans-serif;

    /* Spacing on a 4px grid; motion from the website. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --motion-fast: 150ms;
    --motion-ease: cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@layer reset {
  * { box-sizing: border-box; }
  body { margin: 0; }
  h1, h2, h3, p { margin: 0; font-weight: 400; }
  button, select, input { font: inherit; color: inherit; }
}

@layer base {
  @font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/static/fonts/inter-latin-var.woff2") format("woff2");
  }

  /* Dense app text: 12 px Inter with tabular figures. */
  body {
    background: var(--surface);
    color: var(--ink);
    font: 400 12px/1.4 var(--font-sans);
    font-feature-settings: "tnum" 1, "cv11" 1;
    -webkit-font-smoothing: antialiased;
  }
  kbd { color: var(--ink-3); font: 400 11px var(--font-sans); }
  /* Focus is always visible (LABS-461). */
  :focus { outline: none; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: 0 0 0 4px var(--accent-glow); }
  /* Screen-reader-only text. */
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* The icon sprite (hidden) and its inline icons (ui::icon). */
  .sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
  .i { flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
}

/* One block per component in src/ui. */
@layer components {
  .btn {
    display: inline-flex; align-items: center; gap: 7px;
    height: 36px; padding: 0 12px;
    border: 1px solid var(--line-strong); border-radius: 6px;
    background: var(--white); color: var(--ink);
    font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
  }
  .btn:hover:not(:disabled, [aria-disabled="true"]) { border-color: var(--ink-2); }
  .btn.on { background: var(--accent-weak); border-color: var(--accent); font-weight: 600; }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--white); font-weight: 600; }
  .btn.primary:hover:not(:disabled, [aria-disabled="true"]) { background: var(--accent-strong); border-color: var(--accent-strong); }
  /* aria-disabled: unavailable, but still in the tab order so its title can say why (ui::Button). */
  .btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
  .btn.icon-only { padding: 0 10px; }
  .btn.ghostbtn { border-color: transparent; background: none; color: var(--ink-2); }
  .linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 11px; }
  .chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px;
    background: var(--surface); color: var(--ink-2);
    font-size: 11px; font-weight: 600; white-space: nowrap;
  }
  .chip.accent { background: var(--accent-weak); color: var(--accent); }
  .chip.warn { color: var(--ink); }
  .seg { display: flex; gap: 3px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
  .seg.plain { padding: 0; gap: 6px; background: none; border: 0; }
  /* ui::PageNav: links between pages, drawn as a segmented control. */
  .pagenav { flex: none; }
  .pagenav .btn { text-decoration: none; }
  .avatar {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 16px;
    background: var(--accent-weak); color: var(--accent); font-size: 11px; font-weight: 700;
  }

  .select select {
    appearance: none; height: 36px; padding: 0 28px 0 12px;
    border: 1px solid var(--line-strong); border-radius: 6px; background: var(--white);
    font-size: 12px; font-weight: 500; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23556c81' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
  }
  .select.on select { background-color: var(--accent-weak); border-color: var(--accent); font-weight: 600; }
  .btn .box {
    display: grid; place-items: center; width: 12px; height: 12px;
    border: 1px solid var(--ink-2); border-radius: 2px; color: transparent;
  }
  .btn .box.checked { background: var(--ink-2); color: var(--white); }
  .search {
    flex: 1; min-width: 120px; display: flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 10px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink-2);
  }
  .search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
  .search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 12px; color: var(--ink); }
  .search input::placeholder { color: var(--ink-3); }

  .notice {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 24px; color: var(--ink-2);
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .notice .msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}
