/*
 * BitMatrix IT Solutions theme for Documenso v2.19.0 (sign.bitmatrixit.com).
 *
 * Loaded by a <link> that the documenso-theme proxy (nginx sub_filter) adds
 * before </head> on every HTML page. Documenso's own code and image are
 * untouched (AGPL, unmodified); this file only restyles what the browser shows.
 *
 * Strategy: override Documenso's shadcn/Tailwind CSS variables (defined in
 * packages/ui/styles/theme.css as `:root, .dark-mode-disabled` and
 * `.dark:not(.dark-mode-disabled)`), and use a small number of stable hooks
 * (logo SVG viewBox, the background-pattern <img alt>, the signup panel image)
 * for the brand surfaces. Re-check every hook marked UPGRADE on a version bump.
 *
 * SCOPE: only the Mulish font and the logo swap are global. Every colour,
 * background and variable override applies ONLY to:
 *   AUTH      html:has(main > div > div.absolute > img[alt="background pattern"])
 *             = the _unauthenticated+ layout (signin, signup, forgot/reset
 *             password, verify email, organisation invite). The generic error
 *             page uses the same <img> but not under main>div>div.absolute.
 *   RECIPIENT body.documenso-branded
 *             = Documenso's own class for _recipient+ routes (/sign, /d, /report),
 *             set by React (root.tsx), so it follows client-side navigation.
 * The logged-in app keeps Documenso's own colours in light and dark mode
 * (a global override broke it, 2026-10-05). UPGRADE: re-check both hooks.
 *
 * Palette (same tokens as the CRM / MSP portal web/src/index.css):
 *   navy   222 47% 14%   sidebar / chrome
 *   sky    200 90% 50%   active accent
 * Font: Mulish (bitmatrixit.com), self-hosted, SIL OFL 1.1 (fonts/OFL.txt).
 */

