/* ==========================================================================
   community.css - SketchX Community Page Specific Styles
   Material 3 Expressive Unified Design System
   ========================================================================== */

:root {
    --max-w: 1180px;
    --header-h: 68px;
    --font-heading: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'Roboto Mono', 'JetBrains Mono', monospace;

    --toolbar-bg-rgb: 248, 249, 255;
    --hero-glow: 0, 99, 153;
}

[data-theme="dark"] {
    --toolbar-bg-rgb: 16, 20, 24;
    --hero-glow: 142, 205, 255;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --toolbar-bg-rgb: 16, 20, 24;
        --hero-glow: 142, 205, 255;
    }
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--md-sys-color-background, var(--md-sys-color-surface));
    color: var(--md-sys-color-on-background, var(--md-sys-color-on-surface));
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
}

.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--shape-full, 9999px);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--elevation-1);
}

.btn-primary:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    transform: translateY(-2px);
    box-shadow: var(--elevation-2);
}

.btn-outlined {
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.btn-outlined:hover {
    background-color: var(--md-sys-color-surface-container-high);
    border-color: var(--md-sys-color-primary);
    transform: translateY(-2px);
}

.m3-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--shape-full, 9999px);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.m3-badge.secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.m3-badge.tertiary {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.m3-badge.success {
    background-color: var(--md-sys-color-success-container, #0a4d2c);
    color: var(--md-sys-color-on-success-container, #b3f4cf);
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
.site-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-h);
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    z-index: 1000;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    flex-shrink: 0;
    color: var(--md-sys-color-on-surface);
}

.nav-logo-img {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    object-fit: cover;
    border-radius: var(--shape-medium, 12px);
    display: block;
}

.nav-menu-list {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link-active {
    color: var(--md-sys-color-primary);
}

.nav-actions-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-cta-btn {
    padding: 9px 18px;
    font-size: 0.86rem;
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--shape-full, 9999px);
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.mobile-menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: var(--shape-full, 9999px);
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.mobile-drawer {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding: 20px 24px;
    z-index: 999;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--elevation-3);
}

/* ==========================================================================
   COMMUNITY HERO
   ========================================================================== */
.community-hero {
    padding-top: calc(var(--header-h) + 40px);
    padding-bottom: 44px;
    background: radial-gradient(circle at 50% 0%, rgba(var(--hero-glow), 0.12), transparent 70%),
                var(--md-sys-color-background);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    position: relative;
    overflow: hidden;
}

.community-hero-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 36px;
    flex-wrap: wrap;
}

.community-hero-text {
    flex: 1;
    min-width: 280px;
    max-width: 640px;
}

.community-hero-text .m3-badge {
    margin-bottom: 14px;
    display: inline-flex;
}

.community-hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4.5vw, 2.85rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface);
    line-height: 1.15;
    margin-bottom: 12px;
}

.community-hero-title span {
    background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-tertiary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.community-hero-subtitle {
    font-size: 1.05rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.6;
}

.community-hero-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.hero-stat-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--shape-large, 20px);
    padding: 16px 24px;
    min-width: 145px;
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--elevation-2);
}

.hero-stat-card .stat-number {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 900;
    color: var(--md-sys-color-primary);
    line-height: 1.2;
}

.hero-stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* ==========================================================================
   STICKY TOOLBAR
   ========================================================================== */
.community-toolbar-sticky {
    position: sticky;
    top: var(--header-h);
    z-index: 90;
    background-color: rgba(var(--toolbar-bg-rgb), 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding: 14px 0;
    transition: background-color 0.25s ease;
}

.community-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-pills-row {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 6px;
    max-width: 100%;
}

.filter-pills-row::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--shape-full, 9999px);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface-variant);
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-pill i {
    font-size: 1.05rem;
}

.filter-pill:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border-color: var(--md-sys-color-primary);
}

.filter-pill.active {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--elevation-1);
}

.search-input-box {
    position: relative;
    min-width: 240px;
    max-width: 360px;
    flex: 1;
}

.search-input-box i.ti-search {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-outline);
    font-size: 1.1rem;
    pointer-events: none;
}

.search-input-box input {
    width: 100%;
    padding: 10px 40px 10px 42px;
    border-radius: var(--shape-full, 9999px);
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input-box input:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px rgba(var(--hero-glow), 0.2);
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.15s ease;
}

.search-clear-btn:hover {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* ==========================================================================
   POSTS SECTION
   ========================================================================== */
.community-posts-section {
    padding: 32px 0 68px;
}

.active-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 600;
}

.posts-count-badge {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 4px 14px;
    border-radius: var(--shape-full, 9999px);
    font-size: 0.8rem;
    font-weight: 700;
}

/* ==========================================================================
   POSTS GRID
   ========================================================================== */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 22px;
}

/* ==========================================================================
   POST CARD
   ========================================================================== */
