/* EducationGuard — Historical scroll dispatch toast */

.eg-toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    left: auto;
    z-index: 10050;
    pointer-events: none;
    width: min(24rem, calc(100vw - 2.5rem));
    perspective: 900px;
}

.eg-toast {
    --eg-toast-accent: #461E38;
    --eg-toast-accent-soft: rgba(70, 30, 56, 0.14);
    --eg-toast-seal: radial-gradient(circle at 32% 28%, #e85d5d 0%, #b82e2e 72%, #8a1f1f 100%);
    --eg-toast-ink: linear-gradient(90deg, #8a1f1f, #e85d5d);

    pointer-events: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.85rem 0.95rem 1.1rem;
    border-radius: 1.15rem;
    overflow: hidden;
    font-family: 'Cairo', 'Segoe UI', 'Tajawal', sans-serif;
    background:
        linear-gradient(175deg, rgba(255, 255, 255, 0.72) 0%, transparent 38%),
        linear-gradient(135deg, #f3e8d4 0%, #faf4e8 42%, #e6d4b8 78%, #d9c4a2 100%);
    border: 1px solid rgba(70, 30, 56, 0.2);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.65) inset,
        0 -1px 0 rgba(70, 30, 56, 0.08) inset,
        0 18px 42px rgba(70, 30, 56, 0.22),
        0 0 0 1px rgba(243, 147, 24, 0.1);
    animation: eg-toast-unroll 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eg-toast--success {
    --eg-toast-accent: #1f7a47;
    --eg-toast-accent-soft: rgba(31, 122, 71, 0.14);
    --eg-toast-seal: radial-gradient(circle at 32% 28%, #3cb878 0%, #1f7a47 72%, #145c35 100%);
    --eg-toast-ink: linear-gradient(90deg, #145c35, #3cb878);
}

.eg-toast--warning {
    --eg-toast-accent: #9a6f08;
    --eg-toast-accent-soft: rgba(201, 146, 15, 0.16);
    --eg-toast-seal: radial-gradient(circle at 32% 28%, #f5c842 0%, #c9920f 72%, #9a6f08 100%);
    --eg-toast-ink: linear-gradient(90deg, #9a6f08, #f5c842);
}

.eg-toast--info {
    --eg-toast-accent: #2d6f99;
    --eg-toast-accent-soft: rgba(45, 111, 153, 0.14);
    --eg-toast-seal: radial-gradient(circle at 32% 28%, #5ba8d4 0%, #2d6f99 72%, #1f4f70 100%);
    --eg-toast-ink: linear-gradient(90deg, #1f4f70, #5ba8d4);
}

/* Scroll rolls */
.eg-toast__scroll-roll {
    position: absolute;
    left: 0;
    right: 0;
    height: 0.55rem;
    pointer-events: none;
    z-index: 4;
}

.eg-toast__scroll-roll--top {
    top: 0;
    background:
        linear-gradient(180deg, rgba(70, 30, 56, 0.14) 0%, rgba(70, 30, 56, 0.04) 55%, transparent 100%),
        linear-gradient(180deg, #c9b08a 0%, #e8dcc8 40%, transparent 100%);
    border-radius: 1.15rem 1.15rem 0 0;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

.eg-toast__scroll-roll--bottom {
    bottom: 0;
    background:
        linear-gradient(0deg, rgba(70, 30, 56, 0.16) 0%, rgba(70, 30, 56, 0.05) 55%, transparent 100%),
        linear-gradient(0deg, #b89a72 0%, #dcc9aa 45%, transparent 100%);
    border-radius: 0 0 1.15rem 1.15rem;
}

/* Paper grain */
.eg-toast__texture {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
    pointer-events: none;
}

/* Compass watermark */
.eg-toast__compass {
    position: absolute;
    top: -0.5rem;
    left: -0.75rem;
    width: 5.5rem;
    height: 5.5rem;
    color: var(--eg-toast-accent);
    opacity: 0.1;
    pointer-events: none;
    animation: eg-toast-compass-spin 28s linear infinite;
}

/* Ornate corners */
.eg-toast__corner {
    position: absolute;
    width: 1.35rem;
    height: 1.35rem;
    pointer-events: none;
    z-index: 3;
}

.eg-toast__corner--tl {
    top: 0.55rem;
    left: 0.55rem;
    border-top: 2px solid rgba(243, 147, 24, 0.55);
    border-left: 2px solid rgba(243, 147, 24, 0.55);
    border-radius: 0.35rem 0 0 0;
}

.eg-toast__corner--br {
    right: 0.55rem;
    bottom: 0.55rem;
    border-bottom: 2px solid rgba(70, 30, 56, 0.28);
    border-right: 2px solid rgba(70, 30, 56, 0.28);
    border-radius: 0 0 0.35rem 0;
}

/* Header ribbon */
.eg-toast__header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
    padding-top: 0.15rem;
}

.eg-toast__ribbon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.7rem 0.28rem 0.55rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, var(--eg-secondary, #461E38) 0%, #6b3456 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 3px 10px rgba(70, 30, 56, 0.25);
}

.eg-toast__ribbon i {
    font-size: 0.72rem;
    color: var(--eg-primary, #F39318);
}

.eg-toast__close {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: 1px solid rgba(70, 30, 56, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    color: rgba(70, 30, 56, 0.6);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.25s ease, border-color 0.2s ease;
}

.eg-toast__close:hover {
    background: rgba(243, 147, 24, 0.16);
    border-color: rgba(243, 147, 24, 0.35);
    color: var(--eg-secondary, #461E38);
    transform: rotate(90deg);
}

/* Content row */
.eg-toast__content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

/* Wax seal */
.eg-toast__seal-wrap {
    position: relative;
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    margin-top: 0.1rem;
}

.eg-toast__seal-ring {
    position: absolute;
    inset: -0.2rem;
    border: 1px dashed rgba(70, 30, 56, 0.22);
    border-radius: 50%;
    animation: eg-toast-seal-pulse 3.5s ease-in-out infinite;
}

.eg-toast__seal {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1.2rem;
    color: #fff;
    background: var(--eg-toast-seal);
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.28) inset,
        0 0 0 3px rgba(70, 30, 56, 0.12),
        0 5px 14px rgba(70, 30, 56, 0.28);
}

.eg-toast__seal::before {
    content: "";
    position: absolute;
    inset: 0.35rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.eg-toast__body {
    flex: 1;
    min-width: 0;
}

.eg-toast__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
}

.eg-toast__era {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.45rem;
    border-radius: 0.35rem;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--eg-toast-accent);
    background: var(--eg-toast-accent-soft);
    border: 1px solid rgba(70, 30, 56, 0.1);
}

.eg-toast__label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--eg-secondary, #461E38);
}

.eg-toast__divider {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
    color: var(--eg-primary, #F39318);
    opacity: 0.75;
}

.eg-toast__divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(70, 30, 56, 0.22), transparent);
}

.eg-toast__divider i {
    font-size: 0.62rem;
}

.eg-toast__message {
    margin: 0 0 0.55rem;
    font-size: 0.9rem;
    line-height: 1.65;
    font-weight: 600;
    color: #2a1520;
}

.eg-toast__footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem 0.4rem;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(70, 30, 56, 0.55);
}

.eg-toast__footer i {
    font-size: 0.72rem;
    color: var(--eg-primary, #F39318);
}

.eg-toast__footer-dot {
    width: 0.25rem;
    height: 0.25rem;
    border-radius: 50%;
    background: rgba(243, 147, 24, 0.65);
}

.eg-toast__footer-era {
    color: var(--eg-toast-accent);
    opacity: 0.85;
}

/* Ink progress timer */
.eg-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(70, 30, 56, 0.07);
    z-index: 5;
}

.eg-toast__progress-ink {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: right center;
    background: var(--eg-toast-ink);
    box-shadow: 0 0 8px rgba(243, 147, 24, 0.25);
    animation: eg-toast-progress 5s linear forwards;
}

/* Dark mode */
html[data-bs-theme="dark"] .eg-toast {
    background:
        linear-gradient(175deg, rgba(255, 255, 255, 0.05) 0%, transparent 38%),
        linear-gradient(135deg, #2a2030 0%, #322430 42%, #1e1620 78%, #18121a 100%);
    border-color: rgba(243, 147, 24, 0.24);
    box-shadow:
        0 2px 0 rgba(255, 255, 255, 0.04) inset,
        0 18px 42px rgba(0, 0, 0, 0.45);
}

html[data-bs-theme="dark"] .eg-toast__scroll-roll--top {
    background:
        linear-gradient(180deg, rgba(243, 147, 24, 0.12) 0%, transparent 100%),
        linear-gradient(180deg, #3d3040 0%, transparent 100%);
}

html[data-bs-theme="dark"] .eg-toast__scroll-roll--bottom {
    background:
        linear-gradient(0deg, rgba(243, 147, 24, 0.14) 0%, transparent 100%),
        linear-gradient(0deg, #352838 0%, transparent 100%);
}

html[data-bs-theme="dark"] .eg-toast__label {
    color: #f0e4ea;
}

html[data-bs-theme="dark"] .eg-toast__message {
    color: #faf5f7;
}

html[data-bs-theme="dark"] .eg-toast__close {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(243, 147, 24, 0.22);
    color: rgba(240, 228, 234, 0.75);
}

html[data-bs-theme="dark"] .eg-toast__footer {
    color: rgba(240, 228, 234, 0.45);
}

html[data-bs-theme="dark"] .eg-toast__corner--tl {
    border-color: rgba(243, 147, 24, 0.45);
}

html[data-bs-theme="dark"] .eg-toast__corner--br {
    border-color: rgba(243, 147, 24, 0.2);
}

/* Animations */
@keyframes eg-toast-unroll {
    from {
        opacity: 0;
        transform: perspective(800px) rotateX(-14deg) translateY(-1.25rem) scale(0.94);
        transform-origin: top center;
    }

    to {
        opacity: 1;
        transform: perspective(800px) rotateX(0deg) translateY(0) scale(1);
    }
}

@keyframes eg-toast-compass-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes eg-toast-seal-pulse {
    0%, 100% { transform: scale(1); opacity: 0.55; }
    50% { transform: scale(1.06); opacity: 0.85; }
}

@keyframes eg-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 767.98px) {
    .eg-toast-container {
        top: calc(var(--eg-nav-h, 4.5rem) + 0.75rem);
        right: 0.75rem;
        width: min(24rem, calc(100vw - 1.5rem));
    }
}

@media (prefers-reduced-motion: reduce) {
    .eg-toast,
    .eg-toast__compass,
    .eg-toast__seal-ring {
        animation: none !important;
    }

    .eg-toast__progress-ink {
        animation: none;
        width: 0;
    }
}
