/* The bridge between the older pages and the themes: every variable of mila.css's :root block, the old --mila-* names
   included, takes its value from the --ux-* tokens, so the pages still drawn by mila.css follow the institution's theme and
   the person's mode. Loaded after mila.css and before ux.css.

   - The navy of mila.css is the theme's link colour (its deeper shades lean toward the ink): links on the page, and the buttons
     and dark blocks mila.css fills with it.
   - The gold is the theme's accent; its soft background is a tint of the accent with the ink on it.
   - Green and red are the good and critical tones; the green fill is darkened toward the ink.

   The first block holds values only. The rules after it restate the few colours (and the link underline) that mila.css and
   the Canvas template write down instead of reading a variable, so the older pages also read by night; each takes tokens only,
   mostly with the same selectors as the rule it answers, and keeps !important only where that rule forces the same property
   with !important. */

:root {
  --navy-900: color-mix(in srgb, var(--ux-link) 65%, var(--ux-ink));
  --navy-800: color-mix(in srgb, var(--ux-link) 80%, var(--ux-ink));
  --navy-700: var(--ux-link);
  --gold: var(--ux-accent);
  --gold-2: var(--ux-accent);
  --gold-soft: color-mix(in srgb, var(--ux-accent) 14%, var(--ux-surface));
  --ink: var(--ux-ink);
  --muted: var(--ux-muted);
  --line: var(--ux-line);
  --bg: var(--ux-bg);
  --surface: var(--ux-surface);
  --surface-2: var(--ux-surface-2);
  --green: color-mix(in srgb, var(--ux-tone-good) 70%, var(--ux-ink));
  --green-bg: var(--ux-tone-good-bg);
  --red: var(--ux-tone-critical);
  --red-bg: var(--ux-tone-critical-bg);
  --radius: var(--ux-radius);
  --radius-sm: var(--ux-radius-sm);
  --shadow: var(--ux-shadow);
  --shadow-sm: var(--ux-shadow-sm);
  --sidebar-w: var(--ux-sidebar-width);
  --font: var(--ux-font);

  --gold-ink: var(--ux-accent-ink);
  --gold-ink-soft: var(--ux-ink);
  --gold-rgb: var(--ux-accent-rgb);
  --accent-on-dark: var(--ux-accent);
  --accent-on-dark-rgb: var(--ux-accent-rgb);
  --green-ink: var(--ux-tone-good-ink);
  --red-ink: var(--ux-tone-critical-ink);
  --focus-ring: var(--ux-focus);
  --focus-ring-on-dark: var(--ux-sidebar-ink);

  --mila-navy-900: color-mix(in srgb, var(--ux-link) 65%, var(--ux-ink));
  --mila-navy-800: color-mix(in srgb, var(--ux-link) 80%, var(--ux-ink));
  --mila-navy-700: var(--ux-link);
  --mila-gold: var(--ux-accent);
  --mila-gold-2: var(--ux-accent);
  --mila-gold-soft: color-mix(in srgb, var(--ux-accent) 14%, var(--ux-surface));
  --mila-ink: var(--ux-ink);
  --mila-muted: var(--ux-muted);
  --mila-line: var(--ux-line);
  --mila-bg: var(--ux-bg);
  --mila-surface: var(--ux-surface);
  --mila-surface-2: var(--ux-surface-2);
  --mila-green: color-mix(in srgb, var(--ux-tone-good) 70%, var(--ux-ink));
  --mila-green-bg: var(--ux-tone-good-bg);
  --mila-red: var(--ux-tone-critical);
  --mila-red-bg: var(--ux-tone-critical-bg);
  --mila-radius: var(--ux-radius);
  --mila-radius-sm: var(--ux-radius-sm);
  --mila-shadow: var(--ux-shadow);
  --mila-shadow-sm: var(--ux-shadow-sm);
}

/* The words on a filled button or a dark block: mila.css writes them white; here they are the surface, which is white in
   every light theme and the dark surface by night, when the fills take the light link colour (and the light tones). The
   button rules follow mila.css's order, so a gold or a plain button keeps its own words. */
