/* ==========================================================================
   UniNet - connection / offline overlay
   Drives the Blazor reconnection UI (#components-reconnect-modal).
   Customer-facing: follows the UA brand guide (square, flat, no shadow,
   flat fills, Tenorite, tokens only, Title Case buttons). A light panel over the
   dimmed page, the real logo (no plate), and one calm radar sweep in brand blue.
   Tokens come from app.css, which is already loaded when a connection drops.
   ========================================================================== */

#components-reconnect-modal.ua-offline {
    --ofl-font: var(--ua-font-primary, "Tenorite", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif);

    display: none;
}

#components-reconnect-modal.ua-offline.components-reconnect-show,
#components-reconnect-modal.ua-offline.components-reconnect-retrying,
#components-reconnect-modal.ua-offline.components-reconnect-paused,
#components-reconnect-modal.ua-offline.components-reconnect-failed,
#components-reconnect-modal.ua-offline.components-reconnect-rejected {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 20000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    font-family: var(--ofl-font);
}

/* --- Scrim: the page stays visible underneath, dimmed ------------------- */
.ua-offline__backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--ua-secondary-dark-blue) 55%, transparent);
    animation: ofl-fade-in 0.25s ease both;
}

/* --- Panel: white, square, flat, brand-blue top rule -------------------- */
.ua-offline__card {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 100%;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--ua-hairline);
    border-top: 4px solid var(--ua-primary-blue);
    border-radius: 0;
    box-shadow: none;
    padding: 1.75rem 2rem 1.75rem;
    text-align: center;
    color: var(--ua-text-on-light);
    animation: ofl-fade-in 0.25s ease both;
}

.ua-offline__card:focus {
    outline: none;
}

/* Logo lock-up: the supplied asset on white, never recolored or boxed */
.ua-offline__logo {
    display: block;
    height: 1.75rem;
    width: auto;
    margin: 0 auto 1.25rem;
}

/* --- View switching by connection state -------------------------------- */
.ua-offline__view {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .ua-offline__view--reconnecting,
#components-reconnect-modal.components-reconnect-retrying .ua-offline__view--reconnecting,
#components-reconnect-modal.components-reconnect-paused .ua-offline__view--reconnecting {
    display: block;
    animation: ofl-fade-in 0.25s ease both;
}

#components-reconnect-modal.components-reconnect-failed .ua-offline__view--failed {
    display: block;
    animation: ofl-fade-in 0.25s ease both;
}

#components-reconnect-modal.components-reconnect-rejected:not([data-ua-outcome="signed-out"]) .ua-offline__view--rejected {
    display: block;
    animation: ofl-fade-in 0.25s ease both;
}

/* Rejected and the sign-in cookie is gone: a real expiry, so a sign-in prompt. */
#components-reconnect-modal.components-reconnect-rejected[data-ua-outcome="signed-out"] .ua-offline__view--signin {
    display: block;
    animation: ofl-fade-in 0.25s ease both;
}

/* Rejected, and the server is being asked why (a second or so): show nothing rather than the wrong words.
   Rejected because the server was redeployed: the "UniNet was updated" banner replaces the overlay. */
#components-reconnect-modal.ua-offline.components-reconnect-rejected[data-ua-state="checking"],
#components-reconnect-modal.ua-offline.components-reconnect-rejected[data-ua-outcome="app-updated"] {
    display: none;
}

/* --- Radar: one slow sweep, brand blue on hairlines --------------------- */
/* Circular by nature: a radar graphic, not a card or button (DESIGN-STANDARD rule 3 exception, see PR). */
.ua-offline__radar {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0 auto 1.1rem;
    border-radius: 50%;
    border: 1px solid var(--ua-hairline);
}

.ua-offline__radar::before {
    content: "";
    position: absolute;
    inset: 20px;
    border-radius: 50%;
    border: 1px solid var(--ua-hairline);
}

.ua-offline__radar .ofl-radar-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    clip-path: circle(50%); /* the wedge corner must never poke outside the ring */
    animation: ofl-radar-spin 2.8s linear infinite;
}

/* The sweep: a flat quarter wedge (flat tint) with a solid hand on its leading edge */
.ua-offline__radar .ofl-radar-sweep::before {
    content: "";
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--ua-primary-blue) 14%, transparent);
    clip-path: polygon(50% 50%, 50% 0, 0 0, 0 50%);
}

.ua-offline__radar .ofl-radar-sweep::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 50%;
    margin-left: -1px;
    background: var(--ua-primary-blue);
}

.ua-offline__radar .ofl-radar-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: var(--ua-primary-blue);
}

/* --- Failed / rejected icon (square, flat) ------------------------------ */
.ua-offline__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ua-offline__icon svg {
    width: 28px;
    height: 28px;
}

