/* Progressive enhancement: none of these indicators hide existing page content. */
.loading-feedback-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.4em;
    vertical-align: -0.12em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: loading-feedback-spin 0.8s linear infinite;
}

[data-login-busy][hidden],
[data-login-idle][hidden],
.page-loading-status[hidden] {
    display: none !important;
}

.login-loading-status {
    color: var(--primary-dark, #157a4e);
    font-size: 0.875rem;
    text-align: center;
}

.login-loading-status:empty {
    margin: 0;
}

/* Always present in the accessibility tree, even while visual feedback is idle. */
.loading-feedback-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-loading-status {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 1rem);
    right: 1rem;
    z-index: 1090;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(28rem, calc(100vw - 2rem));
    padding: 0.875rem 1.25rem;
    color: #fff;
    background: var(--primary-dark, #157a4e);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius, 10px);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
    font-weight: 600;
    pointer-events: none;
}

.page-loading-panel {
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: #fff;
    border: 1px solid var(--gray-200, #e2e8f0);
    border-radius: var(--radius, 10px);
}

.page-loading-panel-title {
    margin: 0 0 1rem;
    color: var(--primary-dark, #157a4e);
    font-size: 1rem;
    font-weight: 600;
}

.page-loading-placeholder {
    height: 1.5rem;
    margin: 0.75rem 0;
    border-radius: 6px;
    background: var(--gray-200, #e2e8f0);
    animation: loading-feedback-pulse 1.4s ease-in-out infinite;
}

.page-loading-placeholder:first-child {
    width: 55%;
}

.page-loading-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.page-loading-cards .page-loading-placeholder {
    width: 100%;
    height: 6rem;
    margin: 0;
}

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

@keyframes loading-feedback-pulse {
    50% { opacity: 0.5; }
}

@media (max-width: 575.98px) {
    .page-loading-status {
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }

    .page-loading-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-feedback-spinner,
    .page-loading-placeholder {
        animation: none;
    }
}