/*
 * accessibility.css
 * -----------------
 * Application wide WCAG 2.2 AA fixes. Loaded last in Views/Shared/_Layout.cshtml so that it applies on top of
 * Site.css and every override stylesheet. !important is only used where an earlier rule already uses it.
 */

/* Skip link (WCAG 2.4.1) - hidden until it receives keyboard focus */
.skip-link.visually-hidden-focusable:focus,
.skip-link.visually-hidden-focusable:focus-within {
    position: absolute !important;
    top: 0.25rem;
    left: 0.25rem;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background-color: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    text-decoration: underline;
}

/* The main region and the modal dialogs only receive focus programmatically, so they do not need a ring */
#main-content:focus,
#main-content:focus-visible,
.modal:focus,
.modal:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Keep focused elements clear of the page footer when scrolled into view (WCAG 2.4.11) */
html {
    scroll-padding-bottom: 2.5rem;
}

/* Focus indicator (WCAG 2.4.7 / 2.4.11): a blue ring with a white halo so it is visible on light and dark backgrounds */
:focus-visible,
.k-datepicker:focus-visible,
input.filter-txt-control:focus-visible,
select.filter-dd-control:focus-visible,
.k-link:focus-visible {
    outline: 2px solid #005fcc !important;
    outline-offset: 1px !important;
    box-shadow: 0 0 0 4px #ffffff !important;
}

/* Unticked Kendo checkboxes and radio buttons (WCAG 1.4.11): Kendo's border is rgba(0,0,0,.08), 1.19:1 on white */
.k-checkbox:not(:checked):not(:indeterminate),
.k-radio:not(:checked) {
    border-color: #767676;
}

.k-checkbox:focus-visible,
.k-radio:focus-visible {
    outline: 2px solid #005fcc !important;
    outline-offset: 1px !important;
}

/* Kendo widgets don't use :focus-visible: they mark the focused wrapper, grid cell, tree node or menu item with .k-focus,
   including after a mouse click. html.a11y-keyboard is set by accessibility.js while the keyboard is being used (and
   removed on mouse down), so these rings show for keyboard users (WCAG 2.4.7) but not after clicking. */
html.a11y-keyboard .k-input.k-focus,
html.a11y-keyboard .k-picker.k-focus {
    outline: 2px solid #005fcc !important;
    outline-offset: 1px !important;
}

/* Kendo text inputs (date, time, combo box, numeric) look the same as the other text fields when focused: the browser
   shows a text field's ring after a click too, so do the same, and drop the pale blue glow Site.css gave them on focus
   and hover (it was a different blue to the ring). */
.k-input.k-focus,
.k-input.k-focus {
    outline: 2px solid #005fcc !important;
    outline-offset: 1px !important;
    box-shadow: 0 0 0 4px #ffffff !important;
}

.k-input.k-datepicker:hover:not(.k-focus),
.k-input.k-datepicker:focus:not(.k-focus),
.k-input.k-datepicker::selection {
    box-shadow: none !important;
}

/* The ring is drawn on the wrapper, not on the inner input */
.k-input.k-focus .k-input-inner:focus-visible,
.k-picker.k-focus .k-input-inner:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

html.a11y-keyboard .k-grid td.k-focus,
html.a11y-keyboard .k-grid th.k-focus,
html.a11y-keyboard .k-menu .k-item.k-focus > .k-link,
html.a11y-keyboard .k-menu-group .k-item.k-focus > .k-link,
html.a11y-keyboard .k-tabstrip-items .k-tabstrip-item.k-focus,
html.a11y-keyboard .k-treeview-leaf.k-focus,
html.a11y-keyboard .k-treeview-item-content.k-focus > .k-treeview-leaf,
html.a11y-keyboard .k-list-item.k-focus,
html.a11y-keyboard .k-tabstrip:focus-visible,
html.a11y-keyboard .k-menu:focus-visible {
    outline: 2px solid #005fcc !important;
    outline-offset: -2px !important;
}

/* The menu bar and tab strip are focused by script when they open (commonManagement.menuOpen), which the browser can
   treat as :focus-visible before the first mouse click. Never draw the outer white halo on them (it covers the header
   above the menu), and only draw their inset ring while the keyboard is in use (rule above). */
.k-tabstrip:focus-visible,
.k-menu:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

html.a11y-keyboard .k-tabstrip:focus-visible,
html.a11y-keyboard .k-menu:focus-visible {
    box-shadow: none !important;
}

/* Selected rows, error rows, active tabs and selected tree nodes and list items can have a background close to the ring
   colour, which hid the ring (WCAG 2.4.7 / 1.4.11), so add a white inner ring on those */
