/* ─── Design Tokens ─────────────────────────────── */
:root {
    --bg-color: #050505;
    --accent-color: #ffffff;
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.45);
    --glass: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.1);
    --header-h: 68px;
    --nav-h: 64px;
    /* iOS spring curves */
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
}

/* ─── Reset ─────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #000;
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ─── App Shell ─────────────────────────────────── */
#app-shell {
    width: 100%;
    max-width: 440px;
    height: 100%;
    position: relative;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
}

/* ─── Header ────────────────────────────────────── */
#app-header {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    left: 14px;
    right: 14px;
    height: var(--header-h);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(12, 12, 12, 0.96);
    z-index: 1000;
    border: 1px solid var(--glass-border);
    border-radius: 26px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    /* Smooth fade-in on load */
    transition: opacity 0.35s ease, transform 0.35s var(--spring-soft);
    will-change: transform, opacity;
    /* GPU layer */
    transform: translateZ(0);
}

.header-logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    /* Spring press */
    transition: transform 0.25s var(--spring);
    -webkit-user-select: none; user-select: none;
}

.header-logo-link:active {
    transform: scale(0.93);
}

#app-header h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(160deg, #fff 40%, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: lowercase;
}

/* ─── Header Action Buttons ─────────────────────── */
.header-actions {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.75);
    /* iOS spring press */
    transition: transform 0.2s var(--spring), background 0.15s ease;
    -webkit-user-select: none; user-select: none;
    position: relative;
    overflow: hidden;
}

.header-actions:active {
    transform: scale(0.82);
    background: rgba(255, 255, 255, 0.12);
}

/* Ripple on header actions */
.header-actions::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at center, rgba(255,255,255,0.18) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.header-actions:active::after {
    opacity: 1;
    transform: scale(1.2);
    transition: opacity 0s, transform 0s;
}

/* ─── Content Frame ─────────────────────────────── */
#content-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background-color: transparent;
    z-index: 1;
    /* Page transition: driven by JS adding classes */
    transition: transform 0.32s var(--ease-out-quart),
                opacity 0.25s ease;
    transform: translateX(0);
    opacity: 1;
    will-change: transform, opacity;
    transform: translateZ(0);
}

#app-shell.auth-mode #content-frame {
    z-index: 99999;
    background-color: #050505;
}

/* ─── Page Transition Classes (set by JS) ───────── */
.frame-slide-out-left {
    transform: translateX(-28%) !important;
    opacity: 0 !important;
    pointer-events: none;
}
.frame-slide-out-right {
    transform: translateX(28%) !important;
    opacity: 0 !important;
    pointer-events: none;
}
.frame-slide-in-right {
    transform: translateX(30%) !important;
    opacity: 0 !important;
}
.frame-slide-in-left {
    transform: translateX(-30%) !important;
    opacity: 0 !important;
}

/* ─── Bottom Navigation ─────────────────────────── */
#bottom-nav {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    height: var(--nav-h);
    background: rgba(16, 16, 16, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    z-index: 1000;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.7),
                inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    will-change: transform;
    /* iOS slide-in on load */
    transform: translateX(-50%) translateY(0);
    transition: transform 0.5s var(--spring);
}

/* ─── Nav Items ─────────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    height: 48px;
    width: 64px;
    border-radius: 18px;
    /* iOS spring press */
    transition: color 0.22s ease, background 0.22s ease, transform 0.18s var(--spring);
    -webkit-user-select: none; user-select: none;
    flex-shrink: 0;
}

/* Pill background for active state – positioned behind icon */
.nav-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.09);
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.22s ease, transform 0.3s var(--spring);
}

.nav-item.active::before {
    opacity: 1;
    transform: scale(1);
}

/* Press scale */
.nav-item:active {
    transform: scale(0.8);
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item i {
    width: 23px;
    height: 23px;
    stroke-width: 2px;
    position: relative;
    transition: transform 0.28s var(--spring), color 0.22s ease;
    pointer-events: none;
}

/* Active icon bounce up slightly */
.nav-item.active i {
    transform: translateY(-1px) scale(1.08);
}

/* ─── Global Search Modal ───────────────────────── */
#search-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding: calc(20px + env(safe-area-inset-top)) 18px 18px;
    /* Slide down from top like iOS */
    animation: searchSlideIn 0.38s var(--spring-soft) both;
}

@keyframes searchSlideIn {
    from { opacity: 0; transform: translateY(-18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.search-input-wrapper {
    flex: 1;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 13px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.search-input-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.22);
}

.search-input-wrapper input {
    background: none;
    border: none;
    color: #fff;
    width: 100%;
    outline: none;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
}

.close-search {
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    padding: 6px 2px;
    transition: opacity 0.15s ease;
}
.close-search:active { opacity: 0.5; }

#search-results-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
}

.user-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    margin-bottom: 10px;
    border: 1px solid var(--glass-border);
    /* Stagger entrance handled by JS */
    animation: itemFadeUp 0.3s var(--spring-soft) both;
    transition: background 0.15s ease;
}
.user-result-item:active { background: rgba(255,255,255,0.09); }

