/* ============================================================
   Modal / dialog system
   Replaces the browser's native alert / confirm / prompt boxes,
   which render in the OS chrome ("sci-academy.us says…") and look
   nothing like the site.

   Built on the native <dialog> element, so focus trapping, Esc to
   close, the backdrop and top-layer stacking come from the browser
   rather than from hand-written JS.

   Standard colour scheme: --accent #650640
   ============================================================ */

:root {
    --mdl-accent: #650640;
    --mdl-accent-soft: rgba(101, 6, 64, 0.08);
    --mdl-ink: #2b2630;
    --mdl-muted: #6f6570;
    --mdl-surface: #ffffff;
    --mdl-border: rgba(101, 6, 64, 0.14);
    --mdl-danger: #b91c1c;
    --mdl-danger-soft: rgba(185, 28, 28, 0.09);
    --mdl-radius: 16px;
}

.scia-modal {
    /* Reset the UA dialog box so it can be composed from scratch. */
    padding: 0;
    border: none;
    background: transparent;
    max-width: min(480px, calc(100vw - 32px));
    width: 100%;
    color: var(--mdl-ink);
    overflow: visible;
}

.scia-modal::backdrop {
    background: rgba(28, 18, 26, 0.55);
    backdrop-filter: blur(2px);
    animation: sciaModalFade 0.18s ease-out;
}

.scia-modal-box {
    background: var(--mdl-surface);
    border-radius: var(--mdl-radius);
    box-shadow: 0 18px 50px rgba(17, 12, 46, 0.26);
    overflow: hidden;
    animation: sciaModalIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1);
    text-align: start;
}

/* ── Header ── */
.scia-modal-head {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1.35rem 1.5rem 0.85rem;
}

.scia-modal-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--mdl-accent-soft);
    color: var(--mdl-accent);
    font-size: 1rem;
}

.scia-modal--danger .scia-modal-icon {
    background: var(--mdl-danger-soft);
    color: var(--mdl-danger);
}

.scia-modal-title {
    margin: 0;
    padding-top: 0.35rem;
    font-size: 1.06rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--mdl-ink);
    letter-spacing: -0.01em;
}

/* ── Body ── */
.scia-modal-body {
    padding: 0 1.5rem 0.25rem;
    /* Align with the title, not the icon. */
    padding-inline-start: calc(1.5rem + 38px + 0.85rem);
}

.scia-modal-message {
    margin: 0;
    font-size: 0.925rem;
    line-height: 1.6;
    color: var(--mdl-muted);
    overflow-wrap: anywhere;
}

.scia-modal-input {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.9rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--mdl-border);
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-size: 0.93rem;
    color: var(--mdl-ink);
    resize: vertical;
    min-height: 2.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.scia-modal-input::placeholder { color: #b3aab1; }

.scia-modal-input:focus {
    outline: none;
    border-color: var(--mdl-accent);
    box-shadow: 0 0 0 3px var(--mdl-accent-soft);
}

.scia-modal-hint {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    color: var(--mdl-muted);
}

/* ── Actions ── */
.scia-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1.15rem 1.5rem 1.35rem;
    flex-wrap: wrap;
}

.scia-modal-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.89rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.scia-modal-btn:focus-visible {
    outline: 2px solid var(--mdl-accent);
    outline-offset: 2px;
}

.scia-modal-btn--ghost {
    background: transparent;
    border-color: var(--mdl-border);
    color: var(--mdl-muted);
}
.scia-modal-btn--ghost:hover {
    background: var(--mdl-accent-soft);
    color: var(--mdl-accent);
}

.scia-modal-btn--primary {
    background: var(--mdl-accent);
    color: #fff;
}
.scia-modal-btn--primary:hover { background: #4a0430; }

.scia-modal--danger .scia-modal-btn--primary { background: var(--mdl-danger); }
.scia-modal--danger .scia-modal-btn--primary:hover { background: #991b1b; }
.scia-modal--danger .scia-modal-btn:focus-visible { outline-color: var(--mdl-danger); }

/* ── Motion ── */
@keyframes sciaModalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

@keyframes sciaModalFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .scia-modal-box,
    .scia-modal::backdrop { animation: none; }
    .scia-modal-btn, .scia-modal-input { transition: none; }
}

/* ── Narrow screens: full-width buttons read better than a cramped row ── */
@media (max-width: 420px) {
    .scia-modal-head { padding: 1.15rem 1.15rem 0.75rem; }
    .scia-modal-body { padding-inline: 1.15rem; }
    .scia-modal-foot { padding: 1rem 1.15rem 1.15rem; }
    .scia-modal-btn { flex: 1 1 100%; text-align: center; }
}

/* ── Right-to-left (the site ships an Arabic mode) ── */
[dir="rtl"] .scia-modal-box { text-align: start; }
