/*
 * Public-site Blazor Server host: shell-only styles (error bar + reconnect overlay).
 * Everything else comes from the shared EGKitsPublic wwwroot.
 */

#blazor-error-ui {
    display: none;
    background: #c51244;
    color: #fff;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    z-index: 1000;
    font-family: Inter, Roboto, Arial, sans-serif;
}

    #blazor-error-ui .dismiss {
        position: absolute;
        right: .75rem;
        top: .5rem;
        cursor: pointer;
        background: transparent;
        border: 0;
        color: #fff;
        font-size: 1.25rem;
    }

    [dir="rtl"] #blazor-error-ui .dismiss {
        right: auto;
        left: .75rem;
    }

    #blazor-error-ui .reload {
        color: #fff;
        text-decoration: underline;
    }

/*
 * Reconnect status pill.
 *
 * MudBlazor.min.css ships
 *   #components-reconnect-modal { z-index:9999 !important;
 *                                 background-color: var(--mud-palette-background) !important }
 * Once MudThemeProvider defines the palette that turns the overlay into an OPAQUE
 * sheet in the theme's page colour with white text on it — visitors saw a
 * "completely blank page" for the whole reconnect.
 * The selector below is more specific AND !important so the transparent layer
 * always wins, whatever the stylesheet order; the page stays visible underneath.
 *
 * The root stays a full-viewport layer so clicks and keystrokes cannot reach a
 * disconnected circuit (they would be dropped silently), but it is invisible during
 * a short outage: only the pill at the bottom shows. The page is dimmed lightly,
 * and the hint + reload action appear, only once the outage is long
 * (.reconnect-long), the browser is offline, or recovery has escalated.
 */