@keyframes itemFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-result-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-result-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--glass-border);
}

.add-friend-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 9px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: transform 0.18s var(--spring), background 0.15s ease;
}
.add-friend-btn:active { transform: scale(0.88); background: #ddd; }

/* ─── PWA Install Popup ─────────────────────────── */
#pwa-install-popup {
    position: fixed;
    bottom: calc(100px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(200%);
    width: 90%;
    max-width: 400px;
    background: rgba(20, 20, 20, 0.96);
    border: 1px solid var(--glass-border);
    border-radius: 26px;
    padding: 22px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    transition: transform 0.6s var(--spring);
}

#pwa-install-popup.show {
    transform: translateX(-50%) translateY(0);
}

.pwa-header { display: flex; align-items: center; gap: 16px; }

.pwa-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: linear-gradient(135deg, #333, #111);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

.pwa-info h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 2px; }
.pwa-info p { font-size: 0.85rem; color: var(--text-muted); }
.pwa-actions { display: flex; gap: 10px; }

.btn-pwa-install {
    flex: 2;
    background: #fff;
    color: #000;
    border: none;
    padding: 13px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: transform 0.18s var(--spring), background 0.15s ease;
}
.btn-pwa-install:active { transform: scale(0.94); background: #e8e8e8; }

.btn-pwa-close {
    flex: 1;
    background: var(--glass);
    color: #fff;
    border: 1px solid var(--glass-border);
    padding: 13px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: transform 0.18s var(--spring), background 0.15s ease;
}
.btn-pwa-close:active { transform: scale(0.94); background: rgba(255,255,255,0.12); }

/* ─── iOS Instructions Modal ────────────────────── */
#ios-pwa-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ios-pwa-card {
    background: #1c1c1e;
    width: 100%;
    max-width: 320px;
    border-radius: 22px;
    padding: 28px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: sheetSlideUp 0.42s var(--spring) both;
}

@keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ios-pwa-card h3 { margin-bottom: 20px; font-size: 1.1rem; font-weight: 700; }

.ios-step {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    margin-bottom: 18px;
    font-size: 14px;
}

.ios-icon-box {
    width: 36px;
    height: 36px;
    background: #2c2c2e;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ─── Notification Badge ────────────────────────── */
@keyframes badgePop {
    0%  { transform: scale(0.3); opacity: 0; }
    70% { transform: scale(1.25); opacity: 1; }
    100%{ transform: scale(1);   opacity: 1; }
}

.noti-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: #ff3b30;
    color: white;
    font-size: 9px;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50px;
    animation: badgePop 0.4s var(--spring) both;
    z-index: 2;
    border: 1.5px solid #050505;
}

/* ─── Notification Modal (iOS sheet style) ──────── */
.noti-modal {
    position: fixed;
    top: calc(var(--header-h) + 24px + env(safe-area-inset-top));
    right: 14px;
    width: 298px;
    max-height: 370px;
    background: rgba(20, 20, 20, 0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6),
                inset 0 1px 0 rgba(255,255,255,0.06);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Spring toggle */
    transition: opacity 0.22s ease,
                transform 0.28s var(--spring),
                visibility 0.22s ease;
    will-change: opacity, transform;
    transform-origin: top right;
    visibility: visible;
}

.noti-modal.hidden {
    opacity: 0;
    transform: scale(0.88) translateY(-8px);
    pointer-events: none;
    visibility: hidden;
}

.noti-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.noti-list {
    overflow-y: auto;
    padding: 8px;
    /* Momentum scroll */
    -webkit-overflow-scrolling: touch;
}

.noti-item {
    display: flex;
    gap: 11px;
    padding: 10px;
    border-radius: 12px;
    align-items: center;
    margin-bottom: 5px;
    transition: background 0.15s ease;
    animation: itemFadeUp 0.28s var(--spring-soft) both;
}
.noti-item:active { background: rgba(255,255,255,0.06); }
.noti-item.unread { background: rgba(255, 59, 48, 0.12); }
.noti-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.noti-content { font-size: 13px; line-height: 1.4; color: #ccc; }

/* ─── Share / Add-Friend Modals ─────────────────── */
/* These are inline-styled in HTML, but we add spring animation */
#share-modal > div,
#add-friend-modal > div {
    animation: sheetSlideUp 0.4s var(--spring) both;
}

/* ─── Toast ─────────────────────────────────────── */
.snap-toast {
    background: rgba(30, 30, 32, 0.96);
    color: #fff;
    padding: 11px 20px;
    border-radius: 100px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    animation: toastIn 0.4s var(--spring) both;
    transition: opacity 0.25s ease, transform 0.25s ease;
    will-change: opacity, transform;
}
.snap-toast.toast-success { border-color: rgba(48,209,88,0.4); }
.snap-toast.toast-error   { border-color: rgba(255,59,48,0.4); }

.snap-toast .toast-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.snap-toast.toast-success .toast-dot { background: #30d158; }
.snap-toast.toast-error   .toast-dot { background: #ff3b30; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-14px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
