/* ════════════════════════════════════════════════════════════════════
   HOME PAGE — Phase 1 Visual Foundation
   ─────────────────────────────────────────
   Desktop (≥1024px): 3-column layout (sidebar + feed + right panel)
   Mobile (<1024px): Single-column (unchanged)

   IMPORTANT: This is ADDITIVE — only affects body.home-page.
   Does NOT modify header.php, footer.php, or other pages.
   ════════════════════════════════════════════════════════════════════ */

/* Safety: prevent horizontal scroll on home page at all viewports */
body.home-page {
    overflow-x: hidden;
}

/* ─── Greeting ─────────────────────────────────────────────────── */
.home-greeting {
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}
.home-greeting h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 0.25rem;
    color: var(--foreground);
    letter-spacing: -0.02em;
}
.home-greeting p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0;
}

/* ─── Weather Banner (large gradient) ──────────────────────────── */
.weather-banner {
    background: linear-gradient(135deg, #fb923c 0%, #ef4444 100%);
    border-radius: 1.25rem;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    color: white;
    position: relative;
    overflow: hidden;
}
.weather-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}
.weather-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}
.weather-banner-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}
.weather-banner-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}
.weather-banner-left h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: white;
}
.weather-banner-left p {
    font-size: 0.75rem;
    margin: 0.125rem 0 0;
    color: rgba(255,255,255,0.9);
}
.weather-banner-temp {
    text-align: right;
}
.weather-banner-degrees {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    color: white;
}
.weather-banner-feels {
    display: block;
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.8);
    margin-top: 0.25rem;
}
.weather-banner-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: white;
    color: #ef4444;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    z-index: 1;
}
.weather-banner-cta:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ─── Stories (improved with gradient ring) ────────────────────── */
.story-add-circle {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    border: 2px dashed var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--muted);
    font-size: 1.125rem;
    color: var(--muted-foreground);
}
.story-avatar-ring {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-avatar-ring.viewed {
    background: var(--muted-foreground);
    opacity: 0.6;
}
.story-avatar-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--background);
}

/* ─── Home Section Header ──────────────────────────────────────── */
.home-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}
.home-section-header h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.home-section-header a {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--brand-500);
    text-decoration: none;
}
.home-section-header a:hover {
    text-decoration: underline;
}


/* ════════════════════════════════════════════════════════════════════
   DESKTOP LAYOUT (≥ 1024px) — 3-Column CSS Grid
   ─────────────────────────────────────────
   Uses CSS Grid for proper 3-column layout:
   sidebar | feed | right-panel

   NO margin:auto centering. NO fixed positioning tricks.
   The grid places each column exactly where it belongs.
   ════════════════════════════════════════════════════════════════════ */

body.home-page .home-sidebar,
body.home-page .home-topbar,
body.home-page .home-right-panel {
    display: none; /* Hidden on mobile */
}

