/* BriarWatch brand theme for the whole app (BRAND.md "Palette" and "Type").
   Dark is the default; <html data-theme="light"> switches to the light set (js/theme.js remembers the choice).

   1. --bw-* tokens: the BRAND.md palette, verbatim.
   2. --c-* scales: Tailwind's gray / sky / indigo / blue / purple / cyan / violet and white read these
      (js/theme.js sets tailwind.config), so the starter's pages and every org page follow the brand and the
      theme without being rewritten. Dark reverses each scale (gray-50 is the page navy, gray-900 the body
      text, white is the card surface), so "bg-white text-gray-900" stays a readable card in both themes.
   3. The dashboard RCL (.bw-dash) mapped onto the same navy, text and briar green, so the site dashboard and
      the org pages read as one product.
   4. The starter's hand-written classes (.card, .btn-primary, .form-input, ...) re-pointed at the tokens.

   Contrast: BrandThemeTests checks every text pair here is at least 4.5:1. Edit a value, run the tests. */

:root {
  /* ---- 1. brand tokens: dark (default) ---- */
  --bw-bg:          #0D131F;
  --bw-surface:     #151D2C;
  --bw-raised:      #1D2738;
  --bw-border:      #2A3548;
  --bw-text:        #E8ECF2;
  --bw-text-muted:  #9AA6B8;
  --bw-cream:       #F5F5EB;
  --bw-briar:       #8DB84A;
  --bw-briar-hi:    #A6CC5E;
  --bw-on-briar:    #0D131F;
  --bw-ok:          #4CC38A;
  --bw-warn:        #E8B84E;
  --bw-crit:        #F07171;
  --bw-info:        #6CB4EE;
  --bw-unknown:     #8E9AAD;
  --bw-font-display: "Manrope", system-ui, sans-serif;
  --bw-font-body:    "Inter", system-ui, sans-serif;
  --bw-font-mono:    "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;

  /* ---- 2. Tailwind scales: dark (space-separated RGB for rgb(var() / alpha)) ---- */
  --c-white:    21 29 44;    /* = --bw-surface */
  --c-gray-50:  13 19 31;    /* = --bw-bg */
  --c-gray-100: 29 39 56;    /* = --bw-raised */
  --c-gray-200: 42 53 72;    /* = --bw-border */
  --c-gray-300: 58 70 89;
  --c-gray-400: 122 135 156;
  --c-gray-500: 142 154 173; /* = --bw-unknown */
  --c-gray-600: 154 166 184; /* = --bw-text-muted */
  --c-gray-700: 194 202 214;
  --c-gray-800: 217 223 231;
  --c-gray-900: 232 236 242; /* = --bw-text */
  --c-gray-950: 245 245 235; /* = --bw-cream */
  --c-accent-50:  20 31 18;
  --c-accent-100: 28 42 22;
  --c-accent-200: 42 61 30;
  --c-accent-300: 63 90 38;
  --c-accent-400: 110 154 46;
  --c-accent-500: 141 184 74;  /* = --bw-briar */
  --c-accent-600: 166 204 94;  /* = --bw-briar-hi */
  --c-accent-700: 190 219 134;
  --c-accent-800: 211 231 174;
  --c-accent-900: 230 241 210;
  --c-accent-950: 243 248 233;
  --c-red-50: 69 10 10;   --c-red-100: 127 29 29;  --c-red-200: 153 27 27;  --c-red-300: 185 28 28;
  --c-red-400: 220 38 38; --c-red-500: 239 68 68;  --c-red-600: 240 113 113; --c-red-700: 252 165 165;
  --c-red-800: 254 202 202; --c-red-900: 254 226 226; --c-red-950: 254 242 242;
  --c-green-50: 5 46 22;  --c-green-100: 20 83 45; --c-green-200: 22 101 52; --c-green-300: 21 128 61;
  --c-green-400: 22 163 74; --c-green-500: 34 197 94; --c-green-600: 76 195 138; --c-green-700: 134 239 172;
  --c-green-800: 187 247 208; --c-green-900: 220 252 231; --c-green-950: 240 253 244;
  --c-emerald-50: 2 44 34; --c-emerald-100: 6 78 59; --c-emerald-200: 6 95 70; --c-emerald-300: 4 120 87;
  --c-emerald-400: 5 150 105; --c-emerald-500: 16 185 129; --c-emerald-600: 76 195 138; --c-emerald-700: 110 231 183;
  --c-emerald-800: 167 243 208; --c-emerald-900: 209 250 229; --c-emerald-950: 236 253 245;
  --c-amber-50: 69 26 3;  --c-amber-100: 120 53 15; --c-amber-200: 146 64 14; --c-amber-300: 180 83 9;
  --c-amber-400: 217 119 6; --c-amber-500: 245 158 11; --c-amber-600: 232 184 78; --c-amber-700: 252 211 77;
  --c-amber-800: 253 230 138; --c-amber-900: 254 243 199; --c-amber-950: 255 251 235;
  --c-yellow-50: 66 32 6; --c-yellow-100: 113 63 18; --c-yellow-200: 133 77 14; --c-yellow-300: 161 98 7;
  --c-yellow-400: 202 138 4; --c-yellow-500: 234 179 8; --c-yellow-600: 232 184 78; --c-yellow-700: 253 224 71;
  --c-yellow-800: 254 240 138; --c-yellow-900: 254 249 195; --c-yellow-950: 254 252 232;
  color-scheme: dark;
}

