/*
 * Authoritative modal geometry for the entire application.
 *
 * The overlay deliberately covers the top navigation. Its dialog consumes the
 * overlay's padded content box and the body becomes the only scroll container.
 * This avoids the previous accumulation of page-specific top offsets, minimum
 * heights and margins that pushed dialogs outside short viewports.
 */
.modal {
    --tms-modal-gutter: clamp(.5rem, 2vw, 1.25rem);
    position: fixed;
    inset: 0;
    z-index: 1200;
    width: 100%;
    height: 100dvh;
    padding: var(--tms-modal-gutter) !important;
    overflow: hidden;
}

.modal-dialog,
.modal-dialog.modal-dialog-centered,
.modal-dialog.modal-dialog-scrollable {
    display: flex;
    width: min(100%, var(--bs-modal-width, 46rem));
    max-width: var(--bs-modal-width, 46rem);
    height: 100%;
    min-height: 0;
    max-height: 100%;
    align-items: center;
    margin: 0 auto !important;
}

.modal-dialog.modal-sm { --bs-modal-width: 30rem; }
.modal-dialog.modal-lg { --bs-modal-width: 58rem; }
.modal-dialog.modal-xl { --bs-modal-width: 72rem; }

.modal-content {
    display: flex;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: 100%;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--tms-border, rgba(214, 175, 88, .28));
    border-radius: var(--tms-radius-lg, 1.4rem);
    /* Dialog surfaces are opaque theme tokens. Card glass styles must not
       show the underlying page through financial fields or news text. */
    background: var(--tms-surface-strong, #0a1f19);
    box-shadow: var(--tms-shadow, 0 24px 60px rgba(0, 0, 0, .45));
}

/* Match the legacy ID-specific dialog rule without changing navigation styles.
   This news dialog uses the same opaque active-theme surface as other modals. */
#economicStripDetailModal .modal-content {
    background: var(--tms-surface-strong, #0a1f19);
}

.modal-content > form {
    display: flex;
    width: 100%;
    min-height: 0;
    max-height: 100%;
    flex-direction: column;
}

.modal-header,
.modal-footer {
    flex: 0 0 auto;
    border-color: var(--tms-border, rgba(214, 175, 88, .2));
}

.modal-body {
    min-width: 0;
    min-height: 0;
    flex: 0 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-wrap: anywhere;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.modal-footer { display: flex; gap: .65rem; }

@media (max-width: 575.98px) {
    .modal { --tms-modal-gutter: .4rem; }
    .modal-header,
    .modal-body,
    .modal-footer { padding: .9rem; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer > .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade .modal-dialog { transition: none; }
}
