/* Served from here, not Google Fonts: one origin fewer before the first paint, no third-party
   request, a CSP without a font host. Variable files (400-600), split into latin and latin-ext,
   which carries č ć đ š ž. IBM Plex is OFL-licensed. */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* The one source of colour, type and spacing for both surfaces; must match Brand.cs, which
   BrandTokenTests checks. Three layers: 1. raw scale, never themed; 2. semantic tokens, the only
   thing a theme swaps; 3. derived color-mix over them, so the dark blocks stay short. */

:root {
  color-scheme: light;

  /* 1. Raw scale */

  --accent-200: #BDD5EA;
  --accent-300: #8FB6D8;
  --accent-400: #5C92C1;
  --accent-500: #37719F;
  --accent-600: #2A5F8B;
  --accent-700: #1F4E79;
  --accent-800: #193F62;

  --neutral-0:   #FFFFFF;
  --neutral-25:  #FBFCFD;
  --neutral-50:  #F6F8FA;
  --neutral-100: #EDF1F5;
  --neutral-200: #DFE5EC;
  --neutral-300: #C6D0DA;
  --neutral-400: #9AA7B5;
  --neutral-500: #71808F;
  --neutral-600: #556374;
  --neutral-700: #3D4956;
  --neutral-800: #2A333D;
  --neutral-900: #1A2128;
  --neutral-950: #111619;

  /* 2. Semantic, light theme */

  --bg: var(--neutral-50);
  --surface: var(--neutral-0);
  --surface-sunken: var(--neutral-100);
  --surface-hover: var(--neutral-50);

  --line: var(--neutral-200);
  --line-strong: var(--neutral-300);

  --text: var(--neutral-900);
  --text-muted: var(--neutral-600);
  --text-subtle: var(--neutral-500);
  --text-on-accent: #FFFFFF;

  --accent: var(--accent-700);
  --accent-hover: var(--accent-800);

  --success: #146F4F;
  --warning: #8A5A0F;
  --danger: #A4262C;
  --teal: #0F6E80;

  --shadow-sm: 0 1px 2px rgb(16 24 32 / 6%), 0 1px 3px rgb(16 24 32 / 4%);
  --shadow-md: 0 4px 12px rgb(16 24 32 / 10%), 0 2px 4px rgb(16 24 32 / 6%);

  /* 3. Derived: valid in both themes, since var() resolves at use */

  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --success-soft: color-mix(in srgb, var(--success) 12%, var(--surface));
  --warning-soft: color-mix(in srgb, var(--warning) 14%, var(--surface));
  --danger-soft: color-mix(in srgb, var(--danger) 11%, var(--surface));

  --st-draft: var(--text-subtle);
  --st-issued: var(--accent);
  --st-sent: var(--teal);
  --st-partial: var(--warning);
  --st-paid: var(--success);
  --st-overdue: var(--danger);
  --st-cancelled: var(--text-muted);

  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --fs-micro: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: clamp(2rem, 1.35rem + 2.4vw, 2.625rem);

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.55;

  /* 4 px base */

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-14: 56px;
  --s-20: 80px;

  --r-control: 6px;
  --r-card: 10px;
  --r-panel: 14px;
  --r-pill: 999px;

  --measure: 65ch;
  --page: 1120px;
}

/* Three states: an explicit choice sets data-theme, "follow the system" sets nothing; hence the
   media query and the attribute, and :not([data-theme="light"]) so an explicit light wins. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: var(--neutral-950);
    --surface: #171D22;
    --surface-sunken: #1E252C;
    --surface-hover: #1E252C;

    --line: #2C353E;
    --line-strong: #3B4650;

    --text: var(--neutral-100);
    --text-muted: var(--neutral-400);
    --text-subtle: #7F8D9B;
    --text-on-accent: var(--neutral-950);

    --accent: var(--accent-400);
    --accent-hover: var(--accent-300);

    --success: #4FBE94;
    --warning: #D9A441;
    --danger: #E48187;
    --teal: #4FB8C9;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 6px 20px rgb(0 0 0 / 50%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: var(--neutral-950);
  --surface: #171D22;
  --surface-sunken: #1E252C;
  --surface-hover: #1E252C;

  --line: #2C353E;
  --line-strong: #3B4650;

  --text: var(--neutral-100);
  --text-muted: var(--neutral-400);
  --text-subtle: #7F8D9B;
  --text-on-accent: var(--neutral-950);

  --accent: var(--accent-400);
  --accent-hover: var(--accent-300);

  --success: #4FBE94;
  --warning: #D9A441;
  --danger: #E48187;
  --teal: #4FB8C9;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 6px 20px rgb(0 0 0 / 50%);
}

/* The approved stamp keeps its colour and aspect ratio on every surface. */
.brand-mark { display: block; flex: none; width: 96px; height: auto; }
