/*
 * Connection banner (SKILL.md §15, connection.js): a bar fixed at the top of the page, above everything, red/amber
 * while the device is offline or the server/database isn't answering, green for a few seconds when it's back.
 * Load after theme.css.
 */
.app-conn {
    position: fixed; z-index: 1090; top: 0; left: 0; right: 0;
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem;
    padding: calc(.5rem + env(safe-area-inset-top)) calc(.75rem + env(safe-area-inset-right)) .5rem
             calc(.75rem + env(safe-area-inset-left));
    font-size: .9rem; line-height: 1.35;
    box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .3);
}
.app-conn[hidden] { display: none; }

/* Room for the banner: connection.js sets --app-conn-h to its height while it shows (0 otherwise) */
body { padding-top: var(--app-conn-h, 0px); }
.app-topbar { top: var(--app-conn-h, 0px); }
@media (min-width: 992px) {
    .app-sidebar { top: var(--app-conn-h, 0px); height: calc(100vh - var(--app-conn-h, 0px));
                   height: calc(100dvh - var(--app-conn-h, 0px)); }
}
.app-notif-panel { margin-top: var(--app-conn-h, 0px); }
.app-conn-down { background: #b02a37; color: #fff; }
html[data-connection="database"] .app-conn-down,
html[data-connection="storage"] .app-conn-down,
html[data-connection="signedOut"] .app-conn-down { background: #a35f00; }
.app-conn-ok   { background: #146c43; color: #fff; }

.app-conn-icon { font-size: 1.3rem; }
.app-conn-text { flex: 1 1 16rem; min-width: 0; }
.app-conn-title { font-weight: 700; margin-right: .35rem; }
.app-conn-since { display: block; font-size: .78rem; opacity: .85; }
.app-conn-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    min-height: 36px; padding: .3rem .8rem; border-radius: .4rem;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .45); color: #fff;
    font-size: .85rem; font-weight: 600; text-decoration: none;
}
.app-conn-btn:hover, .app-conn-btn:focus-visible { background: rgba(255, 255, 255, .28); color: #fff; }
@media (pointer: coarse) { .app-conn-btn { min-height: 44px; } }

/* A form or link was blocked while down: a short shake so the eye goes to the banner */
.app-conn-nudge { animation: app-conn-nudge .45s ease; }
@keyframes app-conn-nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* While down, show that saving won't work */
html[data-connection="offline"] form button[type="submit"],
html[data-connection="server"]  form button[type="submit"],
html[data-connection="database"] form button[type="submit"],
html[data-connection="storage"] form button[type="submit"] { opacity: .55; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) { .app-conn-nudge { animation: none; } }