html.a11y-keyboard .k-grid tr.k-selected > td.k-focus,
html.a11y-keyboard .k-grid tr.alarm > td.k-focus,
html.a11y-keyboard .k-treeview-leaf.k-selected.k-focus,
html.a11y-keyboard .k-treeview-item-content.k-selected.k-focus > .k-treeview-leaf,
html.a11y-keyboard .k-list-item.k-selected.k-focus {
    box-shadow: inset 0 0 0 4px #ffffff !important;
}

/* Active tab (WCAG 1.4.11): Site.css and the light themes give every .k-link the same colours, so the active tab only
   differed by a 1.19:1 border. Underline it in its own text colour, which always contrasts with the tab. (It was also
   bold, which made the white text look blurred on the coloured tab; the underline alone gives the 3:1 needed.) */
.k-tabstrip-items .k-tabstrip-item.k-active > .k-link {
    box-shadow: inset 0 -3px 0 currentColor !important;
}

/* The focused active tab keeps its underline inside the white inner ring (the focus outline covers the bottom 2px) */
html.a11y-keyboard .k-tabstrip-items .k-tabstrip-item.k-active.k-focus > .k-link {
    box-shadow: inset 0 0 0 3px #ffffff, inset 0 -6px 0 currentColor !important;
}

/* Current page in grid pagers (WCAG 1.4.11): Kendo 2023 renders the pages as buttons and marks the current one with a
   faint overlay (about 1.4:1). The themes' .k-pager-wrap rules target markup Kendo no longer renders. */
.k-pager-numbers .k-button.k-button-flat.k-selected,
.k-pager-numbers .k-button.k-button-flat.k-selected:hover,
.k-pager-numbers .k-button.k-selected,
.k-pager-numbers .k-button.k-selected:hover {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
    color: #ffffff !important;
}

/* A grid pager that doesn't fit its grid wraps onto a second line rather than being cut off (WCAG 1.4.10), e.g. the
   report output grids' page arrows, page box, page sizes and item count in a sub-report pop-up on a narrow window,
   where Bootstrap makes the pop-up 500px wide. It makes no difference to a pager that fits. */
