/*
 * OneAccess customisation of the Metronic shell (ADR-0003).
 * Loaded after the staged vendor stylesheets. Vendor files are never edited; every override lives here.
 * The only z-index here is the skip link's "z-index: 1" inside the header's own stacking context (see below).
 * Metronic's own layers are used as they are (header 100, drawer 110, Bootstrap modal and toast).
 */

/*
 * ICT Authority brand colour, from wwwroot/css/oa/tokens.css (--oa-primary-600, -700, -50).
 * Metronic keeps its default blue in several separate variables, so each one is overridden here.
 * Muted text and menu headings use gray-700 (#4b5675), because the default #99a1b7 fails WCAG AA contrast on white.
 */
:root,
[data-bs-theme="light"] {
  --bs-primary: #0b57d0;
  --bs-primary-rgb: 11, 87, 208;
  --bs-primary-active: #0a47a8;
  --bs-primary-light: #eaf2ff;
  --bs-primary-clarity: rgba(11, 87, 208, 0.2);
  --bs-primary-inverse: #ffffff;
  --bs-text-primary: #0b57d0;
  --bs-text-muted: #4b5675;
  --bs-component-active-bg: #0b57d0;
  --bs-component-hover-color: #0b57d0;
  --bs-component-checked-bg: #0b57d0;
  --bs-menu-heading-color: #4b5675;
  --bs-app-sidebar-light-menu-heading-color: #4b5675;
  --bs-menu-link-color-hover: #0b57d0;
  --bs-menu-link-color-show: #0b57d0;
  --bs-menu-link-color-here: #0b57d0;
  --bs-menu-link-color-active: #0b57d0;
  --bs-ribbon-label-bg: #0b57d0;

  /*
   * Success, warning and danger use the OneAccess tokens (--oa-success-600/50, --oa-warning-600/50, --oa-danger-600/50),
   * which meet WCAG AA with white or dark text. Metronic's defaults (for example #17c653 and #f8285a) do not.
   * The "-active" values are one step darker than the token and are derived here, not taken from the tokens file.
   */
  --bs-success: #166534;
  --bs-success-rgb: 22, 101, 52;
  --bs-success-active: #14532d;
  --bs-success-light: #e3f6ea;
  --bs-success-inverse: #ffffff;
  --bs-text-success: #166534;
  --bs-warning: #8a5a00;
  --bs-warning-rgb: 138, 90, 0;
  --bs-warning-active: #6b4600;
  --bs-warning-light: #fff3d6;
  --bs-warning-inverse: #ffffff;
  --bs-text-warning: #8a5a00;
  --bs-danger: #b42318;
  --bs-danger-rgb: 180, 35, 24;
  --bs-danger-active: #912018;
  --bs-danger-light: #fde8e8;
  --bs-danger-inverse: #ffffff;
  --bs-text-danger: #b42318;
}

/* Initials in the account button are generated content, so they are decoration and never a second visible name. */
.oa-initials::before {
  content: attr(data-initials);
}

/* Skip link: first focusable element, inside the header so it paints above the header itself. */
.oa-skip-link {
  position: absolute;
  inset-inline-start: 0.5rem;
  inset-block-start: -6rem;
  padding: 0.5rem 1rem;
  border-radius: 0.475rem;
  background: var(--bs-body-bg);
  color: var(--bs-primary);
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--bs-primary);
}

/*
 * z-index: 1 is relative to the header's own stacking context (the header is z-index 100). It lifts the focused skip
 * link above positioned siblings such as the search field, which would otherwise paint over it at the lg breakpoint.
 */
.oa-skip-link:focus {
  inset-block-start: 0.5rem;
  z-index: 1;
}

/* Visible focus on every interactive control in the shell. */
.oa-metronic a:focus-visible,
.oa-metronic button:focus-visible,
.oa-metronic input:focus-visible,
.oa-metronic select:focus-visible,
.oa-metronic textarea:focus-visible,
.oa-metronic [tabindex]:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/*
 * Metronic sets ".btn { outline: none !important }" and ".menu-item .menu-link { outline: none !important }" with no
 * replacement ring, so keyboard focus on buttons and sidebar links would be invisible. These overrides need
 * !important only to beat those vendor rules.
 */
.oa-metronic .btn:focus-visible,
.oa-metronic .menu-item .menu-link:focus-visible {
  outline: 2px solid var(--bs-primary) !important;
  outline-offset: 2px;
}

/* The main landmark receives programmatic focus from the skip link. It needs no ring of its own. */
.oa-metronic main:focus {
  outline: none;
}

/* Toasts: a coloured edge so kind is not carried by colour alone (the header text also names the kind). */
.oa-toast {
  border-inline-start-width: 4px;
}

.oa-toast--success { border-inline-start-color: var(--bs-success); }
.oa-toast--info { border-inline-start-color: var(--bs-primary); }
.oa-toast--warning { border-inline-start-color: var(--bs-warning); }
.oa-toast--danger { border-inline-start-color: var(--bs-danger); }

@media (prefers-reduced-motion: reduce) {
  .oa-metronic *,
  .oa-metronic *::before,
  .oa-metronic *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .oa-metronic .menu-link.active {
    outline: 2px solid CanvasText;
  }

  .oa-metronic .btn:focus-visible,
  .oa-metronic .menu-item .menu-link:focus-visible {
    outline-color: Highlight !important;
  }
}

/*
 * Toolbar: Metronic lays .app-toolbar out as one flex row. The narrow-screen search sits in a second container inside it, so
 * without wrapping it squeezes the breadcrumb and is clipped at 390px (found in the Phase B2 responsive review).
 */
.oa-metronic .app-toolbar { flex-wrap: wrap; }

/* Minimised sidebar: the tagline has no room beside icons and would wrap one word per line. */
[data-kt-app-sidebar-minimize="on"] .oa-sidebar-motto { display: none; }
