/* ===========================================
   Vibe In Pocket - Component Styles
   Post cards, votes, and interactive elements
   =========================================== */

/* ============ Post Card ============ */
.post-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    animation: post-enter 0.4s ease-out;
    animation-fill-mode: both;
}

.post-card {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.post-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.post-card:active,
.post-card.post-card-pressed {
    transform: translateY(1px) scale(0.97);
    border-color: var(--accent-primary, #8b5cf6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35), var(--shadow-sm);
    filter: brightness(1.12);
    transition-duration: 0.06s;
}

@keyframes post-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation delays for posts */
.post-card:nth-child(1) { animation-delay: 0ms; }
.post-card:nth-child(2) { animation-delay: 50ms; }
.post-card:nth-child(3) { animation-delay: 100ms; }
.post-card:nth-child(4) { animation-delay: 150ms; }
.post-card:nth-child(5) { animation-delay: 200ms; }
.post-card:nth-child(6) { animation-delay: 250ms; }
.post-card:nth-child(7) { animation-delay: 300ms; }
.post-card:nth-child(8) { animation-delay: 350ms; }
.post-card:nth-child(9) { animation-delay: 400ms; }
.post-card:nth-child(10) { animation-delay: 450ms; }

.post-card-layout {
    display: flex;
    gap: var(--spacing-lg);
}

/* Vote Section */
.post-votes {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 52px;
}

.vote-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.vote-count-up, .vote-count-down {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 18px;
}

.vote-count-up {
    color: var(--accent-success);
}

.vote-count-down {
    color: var(--accent-danger);
}

.vote-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-tertiary);
    transition: all var(--transition-base);
}

.vote-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.vote-btn.upvoted {
    color: var(--accent-success);
    background: rgba(16, 185, 129, 0.15);
}

.vote-btn.downvoted {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.15);
}

.vote-btn:active {
    transform: scale(0.9);
}

.vote-count {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: var(--spacing-xs) 0;
}

/* Post Content */
.post-content {
    flex: 1;
    min-width: 0;
}

.post-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.post-topic {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.25rem 0.625rem;
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-primary);
    transition: all var(--transition-fast);
}

/* "Sharing-Out" topic uses the secondary cyan accent so it's
   visually distinct from the primary topic palette. */
.post-topic.post-topic-share {
    background: rgba(var(--accent-secondary-rgb), 0.15);
    color: var(--accent-secondary);
}

/* Inline badge that flags a forum post as having originated from
   someone's personal blog (set by blog-posts.js → shareBlogPostToForum).
   Renders next to the post-time line so a reader instantly understands
   the provenance. */
.post-shared-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    background: rgba(var(--accent-secondary-rgb), 0.1);
    transition: background var(--transition-fast);
}
.post-shared-badge:hover {
    background: rgba(var(--accent-secondary-rgb), 0.2);
}

/* Sidebar pulse for the new Sharing-Out topic + Blog quick-link. */
.sidebar-link-share .sidebar-icon,
.sidebar-link-blog .sidebar-icon {
    filter: drop-shadow(0 0 6px rgba(var(--accent-secondary-rgb), 0.5));
}

