/* ==========================================================================
   Page loading feedback (partials/page-loading, partials/page-spinner, js/page-loading.js)
   Colours: purple #5B21B6 on #F1ECFB, white spinner on the purple top bar,
   slow #8A4B0A on #FFF6E5, offline #B0124A on #FFF0F5, pink #D91E5B
   ========================================================================== */

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

/* The spinner in the top bar: only while the next page loads */
.page-spinner {
    display: none;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    animation: page-spin 0.8s linear infinite;
}

.is-page-loading .page-spinner {
    display: inline-block;
}

/* The link that was tapped: fades a little while the next page loads (no border, no browser flash) */
a.is-opening {
    opacity: 0.55;
    transition: opacity 0.15s ease;
    cursor: progress;
}

/* A button sending its form: spinner + "Saving…" */
.page-busy-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: -3px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: currentColor;
    animation: page-spin 0.8s linear infinite;
}

button[aria-busy="true"] {
    cursor: progress;
}

/* ---------- The note under the top bar ---------- */

.page-status {
    position: fixed;
    top: var(--page-status-top, 8px);
    left: 50%;
    z-index: 900;
    width: calc(100% - 24px);
    max-width: 520px;
    box-sizing: border-box;
    transform: translateX(-50%);
    padding: 10px 14px;
    border: 1.5px solid #D9CCF0;
    border-radius: 12px;
    background: #FFFFFF;
    color: #2A1052;
    box-shadow: 0 6px 18px rgba(28, 21, 48, 0.12);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-status[hidden] {
    display: none;
}

.page-status__spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2.5px solid #E2D4F7;
    border-top-color: #5B21B6;
    animation: page-spin 0.8s linear infinite;
}

.page-status__text {
    flex: 1 1 auto;
    min-width: 0;
}

.page-status__retry {
    flex-shrink: 0;
    min-height: 36px;
    padding: 0 14px;
    border: 1.5px solid #B0124A;
    border-radius: 10px;
    background: #FFFFFF;
    color: #B0124A;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.page-status__retry[hidden] {
    display: none;
}

.page-status[data-kind="slow"] {
    border-color: #F5D7A1;
    background: #FFF6E5;
    color: #8A4B0A;
}

.page-status[data-kind="slow"] .page-status__spinner {
    border-color: #F5D7A1;
    border-top-color: #B45309;
}

.page-status[data-kind="offline"] {
    border-color: #F5C6D6;
    background: #FFF0F5;
    color: #B0124A;
}

.page-status[data-kind="offline"] .page-status__spinner {
    display: none;
}

/* ---------- "Placing your order…" over the whole page ---------- */

.page-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(28, 21, 48, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.page-overlay[hidden] {
    display: none;
}

.page-overlay__box {
    width: 100%;
    max-width: 290px;
    box-sizing: border-box;
    padding: 28px 20px;
    border-radius: 20px;
    background: #FFFFFF;
    color: #1C1530;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.page-overlay__spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 4px solid #FCE4EC;
    border-top-color: #D91E5B;
    animation: page-spin 0.9s linear infinite;
}

.page-overlay__title {
    font-size: 18px;
}

.page-overlay__text {
    font-size: 13px;
    line-height: 1.45;
    color: #6A6080;
}

@media (prefers-reduced-motion: reduce) {
    .page-spinner,
    .page-busy-spinner,
    .page-status__spinner,
    .page-overlay__spinner {
        animation-duration: 2.4s;
    }
}
