/**
 * KeyboardNavigation - Frontend styles
 *
 * Sections:
 *   1. Focus ring (keyboard-only mode)
 *   2. Screen-reader-only utility (live regions)
 *   3. Toast notification system
 */

:root {
    --kbnav-focus-color: #2271b1;
}

/* ============================================================
   1. FOCUS RING
   ============================================================ */
html.kbnav-keyboard a:focus,
html.kbnav-keyboard button:focus,
html.kbnav-keyboard [role="button"]:focus,
html.kbnav-keyboard input[type="button"]:focus,
html.kbnav-keyboard input[type="submit"]:focus,
html.kbnav-keyboard input[type="reset"]:focus,
html.kbnav-keyboard [tabindex]:focus {
    outline: 3px solid var(--kbnav-focus-color) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--kbnav-focus-color) 30%, transparent) !important;
    transition: outline 0.1s ease, box-shadow 0.1s ease;
    border-radius: 2px;
}

@supports not (color: color-mix(in srgb, red, blue)) {
    html.kbnav-keyboard a:focus,
    html.kbnav-keyboard button:focus,
    html.kbnav-keyboard [role="button"]:focus,
    html.kbnav-keyboard input[type="button"]:focus,
    html.kbnav-keyboard input[type="submit"]:focus,
    html.kbnav-keyboard input[type="reset"]:focus,
    html.kbnav-keyboard [tabindex]:focus {
        box-shadow: 0 0 0 4px rgba(34, 113, 177, 0.25) !important;
    }
}

html.kbnav-mouse a:focus,
html.kbnav-mouse button:focus,
html.kbnav-mouse [role="button"]:focus,
html.kbnav-mouse input[type="button"]:focus,
html.kbnav-mouse input[type="submit"]:focus,
html.kbnav-mouse input[type="reset"]:focus {
    outline: none;
    box-shadow: none;
}

/* ============================================================
   2. SCREEN-READER-ONLY (for ARIA live regions)
   ============================================================ */
.kbnav-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================
   3. TOAST NOTIFICATIONS
   ============================================================ */
.kbnav-toast-container {
    position: fixed;
    z-index: 2147483000; /* above almost everything */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: min(420px, calc(100vw - 32px));
    box-sizing: border-box;
}
.kbnav-toast-container.kbnav-toast-pos-top-right    { top: 20px;    right: 20px; }
.kbnav-toast-container.kbnav-toast-pos-top-left     { top: 20px;    left: 20px; }
.kbnav-toast-container.kbnav-toast-pos-top-center   { top: 20px;    left: 50%; transform: translateX(-50%); }
.kbnav-toast-container.kbnav-toast-pos-bottom-right { bottom: 20px; right: 20px; flex-direction: column-reverse; }
.kbnav-toast-container.kbnav-toast-pos-bottom-left  { bottom: 20px; left: 20px;  flex-direction: column-reverse; }
.kbnav-toast-container.kbnav-toast-pos-bottom-center{ bottom: 20px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }

.kbnav-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #1f2937;
    color: #f9fafb;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.25), 0 6px 10px -6px rgba(0,0,0,0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    border-left: 4px solid #3b82f6;
    min-width: 240px;
}
.kbnav-toast.is-visible { opacity: 1; transform: translateY(0); }
.kbnav-toast.is-leaving { opacity: 0; transform: translateY(-8px); }

.kbnav-toast--success { border-left-color: #10b981; }
.kbnav-toast--error   { border-left-color: #ef4444; }
.kbnav-toast--info    { border-left-color: #3b82f6; }

.kbnav-toast__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    margin-top: 1px;
    background: rgba(255,255,255,0.15);
}
.kbnav-toast--success .kbnav-toast__icon { background: #10b981; color: #fff; }
.kbnav-toast--error   .kbnav-toast__icon { background: #ef4444; color: #fff; }
.kbnav-toast--info    .kbnav-toast__icon { background: #3b82f6; color: #fff; }

.kbnav-toast__message {
    flex: 1;
    word-wrap: break-word;
    white-space: pre-line;
}

.kbnav-toast__close {
    flex-shrink: 0;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 0 2px;
    margin: -2px 0 0 0;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}
.kbnav-toast__close:hover,
.kbnav-toast__close:focus { opacity: 1; }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .kbnav-toast { transition: opacity 0.05s linear; transform: none !important; }
}

/* Dark mode contrast tweaks */
@media (prefers-color-scheme: light) {
    .kbnav-toast {
        background: #ffffff;
        color: #111827;
        border: 1px solid #e5e7eb;
        border-left-width: 4px;
    }
    .kbnav-toast__icon { background: #e5e7eb; color: #111827; }
}
