/* Circuit reconnect dialog (US-926) -- the custom #components-reconnect-modal in
   App.razor that replaces blazor.web.js's built-in shadow-DOM dialog.
   blazor.web.js owns the state classes on the root:
     components-reconnect-show     connection lost, retrying (attempt counter)
     components-reconnect-failed   retries exhausted -> Try again / Reload
     components-reconnect-rejected server dropped the circuit -> Reload
     components-reconnect-hide     reconnected
   Chrome follows the canonical modal: white card, --lw-radius-card, card
   shadow, navy primary button. The card is fluid (max 360px, 16px page
   gutters) so it fits a 375px phone -- the built-in 20rem + 4rem box did not.
   MudBlazor.min.css ALSO styles #components-reconnect-modal (opaque
   --mud-palette-background !important, z-index 9999 !important, and an
   ID-specific button color), so every rule here is ID-prefixed and the two
   Mud !important declarations are re-asserted with !important. */

#components-reconnect-modal {
    display: none;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    position: fixed;
    inset: 0;
    z-index: 10000 !important; /* above everything, like the built-in overlay; beats Mud's 9999 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: var(--lw-scrim) !important; /* shared dialog scrim; beats Mud's opaque bg */
    animation: lw-reconnect-fade 0.3s ease-out both;
}

@keyframes lw-reconnect-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#components-reconnect-modal .lw-reconnect__dialog {
    width: 100%;
    max-width: 360px;
    box-sizing: border-box;
    padding: 24px;
    border-radius: var(--lw-radius-card);
    background: var(--lw-white);
    box-shadow: var(--lw-shadow-lg);
    font-family: var(--lw-font-family);
    text-align: center;
}

/* One state block visible at a time, keyed off the root's state class. */
#components-reconnect-modal .lw-reconnect__state {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#components-reconnect-modal.components-reconnect-show .lw-reconnect__state--show,
#components-reconnect-modal.components-reconnect-failed .lw-reconnect__state--failed,
#components-reconnect-modal.components-reconnect-rejected .lw-reconnect__state--rejected {
    display: flex;
}

#components-reconnect-modal .lw-reconnect__title {
    margin: 0;
    font-family: var(--lw-font-family-heading);
    font-size: 18px;
    line-height: 26px;
    font-weight: 600;
    color: var(--lw-primary-dark);
}

#components-reconnect-modal .lw-reconnect__text {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 20px;
    color: var(--lw-gray-graphite);
}

#components-reconnect-modal .lw-reconnect__spinner {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    border: 3px solid var(--lw-border);
    border-top-color: var(--lw-primary-blue);
    border-radius: 50%;
    animation: lw-reconnect-spin 0.8s linear infinite;
}

@keyframes lw-reconnect-spin {
    to { transform: rotate(360deg); }
}

/* Phones: the Project Owner modal pattern (US-798, app.css) -- no dialog
   floats as a card on a phone; it is a bottom sheet: full width, pinned to the
   bottom edge, 12px top radius, content height, sliding up on the shared
   lw-sheet-up keyframes (mudblazor-overrides.css). */
@media (max-width: 767.98px) {
    #components-reconnect-modal.components-reconnect-show,
    #components-reconnect-modal.components-reconnect-failed,
    #components-reconnect-modal.components-reconnect-rejected {
        align-items: flex-end;
        padding: 0;
    }

    #components-reconnect-modal .lw-reconnect__dialog {
        max-width: none;
        max-height: calc(100dvh - 48px);
        overflow-y: auto;
        border-radius: 12px 12px 0 0;
        animation: lw-sheet-up 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    }
}

@media (prefers-reduced-motion: reduce) {
    #components-reconnect-modal .lw-reconnect__dialog { animation: none; }
    #components-reconnect-modal .lw-reconnect__spinner { animation-duration: 2.4s; }
    #components-reconnect-modal.components-reconnect-show,
    #components-reconnect-modal.components-reconnect-failed,
    #components-reconnect-modal.components-reconnect-rejected { animation: none; }
}

#components-reconnect-modal .lw-reconnect__primary {
    width: 100%;
    min-height: 44px;
    margin: 0 !important; /* Mud: #components-reconnect-modal button { margin: 40px auto !important } */
    padding: 10px 16px;
    border: 0;
    border-radius: var(--lw-radius-control);
    background: var(--lw-primary-dark);
    color: var(--lw-white);
    font-family: var(--lw-font-family);
    font-size: 15px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    justify-content: center;
    cursor: pointer;
}

#components-reconnect-modal .lw-reconnect__primary:hover {
    background: var(--lw-primary-dark-hover);
}

#components-reconnect-modal .lw-reconnect__secondary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--lw-primary-blue);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

#components-reconnect-modal .lw-reconnect__secondary:hover {
    color: var(--lw-primary-dark);
    text-decoration: underline;
}