:root[data-theme="light"] {
  /* ---- 1. brand tokens: light ---- */
  --bw-bg:          #FFFFFF;
  --bw-surface:     #F5F7F2;
  --bw-raised:      #ECEFE8;
  --bw-border:      #D5DBD0;
  --bw-text:        #16202E;
  --bw-text-muted:  #4F5B6C;
  --bw-cream:       #16202E;
  --bw-briar:       #436B19;
  --bw-briar-hi:    #436B19;
  --bw-on-briar:    #FFFFFF;
  --bw-ok:          #1B6E44;
  --bw-warn:        #8A5A00;
  --bw-crit:        #B42323;
  --bw-info:        #1C64A0;
  --bw-unknown:     #5D6878;

  /* ---- 2. Tailwind scales: light ---- */
  --c-white:    255 255 255;
  --c-gray-50:  245 247 242; /* = --bw-surface */
  --c-gray-100: 236 239 232; /* = --bw-raised */
  --c-gray-200: 213 219 208; /* = --bw-border */
  --c-gray-300: 184 192 184;
  --c-gray-400: 140 150 160;
  --c-gray-500: 93 104 120;  /* = --bw-unknown */
  --c-gray-600: 79 91 108;   /* = --bw-text-muted */
  --c-gray-700: 55 66 83;
  --c-gray-800: 35 46 62;
  --c-gray-900: 22 32 46;    /* = --bw-text */
  --c-gray-950: 13 19 31;
  --c-accent-50:  242 247 234;
  --c-accent-100: 227 239 208;
  --c-accent-200: 200 224 162;
  --c-accent-300: 166 204 94;
  --c-accent-400: 127 168 60;
  --c-accent-500: 77 122 28;
  --c-accent-600: 67 107 25;   /* = --bw-briar (light) */
  --c-accent-700: 55 88 21;
  --c-accent-800: 44 70 17;
  --c-accent-900: 34 55 13;
  --c-accent-950: 20 31 8;
  --c-red-50: 254 242 242; --c-red-100: 254 226 226; --c-red-200: 254 202 202; --c-red-300: 252 165 165;
  --c-red-400: 248 113 113; --c-red-500: 239 68 68; --c-red-600: 180 35 35; --c-red-700: 185 28 28;
  --c-red-800: 153 27 27; --c-red-900: 127 29 29; --c-red-950: 69 10 10;
  --c-green-50: 240 253 244; --c-green-100: 220 252 231; --c-green-200: 187 247 208; --c-green-300: 134 239 172;
  --c-green-400: 74 222 128; --c-green-500: 34 197 94; --c-green-600: 27 110 68; --c-green-700: 21 128 61;
  --c-green-800: 22 101 52; --c-green-900: 20 83 45; --c-green-950: 5 46 22;
  --c-emerald-50: 236 253 245; --c-emerald-100: 209 250 229; --c-emerald-200: 167 243 208; --c-emerald-300: 110 231 183;
  --c-emerald-400: 52 211 153; --c-emerald-500: 16 185 129; --c-emerald-600: 27 110 68; --c-emerald-700: 4 120 87;
  --c-emerald-800: 6 95 70; --c-emerald-900: 6 78 59; --c-emerald-950: 2 44 34;
  --c-amber-50: 255 251 235; --c-amber-100: 254 243 199; --c-amber-200: 253 230 138; --c-amber-300: 252 211 77;
  --c-amber-400: 251 191 36; --c-amber-500: 245 158 11; --c-amber-600: 138 90 0; --c-amber-700: 180 83 9;
  --c-amber-800: 146 64 14; --c-amber-900: 120 53 15; --c-amber-950: 69 26 3;
  --c-yellow-50: 254 252 232; --c-yellow-100: 254 249 195; --c-yellow-200: 254 240 138; --c-yellow-300: 253 224 71;
  --c-yellow-400: 250 204 21; --c-yellow-500: 234 179 8; --c-yellow-600: 138 90 0; --c-yellow-700: 161 98 7;
  --c-yellow-800: 133 77 14; --c-yellow-900: 113 63 18; --c-yellow-950: 66 32 6;
  color-scheme: light;
}

