/*
 * Modal (WP9; UI-Design-Principles Sec. 6/9). One mechanic: centred, --gtx-surface-2
 * body, dimmed overlay, focus trap (JS-driven), ESC closes (except step-up). Uses
 * the native <dialog> where present; the classes also style a div fallback.
 *
 * Class schema: gtx-modal__overlay, gtx-modal, gtx-modal__header, gtx-modal__title,
 * gtx-modal__close, gtx-modal__body, gtx-modal__footer.
 */

.gtx-modal__overlay {
    position: fixed;
    inset: 0;
    z-index: var(--gtx-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gtx-s4);
    background: rgba(0, 0, 0, 0.6);
}

.gtx-modal {
    width: 100%;
    max-width: 32rem;
    background: var(--gtx-surface-2);
    color: var(--gtx-text);
    border: 1px solid var(--gtx-line);
    border-radius: var(--gtx-r-m);
    box-shadow: var(--gtx-shadow-overlay);
    padding: var(--gtx-s5);
    max-height: calc(100vh - 2 * var(--gtx-s4));
    overflow-y: auto;
}

@media (prefers-reduced-motion: no-preference) {
    .gtx-modal {
        animation: gtx-modal-in var(--gtx-t-med) var(--gtx-ease) 1;
    }
}

@keyframes gtx-modal-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.gtx-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--gtx-s3);
    margin-bottom: var(--gtx-s3);
}

.gtx-modal__title {
    font-family: var(--gtx-font-display);
    font-size: var(--gtx-fs-h3);
    font-weight: 600;
}

.gtx-modal__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--gtx-r-s);
    color: var(--gtx-text-dim);
    cursor: pointer;
}

.gtx-modal__close:hover {
    color: var(--gtx-text);
    background: var(--gtx-surface);
}

.gtx-modal__body > * + * {
    margin-top: var(--gtx-s3);
}

.gtx-modal__footer {
    margin-top: var(--gtx-s5);
    display: flex;
    justify-content: flex-end;
    gap: var(--gtx-s2);
    flex-wrap: wrap;
}
