/*
 * components.css
 *
 * Cross-component CSS for the Vue/Headless UI frontend revamp. Bootstrap 5
 * tokens supply most visual styling; this file fills the accessibility-relevant
 * gaps Bootstrap doesn't ship:
 *   - stronger universal focus indicators (WCAG 2.4.7, 1.4.11)
 *   - z-index tokens for toast and live-region overlays
 *   - off-screen live-region positioning for the global Announce singleton
 *   - skip-link positioning
 *   - prefers-reduced-motion handling for our custom transitions
 *   - non-color "modified" row marker for the permission matrix (WCAG 1.4.1)
 */

/* ---------------------------------------------------------------- Focus ring */
/* Stronger than Bootstrap 5's default rgba ring. Uses :focus-visible so mouse
 * clicks don't leave a sticky ring on buttons. #005fcc on #fff = 7:1 contrast. */
:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    box-shadow: none;
}
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid #005fcc;
    outline-offset: 1px;
    box-shadow: 0 0 0 .25rem rgba(0, 95, 204, .35);
    border-color: #005fcc;
}

/* ---------------------------------------------------------------- Skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: .5rem;
    padding: .5rem 1rem;
    background: #005fcc;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 .25rem .25rem;
    z-index: 1200;
    transition: top .12s ease-out;
}
.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- Announce */
/* Off-screen live region for the global Announce component (WCAG 4.1.3).
 * Screen readers receive announcements; nothing displays visually. */
.announce-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    z-index: 1100;
}

/* ---------------------------------------------------------------- Toast host */
.toast-host {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 28rem;
    z-index: 1090;
    pointer-events: none;
}
.toast-host > * {
    pointer-events: auto;
}

/* ---------------------------------------------------------------- Modified row */
/* Non-color marker for "modified but unsaved" rows (permission matrix etc.).
 * Replaces the current background-only yellow which fails WCAG 1.4.1. */
.row-modified {
    border-left: 4px solid #b85c00;
    background-color: #fff8e1;
}
.row-modified > :first-child::before {
    content: "\f33b"; /* bi-exclamation-triangle */
    font-family: "bootstrap-icons";
    margin-right: .35rem;
    color: #b85c00;
    font-weight: bold;
    vertical-align: -.125em;
}

/* ---------------------------------------------------------------- Accordion chevron */
/* Rotates the chevron icon inside the AccordionTrigger when the accordion item
 * is open. Reka UI sets data-state="open"/"closed" on the trigger element. */
.accordion-chevron {
    transition: transform .15s ease-out;
}
[data-state="open"] > .accordion-chevron,
[data-state="open"] .accordion-chevron {
    transform: rotate(180deg);
}

/* ---------------------------------------------------------------- Combobox options */
/* Reka UI sets data-highlighted on the option under the keyboard cursor (moved
 * with Arrow keys) and the pointer. Without a visible style, keyboard users
 * can't tell ArrowDown is doing anything (WCAG 2.4.7). data-state="checked"
 * marks the currently selected option. */
[role="option"] {
    transition: background-color .1s ease-out;
}
[role="option"][data-highlighted] {
    background-color: #0d6efd; /* bootstrap primary */
    color: #fff;
    outline: none;
}
[role="option"][data-state="checked"]:not([data-highlighted]) {
    background-color: #e7f1ff;
    font-weight: 600;
}

/* ---------------------------------------------------------------- Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .skip-link {
        transition: none;
    }
    [role="option"] {
        transition: none;
    }
}