/* ---- base ---- */
html { font-family: var(--bw-font-body); }
body { background: rgb(var(--c-gray-50)); color: rgb(var(--c-gray-900)); font-family: var(--bw-font-body); }
h1, h2, h3, .font-display { font-family: var(--bw-font-display); }
code, kbd, samp, pre, .font-mono { font-family: var(--bw-font-mono); }
.tabular-nums { font-variant-numeric: tabular-nums; }
/* The starter strips focus rings (app.css); keyboard users still need to see where they are. */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--bw-briar-hi) !important;
  outline-offset: 2px;
}
::selection { background: rgb(var(--c-accent-300)); color: rgb(var(--c-gray-950)); }

/* ---- the brand mark in every header (Shared/BrandMark.razor) ---- */
.bw-brand { display: inline-flex; align-items: center; gap: 10px; color: rgb(var(--c-gray-900)); text-decoration: none; }
.bw-brand img { display: block; height: 32px; width: auto; border-radius: 6px; }
.bw-brand span { font-family: var(--bw-font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.bw-brand span b { color: var(--bw-briar); font-weight: 800; }
.bw-brand.on-dark { color: #F5F5EB; }
.bw-brand.on-dark span b { color: #8DB84A; }

/* ---- 3. dashboard RCL (.bw-dash) on the brand palette ----
   html:root beats the RCL's own .bw-dash[data-theme] blocks, so the site's theme drives the dashboard.
   Status tones (ok/warn/down/standby/none) stay the RCL's own, which its ContrastTests cover. */
html:root .bw-dash {
  --bw-font: var(--bw-font-body);
  --bw-mono: var(--bw-font-mono);
  --bw-bg: #0D131F;
  --bw-surface: #151D2C;
  --bw-surface-2: #111827;
  --bw-surface-3: #1D2738;
  --bw-border: #2A3548;
  --bw-border-strong: #334057;
  --bw-border-dashed: #445169;
  --bw-border-hover: #56637A;
  --bw-text: #E8ECF2;
  --bw-text-2: #C9D1DB;
  --bw-muted: #9AA6B8;
  --bw-accent: #8DB84A;
  --bw-accent-bg: #22331A;
  --bw-accent-fg: #A6CC5E;
  --bw-accent-fg-2: #BEDB86;
  --bw-selected-bg: #1A2619;
  --bw-link: #6B778C;
  --bw-cell-empty: #2A3548;
  --bw-ok-bg: #123A2E;      --bw-ok-fg: #6EE7B7;      --bw-ok-fill: #3FB98C;      --bw-ok-line: #3FB98C;      --bw-ok-tint: #12261F;
  --bw-warn-bg: #3A2E10;    --bw-warn-fg: #F8CF6E;    --bw-warn-fill: #F2B33D;    --bw-warn-line: #F2B33D;    --bw-warn-tint: #2A2312;
  --bw-down-bg: #4A1F1A;    --bw-down-fg: #FFB4A8;    --bw-down-fill: #E5484D;    --bw-down-line: #FF6B5B;    --bw-down-tint: #2A1714;
  --bw-standby-bg: #1E3A5F; --bw-standby-fg: #A9D0FF; --bw-standby-fill: #5AA9FF; --bw-standby-line: #5AA9FF; --bw-standby-tint: #14243A;
  --bw-none-bg: #262D36;    --bw-none-fg: #C9D1D9;    --bw-none-fill: #6B7685;    --bw-none-line: #6B7685;    --bw-none-tint: #1C222B;
  --bw-attn-bg: #1F1714;
  --bw-attn-border: #5A2E25;
  color-scheme: dark;
}
html:root[data-theme="light"] .bw-dash {
  --bw-bg: #F5F7F2;
  --bw-surface: #FFFFFF;
  --bw-surface-2: #F9FAF7;
  --bw-surface-3: #ECEFE8;
  --bw-border: #D5DBD0;
  --bw-border-strong: #C3CABF;
  --bw-border-dashed: #A3AC9F;
  --bw-border-hover: #848E80;
  --bw-text: #16202E;
  --bw-text-2: #2E3A4A;
  --bw-muted: #4F5B6C;
  --bw-accent: #436B19;
  --bw-accent-bg: #E3EFD0;
  --bw-accent-fg: #375815;
  --bw-accent-fg-2: #375815;
  --bw-selected-bg: #EEF5E3;
  --bw-link: #848E80;
  --bw-cell-empty: #DFE4DA;
  --bw-ok-bg: #DDF5EA;      --bw-ok-fg: #0B6B43;      --bw-ok-fill: #16704A;      --bw-ok-line: #16704A;      --bw-ok-tint: #F0FAF5;
  --bw-warn-bg: #FBEFCB;    --bw-warn-fg: #7A4D00;    --bw-warn-fill: #A87300;    --bw-warn-line: #A87300;    --bw-warn-tint: #FFF9E8;
  --bw-down-bg: #FDE4E1;    --bw-down-fg: #A3201A;    --bw-down-fill: #8E1B14;    --bw-down-line: #C4312A;    --bw-down-tint: #FFF1EF;
  --bw-standby-bg: #DDEBFF; --bw-standby-fg: #174C8C; --bw-standby-fill: #3B82E0; --bw-standby-line: #3B82E0; --bw-standby-tint: #F0F6FF;
  --bw-none-bg: #E8ECF0;    --bw-none-fg: #3D4752;    --bw-none-fill: #8C96A3;    --bw-none-line: #7C8794;    --bw-none-tint: #F4F6F8;
  --bw-attn-bg: #FFF4F2;
  --bw-attn-border: #F1C2BA;
  color-scheme: light;
}

/* ---- 4. the starter's hand-written classes (app.css hard-codes light colours on them) ---- */
.card { background-color: rgb(var(--c-white)); border: 1px solid rgb(var(--c-gray-200)); box-shadow: none; }
.card-header { border-bottom-color: rgb(var(--c-gray-200)); }
.form-input { color: rgb(var(--c-gray-900)); background-color: rgb(var(--c-gray-50)); border-color: rgb(var(--c-gray-300)); }
.form-input::placeholder { color: rgb(var(--c-gray-500)); }
.form-input:focus { border-color: var(--bw-briar-hi); box-shadow: 0 0 0 3px rgb(var(--c-accent-500) / 0.25); }
.form-label { color: rgb(var(--c-gray-800)); }
.btn-primary { background-color: var(--bw-briar); color: var(--bw-on-briar); font-weight: 600; }
.btn-primary:hover { background-color: var(--bw-briar-hi); }
:root[data-theme="light"] .btn-primary:hover { background-color: rgb(var(--c-accent-700)); }
.btn-secondary { background-color: rgb(var(--c-white)); color: rgb(var(--c-gray-800)); border-color: rgb(var(--c-gray-300)); }
.btn-secondary:hover { background-color: rgb(var(--c-gray-100)); }
.nav-link { color: rgb(var(--c-gray-600)); }
.nav-link:hover { color: rgb(var(--c-gray-900)); border-bottom-color: rgb(var(--c-gray-300)); }
.nav-link.active { color: var(--bw-briar-hi); border-bottom-color: var(--bw-briar); }
.admin-nav-link.active { color: #0D131F; background-color: #8DB84A; }
.blog-content { color: rgb(var(--c-gray-700)); }
.blog-content h2, .blog-content h3 { color: rgb(var(--c-gray-900)); }
.blog-content a { color: var(--bw-briar-hi); }
.blog-content pre { background: rgb(var(--c-gray-100)); }
.alert-error { background-color: rgb(var(--c-red-50)); border-color: rgb(var(--c-red-300)); color: rgb(var(--c-red-800)); }
.alert-success { background-color: rgb(var(--c-green-50)); border-color: rgb(var(--c-green-300)); color: rgb(var(--c-green-800)); }
:root[data-theme="light"] .alert-error { color: rgb(var(--c-red-700)); }
:root[data-theme="light"] .alert-success { color: rgb(var(--c-green-800)); }

/* Admin sidebar: built from gray-900 / white utilities, which the dark scale flips. Keep it navy in both themes. */
aside.from-gray-900 { background: #0D131F; border-right: 1px solid #2A3548; }
aside.from-gray-900 .text-white, aside.from-gray-900 [class~="!text-white"] { color: #F5F5EB !important; }
aside.from-gray-900 .text-gray-400 { color: #9AA6B8; }
aside.from-gray-900 .text-gray-500 { color: #8E9AAD; }
aside.from-gray-900 .bg-gray-800, aside.from-gray-900 .hover\:bg-gray-800:hover { background-color: #1D2738; }
aside.from-gray-900 .border-gray-800, aside.from-gray-900 .border-gray-700 { border-color: #2A3548; }

/* ---- 5. the template's --bz-* colour tokens (patch 089) on the brand ----
   app.css defines them with light values for the template's own pages (account menu, access denied). Pointing
   them at the --bw-* tokens makes those pages follow the brand in both themes: the --bw-* values switch with
   data-theme, so one mapping covers dark and light. */
:root {
  --bz-page: var(--bw-bg);
  --bz-surface: var(--bw-surface);
  --bz-soft: var(--bw-raised);
  --bz-soft-2: var(--bw-border);
  --bz-text: var(--bw-text);
  --bz-text-800: var(--bw-text);
  --bz-text-700: var(--bw-text);
  --bz-text-600: var(--bw-text-muted);
  --bz-text-500: var(--bw-text-muted);
  --bz-text-400: var(--bw-text-muted);
  --bz-line-100: var(--bw-border);
  --bz-line-200: var(--bw-border);
  --bz-line-300: var(--bw-border);
  --bz-accent: var(--bw-briar);
  --bz-accent-strong: var(--bw-briar-hi);
  --bz-accent-soft: var(--bw-raised);
  --bz-frost: var(--bw-surface);
}
