/* ==========================================================================
   Ticket Monkey - branded Blazor reconnect notice.

   Shared by Shop, ManagementDashboard, SystemManagementDashboard and
   CustomerDashboard (one copy per app, kept IDENTICAL - edit all four).

   Markup: Pages/_ReconnectNotice.cshtml (Razor Pages apps) or
   Components/Layout/ReconnectNotice.razor (CustomerDashboard). The element id
   is the framework's contract: Blazor finds #components-reconnect-modal and
   toggles components-reconnect-* classes on it instead of injecting its own
   overlay. js/circuit-reconnect.js drives the copy (data-tmrc-stage) and the
   auto-reload on failed/rejected.

   Theme hooks (all optional, set as custom properties on the element):
     --tmrc-surface  card background        (default white / navy in dark)
     --tmrc-ink      card text              (default TM navy / white in dark)
     --tmrc-accent   spinner + top rule     (default TM orange)
   Shop copies the active event theme into these at show time; dashboards in
   dark mode (html.dark) and CustomerDashboard (.tm-reconnect--dark) use the
   dark set below.
   ========================================================================== */

.tm-reconnect {
    --tmrc-surface: #ffffff;
    --tmrc-ink: #1f2f60;
    --tmrc-accent: #f28a3c;
    --tmrc-muted: color-mix(in srgb, var(--tmrc-ink) 68%, var(--tmrc-surface));
    --tmrc-border: color-mix(in srgb, var(--tmrc-ink) 14%, var(--tmrc-surface));
    --tmrc-track: color-mix(in srgb, var(--tmrc-accent) 22%, var(--tmrc-surface));
    --tmrc-scrim: rgba(15, 22, 45, 0.28);
    --tmrc-shadow: 0 12px 32px rgba(15, 22, 45, 0.18), 0 2px 6px rgba(15, 22, 45, 0.08);
    --tmrc-font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    display: none;
    position: fixed;
    inset: 0;
    /* Above everything the apps float (consent popup sits at 2147483000). */
    z-index: 2147483600;
    background: var(--tmrc-scrim);
    /* The scrim swallows clicks so nobody types or taps into a dead circuit. */
    pointer-events: auto;
    cursor: progress;
}

/* Dashboards in dark mode, and the always-dark CustomerDashboard. */
html.dark .tm-reconnect,
.tm-reconnect.tm-reconnect--dark {
    --tmrc-surface: #1f2f60;
    --tmrc-ink: #ffffff;
    --tmrc-muted: rgba(255, 255, 255, 0.74);
    --tmrc-border: rgba(255, 255, 255, 0.14);
    --tmrc-track: rgba(242, 138, 60, 0.28);
    --tmrc-scrim: rgba(0, 0, 0, 0.5);
    --tmrc-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* Every state Blazor (.NET 8-10) can put the element in, except -hide. */
.tm-reconnect.components-reconnect-show,
.tm-reconnect.components-reconnect-retrying,
.tm-reconnect.components-reconnect-paused,
.tm-reconnect.components-reconnect-failed,
.tm-reconnect.components-reconnect-rejected,
.tm-reconnect.components-reconnect-resume-failed {
    display: block;
}

/* Centring frame. Inside the Shop embed iframe the host tells us which slice
   of the (often very tall, auto-resized) frame is on screen; follow it so the
   card sits where the visitor is looking, like the consent popup does. */
.tm-reconnect__frame {
    position: absolute;
    left: 0;
    right: 0;
    top: var(--tm-embed-visible-top, 0px);
    height: var(--tm-embed-visible-height, 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.tm-reconnect__card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-sizing: border-box;
    /* Fixed width so the card doesn't jump when the "still trying" line lands. */
    width: min(21.5rem, 100%);
    padding: 14px 18px 14px 16px;
    overflow: hidden;
    border: 1px solid var(--tmrc-border);
    border-radius: 8px;
    background: var(--tmrc-surface);
    color: var(--tmrc-ink);
    box-shadow: var(--tmrc-shadow);
    font-family: var(--tmrc-font);
    text-align: left;
    cursor: default;
    /* Fast blips (< ~0.3 s) never flash a card; the scrim still blocks input. */
    animation: tmrc-in 0.18s ease-out 0.3s both;
}

/* Thin accent rule along the top edge - the only brand flourish. */
.tm-reconnect__card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: var(--tmrc-accent);
}

.tm-reconnect__spinner {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    box-sizing: border-box;
    border: 2px solid var(--tmrc-track);
    border-top-color: var(--tmrc-accent);
    border-radius: 50%;
    animation: tmrc-spin 0.9s linear infinite;
}

.tm-reconnect__text {
    min-width: 0;
}

.tm-reconnect__title,
.tm-reconnect__detail {
    margin: 0;
    padding: 0;
}

.tm-reconnect__title {
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    letter-spacing: 0.005em;
    color: var(--tmrc-ink);
}

.tm-reconnect__detail {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    color: var(--tmrc-muted);
}

.tm-reconnect__detail[hidden] {
    display: none;
}

/* Small frames (phones, the ~380px embed): tighter card. */
@media (max-width: 420px) {
    .tm-reconnect__frame { padding: 12px; }
    .tm-reconnect__card { padding: 12px 14px 12px 12px; gap: 10px; }
    .tm-reconnect__title { font-size: 14px; }
    .tm-reconnect__detail { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .tm-reconnect__card { animation: none; }
    /* No spin: a still, solid accent ring reads as "working" without motion. */
    .tm-reconnect__spinner {
        animation: none;
        border-color: var(--tmrc-accent);
        border-width: 5px;
        width: 14px;
        height: 14px;
        margin: 3px 2px 0;
    }
}

@keyframes tmrc-spin {
    to { transform: rotate(360deg); }
}

@keyframes tmrc-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}