@media (min-width: 1024px) {
    /* Keep header + bottom nav visible on home page */
    /* (Previously hidden — now restored per Jamal's request) */

    /* Reset main-content to be the grid container */
    body.home-page .main-content {
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        display: grid;
        grid-template-columns: 260px 1fr 300px;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "sidebar topbar right"
            "sidebar feed  right";
        min-height: 100vh;
        gap: 0;
    }

    /* ─── Sidebar (grid area: sidebar) ───────────────────────── */
    .home-sidebar {
        display: flex;
        flex-direction: column;
        position: sticky;
        top: 0;
        grid-area: sidebar;
        width: 260px;
        height: 100vh;
        background: var(--card, #fff);
        border-right: 1px solid var(--border, #e4e4e7);
        padding: 1rem 0.75rem;
        z-index: 100;
        overflow-y: auto;
    }
    html.dark .home-sidebar {
        background: #0f0f14;
        border-right-color: #1e1e24;
    }

    .sidebar-logo {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0 0.75rem;
        margin-bottom: 1.5rem;
        text-decoration: none;
        color: var(--foreground);
        font-weight: 800;
        font-size: 1.125rem;
    }
    .sidebar-logo-icon {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.625rem;
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 0.9375rem;
        flex-shrink: 0;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
        flex: 1;
    }
    .sidebar-nav-item {
        display: flex;
        align-items: center;
        gap: 0.875rem;
        padding: 0.75rem 0.875rem;
        border-radius: 0.625rem;
        text-decoration: none;
        color: var(--muted-foreground);
        font-size: 0.9375rem;
        font-weight: 500;
        transition: all 0.15s;
    }
    .sidebar-nav-item:hover {
        background: var(--muted, #f4f4f5);
        color: var(--foreground);
    }
    html.dark .sidebar-nav-item:hover {
        background: rgba(255,255,255,0.06);
    }
    .sidebar-nav-item.active {
        background: rgba(99,102,241,0.1);
        color: #6366f1;
        font-weight: 600;
    }
    .sidebar-nav-item i {
        width: 1.25rem;
        text-align: center;
        font-size: 1.0625rem;
    }
    .sidebar-badge-new {
        margin-left: auto;
        padding: 0.125rem 0.5rem;
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: white;
        border-radius: 9999px;
        font-size: 0.5625rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    /* ─── Create Button + Menu ───────────────────────────────── */
    .sidebar-create-wrapper {
        position: relative;
        margin: 0.75rem 0;
    }
    .sidebar-create-btn {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: linear-gradient(135deg, #7c3aed, #f59e0b);
        color: white;
        border: none;
        border-radius: 0.75rem;
        font-size: 0.9375rem;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s;
        box-shadow: 0 4px 12px rgba(124,58,237,0.3);
        font-family: inherit;
    }
    .sidebar-create-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(124,58,237,0.4);
    }
    .sidebar-create-menu {
        position: absolute;
        bottom: calc(100% + 0.5rem);
        left: 0;
        right: 0;
        background: var(--card, #fff);
        border: 1px solid var(--border, #e4e4e7);
        border-radius: 0.75rem;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
        padding: 0.375rem;
        flex-direction: column;
        gap: 0.125rem;
        z-index: 200;
    }
    html.dark .sidebar-create-menu {
        background: #1a1a22;
        border-color: #2a2a32;
    }
    .create-menu-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.625rem 0.75rem;
        border-radius: 0.5rem;
        text-decoration: none;
        color: var(--foreground);
        font-size: 0.875rem;
        font-weight: 500;
        transition: background 0.15s;
    }
    .create-menu-item:hover {
        background: var(--muted, #f4f4f5);
    }
    html.dark .create-menu-item:hover {
        background: rgba(255,255,255,0.06);
    }
    .create-menu-item i {
        width: 1.25rem;
        text-align: center;
        color: #6366f1;
    }

    /* ─── Profile (bottom of sidebar) ────────────────────────── */
    .sidebar-profile {
        display: flex;
        align-items: center;
        gap: 0.625rem;
        padding: 0.625rem 0.75rem;
        border-radius: 0.625rem;
        text-decoration: none;
        color: var(--foreground);
        transition: background 0.15s;
    }
    .sidebar-profile:hover {
        background: var(--muted, #f4f4f5);
    }
    html.dark .sidebar-profile:hover {
        background: rgba(255,255,255,0.06);
    }
    .sidebar-profile img,
    .sidebar-profile-fallback {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
    }
    .sidebar-profile-fallback {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: white;
        font-weight: 600;
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .sidebar-profile-info {
        flex: 1;
        min-width: 0;
    }
    .sidebar-profile-name {
        font-size: 0.8125rem;
        font-weight: 600;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sidebar-profile-link {
        font-size: 0.6875rem;
        color: var(--muted-foreground);
        margin: 0;
    }

    .sidebar-auth-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0 0.75rem;
    }
    .sidebar-login-btn {
        display: block;
        text-align: center;
        padding: 0.625rem;
        background: var(--muted);
        border-radius: 0.625rem;
        color: var(--foreground);
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
    }
    .sidebar-signup-btn {
        display: block;
        text-align: center;
        padding: 0.625rem;
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        border-radius: 0.625rem;
        color: white;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
    }

    /* ─── Top Bar (grid area: topbar) ────────────────────────── */
    .home-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1.5rem;
        background: var(--card, #fff);
        border-bottom: 1px solid var(--border, #e4e4e7);
        grid-area: topbar;
        position: sticky;
        top: 0;
        z-index: 90;
    }
    html.dark .home-topbar {
        background: rgba(15,15,20,0.8);
        backdrop-filter: blur(12px);
        border-bottom-color: #1e1e24;
    }
    .topbar-search {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 1;
        max-width: 20rem;
        padding: 0.5rem 1rem;
        background: var(--muted, #f4f4f5);
        border-radius: 9999px;
    }
    .topbar-search i {
        color: var(--muted-foreground);
        font-size: 0.875rem;
    }
    .topbar-search input {
        flex: 1;
        background: transparent;
        border: none;
        outline: none;
        color: var(--foreground);
        font-size: 0.875rem;
        font-family: inherit;
        min-width: 0;
    }
    .topbar-search input::placeholder {
        color: var(--muted-foreground);
    }
    .topbar-actions {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        flex-shrink: 0;
    }
    .topbar-icon-btn {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 50%;
        border: none;
        background: transparent;
        color: var(--muted-foreground);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.0625rem;
        transition: all 0.15s;
        position: relative;
        flex-shrink: 0;
    }
    .topbar-icon-btn:hover {
        background: var(--muted, #f4f4f5);
        color: var(--foreground);
    }
    html.dark .topbar-icon-btn:hover {
        background: rgba(255,255,255,0.06);
    }
    .topbar-badge {
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
        background: #ef4444;
        color: white;
        font-size: 0.5625rem;
        font-weight: 700;
        min-width: 1rem;
        height: 1rem;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 0.25rem;
    }
    .topbar-avatar-btn {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 50%;
        border: 2px solid var(--border, #e4e4e7);
        overflow: hidden;
        cursor: pointer;
        padding: 0;
        background: none;
        flex-shrink: 0;
    }
    .topbar-avatar-btn img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    .topbar-avatar-fallback {
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
    }
    .topbar-login-btn {
        padding: 0.5rem 1.25rem;
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: white;
        border-radius: 9999px;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        flex-shrink: 0;
    }

    /* ─── Main Feed (grid area: feed) ────────────────────────── */
    /* NO margin-left/right. NO margin:auto. Grid places it. */
    /* Padding-top clears the fixed header (~56px). */
    /* Padding-bottom clears the fixed bottom-nav (~60px). */
    .home-feed-wrapper {
        grid-area: feed;
        padding: calc(56px + 1.5rem) 1.5rem calc(60px + 1.5rem);
        max-width: 100%;
        min-width: 0; /* critical for grid — allows shrinking */
        overflow-x: hidden;
    }

    /* ─── Right Panel (grid area: right) ─────────────────────── */
    .home-right-panel {
        display: flex;
        flex-direction: column;
        grid-area: right;
        width: 300px;
        height: 100vh;
        position: sticky;
        top: 0;
        padding: 1.5rem 1rem;
        z-index: 50;
        overflow-y: auto;
        border-left: 1px solid var(--border, #e4e4e7);
    }
    html.dark .home-right-panel {
        border-left-color: #1e1e24;
    }
    .right-panel-placeholder {
        text-align: center;
        padding: 2rem;
        margin: auto;
    }

    /* ─── S1.2: Suggested Users widget ─────────────────────── */
    .suggested-users-widget {
        padding: 1rem;
    }
    .suggested-users-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 0.75rem;
    }
    .suggested-users-header h3 {
        font-size: 0.875rem;
        font-weight: 700;
        margin: 0;
        color: var(--foreground);
        display: flex;
        align-items: center;
        gap: 0.375rem;
    }
    .suggested-users-header h3 i {
        color: #7c3aed;
        font-size: 0.8125rem;
    }
    .suggested-users-see-all {
        font-size: 0.7rem;
        font-weight: 600;
        color: #7c3aed;
        text-decoration: none;
    }
    .suggested-users-see-all:hover {
        text-decoration: underline;
    }
    .suggested-users-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .suggested-user-card {
        display: flex;
        align-items: center;
        gap: 0.625rem;
        padding: 0.5rem;
        border-radius: 0.625rem;
        transition: background 0.15s;
    }
    .suggested-user-card:hover {
        background: var(--muted);
    }
    .suggested-user-avatar-link {
        flex-shrink: 0;
        text-decoration: none;
    }
    .suggested-user-avatar {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 50%;
        object-fit: cover;
        display: block;
    }
    .suggested-user-avatar-fallback {
        background: linear-gradient(135deg, #7c3aed, #ec4899);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 0.9375rem;
    }
    .suggested-user-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
    }
    .suggested-user-name {
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--foreground);
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    .suggested-user-name:hover {
        color: #7c3aed;
    }
    .suggested-user-meta {
        font-size: 0.6875rem;
        color: var(--muted-foreground);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .suggested-user-type {
        font-weight: 500;
    }
    .suggested-user-followers {
        opacity: 0.8;
    }
    .suggested-user-follow-btn {
        flex-shrink: 0;
        padding: 0.375rem 0.75rem;
        border: none;
        border-radius: 999px;
        background: linear-gradient(135deg, #7c3aed, #6d28d9);
        color: #fff;
        font-size: 0.7rem;
        font-weight: 600;
        cursor: pointer;
        font-family: inherit;
        transition: all 0.15s;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }
    .suggested-user-follow-btn:hover {
        box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
        transform: translateY(-1px);
    }
    .suggested-user-follow-btn.following {
        background: var(--muted);
        color: var(--foreground);
        border: 1px solid var(--border);
    }
    .suggested-user-follow-btn.following:hover {
        background: #ef4444;
        color: #fff;
        border-color: #ef4444;
    }
    .suggested-user-follow-btn.loading {
        opacity: 0.6;
        pointer-events: none;
    }

    /* ─── Desktop typography upgrades ────────────────────────── */
    .home-greeting h1 { font-size: 1.5rem; }
    .home-greeting p { font-size: 0.875rem; }
    .weather-banner { padding: 1.5rem; }
    .weather-banner-left h3 { font-size: 1.125rem; }
    .weather-banner-degrees { font-size: 2.5rem; }
}

/* ─── Larger desktops (≥ 1280px) ───────────────────────────────── */
@media (min-width: 1280px) {
    body.home-page .main-content {
        grid-template-columns: 260px 1fr 300px;
    }
    .home-feed-wrapper {
        padding: calc(56px + 2rem) 2rem calc(60px + 2rem);
        max-width: 640px;
        margin: 0 auto; /* center within the feed grid cell */
    }
    .home-greeting h1 { font-size: 1.75rem; }
    .home-greeting p { font-size: 0.9375rem; }
    .weather-banner { padding: 1.75rem; }
    .weather-banner-left h3 { font-size: 1.25rem; }
    .weather-banner-degrees { font-size: 3rem; }
}

/* ─── Extra large desktops (≥ 1440px) ──────────────────────────── */
@media (min-width: 1440px) {
    body.home-page .main-content {
        grid-template-columns: 280px 1fr 320px;
    }
    .home-sidebar {
        width: 280px;
    }
    .home-right-panel {
        width: 320px;
    }
    .home-feed-wrapper {
        max-width: 700px;
    }
}

/* ─── Full HD desktops (≥ 1920px) ──────────────────────────────── */
@media (min-width: 1920px) {
    .home-feed-wrapper {
        max-width: 800px;
    }
}

/* ─── Mobile: hide desktop-only elements (safety) ──────────────── */
@media (max-width: 1023px) {
    body.home-page .home-sidebar,
    body.home-page .home-topbar,
    body.home-page .home-right-panel {
        display: none !important;
    }
    .home-feed-wrapper {
        margin: 0 !important;
        /* Keep horizontal padding at 0 (let inner content set its own),
           but add top/bottom padding to clear the fixed header + bottom-nav.
           Matches the values used by .main-content on mobile. */
        padding: 56px 0 80px !important;
        max-width: 100% !important;
    }
}

/* ════════════════════════════════════════════════════════════════════
   LAZY VIDEO PREVIEWS (when no thumbnail_url exists)
   ─────────────────────────────────────────
   Videos load with preload="none" — NO data downloaded on page load.
   JavaScript (Intersection Observer) loads the video ONLY when the
   user scrolls near it. This shows real video frame previews without
   downloading all videos at once.
   ════════════════════════════════════════════════════════════════════ */
.short-lazy-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #1a1a2e; /* Dark background before video loads */
}

/* Larger variant for feed post cards */
.short-lazy-video-lg {
    max-height: 500px;
}

/* ════════════════════════════════════════════════════════════════════
   FEED TABS (For You / Following / Nearby)
   ════════════════════════════════════════════════════════════════════ */
.feed-tabs {
    display: flex;
    gap: 0.375rem;
    padding: 0 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border, #e4e4e7);
    overflow-x: auto;
    scrollbar-width: none;
}
.feed-tabs::-webkit-scrollbar { display: none; }

.feed-tab {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted-foreground, #71717a);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    margin-bottom: -1px;
}
.feed-tab:hover {
    color: var(--foreground, #18181b);
    background: var(--muted, #f4f4f5);
    border-radius: 0.5rem 0.5rem 0 0;
}
.feed-tab.active {
    color: #6366f1;
    border-bottom-color: #6366f1;
}
.feed-tab i {
    font-size: 0.875rem;
}

/* ════════════════════════════════════════════════════════════════════
   POST LISTING CARDS — listing cards that appear inside feed posts
   (Restored from old index.php inline styles — class refactor forgot CSS)
   ════════════════════════════════════════════════════════════════════ */
