/* ==========================================
// 1. GLOBAL VARIABLES & RESET
// ========================================== */
:root {
    --bg-main: #0f1115;
    --bg-panel: rgba(20, 24, 32, 0.85);
    --bg-card: rgba(30, 35, 45, 0.9);
    --border: rgba(255, 255, 255, 0.1);
    --brand: #9b5de5;
    --text-main: #ffffff;
    --text-muted: #8892b0;
    --danger: #ff4d4d;
}

body.light-mode {
    --bg-main: #f0f2f5;
    --bg-panel: rgba(255, 255, 255, 0.9);
    --bg-card: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --text-main: #1a1a2e;
    --text-muted: #666;
}

* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg-main); color: var(--text-main); }

/* ==========================================
// 2. MAP & BASIC UI COMPONENTS
// ========================================== */
#map { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; }

button { cursor: pointer; border: none; background: none; color: inherit; outline: none; transition: 0.2s; }
.primary-btn { background: var(--brand); color: white; padding: 10px 20px; border-radius: 8px; font-weight: bold; width: 100%; }
.primary-btn:hover { filter: brightness(1.2); }
.icon-btn { font-size: 1.2em; padding: 5px; opacity: 0.7; }
.icon-btn:hover { opacity: 1; }

input, textarea { width: 100%; padding: 12px; margin-bottom: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 8px; color: var(--text-main); }

/* ==========================================
// 3. AUTHENTICATION VIEWS
// ========================================== */
#auth-views { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1000; width: 90%; max-width: 400px; }
.auth-panel { background: var(--bg-panel); backdrop-filter: blur(10px); padding: 30px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.strength-meter { height: 4px; background: rgba(255,255,255,0.1); margin-bottom: 15px; border-radius: 2px; overflow: hidden; }
#pass-strength { height: 100%; width: 0; transition: 0.3s; }

/* ==========================================
// 4. NAVIGATION RAIL (Bottom Bar on Mobile)
// ========================================== */
#dashboard-nav {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--bg-panel); backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: 30px;
    display: flex; gap: 20px; padding: 10px 30px; z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; opacity: 0.6; }
.nav-btn.active { opacity: 1; color: var(--brand); }
.nav-btn .icon { font-size: 1.5em; }
.nav-btn .label { font-size: 0.7em; font-weight: bold; }
.avatar-small { width: 28px; height: 28px; border-radius: 50%; background: #444; display: flex; align-items: center; justify-content: center; font-size: 0.8em; font-weight: bold; }

/* The "Create Post" Center Button */
.create-btn { opacity: 1 !important; transform: translateY(-15px); }
.plus-icon { width: 50px; height: 50px; background: var(--brand); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2em; color: white; box-shadow: 0 5px 15px rgba(155, 93, 229, 0.4); }

/* ==========================================
// 5. 3D FEED COLUMN & FILTERS
// ========================================== */
#feed-column {
    position: absolute; top: 0; right: -100%; width: 100%; max-width: 500px; height: 100vh;
    background: linear-gradient(to bottom, var(--bg-panel) 0%, transparent 15%, transparent 85%, var(--bg-panel) 100%);
    backdrop-filter: blur(8px); border-left: 1px solid var(--border);
    transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 50; display: flex; flex-direction: column;
}
#feed-column.open { right: 0; }
.feed-header { padding: 40px 20px 10px 20px; }
.feed-header h2 { margin: 0; font-size: 1.8em; }

#feed-filters { display: flex; gap: 10px; overflow-x: auto; padding: 10px 20px 15px 20px; flex-shrink: 0; scrollbar-width: none; }
#feed-filters::-webkit-scrollbar { display: none; }
.filter-pill { background: rgba(255,255,255,0.05); border: 1px solid var(--border); padding: 8px 16px; border-radius: 20px; white-space: nowrap; font-size: 0.9em; }
.filter-pill.active { background: var(--brand); color: white; border-color: var(--brand); }
.dev-btn { background: #ff9f1c !important; color: #000 !important; border: none !important; }

#feed-content { 
    position: relative; /* CRITICAL for JS offsetTop calculations */
    flex: 1; 
    overflow-y: auto; 
    padding: 30dvh 0; /* Padding allows first/last cards to reach the center */
    scroll-snap-type: y mandatory; 
    scrollbar-width: none; 
}
#feed-content::-webkit-scrollbar { display: none; }

/* ==========================================
// 6. SOCIAL CARDS (Focus Mode)
// ========================================== */
.card-hitbox {
    height: clamp(300px, 50dvh, 500px); 
    margin: 30px 15px;
    scroll-snap-align: center; 
    scroll-snap-stop: always;
    position: relative; /* Anchors the 3D card inside it */
}

.social-card {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    
    background: var(--bg-card); 
    border: 1px solid var(--border); 
    border-radius: 16px;
    padding: 20px; 
    display: flex; flex-direction: column;

    transform-style: preserve-3d;
    will-change: transform, opacity, filter, z-index;
}

.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-user-info { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.card-name { font-weight: bold; }
.card-meta { font-size: 0.8em; color: var(--text-muted); }

.card-body {
    flex: 1; min-height: 0; /* min-height: 0 stops flexbox from blowing out the bounds */
    margin-top: 15px; font-size: 1.05em; line-height: 1.5;
    overflow-y: auto; scrollbar-width: none;
}
.card-actions { display: flex; gap: 15px; border-top: 1px solid var(--border); padding-top: 15px; margin-top: 10px; }

/* ==========================================
// 7. DASHBOARD PANELS
// ========================================== */
#left-panel, #content-area {
    position: absolute; top: 0; height: 100vh;
    background: var(--bg-panel); backdrop-filter: blur(15px); border-right: 1px solid var(--border);
    transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); z-index: 90;
}
#left-panel { left: -300px; width: 300px; display: flex; flex-direction: column; }
#left-panel.open { left: 0; }
#content-area { left: -100%; width: 100%; z-index: 80; padding: 20px; overflow-y: auto; }
#left-panel.wide + #content-area { left: 300px; width: calc(100% - 300px); }

/* ==========================================
// 8. MODALS & OVERLAYS
// ========================================== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    width: 90%; max-width: 500px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; gap: 15px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.modal-header h3 { margin: 0; }
#post-text { background: rgba(255,255,255,0.05); border: 1px solid var(--border); font-size: 1.1em; resize: none; }
#post-text:focus { border-color: var(--brand); }
.modal-actions { display: flex; gap: 10px; align-items: center; }

/* ==========================================
// 9. MEDIA UPLOADS & IMAGES
// ========================================== */

/* The preview inside the Create Post Modal */
#media-preview-container {
    width: 100%;
    max-height: 200px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
#media-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Prevents stretching */
    display: block;
}
.remove-media-btn {
    position: absolute;
    top: 5px; right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
}

/* How the image looks on the actual 3D Feed Card */
.card-media {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid var(--border);
}