@font-face {
  font-family: "Mulish";
  src: url("/bmx-theme/fonts/mulish-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
  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: "Mulish";
  src: url("/bmx-theme/fonts/mulish-latin-ext-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
  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;
}

/* ---------- Global: font only ---------- */
:root { --font-sans: "Mulish"; }

/* ---------- Scoped private tokens (both modes) ---------- */
html:has(main > div > div.absolute > img[alt="background pattern"]),
body.documenso-branded {
  --bmx-navy: 222 47% 14%;
  --bmx-navy-deep: 223 52% 9%;
  --bmx-sky: 200 90% 50%;
  --bmx-sky-ink: 200 92% 31%;   /* links and accent text on white 6.2:1, on neutral-100 5.7:1 */
  --bmx-sky-ring: 200 90% 40%;  /* focus ring on white: 4.1:1 (non-text, AA needs 3:1) */
  accent-color: hsl(var(--bmx-sky-ring));
  caret-color: hsl(var(--bmx-sky-ring));
}

/* ---------- Scoped tokens: light ---------- */
html:not(.dark):has(main > div > div.absolute > img[alt="background pattern"]),
html:not(.dark) body.documenso-branded {
  --foreground: 222 47% 11%;
  --popover-foreground: 222 47% 11%;
  --card-foreground: 222 47% 11%;

  --primary: var(--bmx-navy);
  --primary-foreground: 0 0% 100%;
  --ring: var(--bmx-sky-ring);

  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222 47% 14%;
  --accent: 205 60% 95%;
  --accent-foreground: 222 47% 14%;

  /* Destructive: the CRM's crimson; white on it passes AA (Documenso's pure red is 4.0:1). */
  --destructive: 345 82.7% 40.8%;
  --destructive-foreground: 0 0% 100%;

  /* Field cards on the signing page: a sky wash instead of Documenso green. */
  --field-card: 200 90% 95%;
  --field-card-border: 200 85% 55%;
  --field-card-foreground: 222 47% 11%;
  --card-border-tint: 13 162 242;

  /* The "new" palette scale some v2 screens use (comma-separated HSL). */
  --new-primary-50: 200, 90%, 97%;
  --new-primary-100: 200, 90%, 94%;
  --new-primary-200: 200, 90%, 87%;
  --new-primary-300: 200, 90%, 78%;
  --new-primary-400: 200, 90%, 64%;
  --new-primary-500: 200, 90%, 50%;
  --new-primary-600: 200, 92%, 40%;
  --new-primary-700: 200, 92%, 31%;
  --new-primary-800: 210, 80%, 22%;
  --new-primary-900: 222, 47%, 14%;
  --new-primary-950: 223, 52%, 9%;

  /* Documenso's named green scale (hex vars). */
  --documenso-200: #dff2fd;
  --documenso-300: #b4e3fb;
  --documenso-400: #6fc8f6;
  --documenso-500: #0da2f2;
  --documenso-600: #0b8ccf;
  --documenso-700: #0672a6;
  --documenso-800: #0b5a86;
  --documenso-900: #13203a;
}

/* ---------- Scoped tokens: dark (only if the user's theme is dark) ---------- */
html.dark:has(main > div > div.absolute > img[alt="background pattern"]),
html.dark body.documenso-branded {
  --background: 223 40% 10%;
  --popover: 223 40% 12%;
  --card: 223 40% 12%;
  --widget: 223 40% 12%;
  --envelope-editor-background: 223 40% 10%;
  --muted: 222 30% 18%;
  --secondary: 222 30% 18%;
  --accent: 222 30% 22%;
  --border: 222 25% 24%;
  --input: 222 25% 24%;
  --primary: 200 90% 56%;
  --primary-foreground: 223 52% 9%;
  --secondary-foreground: 200 90% 70%;
  --accent-foreground: 200 90% 70%;
  --ring: 200 90% 56%;
  --card-border-tint: 13 162 242;
}

/* ---------- Scoped browser surfaces ---------- */
html:has(main > div > div.absolute > img[alt="background pattern"]) ::selection,
body.documenso-branded ::selection { background: hsl(200 90% 50% / 0.22); }

/* Documenso's green utility classes (compiled to literal colours, so they need a class rule). UPGRADE */
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) :is(.text-documenso, .group:hover .group-hover\:text-documenso, .text-documenso-700, .text-documenso-800, .hover\:text-documenso-600:hover) { color: hsl(var(--bmx-sky-ink)); }
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) .text-documenso-900 { color: hsl(var(--bmx-navy)); }
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) :is(.bg-documenso, .group:hover .group-hover\:bg-documenso) { background-color: hsl(var(--bmx-sky)); }
:is(html.dark:has(main > div > div.absolute > img[alt="background pattern"]), html.dark body.documenso-branded) .dark\:bg-documenso { background-color: hsl(var(--bmx-sky)); }
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) .bg-documenso-200 { background-color: #dff2fd; }
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) .border-documenso-300 { border-color: #b4e3fb; }
:is(html:has(main > div > div.absolute > img[alt="background pattern"]), body.documenso-branded) .group:hover .group-hover\:border-documenso\/80 { border-color: hsl(var(--bmx-sky) / 0.8); }
:is(html.dark:has(main > div > div.absolute > img[alt="background pattern"]), html.dark body.documenso-branded) :is(.text-documenso-700, .text-documenso-800) { color: hsl(200 90% 70%); }

/* ---------- Logo (global): Documenso wordmark and icon -> BitMatrix ---------- */
/* BrandingLogo is an inline <svg viewBox="0 0 2248 320">; BrandingLogoIcon is viewBox="0 0 84 84". UPGRADE */
svg[viewBox="0 0 2248 320"],
svg[viewBox="0 0 84 84"] {
  background: url("/bmx-theme/brand/logo-color.svg") left center / contain no-repeat;
}
svg[viewBox="0 0 84 84"] { background-image: url("/bmx-theme/brand/favicon-32x32.png"); background-position: center; }
svg[viewBox="0 0 2248 320"] > *,
svg[viewBox="0 0 84 84"] > * { display: none; }
.dark svg[viewBox="0 0 2248 320"] { background-image: url("/bmx-theme/brand/logo-white.svg"); }

/* ---------- Sign-in / sign-up: brand stage ---------- */
/* The unauthenticated layout is the only place Documenso renders img[alt="background pattern"]. UPGRADE */
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) {
  background-color: hsl(var(--bmx-navy-deep));
  background-image:
    url("/bmx-theme/brand/mark-faint.svg"),
    radial-gradient(120% 90% at 100% 0%, hsl(200 90% 50% / 0.20) 0%, transparent 55%),
    radial-gradient(90% 80% at 0% 100%, hsl(222 60% 30% / 0.55) 0%, transparent 60%),
    linear-gradient(160deg, hsl(222 47% 16%) 0%, hsl(223 52% 9%) 100%);
  background-repeat: no-repeat;
  background-size: min(56vw, 760px) auto, cover, cover, cover;
  background-position: right -12vw bottom -14vw, center, center, center;
  isolation: isolate;
}
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) img[alt="background pattern"] { display: none; }

