/* GuestRise Loyalty — reusable skeleton / empty / error / loading states.
   Mobile-first. Safe-area aware. Works in both wallet-ui-v2 and legacy. */

:root {
    --gr-skeleton-bg: rgba(0, 0, 0, 0.06);
    --gr-skeleton-shine: rgba(255, 255, 255, 0.65);
    --gr-state-fg: #1c1c1e;
    --gr-state-fg-muted: #636366;
    --gr-state-accent: #0ea5e9;
    --gr-state-danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
    :root {
        --gr-skeleton-bg: rgba(255, 255, 255, 0.08);
        --gr-skeleton-shine: rgba(255, 255, 255, 0.18);
        --gr-state-fg: #f4f4f5;
        --gr-state-fg-muted: #a1a1aa;
    }
}

/* ----- Skeleton blocks ----- */
.gr-skel {
    position: relative;
    overflow: hidden;
    background: var(--gr-skeleton-bg);
    border-radius: 12px;
    isolation: isolate;
}
.gr-skel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 0%,
        var(--gr-skeleton-shine) 45%,
        var(--gr-skeleton-shine) 55%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: gr-shine 1.4s ease-in-out infinite;
}
@keyframes gr-shine {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
    .gr-skel::after { animation: none; }
}

.gr-skel-line   { height: 12px; margin: 8px 0; }
.gr-skel-line.lg { height: 18px; }
.gr-skel-line.sm { height: 8px; }
.gr-skel-circle { border-radius: 9999px; aspect-ratio: 1/1; }
.gr-skel-card   { height: 200px; border-radius: 20px; }
.gr-skel-avatar { width: 48px; height: 48px; border-radius: 9999px; }

.gr-skel-stack > * + * { margin-top: 12px; }

/* ----- Empty state ----- */
.gr-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--gr-state-fg-muted);
}
.gr-empty .gr-empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 9999px;
    background: var(--gr-skeleton-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--gr-state-fg-muted);
    font-size: 28px;
}
.gr-empty h3 {
    color: var(--gr-state-fg);
    font-weight: 600;
    margin: 0 0 6px;
    font-size: 1.05rem;
}
.gr-empty p {
    margin: 0 auto;
    max-width: 32ch;
    font-size: 0.92rem;
    line-height: 1.4;
}
.gr-empty .gr-empty-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px 18px;
    border-radius: 9999px;
    background: var(--gr-state-accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    min-height: 44px;
}

/* ----- Error state ----- */
.gr-error {
    text-align: center;
    padding: 32px 24px;
    border-radius: 16px;
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.18);
    color: var(--gr-state-danger);
}
.gr-error h3 {
    margin: 8px 0 4px;
    font-weight: 600;
    color: var(--gr-state-danger);
}
.gr-error p {
    color: var(--gr-state-fg-muted);
    font-size: 0.92rem;
    margin: 0 auto 16px;
    max-width: 36ch;
}
.gr-error button,
.gr-error .gr-error-cta {
    appearance: none;
    border: 0;
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 9999px;
    background: var(--gr-state-danger);
    color: #fff;
    font-weight: 600;
    min-height: 44px;
}

/* ----- Inline spinner ----- */
.gr-spinner {
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    border: 2px solid var(--gr-skeleton-bg);
    border-top-color: var(--gr-state-accent);
    animation: gr-spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes gr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .gr-spinner { animation-duration: 1.6s; }
}

/* ----- Safe area helpers (iOS notch / home bar) ----- */
.gr-safe-top    { padding-top: env(safe-area-inset-top, 0); }
.gr-safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.gr-safe-left   { padding-left:  env(safe-area-inset-left, 0); }
.gr-safe-right  { padding-right: env(safe-area-inset-right, 0); }

/* Bottom nav respects home bar without a JS calc. */
.gr-bottom-nav {
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 8px);
}

/* Minimum tap targets */
.gr-tap { min-width: 44px; min-height: 44px; }
