/* Note: this file loads BEFORE bootstrap-osu.min.css (see App.razor), so a rule here with the same
   specificity as a Bootstrap rule loses to it. Font family and link color come from the Bootstrap theme. */
/* No min-width on html/body: pages must reflow down to 320px wide without horizontal scrolling
   (WCAG 1.4.10, which also covers desktop browsers zoomed to 400%). Browsers still show a horizontal
   scrollbar on their own if something is genuinely too wide. */

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #000;
}

/* Focus ring for form fields: the same black/white ring as buttons (well above the 3:1 WCAG 1.4.11 minimum).
   !important is required because Bootstrap's field focus style (pale pink border and faint glow, about 2.7:1)
   loads after this file, and the .shadow-sm utility removes any focus box-shadow with !important. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: #000 !important;
    box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #000 !important;
}

/* Invalid fields. Styled from aria-invalid, so what sighted users see always matches what screen readers
   announce. Red border plus Bootstrap's warning icon inside the field, so the state isn't shown by color alone.
   Comes after the focus rule so a focused invalid field keeps its red border inside the black focus ring. */
.form-control[aria-invalid="true"],
.form-select[aria-invalid="true"],
.form-check-input[aria-invalid="true"] {
    border-color: var(--bs-form-invalid-border-color) !important;
}

.form-control[aria-invalid="true"] {
    padding-right: calc(1.5em + .75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
}

textarea.form-control[aria-invalid="true"] {
    background-position: top calc(.375em + .1875rem) right calc(.375em + .1875rem);
}

.form-select[aria-invalid="true"]:not([multiple]):not([size]) {
    --bs-form-select-bg-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    padding-right: 4.125rem;
    background-position: right .75rem center, center right 2.25rem;
    background-size: 16px 12px, calc(.75em + .375rem) calc(.75em + .375rem);
}

/* Error message under a field (FieldError.razor). #b02a37 is a darker red than the border so the
   small text has comfortable contrast (about 6.5:1 on white); the icon and "Error:" don't rely on color. */
.field-error {
    display: flex;
    align-items: flex-start;
    gap: .375rem;
    margin: .375rem 0 0;
    color: #b02a37;
    font-size: .875em;
    font-weight: 600;
}

    .field-error .app-icon {
        flex-shrink: 0;
        margin: .15em 0 0;
    }


.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNj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mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* ---------- Non-text contrast (WCAG 1.4.11: controls need 3:1 against what is next to them) ---------- */

/* Field borders. Bootstrap's default (#dee2e6) is only 1.3:1 on white, so the edge of a text box,
   select or checkbox can't be seen by many low-vision users. #6c757d is 4.7:1.
   Set through Bootstrap's own variable because Bootstrap's border rule loads after this file. */
.form-control,
.form-select,
.form-check-input {
    --bs-border-color: #6c757d;
}

/* Menu button icon on the scarlet navbar. Bootstrap draws it in 55% white (about 2.6:1 on scarlet);
   solid white is at least 5.4:1 everywhere on the navbar gradient. */
.navbar-dark .navbar-toggler-icon {
    --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23fff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ---------- Native modal dialogs (ModalDialog.razor, ConfirmationDialog.razor) ---------- */
.app-dialog {
    width: min(40rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem;
    border: 1px solid transparent; /* visible in Windows high contrast mode */
    border-radius: .5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.3);
}

    .app-dialog::backdrop {
        background-color: rgba(0, 0, 0, 0.5);
    }

.app-dialog-sm {
    width: min(26rem, calc(100vw - 2rem));
}

.app-dialog-title {
    margin: 0 0 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid #dee2e6;
    font-size: 1.5rem;
}

.app-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem;
    margin-top: 1.5rem;
}

/* ---------- Connection-lost dialog (ReconnectModal.razor) ----------
   Blazor sets a components-reconnect-* class on the dialog for the current state; only the text and
   buttons for that state are shown. The #id in the selectors is needed to beat Bootstrap's .btn
   display rule, which loads after this file. */
#components-reconnect-modal .reconnect-spinner,
#components-reconnect-modal .reconnect-first-attempt,
#components-reconnect-modal .reconnect-retrying,
#components-reconnect-modal .reconnect-failed,
#components-reconnect-modal .reconnect-paused,
#components-reconnect-modal .reconnect-resume-failed,
#components-reconnect-modal .reconnect-retry,
#components-reconnect-modal .reconnect-resume {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .reconnect-spinner,
#components-reconnect-modal.components-reconnect-show .reconnect-first-attempt,
#components-reconnect-modal.components-reconnect-retrying .reconnect-spinner,
#components-reconnect-modal.components-reconnect-retrying .reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-paused .reconnect-paused,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-resume-failed {
    display: block;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-retry,
#components-reconnect-modal.components-reconnect-paused .reconnect-resume,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-resume {
    display: inline-block;
}