/* BitMatrix logo above the card (sign-in has none; sign-up's panel is replaced below). */
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) > div > .relative.w-full::before {
  content: "";
  display: block;
  width: 228px;
  height: 45px;
  margin: 0 auto 28px;
  background: url("/bmx-theme/brand/logo-white.svg") center / contain no-repeat;
}

/* On sign-up at >= 1280px the brand panel carries the logo instead. */
@media (min-width: 1280px) {
  html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(img[src*="community-cards"]) > div > .relative.w-full::before { display: none; }
}
/* Sign-up's form row carries lg:-my-16, which would slide the card over the logo. */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(img[src*="community-cards"]) > div > .relative.w-full::before { margin-bottom: 92px; }
}

/* The card: white, crisp, a real shadow on the navy stage. */
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) .rounded-xl.border.bg-neutral-100 {
  background: hsl(0 0% 100%);
  border-color: hsl(222 47% 14% / 0.12);
  border-radius: 14px;
  box-shadow: 0 1px 2px hsl(223 52% 5% / 0.25), 0 24px 48px -12px hsl(223 52% 5% / 0.55);
}
/* The card is ALWAYS light, in dark mode too (2026-10-05: in macOS dark mode
   the white card carried dark-mode tokens: white text, near-black inputs).
   Re-declare the light token set on the card itself so every descendant
   resolves light values whatever html.dark says; the navy stage stays.
   `color` is set here because body's colour is inherited as a computed value.
   Two shapes: sign-in/sign-up wrap the form in a card (.rounded-xl.border.
   bg-neutral-100); forgot/reset password and similar pages put the bare form
   (.w-screen.max-w-lg > .w-full) on the stage, which in light mode meant navy
   text on navy. The bare form gets the same card below. UPGRADE */
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) :is(.rounded-xl.border.bg-neutral-100, .relative.w-full > .w-screen.max-w-lg > .w-full:not(:has(.rounded-xl.border.bg-neutral-100))) {
  color-scheme: light;
  --background: 0 0% 100%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --popover: 0 0% 100%;
  --popover-foreground: 222 47% 11%;
  --widget: 0 0% 100%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 220 14% 36%;     /* on white ~7:1 */
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222 47% 14%;
  --accent: 205 60% 95%;
  --accent-foreground: 222 47% 14%;
  --border: 220 16% 82%;
  --input: 220 13% 54%;                /* input outline on white ~3.9:1 (non-text AA 3:1) */
  --primary: var(--bmx-navy);
  --primary-foreground: 0 0% 100%;
  --ring: var(--bmx-sky-ring);
  --destructive: 345 82.7% 40.8%;
  --destructive-foreground: 0 0% 100%;
  color: hsl(var(--foreground));
}
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) :is(.rounded-xl.border.bg-neutral-100, .relative.w-full > .w-screen.max-w-lg > .w-full:not(:has(.rounded-xl.border.bg-neutral-100))) :is(input, textarea)::placeholder {
  color: hsl(220 9% 40%);              /* ~6:1 on white */
  opacity: 1;
}
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) :is(.rounded-xl.border.bg-neutral-100, .relative.w-full > .w-screen.max-w-lg > .w-full:not(:has(.rounded-xl.border.bg-neutral-100))) :is(.text-documenso-700, .text-documenso-800, a.text-primary) { color: hsl(var(--bmx-sky-ink)); }
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) :is(.rounded-xl.border.bg-neutral-100, .relative.w-full > .w-screen.max-w-lg > .w-full:not(:has(.rounded-xl.border.bg-neutral-100))) :is(button.bg-primary, .dark\:bg-documenso) { background-color: hsl(var(--bmx-navy)); color: hsl(0 0% 100%); }
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) .relative.w-full > .w-screen.max-w-lg > .w-full:not(:has(.rounded-xl.border.bg-neutral-100)) {
  background: hsl(0 0% 100%);
  border: 1px solid hsl(222 47% 14% / 0.12);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 1px 2px hsl(223 52% 5% / 0.25), 0 24px 48px -12px hsl(223 52% 5% / 0.55);
}
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(> div > div.absolute > img[alt="background pattern"]) h1 { letter-spacing: -0.015em; font-weight: 700; }