.button { color: var(--ux-surface) !important; }
.button:hover { color: var(--ux-surface) !important; }
.btn-gold, .button-gold, .button.button-gold,
.button-3d.gradient-grey-orange, .button.gradient-grey-orange { color: var(--gold-ink) !important; }
.btn-gold:hover, .button-gold:hover { color: var(--gold-ink) !important; }
.btn-navy, .button-navy,
.gradient-blue-green, .gradient-ocean, .gradient-sky, .gradient-deep,
.button-blue, .button-teal, .button-aqua, .button-purple { color: var(--ux-surface) !important; }
.gradient-green, .button-green, .gradient-fun { color: var(--ux-surface) !important; }
.gradient-horizon, .gradient-cherry, .button-red, .button-pink, .gradient-purple-red { color: var(--ux-surface) !important; }
.btn-ghost, .gradient-earth, .button-light, .gradient-grey, .button.button-3d.gradient-earth { color: var(--navy-700) !important; }
.btn-ghost:hover, .gradient-earth:hover { color: var(--navy-700) !important; }
.btn-primary { color: var(--ux-surface) !important; }
.btn-success { color: var(--ux-surface) !important; }
.btn-danger { color: var(--ux-surface) !important; }
.btn-secondary { color: var(--ux-surface) !important; }
.btn-warning { color: var(--gold-ink) !important; }
.btn-link { color: var(--navy-700) !important; }
.btn-outline-primary { color: var(--navy-700) !important; }
.btn-outline-primary:hover { color: var(--ux-surface) !important; }
.btn-outline-warning { color: var(--gold-ink-soft) !important; }
.btn-outline-warning:hover { color: var(--gold-ink) !important; }
.pagination .page-item.active .page-link,
.pagination.pagination-light .page-item.active .page-link,
.pagination .page-link[aria-current="page"] { color: var(--ux-surface) !important; }
.pagination .page-link:hover, .pagination .page-link:focus,
.pagination.pagination-light .page-link:hover,
.pagination.pagination-light .page-link:focus { color: var(--navy-700) !important; }
.pagination.pagination-light .page-item.active .page-link:hover,
.pagination.pagination-light .page-item.active .page-link:focus { color: var(--ux-surface) !important; }
.btn-ghost.active, .btn-ghost[aria-current="true"], .btn-ghost[aria-current="page"],
.button-light.active, .gradient-earth.active { color: var(--ux-surface) !important; }
.mila-lang a.on, .mila-lang button.on { color: var(--ux-surface); }
.mila-content .promo { color: var(--ux-surface) !important; }
.mila-content .promo h1, .mila-content .promo h2, .mila-content .promo h3,
.mila-content .promo h4, .mila-content .promo p, .mila-content .promo span { color: var(--ux-surface) !important; }
.mila-content .feature-box.fbox-border .fbox-icon i { color: var(--ux-surface) !important; }
.mila-content .feature-box.fbox-effect .fbox-icon i:hover,
.mila-content .feature-box.fbox-effect:hover .fbox-icon i { color: var(--ux-surface) !important; }

/* The soft backgrounds mila.css writes as fixed light colours: a tint of the link colour (navy notes and badges) and of the
   accent (gold badges) over the surface, light by day as before and dark by night. */
.badge-info, .badge-primary, .b-navy { background: color-mix(in srgb, var(--ux-link) 8%, var(--ux-surface)) !important; }
.badge-warning, .b-gold { background: color-mix(in srgb, var(--gold) 22%, var(--ux-surface)) !important; }
.alert-info {
  background: color-mix(in srgb, var(--ux-link) 8%, var(--ux-surface)) !important;
  border-color: color-mix(in srgb, var(--ux-link) 16%, var(--ux-surface)) !important;
}
.badge.bg-warning, .bg-warning-subtle { background: color-mix(in srgb, var(--gold) 22%, var(--ux-surface)) !important; }
.badge.bg-info, .bg-info-subtle, .badge.bg-primary, .bg-primary-subtle { background: color-mix(in srgb, var(--ux-link) 8%, var(--ux-surface)) !important; }
.badge.bg-secondary, .bg-secondary-subtle { background: color-mix(in srgb, var(--ux-link) 8%, var(--ux-surface)) !important; }

/* The Canvas template's headings (a fixed grey), Bootstrap's menus and dialogs (white), inline code (pink) and preformatted samples (a fixed dark grey,
   unreadable on a night surface) take the ink and the surface. */
h1, h2, h3, h4, h5, h6 { color: var(--ux-ink); }
.dropdown-menu, .modal-content { background-color: var(--ux-surface); color: var(--ux-ink); }
code, pre { color: var(--ux-ink); }

/* Bootstrap writes a table's caption in a fixed grey, too faint on a night surface: it takes the quiet text colour. */
caption { color: var(--ux-muted); }

/* The theme's Arabic face sets wider than mila.css's Cairo: the tables of a two-column panel row keep a narrower cell padding,
   so the columns of the narrow panel still fit without a sideways scroll. */
.mila-row2 .table td, .mila-row2 .table th { padding-inline: 8px; }

/* A link inside running text (a note, a quiet line, a page's subtitle) is underlined, so it is told apart from the words around
   it by more than its colour; the Canvas template removes every link's underline with !important. */
.alert a:not(.btn):not(.button),
.meta a:not(.btn):not(.button),
.mila-page-head p a:not(.btn):not(.button) { text-decoration: underline !important; text-underline-offset: 0.2em; }

/* A heading's quiet count («(N)» after a panel's title): the Canvas template gives every span of a heading its fixed teal (2.4:1 on white); the
   quiet text colour reads on the panel by day and by night. */
h1 > span.meta:not(.nocolor):not(.badge), h2 > span.meta:not(.nocolor):not(.badge), h3 > span.meta:not(.nocolor):not(.badge),
h4 > span.meta:not(.nocolor):not(.badge), h5 > span.meta:not(.nocolor):not(.badge), h6 > span.meta:not(.nocolor):not(.badge) { color: var(--ux-muted); }

/* A link in a note keeps the note's own colour: the note's tint is not the page's, so the link colour of a theme can fall short on it. The underline above tells it apart. */
.alert a:not(.btn):not(.button) { color: inherit; }