.k-grid-pager {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

/* Kendo's flat buttons (WCAG 1.4.3): the pagers' other page numbers and arrows, and the month and year title in every
   calendar and date picker. Kendo 2026 draws these as flat buttons, whose "background: none !important" beats the
   themes' .k-button background, but the themes' "color: white !important" still wins, so they were white on white.
   The app doesn't make flat buttons itself; Kendo only uses them on light backgrounds. The current page keeps its
   own colours (above). */
.k-button.k-button-flat:not(.k-selected),
.k-button.k-button-flat:not(.k-selected):hover {
    color: #424242 !important;
}

/* Selected item in drop-down and combo box lists (WCAG 1.4.3): Kendo's default is white on #ff6358 (2.93:1) */
.k-list-item.k-selected,
.k-list-item.k-selected:hover,
.k-list-item.k-selected.k-hover {
    background-color: #0056b3 !important;
    color: #ffffff !important;
}

/* Date picker calendars (WCAG 2.4.7 / 1.4.11). Site.css and the theme overrides give every .k-link a fixed background,
   which hides Kendo's selected, today and focused date styles, so restore them here. */
.k-calendar .k-calendar-td.k-selected .k-link,
.k-calendar .k-calendar-td.k-selected:hover .k-link {
    background-color: #0056b3 !important;
    color: #fff !important;
}

.k-calendar .k-calendar-td.k-today .k-link {
    font-weight: bold;
    text-decoration: underline;
}

.k-calendar .k-calendar-td:hover:not(.k-selected) .k-link {
    background-color: #e6eef8 !important;
}

html.a11y-keyboard .k-calendar .k-calendar-td.k-focus .k-link,
html.a11y-keyboard .k-calendar .k-calendar-view.k-focus .k-calendar-td.k-focus .k-link {
    outline: 2px solid #005fcc !important;
    outline-offset: -2px !important;
    box-shadow: none !important;
}

/* The ring would not show against the selected date's blue, so add a white inner ring there */
html.a11y-keyboard .k-calendar .k-calendar-td.k-selected.k-focus .k-link {
    box-shadow: inset 0 0 0 4px #fff !important;
}

/* Links (WCAG 1.4.1 / 1.4.3): 7:1 contrast, and underline text links that have no styling class */
:root {
    --bs-link-color: #0056b3;
    --bs-link-color-rgb: 0, 86, 179;
    --bs-link-hover-color: #003d80;
    --bs-link-hover-color-rgb: 0, 61, 128;
}

a:not([class]) {
    text-decoration: underline;
}

/* Error colours (WCAG 1.4.3): #cc0000 is 5.9:1 against white */
.alarm {
    background-color: #cc0000 !important;
}

/* Grid rows with an error: the themes colour the cells themselves (iCasework text colours, the light themes' row
   stripes), which made the text unreadable on the red or hid the red altogether (WCAG 1.4.3 / 1.4.1) */
.k-grid tr.alarm > td {
    background-color: #cc0000 !important;
    color: #ffffff !important;
}

.validationMsg,
.CustomValidate,
.field-validation-error {
    color: #cc0000 !important;
}

/* Input boundaries (WCAG 1.4.11): at least 3:1 against the background */
.form-control:not(.input-validation-error):not(.k-invalid),
.k-input:not(.k-invalid),
.k-picker:not(.k-invalid) {
    border-color: #767676 !important;
}

/* Fields in error: nothing styled them, so they fell back to the theme's border (1.6:1 in the base theme). #cc0000 is
   5.9:1 on white and also marks the field as the one to fix (WCAG 1.4.11 / 3.3.1). */
.form-control.input-validation-error,
.form-control.k-invalid,
.k-input.k-invalid,
.k-picker.k-invalid {
    border-color: #cc0000 !important;
}

/* Coloured icons are often the only content of a button (WCAG 1.4.11) */
.k-icon-coloured {
    color: #3B8234;
}

/* Modal close button: full opacity in the header text colour so it contrasts on every theme (WCAG 1.4.11) */
.modal-header .close,
.modal-header .close:not(:disabled):not(.disabled):hover,
.modal-header .close:not(:disabled):not(.disabled):focus {
    color: inherit;
    opacity: 1;
    text-shadow: none;
}

/* Target size (WCAG 2.5.8): at least 24 x 24 CSS pixels */
.close,
.link-list-small {
    min-width: 24px;
    min-height: 24px;
}

.link-list-small {
    width: 24px;
    height: 24px;
}

/* Headings (WCAG 1.3.1 / 2.4.6): page titles are now <h1>/<h2 class="heading"> and modal titles <h2 class="modal-title h4">.
   Keep the look of the <span> / <h4> elements they replaced. */
h1.heading,
h2.heading,
.heading > h1.modal-title {
    margin: 0;
    font-weight: inherit;
    line-height: inherit;
}

/* Icon buttons that replaced <a onclick> links (e.g. dashboard View Details / Refresh) - keep the link look */
.link-button {
    min-width: 24px;
    min-height: 24px;
    padding: 0 2px;
    border: 0;
    background: none;
    color: var(--bs-link-color);
    cursor: pointer;
}

/* Required fields (WCAG 3.3.2) - added by accessibilityManagement.markRequired */
.required-indicator {
    color: #cc0000;
    font-weight: bold;
}

/* Keyboard alternative to dragging tree nodes (WCAG 2.5.7) - see accessibilityManagement.bindTreeMove */
.tree-move-banner {
    margin: 4px 0;
    padding: 6px 8px;
    border: 2px solid #005fcc;
    border-radius: 3px;
    background-color: #eef4fc;
    color: #000000;
}

.tree-move-message {
    margin: 0 0 6px 0;
}

.tree-move-actions .btn {
    min-height: 24px;
    margin-right: 6px;
}

.tree-move-source {
    outline: 2px dashed #005fcc;
    outline-offset: 1px;
    font-weight: bold;
}

/* Reduced motion (WCAG 2.3.3 advisory) - Kendo effects are also disabled in accessibility.js */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* The existing entry in the split time grid: white on red (about 8:1, WCAG 1.4.3), cells included, as the grid gives
   every cell its own text colour. Its first cell wraps, so the "Existing entry" marker sits above the date instead of
   pushing it out of the narrow column. */
#splitTimeGrid tr.split-existing-row,
#splitTimeGrid tr.split-existing-row > td,
#splitTimeGrid tr.split-existing-row:hover > td {
    background-color: #a50000 !important;
    color: #ffffff !important;
}

#splitTimeGrid tr.split-existing-row > td:has(.split-existing-entry) {
    white-space: normal;
    text-overflow: clip;
}

#splitTimeGrid tr.split-existing-row .split-existing-entry {
    display: table;
    margin: 0 0 0.125rem 0;
}

