/* ============================================================================
   Atlas PWA — Install Prompt + Update Toast
   Loaded after atlas.css so all tokens (--jacarta, --lavender, --iris, etc.)
   are available. A centered modal on desktop, a slide-up bottom sheet on
   phones. Respects env(safe-area-inset-*) for notched devices.
   ============================================================================ */

/* Fallback tokens in case atlas.css ever loads after this file. */
:root {
    --atlas-pwa-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --atlas-pwa-duration: 280ms;
    --atlas-pwa-scrim: rgba(10, 8, 32, 0.72);
}

/* ============================================================================
   1. BACKDROP + CARD
   ============================================================================ */
.atlas-install {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--atlas-pwa-duration) var(--atlas-pwa-ease);
}
.atlas-install.is-visible {
    opacity: 1;
    pointer-events: auto;
}
.atlas-install[hidden] { display: none !important; }

.atlas-install-backdrop {
    position: absolute;
    inset: 0;
    background: var(--atlas-pwa-scrim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.atlas-install-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 2.25rem 1.75rem 1.5rem;
    background: linear-gradient(180deg,
        rgba(30, 26, 74, 0.98) 0%,
        rgba(15, 12, 36, 0.98) 100%);
    border: 1px solid rgba(152, 137, 192, 0.22);
    border-radius: 24px;
    box-shadow:
        0 30px 80px rgba(10, 8, 32, 0.7),
        0 0 0 1px rgba(196, 156, 224, 0.06) inset,
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
    text-align: center;
    transform: translateY(30px) scale(0.96);
    opacity: 0;
    transition: opacity var(--atlas-pwa-duration) var(--atlas-pwa-ease),
                transform var(--atlas-pwa-duration) var(--atlas-pwa-ease);
}
.atlas-install.is-visible .atlas-install-card {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: atlas-install-in 0.5s var(--atlas-pwa-ease) both;
}
@keyframes atlas-install-in {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================================
   2. CLOSE BUTTON
   ============================================================================ */
.atlas-install-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(152, 137, 192, 0.12);
    border-radius: 50%;
    color: #B5A9D3;
    cursor: pointer;
    transition: all 180ms var(--atlas-pwa-ease);
    -webkit-tap-highlight-color: transparent;
}
.atlas-install-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(152, 137, 192, 0.3);
    transform: scale(1.05);
}
.atlas-install-close:focus-visible {
    outline: 2px solid var(--iris, #C49CE0);
    outline-offset: 3px;
}
.atlas-install-close svg { width: 16px; height: 16px; }

/* ============================================================================
   3. MARK MEDALLION — breathing iris halo
   ============================================================================ */
.atlas-install-mark {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.atlas-install-mark::before {
    content: '';
    position: absolute;
    inset: -18px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(196, 156, 224, 0.35) 0%, transparent 72%);
    animation: atlas-install-breathe 3.6s ease-in-out infinite;
}
.atlas-install-mark img {
    position: relative;
    width: 56px;
    height: 56px;
    z-index: 1;
    border-radius: 14px;
}
@keyframes atlas-install-breathe {
    0%, 100% { opacity: 0.65; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.07); }
}

/* ============================================================================
   4. EYEBROW
   ============================================================================ */
.atlas-install-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 1rem;
    padding: 0.35rem 0.95rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--iris, #C49CE0);
    background: rgba(196, 156, 224, 0.08);
    border: 1px solid rgba(196, 156, 224, 0.22);
    border-radius: 999px;
    justify-content: center;
}
.atlas-install-spark {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--iris, #C49CE0);
    box-shadow: 0 0 10px var(--iris, #C49CE0);
    animation: atlas-install-spark 1.8s ease-in-out infinite;
}
@keyframes atlas-install-spark {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.75); }
}

/* ============================================================================
   5. TITLE + BODY
   ============================================================================ */
.atlas-install-title {
    margin: 0 0 0.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    text-wrap: balance;
}
.atlas-install-body {
    margin: 0 0 1.1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    line-height: 1.6;
    font-weight: 500;
    color: #E2DBF5;
    text-align: center;
}
.atlas-install-body strong {
    color: #FFFFFF;
    font-weight: 700;
}

/* ============================================================================
   6. BENEFITS LIST
   ============================================================================ */
.atlas-install-benefits {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    background: rgba(165, 148, 214, 0.06);
    border: 1px solid rgba(196, 156, 224, 0.16);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.atlas-install-benefits li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.86rem;
    font-weight: 500;
    color: #E2DBF5;
    line-height: 1.4;
    text-align: left;
}
.atlas-install-benefits li svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--iris, #C49CE0);
}

/* ============================================================================
   7. ACTIONS
   ============================================================================ */
.atlas-install-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}
.atlas-install-actions[hidden] { display: none !important; }

.atlas-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 46px;
    padding: 0 1.2rem;
    border: 1px solid transparent;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 180ms var(--atlas-pwa-ease);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}
