/* ================================================
   FlavorQuest — PWA Install Banner & CSS
   ================================================
   iOS Bottom Sheet + Android FAB + Kitchen Button
   ================================================ */

/* ─── Shared: Hide everything when already installed ─── */
@media (display-mode: standalone) {
    .pwa-install-fab,
    .pwa-ios-sheet,
    .pwa-ios-backdrop,
    #kitchen-install-btn-wrap {
        display: none !important;
    }
}

/* ─── iOS Bottom Sheet ─── */
.pwa-ios-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.pwa-ios-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.pwa-ios-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: rgba(28, 25, 23, 0.97);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(217, 119, 6, 0.25);
    border-radius: 24px 24px 0 0;
    padding: 28px 24px calc(28px + env(safe-area-inset-bottom, 0px));
    max-width: 480px;
    margin: 0 auto;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
}

.pwa-ios-sheet.active {
    transform: translateY(0);
}

/* ── Sheet drag handle ── */
.pwa-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto 20px;
}

/* ── Sheet header ── */
.pwa-sheet-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.pwa-sheet-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pwa-sheet-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.pwa-sheet-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}

/* ── Steps ── */
.pwa-step {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pwa-step:last-child {
    border-bottom: none;
}

.pwa-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #D97706, #F59E0B);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.pwa-step-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
}

.pwa-step-text strong {
    color: #F59E0B;
    font-weight: 700;
}

.pwa-step-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-step-icon svg {
    width: 22px;
    height: 22px;
    fill: #D97706;
}

/* ── Dismiss button ── */
.pwa-dismiss-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #D97706, #B45309);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.3);
}

.pwa-dismiss-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
}

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

/* ── Close X button ── */
.pwa-sheet-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    font-size: 18px;
    transition: all 0.2s ease;
}

.pwa-sheet-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ─── Android Install FAB ─── */
.pwa-install-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    background: linear-gradient(135deg, #D97706, #B45309);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(217, 119, 6, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    animation: pwa-fab-entrance 0.5s cubic-bezier(0.32, 0.72, 0, 1) both;
}

.pwa-install-fab:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 40px rgba(217, 119, 6, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pwa-install-fab:active {
    transform: scale(0.97);
}

.pwa-install-fab .material-symbols-outlined {
    font-size: 22px;
}

/* ── FAB pulse ring ── */
.pwa-install-fab::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    border: 2px solid rgba(217, 119, 6, 0.4);
    animation: pwa-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pwa-fab-entrance {
    from {
        transform: translateY(100px) scale(0.5);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes pwa-pulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* ─── Kitchen Install Button ─── */
#kitchen-install-btn-wrap {
    display: none; /* shown by JS when eligible */
}

#kitchen-install-btn-wrap.visible {
    display: block;
}

.kitchen-install-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: 1px solid rgba(217, 119, 6, 0.25);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.08), rgba(217, 119, 6, 0.03));
    color: #D97706;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kitchen-install-btn:hover {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.15), rgba(217, 119, 6, 0.05));
    border-color: rgba(217, 119, 6, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(217, 119, 6, 0.15);
}

.kitchen-install-btn:active {
    transform: scale(0.98);
}

.kitchen-install-btn .material-symbols-outlined {
    font-size: 22px;
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
    .pwa-ios-sheet,
    .pwa-ios-backdrop,
    .pwa-install-fab {
        transition: none;
        animation: none;
    }
    .pwa-install-fab::after {
        animation: none;
    }
}

/* ─── Desktop: hide FAB (desktop doesn't need it) ─── */
@media (min-width: 1024px) {
    .pwa-install-fab {
        display: none !important;
    }
}

/* ─── RTL support ─── */
[dir="rtl"] .pwa-ios-sheet {
    direction: rtl;
}

[dir="rtl"] .pwa-sheet-close {
    right: auto;
    left: 16px;
}

[dir="rtl"] .pwa-install-fab {
    right: auto;
    left: 24px;
}