/* Text marker for the existing entry in the split time grid, which is otherwise shown only by a red row (WCAG 1.4.1) */
.split-existing-entry {
    display: inline-block;
    margin-right: 0.25rem;
    padding: 0 0.25rem;
    border: 1px solid #000000;
    background-color: #ffffff;
    color: #000000;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Let the menu bar and long menu items wrap on narrow screens instead of scrolling sideways (WCAG 1.4.10) */
@media (max-width: 480px) {
    .k-menu.k-menu-horizontal {
        flex-wrap: wrap;
    }

    .k-menu .k-link {
        white-space: normal;
    }
}

/* Reflow and text spacing (WCAG 1.4.10 / 1.4.12) */

/* Generate Bill: the three fixed-width columns stack on narrow screens (and when zoomed) instead of shrinking */
@media (max-width: 767px) {
    .bill-container {
        flex-wrap: wrap;
    }

    .bill-col-1,
    .bill-col-2 {
        width: 100% !important;
    }
}

/* Rows of link buttons and the group caption bars had fixed heights, so wrapped buttons or text overlapped the
   content below. Let them grow. */
.link-list-row-modal {
    height: auto;
    min-height: 1.6rem;
}

.link-list-menu-row {
    height: auto;
    min-height: 1.65rem;
}

.headerDiv-alt,
.headerDiv-alt-row,
.headerDiv-grp,
.headerDiv-grp-right,
.headerDiv-grp-right-import {
    height: auto;
    min-height: 30px;
}

/* Supplements were shown only in italics (WCAG 1.3.1), so also give them hidden text. accessibility.js sets the text
   from the resources. (Documents already in the bundle get their hidden text from Document.js.) */
.is-supplement > .k-treeview-item-content > .k-treeview-leaf::after {
    content: var(--a11y-supplement-text, " (Supplement)");
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Context menu check items: the checkbox inside only shows the state, so clicks go to the menu item */
.a11y-menu-check {
    pointer-events: none;
}

/* Kendo numeric boxes, date pickers and time pickers that are disabled or read-only (e.g. a charge rate detail's
   Charge and Court Rate for a non-chargeable activity, the Start of a new year or period): grey like a read-only
   .form-control, rather than white with faded text, so they don't look editable. Those greyed by
   commonManagement.EnableDisableDiv (disable-field, in Site.css) keep their own grey. */
.k-numerictextbox.k-disabled:not(.disable-field),
.k-numerictextbox:not(.disable-field):has(input.k-input-inner[readonly]),
.k-datepicker.k-disabled:not(.disable-field),
.k-datepicker:not(.disable-field):has(input[readonly]),
.k-timepicker.k-disabled:not(.disable-field),
.k-timepicker:not(.disable-field):has(input[readonly]),
.k-datetimepicker.k-disabled:not(.disable-field),
.k-datetimepicker:not(.disable-field):has(input[readonly]) {
    background-color: #e9ecef !important;
    opacity: 1;
    filter: none;
}

.k-numerictextbox.k-disabled:not(.disable-field) .k-input-inner,
.k-numerictextbox.k-disabled:not(.disable-field) .k-input-spinner .k-button,
.k-numerictextbox:not(.disable-field):has(input.k-input-inner[readonly]) .k-input-inner,
.k-numerictextbox:not(.disable-field):has(input.k-input-inner[readonly]) .k-input-spinner .k-button,
.k-datepicker.k-disabled:not(.disable-field) .k-input-inner,
.k-datepicker.k-disabled:not(.disable-field) .k-input-button,
.k-datepicker:not(.disable-field):has(input[readonly]) .k-input-inner,
.k-datepicker:not(.disable-field):has(input[readonly]) .k-input-button,
.k-timepicker:not(.disable-field):has(input[readonly]) .k-input-inner,
.k-timepicker:not(.disable-field):has(input[readonly]) .k-input-button,
.k-datetimepicker:not(.disable-field):has(input[readonly]) .k-input-inner,
.k-datetimepicker:not(.disable-field):has(input[readonly]) .k-input-button {
    background: transparent !important;
}

/* The chosen values of a report "in / not in" parameter: read-only (not disabled, so they can be reached and read,
   WCAG 4.1.2), with the disabled look kept, as they are changed with the button beside them */
.form-control.readonly-value {
    background-color: var(--bs-secondary-bg);
}

/* A grid filling its section with a heading above it (the Logs tab): the grid takes the height left */
.grid-with-heading {
    display: flex;
    flex-direction: column;
}

.grid-with-heading > .k-grid {
    flex: 1 1 auto;
    min-height: 0;
}

.grid-heading {
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: bold;
    margin: 0.25rem 0;
}