.atlas-install-btn.is-primary {
    background: linear-gradient(135deg, var(--lavender-d, #7B6EA8) 0%, var(--jacarta, #2D2769) 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset,
                0 8px 20px rgba(45, 39, 105, 0.55);
}
.atlas-install-btn.is-primary:hover {
    background: linear-gradient(135deg, var(--lavender, #9889C0) 0%, var(--jacarta-l, #3D3580) 100%);
    transform: translateY(-1px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset,
                0 12px 28px rgba(95, 79, 148, 0.55);
}
.atlas-install-btn.is-ghost {
    background: transparent;
    border-color: rgba(165, 148, 214, 0.32);
    color: #C8BFE2;
}
.atlas-install-btn.is-ghost:hover {
    border-color: var(--lavender-l, #B5A9D3);
    color: #FFFFFF;
    background: rgba(165, 148, 214, 0.10);
}
.atlas-install-btn:focus-visible {
    outline: 2px solid var(--iris, #C49CE0);
    outline-offset: 3px;
}
.atlas-install-btn:not(:disabled):active { transform: scale(0.97); }
.atlas-install-btn svg { width: 16px; height: 16px; }

/* ============================================================================
   8. iOS WALKTHROUGH
   ============================================================================ */
.atlas-install-ios {
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    background: rgba(165, 148, 214, 0.04);
    border: 1px solid rgba(152, 137, 192, 0.16);
    border-radius: 14px;
    text-align: left;
}
.atlas-install-ios[hidden] { display: none !important; }

.atlas-install-ios-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #FFFFFF;
}
.atlas-install-ios-header svg {
    width: 16px;
    height: 16px;
    color: #D6CFEC;
}

.atlas-install-ios-steps {
    list-style: none;
    margin: 0 0 0.85rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.atlas-install-ios-steps li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #E2DBF5;
}
.atlas-install-ios-steps .step-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--iris, #C49CE0);
    background: rgba(196, 156, 224, 0.1);
    border: 1px solid rgba(196, 156, 224, 0.28);
    border-radius: 50%;
}
.atlas-install-ios-steps .step-body strong { color: #fff; font-weight: 700; }
.atlas-install-ios-steps .step-inline-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin: 0 0.15rem;
    background: rgba(196, 156, 224, 0.1);
    border: 1px solid rgba(196, 156, 224, 0.28);
    border-radius: 6px;
    color: var(--iris, #C49CE0);
    vertical-align: middle;
}
.atlas-install-ios-steps .step-inline-icon svg { width: 12px; height: 12px; }

.atlas-install-ios-dismiss {
    width: 100%;
    height: 40px;
    font-size: 0.8rem;
}

/* ============================================================================
   9. FOOTER WORDMARK
   Aristos light wordmark, sized for the card width. Kept slightly
   dimmed via opacity so it reads as a signature, not a headline.
   ============================================================================ */
.atlas-install-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1.05rem;
    border-top: 1px solid rgba(165, 148, 214, 0.14);
}
.atlas-install-footer img {
    height: 18px;
    width: auto;
    max-width: 60%;
    opacity: 0.78;
    object-fit: contain;
    filter: drop-shadow(0 1px 12px rgba(196, 156, 224, 0.18));
    transition: opacity 180ms var(--atlas-pwa-ease);
}
.atlas-install-footer img:hover { opacity: 1; }

/* ============================================================================
   10. RESPONSIVE: BOTTOM SHEET ON PHONES
   ============================================================================ */
@media (max-width: 560px) {
    .atlas-install {
        padding: 0;
        align-items: flex-end;
    }
    .atlas-install.is-visible .atlas-install-card {
        animation: atlas-install-slide-up 0.5s var(--atlas-pwa-ease) both;
    }
    @keyframes atlas-install-slide-up {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .atlas-install-card {
        max-width: 100%;
        padding: 1.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
        border-radius: 24px 24px 0 0;
        border-bottom: none;
        border-left: none;
        border-right: none;
    }
    .atlas-install-card::before {
        content: '';
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: rgba(196, 156, 224, 0.3);
    }
    .atlas-install-close {
        top: 1rem;
        right: 1rem;
    }
}

/* ============================================================================
   11. UPDATE-READY / INSTALLED TOAST
   ============================================================================ */
.atlas-toast {
    position: fixed;
    left: 50%;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    transform: translate(-50%, 40px);
    z-index: 350;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem 0.85rem 0.85rem;
    max-width: calc(100vw - 2rem);
    background: linear-gradient(180deg, rgba(30, 26, 74, 0.98) 0%, rgba(15, 12, 36, 0.98) 100%);
    border: 1px solid rgba(196, 156, 224, 0.22);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(10, 8, 32, 0.55);
    color: #EDE9F4;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--atlas-pwa-duration) var(--atlas-pwa-ease),
                transform var(--atlas-pwa-duration) var(--atlas-pwa-ease);
    cursor: pointer;
}
.atlas-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.atlas-toast[hidden] { display: none !important; }

.atlas-toast-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: rgba(111, 207, 151, 0.12);
    border: 1px solid rgba(111, 207, 151, 0.3);
    border-radius: 10px;
    color: #6FCF97;
}
.atlas-toast-icon svg { width: 16px; height: 16px; }

.atlas-toast-body { min-width: 0; }
.atlas-toast-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.atlas-toast-sub {
    margin-top: 0.15rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #B5A9D3;
    line-height: 1.3;
}

@media (max-width: 560px) {
    .atlas-toast {
        left: 1rem;
        right: 1rem;
        bottom: max(1rem, env(safe-area-inset-bottom));
        transform: translateY(40px);
        max-width: none;
    }
    .atlas-toast.is-visible {
        transform: translateY(0);
    }
}

/* ============================================================================
   12. REDUCED MOTION
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .atlas-install-card,
    .atlas-install.is-visible .atlas-install-card,
    .atlas-install-mark::before,
    .atlas-install-spark,
    .atlas-toast {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