/* Blazor leaves the earlier classes on (for example "show" stays while "retrying" or "failed" is
   added), so each later state hides what the earlier ones showed. Must come after the rules above. */
#components-reconnect-modal.components-reconnect-retrying .reconnect-first-attempt,
#components-reconnect-modal.components-reconnect-failed .reconnect-first-attempt,
#components-reconnect-modal.components-reconnect-failed .reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-paused .reconnect-first-attempt,
#components-reconnect-modal.components-reconnect-paused .reconnect-retrying,
#components-reconnect-modal.components-reconnect-paused .reconnect-failed,
#components-reconnect-modal.components-reconnect-paused .reconnect-retry,
#components-reconnect-modal.components-reconnect-paused .reconnect-spinner,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-first-attempt,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-retrying,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-paused,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-retry,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-spinner {
    display: none;
}

#components-reconnect-modal .reconnect-spinner {
    margin-bottom: 1rem;
    text-align: center;
}

/* Visible "(required)" marker next to a form label */
.required-indicator {
    font-weight: 400;
    font-size: .875em;
}

/* Focus moves to the page heading after navigation. Keyboard users keep the focus outline on it;
   it is hidden only for mouse users. Do not hide it for everyone: a hidden heading outline has
   been flagged in an accessibility review before (WCAG 2.4.7 Focus Visible). */
.page-heading:focus:not(:focus-visible) {
    outline: none;
}

/* A user name or an email address has no spaces to break at. Without this, a long one in a page
   heading or a details list pushes the page wider than a phone screen (WCAG 1.4.10 Reflow). */
.page-heading,
dd {
    overflow-wrap: anywhere;
}

/* Success/error messages stay visible at the top while the page scrolls */
.page-messages {
    position: sticky;
    top: .5rem;
    z-index: 10;
}

    .page-messages .alert {
        margin-bottom: .75rem;
    }

/* While a sticky message is showing, keep focused elements scrolled clear of it so it
   can never cover the element that has keyboard focus (WCAG 2.4.11). CSS only, no script. */
html:has(.page-messages .alert) {
    scroll-padding-top: 6rem;
}

/* Decorative inline icons (AppIcon.razor), sized to the surrounding text */
.app-icon {
    width: 1em;
    height: 1em;
    margin-right: .25em;
    vertical-align: -0.125em;
}

/* Nav items sit on the dark/scarlet navbar background */
.navbar .nav-link:focus-visible,
.navbar .navbar-toggler:focus-visible,
.navbar .navbar-brand:focus-visible,
.navbar .dropdown-toggle:focus-visible,
.navbar .nav-link:hover,
.navbar .navbar-toggler:hover,
.navbar .navbar-brand:hover,
.navbar .dropdown-toggle:hover {
    outline: 3px solid #fff !important;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Dropdown items sit on a white dropdown-menu background */
.dropdown-menu .dropdown-item:focus-visible,
.dropdown-menu .nav-link:focus-visible {
    outline: 3px solid #000 !important;
    outline-offset: -2px;
    border-radius: 2px;
}

.btn.shadow-sm {
    --btn-drop-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.btn.shadow {
    --btn-drop-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.btn.shadow-lg {
    --btn-drop-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* Black/white focus ring for buttons, keeping any drop shadow.
   - !important is needed to beat Bootstrap's .shadow* utilities, which are !important themselves.
   - The fallback in var() matters: on a button with no shadow class --btn-drop-shadow is undefined,
     which made the whole box-shadow invalid, and those buttons had no focus ring at all.
   - .btn:focus-visible already outranks .shadow-sm etc., so separate .btn.shadow-*:focus-visible selectors aren't needed. */
.btn:focus-visible,
.btn:hover {
    box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #000, var(--btn-drop-shadow, 0 0 #0000) !important;
}

/* ---------- List pager (ListPager.razor) ---------- */
.list-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    margin: .5rem 0;
}

    .list-pager .btn {
        min-width: 2rem; /* at least 24x24px targets (WCAG 2.5.8) */
    }

    .list-pager .btn[aria-disabled="true"] {
        opacity: .65;
        cursor: not-allowed;
    }

.list-pager-summary {
    margin-left: .5rem;
}

@media print {
    /* Never print the site's navigation, footer or skip link */
    .app-nav,
    .app-footer,
    .visually-hidden-focusable {
        display: none !important;
    }

    /* Beats Bootstrap's .px-4 (!important) by specificity */
    article.content {
        padding: 0 !important;
    }
}

/* Site announcements (Components/Layout/AnnouncementBanner.razor): a band across the top of every
   page. Dark text on a pale yellow, which keeps a contrast of more than 7:1. Nothing is shown,
   and no space is taken, while there are none. */
.site-announcement {
    margin: 0;
    padding: 0.6rem 1rem;
    text-align: center;
    font-weight: 600;
    color: #212529;
    background-color: #fff3cd;
    border-bottom: 1px solid #997404;
    overflow-wrap: anywhere;
}