.post-topic:hover {
    background: rgba(var(--accent-primary-rgb), 0.25);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.post-author {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.post-author:hover {
    color: var(--accent-primary);
}

.post-author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.post-dot {
    color: var(--text-muted);
}

.post-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    transition: color var(--transition-fast);
}

.post-title a {
    color: inherit;
    text-decoration: none;
}

.post-title a:hover {
    color: var(--accent-primary);
}

.post-preview {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.post-tag {
    padding: 0.2rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.post-tag:hover {
    background: var(--bg-elevated);
    color: var(--accent-secondary);
}

.post-footer {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.post-action {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.post-action:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.post-action-icon {
    font-size: 1rem;
}

/* Post Image */
.post-image {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.post-image img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.post-image:hover img {
    transform: scale(1.02);
}

/* ============ Comment Styles ============ */
.comment {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    animation: comment-enter 0.3s ease-out;
}

@keyframes comment-enter {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.comment-layout {
    display: flex;
    gap: var(--spacing-md);
}

.comment-votes {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 40px;
}

.comment-vote-row {
    display: flex;
    align-items: center;
    gap: 1px;
}

.comment-vote-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.comment-vote-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.comment-vote-btn.upvoted {
    color: var(--accent-success);
}

.comment-vote-btn.downvoted {
    color: var(--accent-danger);
}

.comment-vote-count {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 14px;
}

.comment-vote-count.vote-count-up {
    color: var(--accent-success);
}

.comment-vote-count.vote-count-down {
    color: var(--accent-danger);
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.comment-author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-author-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.comment-author-name:hover {
    color: var(--accent-primary);
}

.comment-time {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.comment-op-badge {
    padding: 0.125rem 0.5rem;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.comment-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.comment-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.comment-action {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.comment-action:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Nested Replies */
.comment-replies {
    margin-left: var(--spacing-xl);
    margin-top: var(--spacing-md);
    padding-left: var(--spacing-lg);
    border-left: 2px solid var(--glass-border);
}

.comment-replies .comment {
    background: rgba(255, 255, 255, 0.02);
}

/* Show/Hide Replies */
.toggle-replies {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) 0;
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.toggle-replies:hover {
    opacity: 0.8;
}

.toggle-replies-icon {
    transition: transform var(--transition-fast);
}

.toggle-replies.expanded .toggle-replies-icon {
    transform: rotate(180deg);
}

/* ============ Post / Comment / Reply Emoji Reactions ============
   Layout requirements (per spec):
     • The reaction cluster grows from the BOTTOM-RIGHT corner.
     • With 1 emoji type, the pill sits in the bottom-right.
     • Adding more pills extends LEFTWARD on the same row.
     • When the row fills, new pills wrap UPWARD onto a row above —
       still anchored to the right.

   Achieved with a single flex container:
     flex-direction: row-reverse  → first DOM child renders at the right
     flex-wrap:     wrap-reverse  → overflow rows wrap upward
     justify-content: flex-start  → items pack against the (now-right) start
     align-content:   flex-start  → wrapped rows pack against the (now-bottom) start

   Pills are sorted DESC by count in JS, so the most-popular emoji
   ends up first in DOM order → rightmost on screen. The "+ react"
   button is rendered LAST in DOM → leftmost in the cluster. */
.post-reactions {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap-reverse;
    justify-content: flex-start;
    align-content: flex-start;
    gap: 6px 6px;
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    /* Lives at the bottom-right of its host. The host (post-card,
       article actions row, comment-content, reply-content) decides
       its own width; we just lay items out within that. */
}

/* Each emoji pill: compact rounded surface that scales up subtly on
   hover so users feel the click target without the row jumping. */
.post-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 8px;
    border-radius: 13px;
    background: var(--bg-tertiary, rgba(148, 163, 184, 0.12));
    border: 1px solid var(--glass-border, rgba(148, 163, 184, 0.22));
    color: var(--text-primary, #e2e8f0);
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
    -webkit-tap-highlight-color: transparent;
    /* Buttons defaults reset: post-card's whole-card click handler
       inspects e.target.closest('button') to skip these — the reset
       guarantees the closest() match never accidentally skips a pill
       because of inherited button chrome. */
    user-select: none;
}
.post-reaction-pill:hover {
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.15);
    border-color: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.45);
}
.post-reaction-pill:active {
    transform: scale(0.96);
}
/* Highlighted state when the caller has already reacted with this
   emoji — same brand-tint as the chat reaction pills for cross-
   surface familiarity. */
.post-reaction-pill.mine {
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.22);
    border-color: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.6);
    color: var(--text-primary, #e2e8f0);
}
.post-reaction-pill.mine:hover {
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.30);
}

.post-reaction-emoji {
    font-size: 0.95rem;
    line-height: 1;
    /* Apple's color emoji font is the gold standard cross-platform.
       Without this fallback, some Android browsers fall back to a
       grey monochrome glyph for harder-to-render emojis (🥹, etc). */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}
.post-reaction-count {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
}
.post-reaction-pill.mine .post-reaction-count {
    color: var(--text-primary, #e2e8f0);
}

/* "+ N more" pill shown when the cluster's distinct-emoji count
   exceeds REACTION_DISPLAY_LIMIT (24). Non-interactive informational
   chip — clicking it does nothing because the data is already in the
   visible top-N pills. */
.post-reaction-overflow {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 8px;
    border-radius: 13px;
    background: transparent;
    border: 1px dashed var(--glass-border, rgba(148, 163, 184, 0.32));
    color: var(--text-tertiary, #64748b);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    user-select: none;
    cursor: default;
}

/* "Add reaction" button: smiley-with-plus affordance matching the
   chat composer's emoji button. Always visible (per spec) so any
   visitor has a one-click path to react, even on a post with zero
   existing reactions. */
.post-reactions-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 36px;
    height: 26px;
    padding: 0;
    border-radius: 13px;
    background: transparent;
    border: 1px dashed var(--glass-border, rgba(148, 163, 184, 0.4));
    color: var(--text-tertiary, #64748b);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, border-style 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.post-reactions-add:hover {
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.12);
    color: var(--accent-primary, #8b5cf6);
    border-color: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.5);
    border-style: solid;
}
.post-reactions-add:active {
    transform: scale(0.94);
}
/* Visually pressed state when the emoji picker is open against this
   button. The shared message-actions.js picker stamps this class on
   whichever element triggered it — same name as the chat reaction
   "+" button so we get a consistent active treatment without a second
   class. */
.post-reactions-add.msg-action-btn-active,
.post-reactions-add.msg-action-btn-active:hover {
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.20);
    color: var(--accent-primary, #8b5cf6);
    border-color: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.65);
    border-style: solid;
}
.post-reactions-add-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
/* The little "+" sits directly next to the smiley like a stacked
   badge. Slightly larger weight so it reads as an action indicator
   rather than punctuation. */
.post-reactions-add-plus {
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    margin-left: 1px;
    margin-bottom: 8px;
}

/* Tighten spacing on inner reaction clusters (replies + nested
   comments) so they don't dominate already-compact card surfaces. */
.reply .post-reactions,
.comment .post-reactions {
    margin-top: var(--spacing-xs);
    margin-bottom: 0;
}
.reply .post-reaction-pill,
.reply .post-reactions-add,
.reply .post-reaction-overflow {
    height: 22px;
    border-radius: 11px;
    padding: 0 6px;
    font-size: 0.7rem;
}
.reply .post-reactions-add {
    width: 30px;
    padding: 0;
}

/* Mobile: pills stay compact, but the cluster gets a small extra
   right padding to keep it off the edge of the card. */
@media (max-width: 640px) {
    .post-reactions {
        gap: 4px;
    }
    .post-reaction-pill,
    .post-reactions-add,
    .post-reaction-overflow {
        height: 24px;
    }
}

/* ============ Empty States ============ */
.empty-state {
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-xl);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-lg);
}

/* ============ Responsive Adjustments ============ */
@media (max-width: 768px) {
    .post-card-layout {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .post-votes {
        flex-direction: row;
        min-width: auto;
        gap: var(--spacing-sm);
    }
    
    .post-footer {
        flex-wrap: wrap;
    }
    
    .comment-layout {
        flex-direction: column;
    }
    
    .comment-votes {
        flex-direction: row;
        justify-content: flex-start;
        gap: var(--spacing-sm);
    }
    
    .comment-replies {
        margin-left: var(--spacing-md);
        padding-left: var(--spacing-md);
    }
}

