/* PWA Online/Offline Indicator Styles */

/* Offline indicator banner */
body.offline::before {
    content: 'You are offline. Some features may not be available.';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--color-danger);
    color: white;
    padding: 12px 20px;
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 600;
    z-index: 10000;
    box-shadow: var(--shadow-overlay);
    animation: pwa-slide-down var(--transition-base);
}

@keyframes pwa-slide-down {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Online indicator (subtle, brief) */
body.online.was-offline::before {
    content: 'Back online';
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--color-success);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    z-index: 10000;
    box-shadow: var(--shadow-raised);
    animation: slideInRight var(--transition-base), pwa-fade-out var(--transition-base) 2.7s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pwa-fade-out {
    to {
        opacity: 0;
        transform: translateX(120%);
    }
}

@media (max-width: 640px) {
    body.offline::before {
        font-size: var(--font-size-xs);
        padding: 10px 16px;
    }
}

/* The install bar (T-20261121-01, P5, D323): the first child of <main> (InstallBar.razor), hidden until install-bar.js
   sets one class on <html>: install-can-prompt (the browser gave its install event: "Install") or install-ios (an iPhone
   or iPad browser: "How to install"). An installed app and a "Not now" of the last 30 days get no class. The state is on
   <html> because the first render of the circuit replaces the layout's markup. */
.install-bar {
    display: none;
    align-items: center;
    gap: var(--space-md);
    /* The sides of .list-page (lists.css: 16 px, 4 px at 768 px and below), so the bar lines up with the cards */
    margin: 0 16px var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

html.install-can-prompt .install-bar,
html.install-ios .install-bar {
    display: flex;
}

.install-bar-icon {
    flex-shrink: 0;
    color: var(--color-primary);
    font-size: var(--font-size-xl);
}

.install-bar-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.install-bar-title {
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.install-bar-hint {
    color: var(--text-secondary);
    font-size: var(--font-size-caption);
}

.install-bar-actions {
    flex-shrink: 0;
    display: flex;
    gap: var(--space-sm);
}

.install-bar-actions .btn {
    min-height: var(--tap-min);
}

/* One of the two first buttons shows: "Install" for the kept install event, "How to install" on an iPhone or iPad */
.install-bar-install,
.install-bar-guide {
    display: none;
}

html.install-can-prompt .install-bar-install,
html.install-ios .install-bar-guide {
    display: inline-flex;
}

/* The ask bar for alerts (T-20261123-01 Part C, C1b, D356): the look of the install bar (its inner classes), hidden until push.js sets
   the class push-ask on <html> (the device's alerts are off, the user can get one, no "Not now" in the last 7 days). The install bar
   comes first: while it shows (install-can-prompt or install-ios), the ask bar stays hidden. */
.push-ask-bar {
    display: none;
    align-items: center;
    gap: var(--space-md);
    margin: 0 16px var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

html.push-ask:not(.install-can-prompt):not(.install-ios) .push-ask-bar {
    display: flex;
}

@media (max-width: 768px) {
    .install-bar,
    .push-ask-bar {
        margin-left: 4px;
        margin-right: 4px;
    }
}

@media (max-width: 640px) {
    .install-bar,
    .push-ask-bar {
        flex-wrap: wrap;
    }

    .install-bar-actions {
        width: 100%;
    }

    .install-bar-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

/* The install guide (InstallGuide.razor in App.razor, outside <Routes>): a <dialog> that install-bar.js opens with
   showModal(). Escape, "Close" and a click on the backdrop close it; the page lock is in lists.css. */
.install-guide {
    width: min(400px, calc(100vw - 32px));
    max-width: none;
    /* The browser centres a modal dialog by margin: auto; the reset of base.css sets every margin to 0 */
    margin: auto;
    padding: 0;
    border: none;
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-overlay);
}

/* A literal colour: a ::backdrop reads no custom property in Safari before 17.4 (the reconnect dialog's form) */
.install-guide::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.install-guide-body {
    padding: var(--space-lg);
}

.install-guide-title {
    margin: 0 0 var(--space-md);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.install-guide-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: 0 0 var(--space-lg);
    padding: 0;
    list-style: none;
}

.install-guide-steps li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
}

.install-guide-n {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--text-inverse);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

.install-guide-close {
    width: 100%;
    min-height: var(--tap-min);
    justify-content: center;
}