.community-post-card {
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--shape-large, 20px);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1),
                border-color 0.25s cubic-bezier(0.2, 0, 0, 1),
                box-shadow 0.25s cubic-bezier(0.2, 0, 0, 1),
                background-color 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.community-post-card:hover {
    transform: translateY(-4px);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--elevation-3);
    background-color: var(--md-sys-color-surface-container-high);
}

.community-post-card:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.post-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.post-author-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.post-avatar-initial {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.community-post-card:hover .post-avatar-initial {
    transform: scale(1.05);
}

.post-avatar-initial.avatar-0 {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.post-avatar-initial.avatar-1 {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.post-avatar-initial.avatar-2 {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.post-author-meta {
    min-width: 0;
}

.post-author-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-date-tag {
    font-size: 0.76rem;
    color: var(--md-sys-color-outline);
}

.post-card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.post-badge {
    font-size: 0.7rem !important;
    padding: 3px 9px !important;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--shape-full, 9999px);
}

.post-card-title {
    font-family: var(--font-heading);
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

.post-code-snippet {
    background-color: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--shape-small, 10px);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--md-sys-color-primary);
    max-height: 92px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    position: relative;
    mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
}

.post-code-snippet code {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.post-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}

.post-metrics-group {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 700;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.84rem;
    color: var(--md-sys-color-on-surface-variant);
}

.metric-item.metric-likes i {
    color: var(--md-sys-color-error);
    font-size: 1rem;
}

.metric-item.metric-comments i {
    font-size: 1rem;
}

.post-view-btn {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.2s ease;
}

.community-post-card:hover .post-view-btn {
    gap: 8px;
}

.post-view-btn i {
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.community-post-card:hover .post-view-btn i {
    transform: translateX(3px);
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.posts-empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--shape-extra-large, 28px);
    border: 1px dashed var(--md-sys-color-outline-variant);
    max-width: 600px;
    margin: 20px auto;
}

.empty-icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--md-sys-color-surface-container-high);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--md-sys-color-outline);
}

.posts-empty-state h3 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--md-sys-color-on-surface);
}

.posts-empty-state p {
    font-size: 0.92rem;
    color: var(--md-sys-color-on-surface-variant);
    max-width: 400px;
    line-height: 1.5;
}

.btn-reset-filters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--shape-full, 9999px);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.btn-reset-filters i {
    font-size: 1.15rem;
}

.btn-reset-filters:hover {
    background-color: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
    transform: translateY(-2px);
    box-shadow: var(--elevation-1);
}

/* ==========================================================================
   LOAD MORE
   ========================================================================== */
.load-more-wrap {
    text-align: center;
    margin-top: 36px;
}

/* ==========================================================================
   SKELETON SHIMMER
   ========================================================================== */
.post-skeleton-card {
    background: linear-gradient(90deg, 
        var(--md-sys-color-surface-container) 0%, 
        var(--md-sys-color-surface-container-high) 50%, 
        var(--md-sys-color-surface-container) 100%);
    background-size: 200% 100%;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--shape-large, 20px);
    height: 240px;
    animation: skeletonShimmer 1.8s infinite ease-in-out;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
    background-color: var(--md-sys-color-surface-container-lowest);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    padding: 56px 0 28px;
    margin-top: 40px;
}

.footer-grid-wrap {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 36px;
    margin-bottom: 36px;
}

.footer-brand-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.footer-brand-desc {
    font-size: 0.86rem;
    color: var(--md-sys-color-on-surface-variant);
    max-width: 300px;
    line-height: 1.6;
}

.footer-col-title {
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 14px;
}

.footer-links-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-link-anchor {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.2s ease;
}

.footer-link-anchor:hover {
    color: var(--md-sys-color-primary);
}

.footer-bottom-bar {
    padding-top: 24px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--md-sys-color-outline);
    flex-wrap: wrap;
    gap: 12px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .nav-menu-list {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-cta-btn {
        display: none;
    }

    .community-hero {
        padding-top: calc(var(--header-h) + 24px);
        padding-bottom: 28px;
    }

    .community-hero-inner {
        flex-direction: column;
        gap: 24px;
    }

    .community-hero-stats {
        width: 100%;
        justify-content: flex-start;
    }

    .hero-stat-card {
        flex: 1;
    }

    .community-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-pills-row {
        overflow-x: auto;
        padding-bottom: 4px;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-pills-row::-webkit-scrollbar {
        display: none;
    }

    .search-input-box {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .footer-grid-wrap {
        grid-template-columns: 1fr 1fr;
        gap: 28px;
    }

    .footer-bottom-bar {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 500px) {
    .container {
        padding: 0 16px;
    }

    .footer-grid-wrap {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .community-hero-stats {
        flex-direction: column;
    }

    .hero-stat-card {
        width: 100%;
    }
}
