/* Portal PWA refresh controls — loaded only by the portal Institute panel. */
.portal-pwa-refresh[hidden] {
    display: none !important;
}

html.portal-pwa-refresh-enabled,
html.portal-pwa-refresh-enabled body {
    /* Prevent the browser's native pull gesture from racing our standalone-PWA gesture. */
    overscroll-behavior-y: contain;
}

.portal-pwa-refresh-button,
.portal-pwa-pull-indicator {
    position: fixed;
    display: grid;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 0.72);
    border-radius: 9999px;
    background: #1b2a4a;
    color: #fff;
    box-shadow: 0 5px 18px rgb(15 23 42 / 0.28);
}

.portal-pwa-refresh-button {
    right: calc(env(safe-area-inset-right, 0px) + 1rem);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 5.25rem);
    z-index: 30;
    width: 3rem;
    height: 3rem;
    padding: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.portal-pwa-refresh-button:hover {
    background: #24385f;
}

.portal-pwa-refresh-button:focus-visible {
    outline: 3px solid #f1cf63;
    outline-offset: 3px;
}

.portal-pwa-refresh-button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.portal-pwa-refresh-button svg,
.portal-pwa-pull-indicator svg {
    width: 1.35rem;
    height: 1.35rem;
}

.portal-pwa-refresh-button[aria-busy="true"] svg,
.portal-pwa-pull-indicator.is-refreshing svg {
    animation: portal-pwa-refresh-spin 0.8s linear infinite;
}

.portal-pwa-pull-indicator {
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    left: 50%;
    z-index: 60;
    width: 2.65rem;
    height: 2.65rem;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-4rem + var(--portal-pull-y, 0px)));
}

.portal-pwa-pull-indicator.is-returning {
    transition: transform 180ms ease-out, opacity 180ms ease-out;
}

.portal-pwa-pull-indicator.is-ready {
    background: #c9a227;
    color: #0f172a;
}

.portal-pwa-pull-indicator.is-ready svg {
    transform: rotate(180deg);
}

.portal-pwa-refresh-status {
    position: fixed;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.portal-pwa-refresh-status.is-visible {
    right: calc(env(safe-area-inset-right, 0px) + 1rem);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 9rem);
    z-index: 30;
    width: auto;
    max-width: min(18rem, calc(100vw - 2rem));
    height: auto;
    padding: 0.55rem 0.75rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border: 1px solid rgb(255 255 255 / 0.72);
    border-radius: 0.65rem;
    background: #1b2a4a;
    color: #fff;
    box-shadow: 0 5px 18px rgb(15 23 42 / 0.22);
    font-size: 0.8125rem;
    line-height: 1.35;
}

@keyframes portal-pwa-refresh-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .portal-pwa-pull-indicator.is-returning,
    .portal-pwa-pull-indicator svg {
        transition: none;
    }

    .portal-pwa-refresh-button[aria-busy="true"] svg,
    .portal-pwa-pull-indicator.is-refreshing svg {
        animation: none;
    }
}

@media (forced-colors: active) {
    .portal-pwa-refresh-button,
    .portal-pwa-pull-indicator {
        border: 2px solid ButtonText;
    }
}