body > #components-reconnect-modal {
    --egk-rc-accent: #34d399;
    --egk-rc-warn: #fbbf24;
    position: fixed;
    inset: 0;
    z-index: 10000 !important;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    background: transparent !important;
    background-color: transparent !important;
    cursor: progress;
    color: #f8fafc;
    font-family: Inter, Roboto, Arial, sans-serif;
    transition: background-color .4s ease;
}

    body > #components-reconnect-modal.reconnect-long,
    body > #components-reconnect-modal.reconnect-offline,
    body > #components-reconnect-modal.components-reconnect-failed,
    body > #components-reconnect-modal.components-reconnect-rejected {
        background: rgba(7, 11, 26, .18) !important;
        background-color: rgba(7, 11, 26, .18) !important;
    }

    body > #components-reconnect-modal .reconnect-card {
        position: relative;
        display: flex;
        align-items: center;
        gap: .75rem;
        min-width: 13rem;
        max-width: min(30rem, 100%);
        padding: .625rem .875rem .625rem .75rem;
        border-radius: 14px;
        overflow: hidden;
        cursor: default;
        text-align: start;
        line-height: 1.35;
        background: rgba(15, 23, 42, .82);
        -webkit-backdrop-filter: blur(16px) saturate(1.4);
        backdrop-filter: blur(16px) saturate(1.4);
        border: 1px solid rgba(255, 255, 255, .09);
        box-shadow: 0 12px 32px -8px rgba(2, 6, 23, .45), 0 2px 6px rgba(2, 6, 23, .18), inset 0 1px 0 rgba(255, 255, 255, .06);
        animation: egk-reconnect-in .35s cubic-bezier(.2, .8, .2, 1);
    }

    /* Status indicator: spinning ring while working, amber dot when offline,
       check mark once the connection is back. */
    body > #components-reconnect-modal .reconnect-indicator {
        flex: none;
        width: 1rem;
        height: 1rem;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, .16);
        border-top-color: var(--egk-rc-accent);
        animation: egk-reconnect-spin .9s linear infinite;
    }

    body > #components-reconnect-modal.reconnect-offline .reconnect-indicator {
        width: .625rem;
        height: .625rem;
        margin-inline: .1875rem;
        border: 0;
        background: var(--egk-rc-warn);
        box-shadow: 0 0 0 0 rgba(251, 191, 36, .5);
        animation: egk-reconnect-pulse 2s ease-out infinite;
    }

    body > #components-reconnect-modal .reconnect-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    body > #components-reconnect-modal .reconnect-card h4 {
        margin: 0;
        font-size: .875rem;
        font-weight: 600;
        letter-spacing: .005em;
        color: #f8fafc;
    }

    body > #components-reconnect-modal .reconnect-card p {
        margin: 0;
    }

    body > #components-reconnect-modal .reconnect-hint {
        margin-top: .125rem !important;
        font-size: .78125rem;
        color: rgba(226, 232, 240, .72);
    }

        /* Quiet phase: a short reconnect shows the title only. */
        body > #components-reconnect-modal.components-reconnect-show:not(.reconnect-long):not(.reconnect-offline) .reconnect-hint,
        body > #components-reconnect-modal.components-reconnect-retrying:not(.reconnect-long):not(.reconnect-offline) .reconnect-hint,
        body > #components-reconnect-modal .reconnect-hint:empty {
            display: none;
        }

    /* Manual reload is offered only after a long outage (.reconnect-long, set by
       public-server-shell.js) and never while a resume or an automatic refresh is
       already in progress. */
    body > #components-reconnect-modal .reconnect-actions {
        display: flex;
        flex: none;
        align-items: center;
        gap: .375rem;
    }

    body > #components-reconnect-modal .reconnect-reload,
    body > #components-reconnect-modal .reconnect-retry {
        display: none;
    }

    /* Retry now: only during the slow background cadence, where the next attempt
       can be many seconds away. */
    body > #components-reconnect-modal.components-reconnect-failed:not(.reconnect-offline) .reconnect-retry {
        display: inline-block;
    }

    body > #components-reconnect-modal.reconnect-long .reconnect-reload {
        display: block;
    }

    /* ...nor while the browser itself is offline: reloading then just swaps this
       page for the browser's error screen and discards the preserved state. */
    body > #components-reconnect-modal.components-reconnect-resuming .reconnect-reload,
    body > #components-reconnect-modal.components-reconnect-rejected .reconnect-reload,
    body > #components-reconnect-modal.reconnect-offline .reconnect-reload {
        display: none;
    }

    body > #components-reconnect-modal .reconnect-reload a,
    body > #components-reconnect-modal .reconnect-retry {
        font-family: inherit;
        line-height: 1.35;
        cursor: pointer;
        white-space: nowrap;
    }

    body > #components-reconnect-modal .reconnect-retry {
        padding: .3125rem .75rem;
        border-radius: 8px;
        font-size: .78125rem;
        font-weight: 600;
        color: #052e1c;
        background: var(--egk-rc-accent);
        border: 1px solid transparent;
        transition: filter .15s ease;
    }

        body > #components-reconnect-modal .reconnect-retry:hover { filter: brightness(1.08); }

        body > #components-reconnect-modal .reconnect-retry:focus-visible {
            outline: 2px solid #f8fafc;
            outline-offset: 2px;
        }

        body > #components-reconnect-modal .reconnect-retry:disabled {
            opacity: .6;
            cursor: progress;
        }

    body > #components-reconnect-modal .reconnect-reload a {
        display: inline-block;
        padding: .3125rem .75rem;
        border-radius: 8px;
        font-size: .78125rem;
        font-weight: 600;
        color: #f8fafc;
        text-decoration: none;
        background: rgba(255, 255, 255, .08);
        border: 1px solid rgba(255, 255, 255, .14);
        transition: background-color .15s ease, border-color .15s ease;
    }

        body > #components-reconnect-modal .reconnect-reload a:hover {
            background: rgba(255, 255, 255, .14);
            border-color: rgba(255, 255, 255, .22);
        }

        body > #components-reconnect-modal .reconnect-reload a:focus-visible {
            outline: 2px solid var(--egk-rc-accent);
            outline-offset: 2px;
        }

    /* Hairline activity bar along the bottom edge of the pill. */
    body > #components-reconnect-modal .reconnect-progress {
        position: absolute;
        inset: auto 0 0 0;
        height: 2px;
        overflow: hidden;
        pointer-events: none;
    }

        body > #components-reconnect-modal .reconnect-progress::after {
            content: '';
            position: absolute;
            inset: 0 auto 0 -35%;
            width: 35%;
            background: linear-gradient(90deg, transparent, var(--egk-rc-accent), transparent);
            animation: egk-reconnect-sweep 1.8s ease-in-out infinite;
        }

    /* Browser reports offline: no sweep, it would suggest activity that is not happening. */
    body > #components-reconnect-modal.reconnect-offline .reconnect-progress {
        display: none;
    }

    /* Brief "Reconnected" confirmation after a visible outage. The page is live
       again, so the layer no longer intercepts input. */
    body > #components-reconnect-modal.reconnect-restored {
        display: flex;
        pointer-events: none;
        cursor: auto;
        background: transparent !important;
        background-color: transparent !important;
    }

        body > #components-reconnect-modal.reconnect-restored .reconnect-card {
            min-width: 0;
            padding-inline-end: 1.125rem;
            animation: egk-reconnect-restored 1.8s ease forwards;
        }

        body > #components-reconnect-modal.reconnect-restored .reconnect-indicator {
            width: 1rem;
            height: 1rem;
            margin-inline: 0;
            border: 0;
            border-radius: 50%;
            background: var(--egk-rc-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-4.9' fill='none' stroke='%230f172a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
            box-shadow: none;
            animation: none;
        }

        body > #components-reconnect-modal.reconnect-restored .reconnect-hint,
        body > #components-reconnect-modal.reconnect-restored .reconnect-actions,
        body > #components-reconnect-modal.reconnect-restored .reconnect-progress {
            display: none;
        }

    /* Phones: a full-width bar is easier to read and to tap than a floating pill. */
    @media (max-width: 480px) {
        body > #components-reconnect-modal { padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom, 0px)); }
        body > #components-reconnect-modal .reconnect-card { width: 100%; max-width: none; min-width: 0; }
        body > #components-reconnect-modal.reconnect-restored .reconnect-card { width: auto; }
    }

    @keyframes egk-reconnect-in {
        from { opacity: 0; transform: translateY(12px) scale(.98); }
        to { opacity: 1; transform: none; }
    }

    @keyframes egk-reconnect-restored {
        0% { opacity: 1; transform: none; }
        75% { opacity: 1; transform: none; }
        100% { opacity: 0; transform: translateY(8px); }
    }

    @keyframes egk-reconnect-spin {
        to { transform: rotate(360deg); }
    }

    @keyframes egk-reconnect-pulse {
        0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .5); }
        70%, 100% { box-shadow: 0 0 0 .5rem rgba(251, 191, 36, 0); }
    }

    @keyframes egk-reconnect-sweep {
        to { left: 100%; }
    }

    @media (prefers-reduced-motion: reduce) {
        body > #components-reconnect-modal .reconnect-card { animation: none; }
        body > #components-reconnect-modal.reconnect-restored .reconnect-card { animation: egk-reconnect-restored 1.8s steps(1, end) forwards; }
        body > #components-reconnect-modal .reconnect-indicator { animation-duration: 2.4s; }
        body > #components-reconnect-modal.reconnect-offline .reconnect-indicator { animation: none; }
        body > #components-reconnect-modal .reconnect-progress::after { animation: none; left: 0; width: 100%; opacity: .35; }
    }

    /* Every non-hidden state the .NET 10 client can apply must be visible: the
       'paused' / 'resume-failed' states were added in .NET 10 and, if left
       display:none, produce an unresponsive page with no visual cue. */
    body > #components-reconnect-modal.components-reconnect-show,
    body > #components-reconnect-modal.components-reconnect-retrying,
    body > #components-reconnect-modal.components-reconnect-failed,
    body > #components-reconnect-modal.components-reconnect-rejected,
    body > #components-reconnect-modal.components-reconnect-paused,
    body > #components-reconnect-modal.components-reconnect-resume-failed,
    body > #components-reconnect-modal.components-reconnect-resuming {
        display: flex;
    }

    body > #components-reconnect-modal.components-reconnect-hide:not(.reconnect-restored) {
        display: none;
    }