.ua-offline__icon--warn {
    background: var(--ua-alert-warning-bg);
    color: var(--ua-status-pill-warning-text);
    border: 1px solid var(--ua-alert-warning-accent);
}

.ua-offline__icon--refresh {
    background: var(--ua-alert-info-bg);
    color: var(--ua-primary-blue);
    border: 1px solid var(--ua-primary-blue);
}

/* --- Typography --------------------------------------------------------- */
.ua-offline__title {
    margin: 0 0 0.5rem;
    font-family: var(--ofl-font);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ua-secondary-dark-blue);
}

.ua-offline__text {
    margin: 0 auto;
    max-width: 40ch;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ua-text-on-light);
}

.ua-offline__help {
    margin: 1rem 0 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--ua-primary-gray);
}

.ua-offline__help a {
    color: var(--ua-primary-blue);
    text-decoration: underline;
}

/* --- Attempt counter ---------------------------------------------------- */
.ua-offline__meta {
    margin: 0.9rem 0 0;
    font-size: 0.85rem;
    color: var(--ua-primary-gray);
    min-height: 1.2em;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ua-offline__meta:has(#components-reconnect-current-attempt:not(:empty)) {
    opacity: 1;
}

.ua-offline__meta b {
    color: var(--ua-text-on-light);
    font-weight: 700;
}

.ua-offline__next {
    display: none;
}

.ua-offline__meta:has(#components-seconds-to-next-attempt:not(:empty)) .ua-offline__next {
    display: inline;
}

/* --- Buttons: square, flat, Title Case, 700 ----------------------------- */
.ua-offline__actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.ua-offline__btn {
    min-height: 40px;
    padding: 0.5rem 1.4rem;
    border: 2px solid var(--ua-primary-blue);
    border-radius: 0;
    background: white;
    color: var(--ua-primary-blue);
    font-family: var(--ofl-font);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    box-shadow: none;
}

.ua-offline__btn:hover {
    background: var(--ua-alert-info-bg);
}

.ua-offline__btn--primary {
    background: var(--ua-primary-blue);
    color: white;
}

.ua-offline__btn--primary:hover {
    background: var(--ua-secondary-dark-blue);
    border-color: var(--ua-secondary-dark-blue);
}

.ua-offline__btn:focus-visible {
    outline: 2px solid var(--ua-primary-blue);
    outline-offset: 2px;
}

/* --- Keyframes ---------------------------------------------------------- */
@keyframes ofl-radar-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ofl-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* --- Reduced motion: no sweep, no fades --------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .ua-offline__backdrop,
    .ua-offline__card,
    .ua-offline__view,
    .ua-offline__radar .ofl-radar-sweep {
        animation: none !important;
    }

    .ua-offline__meta {
        transition: none;
    }
}

/* --- Small screens ------------------------------------------------------ */
@media (max-width: 480px) {
    .ua-offline__card {
        padding: 1.5rem 1.25rem;
    }

    .ua-offline__btn {
        min-height: 44px; /* touch target */
    }
}

/* --- "UniNet was updated" banner ----------------------------------------
   Shown (by offline-overlay.js) when the server was redeployed since the page loaded. An inline alert in the
   shared info look (DESIGN-STANDARD section 6): tinted surface, 4px left accent, square, no shadow. Not a
   modal - nothing is signed out, and the customer can still read and copy what they typed. */
.ua-update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20001; /* above the overlay (20000) and the app chrome */
    font-family: var(--ua-font-primary, "Tenorite", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif);
}

.ua-update-banner__box[hidden] {
    display: none;
}

.ua-update-banner__box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--ua-alert-info-bg);
    color: var(--ua-alert-info-fg, var(--ua-secondary-dark-blue));
    border-bottom: 1px solid var(--ua-hairline);
    border-left: 4px solid var(--ua-alert-info-accent, var(--ua-primary-blue));
    border-radius: 0;
    box-shadow: none;
}

.ua-update-banner__box:focus-visible {
    outline: 2px solid var(--ua-primary-blue);
    outline-offset: -2px;
}

.ua-update-banner__icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: var(--ua-primary-blue);
}

.ua-update-banner__text {
    flex: 1 1 auto;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.35;
}

.ua-update-banner__btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0.4rem 1.1rem;
    border: 1px solid var(--ua-primary-blue);
    border-radius: 0;
    background: var(--ua-primary-blue);
    color: white;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

.ua-update-banner__btn:hover {
    background: var(--ua-secondary-dark-blue);
    border-color: var(--ua-secondary-dark-blue);
}

.ua-update-banner__btn:focus-visible {
    outline: 2px solid var(--ua-primary-blue);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .ua-update-banner__box {
        flex-wrap: wrap;
    }

    .ua-update-banner__btn {
        min-height: 44px; /* touch target */
    }
}
