/* ============================================================================
   COMMAND CENTER — CONNECTION LOST (Blazor circuit reconnect UI).

   Replaces the framework default "Could not reconnect to the server." banner.
   blazor.web.js looks for an element with id `components-reconnect-modal`
   (Components/App.razor) and, when it finds one, drives it ENTIRELY by toggling
   four classes on that element:

       .components-reconnect-show        retrying — automatic attempts running
       .components-reconnect-hide        back online
       .components-reconnect-failed      all attempts used up
       .components-reconnect-rejected    server no longer holds the circuit
   ============================================================================ */

#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: flex; }

/* ---------------- SCRIM ---------------- */
#components-reconnect-modal.cc-reconnect {
    position: fixed;
    inset: 0;
    z-index: 20000 !important;           /* over Mud's 9999 — above dialogs and .cc-modal */
    align-items: center;
    /* "safe": on a short viewport the card would overflow upward past the top
       edge where it can't be scrolled to; this pins it to the top instead. */
    align-items: safe center;
    justify-content: center;
    overflow-y: auto;                    /* fixed scrim never scrolls with the page */
    padding: var(--cc-sp-8);
    background: rgba(0, 0, 0, 0.72) !important;   /* over Mud's opaque palette background */
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: cc-reconnect-scrim-in 0.2s ease both;
}
@keyframes cc-reconnect-scrim-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------------- CARD ----------------
   Square white card (entry motion from .cc-accept-card--enter). */
.cc-reconnect-card {
    width: 100%;
    max-width: 520px;
    background: var(--cc-white);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.04),
        0 18px 40px rgba(0, 0, 0, 0.30),
        0 40px 80px rgba(0, 0, 0, 0.24);
}

/* ---------------- HERO ----------------
   A plain dark band in the app header's color, carrying the company logo. */
.cc-reconnect-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 168px;
    padding: var(--cc-sp-6) var(--cc-sp-8) var(--cc-sp-8);
    background: var(--cc-header-bg);
}
.cc-reconnect-logo {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.55));
}

.cc-reconnect-body {
    padding: 0 var(--cc-sp-8) var(--cc-sp-8);
    text-align: center;
}

/* ---------------- STATUS DISC ----------------
   The 56px .cc-accept-state-icon circle, with a spinning accent arc while
   attempts run and a static danger disc once they are spent. */
/* It rides the hero's bottom edge: pulled up by half its height, with a white
   collar so it reads as sitting on the card rather than the photo. */
.cc-reconnect-disc {
    position: relative;
    width: 72px;
    height: 72px;
    margin: -36px auto var(--cc-sp-6);
    background: var(--cc-white);
    box-shadow: 0 0 0 6px var(--cc-white), 0 6px 18px rgba(0, 0, 0, 0.25);
}
.components-reconnect-failed .cc-reconnect-disc,
.components-reconnect-rejected .cc-reconnect-disc { background: var(--cc-red); }

.cc-reconnect-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--cc-red);
    animation: cc-reconnect-spin 0.9s linear infinite;
}
@keyframes cc-reconnect-spin {
    to { transform: rotate(360deg); }
}
.cc-reconnect-bang {
    font-family: var(--cc-font-display);
    font-size: var(--cc-fs-display-sm);
    font-weight: 800;
    line-height: 1;
    color: var(--cc-white);
}
/* A pulsing accent dot sits inside the spinning ring while retrying. */
.cc-reconnect-disc::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cc-red);
    animation: cc-reconnect-pulse 1.4s ease-in-out infinite;
}
.components-reconnect-failed .cc-reconnect-disc::after,
.components-reconnect-rejected .cc-reconnect-disc::after { display: none; }
@keyframes cc-reconnect-pulse {
    0%, 100% { opacity: 0.25; transform: scale(0.8); }
    50%      { opacity: 1;    transform: scale(1); }
}

/* ---------------- COPY ----------------
   Id-scoped so the global h1/p rules in app.css can't recolor or recase them. */
#components-reconnect-modal .cc-reconnect-title {
    margin: 0 0 var(--cc-sp-2);
    font-family: var(--cc-font-display);
    font-size: var(--cc-fs-display-sm);
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1.25;
    text-transform: none;
    color: var(--cc-black);
}
#components-reconnect-modal .cc-reconnect-text {
    margin: 0;
    font-size: var(--cc-fs-lg);
    line-height: 1.5;
    color: var(--cc-dark-gray);
}

