/* ── RTG Pulse — install prompt + standalone chrome ─────────────────────────
   Visual language is inherited from onboarding.css: the same dark card
   gradient, the same cyan pulse accent, the same easing and radii. The one
   signature element here is the share beacon — a pointer parked at the real
   on-screen location of the browser's Share button.
   Everything is prefixed .rtg-pwa- so nothing collides with site.css.
   ───────────────────────────────────────────────────────────────────────── */

.rtg-pwa {
    --rtg-pwa-surface: linear-gradient(165deg, #0F2133 0%, #132D44 40%, #0D1F2D 100%);
    --rtg-pwa-accent: #4DD8E8;
    --rtg-pwa-ink: #FFFFFF;
    --rtg-pwa-ink-soft: rgba(255, 255, 255, 0.55);
    --rtg-pwa-ink-faint: rgba(255, 255, 255, 0.35);
    --rtg-pwa-hairline: rgba(255, 255, 255, 0.08);
    --rtg-pwa-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Shared primitives ──────────────────────────────────────────────────── */

.rtg-pwa-btn-primary,
.rtg-pwa-btn-quiet {
    font: inherit;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.15s, color 0.2s, background 0.2s;
}

.rtg-pwa-btn-primary {
    border: none;
    padding: 11px 20px;
    background: linear-gradient(135deg, var(--rtg-primary-600) 0%, var(--rtg-accent) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(53, 92, 125, 0.35);
}

.rtg-pwa-btn-primary:active {
    transform: scale(0.98);
}

.rtg-pwa-btn-quiet {
    border: none;
    background: none;
    padding: 11px 14px;
    color: var(--rtg-pwa-ink-faint);
    font-size: 13px;
}

.rtg-pwa-btn-quiet:hover {
    color: var(--rtg-pwa-ink-soft);
}

.rtg-pwa :focus-visible {
    outline: 2px solid var(--rtg-pwa-accent);
    outline-offset: 2px;
}

/* ── Install bar (Chromium: Android + desktop) ──────────────────────────── */

.rtg-pwa-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--rtg-bottom-nav-height) + 12px + env(safe-area-inset-bottom));
    /* Every install layer sits below onboarding.css's modal (9999), so if push.js
       raises its modal while this is still up, the modal wins. */
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--rtg-pwa-surface);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--rtg-pwa-hairline);
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    /* visibility, not just opacity — a transparent bar would still swallow taps
       meant for the bottom nav underneath it. */
    visibility: hidden;
    transition: transform 0.45s var(--rtg-pwa-ease), opacity 0.3s ease, visibility 0.3s ease;
}

.rtg-pwa-visible .rtg-pwa-bar {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Signed-out pages have no bottom nav to clear. */
.rtg-pwa-nonav .rtg-pwa-bar {
    bottom: calc(12px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .rtg-pwa .rtg-pwa-bar,
    .rtg-pwa-nonav .rtg-pwa-bar {
        left: auto;
        right: 20px;
        bottom: 20px;
        width: 380px;
    }
}

.rtg-pwa-bar-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
}

.rtg-pwa-bar-text {
    flex: 1;
    min-width: 0;
}

.rtg-pwa-bar-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--rtg-pwa-ink);
    line-height: 1.3;
}

.rtg-pwa-bar-desc {
    display: block;
    font-size: 12px;
    color: var(--rtg-pwa-ink-soft);
    line-height: 1.4;
    margin-top: 2px;
}

.rtg-pwa-bar-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    flex-shrink: 0;
}

/* ── iOS guide sheet ────────────────────────────────────────────────────── */

.rtg-pwa-sheet-wrap {
    position: fixed;
    inset: 0;
    z-index: 9990;   /* below the onboarding modal (9999) */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.rtg-pwa-visible .rtg-pwa-sheet-wrap {
    opacity: 1;
    visibility: visible;
}

.rtg-pwa-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 18, 28, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.rtg-pwa-sheet {
    position: relative;
    width: 100%;
    max-width: 420px;
    /* Leave a gap under the sheet so the share beacon has room to point. */
    margin: 0 12px calc(76px + env(safe-area-inset-bottom));
    padding: 22px 24px 18px;
    border-radius: 24px;
    background: var(--rtg-pwa-surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--rtg-pwa-hairline);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.4s var(--rtg-pwa-ease);
}

.rtg-pwa-visible .rtg-pwa-sheet {
    transform: translateY(0) scale(1);
}

/* iPad: the Share button is at the top of the window, so anchor the sheet
   high and give the beacon the bottom of the screen back. */
.rtg-pwa-ipad .rtg-pwa-sheet-wrap {
    align-items: flex-start;
}

.rtg-pwa-ipad .rtg-pwa-sheet {
    margin: calc(76px + env(safe-area-inset-top)) 12px 0;
}

.rtg-pwa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(77, 216, 232, 0.1);
    border: 1px solid rgba(77, 216, 232, 0.2);
    color: var(--rtg-pwa-accent);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rtg-pwa-sheet-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--rtg-pwa-ink);
    line-height: 1.3;
    margin: 14px 0 6px;
}