/* Sign-up side panel (Documenso's community image + testimonial) -> BitMatrix brand panel.
   Shown by Documenso only at >= 1280px wide. UPGRADE */
html:has(main > div > div.absolute > img[alt="background pattern"]) div:has(> div > img[src*="community-cards"]) {
  position: relative;
  background:
    url("/bmx-theme/brand/mark-faint.svg") right -14% bottom -12% / 72% auto no-repeat,
    radial-gradient(90% 70% at 0% 0%, hsl(200 90% 50% / 0.16) 0%, transparent 60%),
    linear-gradient(165deg, hsl(222 47% 18%) 0%, hsl(223 52% 10%) 100%);
  border-color: hsl(200 90% 50% / 0.22) !important;
  border-radius: 14px;
  box-shadow: 0 24px 48px -12px hsl(223 52% 5% / 0.55);
}
html:has(main > div > div.absolute > img[alt="background pattern"]) div:has(> div > img[src*="community-cards"]) > * { display: none !important; }
html:has(main > div > div.absolute > img[alt="background pattern"]) div:has(> div > img[src*="community-cards"])::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/bmx-theme/brand/logo-white.svg") center 44% / 60% auto no-repeat;
  pointer-events: none;
}
html:has(main > div > div.absolute > img[alt="background pattern"]) div:has(> div > img[src*="community-cards"])::before {
  content: "BitMatrix IT Solutions";
  position: absolute;
  left: 32px;
  bottom: 28px;
  color: hsl(210 30% 86%);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Sign-up: hide Documenso's own marketing and legal lines (they are not ours).
   Both anchored on the sign-up page's Documenso terms link, so nothing else
   (and nothing on the recipient signing flow) can match. UPGRADE */
html:has(main > div > div.absolute > img[alt="background pattern"]) p:has(> a[href="https://documen.so/terms"]) { display: none !important; }
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(a[href="https://documen.so/terms"]) div.h-20 > h1 + p.text-muted-foreground { display: none !important; }
html:has(main > div > div.absolute > img[alt="background pattern"]) main:has(a[href="https://documen.so/terms"]) div.h-20:has(> h1) { height: auto; padding-bottom: 1.25rem; }

/* Sign-in: sign-up is closed (the /signup route 403s at the proxy), so hide
   "Don't have an account? Sign up". UPGRADE */
html:has(main > div > div.absolute > img[alt="background pattern"]) p:has(> a[href^="/signup"]) { display: none !important; }