/* ---------------- ACTIONS ----------------
   Plain <button>s (this markup sits in the static host page, where no MudButton
   can render). Solid red = the step to take; outlined = the fallback. */
.cc-reconnect-actions {
    display: flex;
    flex-direction: column;
    gap: var(--cc-sp-4);
    margin-top: var(--cc-sp-8);
}
#components-reconnect-modal .cc-reconnect-cta {
    width: 100%;
    min-width: 0;
    align-items: center;
    justify-content: center;
    height: 52px;
    margin: 0 !important;                /* over Mud's `margin: 40px auto` */
    padding: 0 var(--cc-sp-6);
    border: 2px solid var(--cc-red);
    border-radius: 0;
    background: linear-gradient(180deg, var(--cc-red), var(--cc-red-hover));
    color: var(--cc-white);
    font-family: var(--cc-font-heading);
    font-size: var(--cc-fs-lg);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: none;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
#components-reconnect-modal .cc-reconnect-cta:hover:not(:disabled) {
    background: var(--cc-red-hover);
    border-color: var(--cc-red-hover);
}
#components-reconnect-modal .cc-reconnect-cta--outline {
    background: transparent;
    color: var(--cc-red);
}
#components-reconnect-modal .cc-reconnect-cta--outline:hover:not(:disabled) {
    background: rgba(var(--cc-red-rgb), 0.08);
    color: var(--cc-red-hover);
}
#components-reconnect-modal .cc-reconnect-cta:disabled {
    background: var(--cc-medium-gray);
    border-color: var(--cc-medium-gray);
    color: var(--cc-white);
    cursor: progress;
}
#components-reconnect-modal .cc-reconnect-cta:focus-visible {
    outline: 2px solid var(--cc-red);
    outline-offset: 2px;
}

/* ---------------- SUPPORT LINE ---------------- */
.cc-reconnect-support {
    margin-top: var(--cc-sp-8);
    padding-top: var(--cc-sp-6);
    border-top: 1px solid var(--cc-light-gray);
    font-size: var(--cc-fs-sm);
    color: var(--cc-dark-gray);
}
.cc-reconnect-support a {
    color: var(--cc-red);
    font-weight: 700;
    text-decoration: none;
}
.cc-reconnect-support a:hover {
    color: var(--cc-red-hover);
    text-decoration: underline;
}

/* ---------------- PER-STATE COPY ----------------
   Every `*-when-*` element stays hidden until its own state is the active one;
   an element carrying two of them shows in both. The buttons are switched back
   on explicitly because they need flex, not their inline-block default. */
.cc-reconnect [class*="cc-reconnect-when-"] { display: none; }
.components-reconnect-show     .cc-reconnect-when-retrying,
.components-reconnect-failed   .cc-reconnect-when-failed,
.components-reconnect-rejected .cc-reconnect-when-rejected { display: revert; }
.components-reconnect-show     .cc-reconnect-cta.cc-reconnect-when-retrying,
.components-reconnect-failed   .cc-reconnect-cta.cc-reconnect-when-failed,
.components-reconnect-rejected .cc-reconnect-cta.cc-reconnect-when-rejected { display: flex; }

/* ---------------- SMALL SCREENS ---------------- */
@media (max-width: 599.98px) {
    #components-reconnect-modal.cc-reconnect { padding: var(--cc-sp-5); }
    .cc-reconnect-hero { height: 132px; }
    .cc-reconnect-body { padding: 0 var(--cc-sp-6) var(--cc-sp-6); }
    #components-reconnect-modal .cc-reconnect-title { font-size: var(--cc-fs-3xl); }
}

/* Respect a reduced-motion preference: keep the state changes, drop the motion.
   (Mud sets a transition on the button, so that one needs the id as well.) */
@media (prefers-reduced-motion: reduce) {
    .cc-reconnect,
    .cc-reconnect-ring,
    .cc-reconnect-disc::after { animation: none; }
    #components-reconnect-modal .cc-reconnect-cta { transition: none; }
}