.rtg-pwa-sheet-why {
    font-size: 13px;
    color: var(--rtg-pwa-ink-soft);
    line-height: 1.45;
    margin: 0 0 18px;
}

/* Steps — an ordered gesture, so the numbers carry real information. */
.rtg-pwa-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--rtg-pwa-hairline);
}

.rtg-pwa-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rtg-pwa-hairline);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.35;
}

.rtg-pwa-step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(77, 216, 232, 0.12);
    color: var(--rtg-pwa-accent);
    font-size: 11px;
    font-weight: 700;
}

.rtg-pwa-step svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: var(--rtg-pwa-accent);
}

.rtg-pwa-sheet-actions {
    display: flex;
    justify-content: center;
    padding-top: 6px;
}

/* ── Signature: the share beacon ────────────────────────────────────────── */
/* Parked at the real screen position of Safari's Share button and pointing
   at it — bottom center on iPhone, top right on iPad. */

.rtg-pwa-beacon {
    position: fixed;
    left: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 9991;   /* one above the sheet wrap, still below onboarding (9999) */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease 0.25s;
}

.rtg-pwa-visible .rtg-pwa-beacon {
    opacity: 1;
}

.rtg-pwa-ipad .rtg-pwa-beacon {
    left: auto;
    right: 56px;
    bottom: auto;
    top: calc(10px + env(safe-area-inset-top));
    transform: rotate(180deg);
}

.rtg-pwa-beacon-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--rtg-pwa-accent);
    animation: rtg-pwa-beacon-ping 2s ease-out infinite;
}

@keyframes rtg-pwa-beacon-ping {
    0%   { opacity: 0.55; transform: scale(0.7); }
    100% { opacity: 0;    transform: scale(1.25); }
}

.rtg-pwa-beacon-arrow {
    width: 26px;
    height: 26px;
    color: var(--rtg-pwa-accent);
    filter: drop-shadow(0 2px 10px rgba(77, 216, 232, 0.55));
    animation: rtg-pwa-beacon-bob 2s ease-in-out infinite;
}

@keyframes rtg-pwa-beacon-bob {
    0%, 100% { transform: translateY(-3px); }
    50%      { transform: translateY(3px); }
}

/* ── Settings entry (#rtg-install-entry, owned by the settings page) ─────── */

.rtg-pwa-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f4f8;
}

.rtg-pwa-entry-text {
    min-width: 0;
}

.rtg-pwa-entry-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
}

.rtg-pwa-entry-desc {
    display: block;
    font-size: 12px;
    color: var(--rtg-text-secondary);
    line-height: 1.4;
    margin-top: 2px;
}

.rtg-pwa-entry-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    background: var(--rtg-primary-600);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.rtg-pwa-entry-btn:active {
    background: var(--rtg-primary-700);
}

/* ── Standalone chrome ──────────────────────────────────────────────────── */
/* Installed on a notched iPhone there is no browser toolbar under the bottom
   nav, so the home indicator sits on top of it. site.css already pads the nav
   by env(safe-area-inset-bottom); the nav's fixed height must grow to match,
   and .rtg-main needs the same amount of extra scroll room. */

@supports (padding: env(safe-area-inset-bottom)) {
    @media (display-mode: standalone) {
        .rtg-bottom-nav {
            height: calc(var(--rtg-bottom-nav-height) + env(safe-area-inset-bottom));
        }

        .rtg-main {
            padding-bottom: calc(var(--rtg-bottom-nav-height) + env(safe-area-inset-bottom));
        }

        @media (min-width: 768px) {
            .rtg-main {
                padding-bottom: env(safe-area-inset-bottom);
            }
        }
    }
}

/* ── Small phones ───────────────────────────────────────────────────────── */

@media (max-width: 360px) {
    .rtg-pwa-sheet {
        padding: 18px 18px 14px;
    }

    .rtg-pwa-sheet-title {
        font-size: 18px;
    }

    .rtg-pwa-bar {
        gap: 10px;
        padding: 12px;
    }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .rtg-pwa-bar,
    .rtg-pwa-sheet,
    .rtg-pwa-sheet-wrap,
    .rtg-pwa-beacon {
        transition-duration: 0.01ms;
    }

    .rtg-pwa-bar,
    .rtg-pwa-sheet {
        transform: none;
    }

    .rtg-pwa-beacon-ring,
    .rtg-pwa-beacon-arrow {
        animation: none;
    }

    .rtg-pwa-beacon-ring {
        opacity: 0.4;
    }
}
