/* Global Styles */
:root {
    --primary-color: #e60023;
    /* Pinterest Red */
    --hover-bg: #e9e9e9;
    --text-color: #111;
    --gray-text: #767676;
    --bg-color: #ffffff;
}

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    display: flex;
}

/* Fixed Left Sidebar */
.sidebar {
    width: 240px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    z-index: 1000;
    border-right: 1px solid #ddd;
}

.sidebar-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sidebar-icon:hover {
    background-color: var(--hover-bg);
}

.sidebar-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--text-color);
}

.logo-icon {
    margin-bottom: 30px;
    width: 50px;
    height: 50px;
    border-radius: 0;
    /* Let the logo image define shape */
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Main Content Area */
.main-content {
    margin-left: 240px;
    width: calc(100% - 240px);
}

/* Sticky Header */
.top-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.search-bar {
    flex: 1;
    margin: 0 20px;
    background: #e9e9e9;
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
}

.search-bar svg {
    fill: var(--gray-text);
    margin-right: 10px;
}

.search-bar input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 16px;
    outline: none;
    color: var(--text-color);
}

.header-profile {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Sub Navigation */
.sub-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 0 20px 0;
    background: white;
}

.nav-pill {
    padding: 10px 16px;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.nav-pill.active {
    background-color: #111;
    color: white;
}

.nav-pill:not(.active):hover {
    background-color: var(--hover-bg);
}

/* Masonry Grid */
.masonry-grid {
    column-count: 5;
    column-gap: 16px;
    padding: 0 30px 30px 30px;
    margin: 0 auto;
    max-width: 1800px;
}

.card {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: 16px;
    position: relative;
    /* Context for absolute positioning of overlay */
    cursor: zoom-in;
    background-color: white;
    overflow: hidden;
    /* Ensure image and overlay comply with border radius */
    will-change: transform;
}

/* Provide diverse heights even without images initially, or with varying aspect ratios */
.card img {
    width: 100%;
    height: auto;
    display: block;
    /* border-radius is handled by .card overflow: hidden */
}

/* Hover Overlay */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    box-sizing: border-box;
    pointer-events: none;
}

.card:hover .card-overlay {
    opacity: 1;
    pointer-events: auto;
}

.join-btn {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 24px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s;
}

.join-btn:hover {
    background-color: #ad081b;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    pointer-events: auto;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background: white;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: #111;
}

.card-title {
    padding: 8px 5px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #111;
    line-height: 1.3;
}

/* Responsive Breakpoints */
@media (max-width: 1600px) {
    .masonry-grid {
        column-count: 4;
    }
}

@media (max-width: 1100px) {
    .masonry-grid {
        column-count: 3;
    }
}

@media (max-width: 800px) {
    .masonry-grid {
        column-count: 2;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .masonry-grid {
        column-count: 2;
        padding: 10px;
        column-gap: 10px;
    }
}