/* components-overlays.css — toast (Phase 5 owns the toast block), native <dialog> modals. */

/* Toast (spec §3.9): one region, max one visible. Action variant: message · text button (+ key chip). Never steals focus. */
.toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 280px;
    max-width: min(440px, calc(100vw - 2 * var(--space-4)));
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--surface-inverse);
    color: var(--text-inverse);
    box-shadow: var(--shadow-3);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.toast-action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    min-height: 32px;
    padding: 0 var(--space-2);
    border: 0;
    border-radius: var(--radius-xs);
    background: none;
    color: var(--toast-action);
    font: inherit;
    font-weight: var(--fw-bold);
    cursor: pointer;
}

.toast-action:hover { text-decoration: underline; }
.toast-action:focus-visible { outline: 2px solid var(--toast-action) !important; outline-offset: 2px; }

/* Keycap chip (spec §3.7); single-key chips disappear when the learner turns single-key shortcuts off or has no keyboard. */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-xs);
    border-bottom: 2px solid var(--border-strong);
    background: var(--surface-3);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1;
}

.toast .kbd { background: color-mix(in srgb, var(--text-inverse) 18%, transparent); color: var(--text-inverse); border-color: color-mix(in srgb, var(--text-inverse) 40%, transparent); }

body[data-shortcuts="off"] .kbd-single { display: none; }

@media (hover: none) { .btn .kbd, .btn-grade .kbd, .toast .kbd { display: none; } }

/* Global Auth Overlay Modal */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--scrim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.auth-card {
    background: var(--surface-1);
    background-image: var(--gradient-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 35px;
    box-shadow: var(--shadow-3);
    font-family: var(--font-ui);
}

/* Modal Inputs Styling Adjustments */
#modalCollection textarea,
#modalDeck textarea,
#modalCard textarea {
    outline: none;
    transition: var(--transition-smooth);
}

#modalCollection textarea:focus,
#modalDeck textarea:focus,
#modalCard textarea:focus {
    border-color: var(--text-brand);
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.1);
}

#modalCollection select {
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text-1);
    outline: none;
    transition: var(--transition-smooth);
}

#modalCollection select:focus {
    border-color: var(--text-brand);
}

#modalCard .recall-fieldset textarea { width: 100%; }

/* Native <dialog> (spec §3.10). Opened with showModal(): focus trap, Esc, inert page, top layer.
   Legacy .auth-overlay/.auth-card classes stay on the elements until Phase 8 restyles them. */
dialog.auth-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    color: inherit;
    background-color: var(--scrim);
    align-items: safe center; /* tall forms (card modal) scroll instead of clipping the top */
    overflow-y: auto;
}

dialog.auth-overlay:not([open]) {
    display: none;
}

dialog.auth-overlay::backdrop {
    background: transparent;
}

dialog.dialog {
    margin: auto;
    width: min(560px, calc(100% - 2 * var(--space-4)));
    max-height: 85dvh;
    padding: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    color: var(--text-1);
    box-shadow: var(--shadow-3);
}

dialog.dialog.dialog-sm {
    width: min(420px, calc(100% - 2 * var(--space-4)));
}

dialog.dialog::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(4px);
}
