/* ==========================================================================
   Corpserve KSA - colour palettes
   --------------------------------------------------------------------------
   Every Tailwind colour token used on the site (see assets/js/theme.js) reads
   one of the CSS variables below, as space-separated RGB channels so that
   opacity modifiers such as bg-accent/15 keep working.

   Two palettes are available, switched from the navbar (#palette-toggle):
     - default : original teal / orange palette   (no attribute needed)
     - navy    : html[data-palette="navy"]        (navy / midnight / royal / cream)

   Light / dark mode (html.dark) works inside BOTH palettes.

   Navy palette source colours:
     navy #010737   midnight-blue #0D1C43   royal-blue #22396D   cream #FCF1D1
   A few derived tints (deeper cream for section backgrounds / borders, a
   muted blue for body text) are used where the 4 brand colours alone can't
   give enough contrast or separation.
   ========================================================================== */

:root {
  --c-white: 255 255 255;
  --c-section: 242 243 244;
  --c-border-soft: 226 229 231;
  --c-text: 21 23 25;            /* headings / main text   (midnight_text) */
  --c-body: 89 102 109;          /* muted body text        (grey, body_color) */
  --c-primary: 33 62 72;
  --c-accent: 255 121 46;
  --c-on-accent: 255 255 255;    /* text colour on a solid accent background */
  --c-logo-dot: 255 121 46;
  --c-footer-bg: 0 0 0;
  --c-footer-text: 184 194 199;
  --c-footer-line: 51 51 51;
  --c-darkmode: 21 23 25;
  --c-darklight: 33 62 72;
  --c-dark-border: 89 102 109;

  /* toggle-button swatch: previews the palette you will switch TO */
  --sw-a: 1 7 55;
  --sw-b: 248 248 255;
}

/* ---------- Navy palette : light mode (cream surfaces) ---------- */
html[data-palette="navy"] {
  --c-white: 245 245 245;        /* cream  - page + card background */
  --c-section: 243 227 174;      /* deeper cream - alternate sections */
  --c-border-soft: 230 215 166;
  --c-text: 1 7 55;              /* navy */
  --c-body: 67 85 124;           /* royal-blue tinted, readable on cream */
  --c-primary: 13 28 67;         /* midnight-blue */
  --c-accent: 34 57 109;         /* royal-blue */
  --c-on-accent: 248 248 255;
  --c-logo-dot: 248 248 255;
  --c-footer-bg: 1 7 55;
  --c-footer-text: 201 194 169;
  --c-footer-line: 34 57 109;
  --c-darkmode: 13 28 67;
  --c-darklight: 34 57 109;
  --c-dark-border: 89 103 134;

  --sw-a: 33 62 72;
  --sw-b: 255 121 46;
}

/* ---------- Navy palette : dark mode ---------- */
html[data-palette="navy"].dark {
  --c-accent: 252 241 209;       /* cream accent on navy surfaces */
  --c-on-accent: 1 7 55;
  --c-primary: 34 57 109;        /* royal-blue blocks stand out on midnight */
}

/* Dark blocks inside the light navy palette: accent must flip to cream so it
   stays readable on midnight / navy backgrounds (the footer and bg-primary
   bands). Variables are inherited, so everything inside follows. */
html[data-palette="navy"] .bg-primary,
html[data-palette="navy"] .bg-footer_bg {
  --c-accent: 252 241 209;
  --c-on-accent: 1 7 55;
}
html[data-palette="navy"] .bg-footer_bg {
  --c-primary: 34 57 109;
}

/* Solid accent buttons/badges: the template hard-codes text-white on them.
   In the navy palette the text colour has to follow the accent instead. */
html[data-palette="navy"] .bg-accent {
  color: rgb(var(--c-on-accent));
}
html[data-palette="navy"] .bg-accent[class*="hover:bg-primary"]:hover {
  color: rgb(var(--c-white));
}

/* Progress bar colour (was hard-coded orange) */
#nprogress .bar { background: rgb(var(--c-accent)) !important; }

/* ---------- Palette toggle button (navbar) ---------- */
.palette-swatch {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 9999px;
  border: 2px solid currentColor;
  background: linear-gradient(135deg, rgb(var(--sw-a)) 50%, rgb(var(--sw-b)) 50%);
  transition: transform .3s ease;
}
#palette-toggle:hover .palette-swatch { transform: rotate(180deg); }
/* label shows which palette a click will switch to */
#palette-toggle .pal-to-default { display: none; }
html[data-palette="navy"] #palette-toggle .pal-to-navy { display: none; }
html[data-palette="navy"] #palette-toggle .pal-to-default { display: inline; }
