/* ═══════════════════════════════════════════════
   COMMUNITY FORUM — Reddit-style warm theme
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-page: hsl(40, 30%, 97%);
    --bg-white: hsl(0, 0%, 100%);
    --bg-warm: hsl(35, 40%, 95%);
    --bg-soft: hsl(30, 20%, 93%);
    --bg-card: hsl(0, 0%, 100%);
    --border: hsl(30, 15%, 88%);
    --border-hover: hsl(30, 20%, 78%);
    --text-0: hsl(20, 15%, 15%);
    --text-1: hsl(20, 10%, 35%);
    --text-2: hsl(20, 8%, 55%);
    --text-3: hsl(20, 6%, 72%);
    --accent: hsl(245, 58%, 56%);
    --accent-bg: hsl(245, 60%, 96%);
    --accent-border: hsl(245, 40%, 85%);
    --upvote: hsl(15, 85%, 55%);
    --downvote: hsl(245, 50%, 60%);
    --teal: hsl(170, 50%, 45%);
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px hsla(20, 10%, 10%, 0.04);
    --shadow-md: 0 4px 12px hsla(20, 10%, 10%, 0.06);
    --transition: 200ms ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    background: var(--bg-page);
    color: var(--text-0);
    min-height: 100vh;
}

.community-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}


/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */

.forum-layout {
    display: flex;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    width: 100%;
}

.forum-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.forum-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}


/* ═══════════════════════════════════════════════
   SIDEBAR CARDS
   ═══════════════════════════════════════════════ */

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.sidebar-card h3 {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-0);
}

.sidebar-card h4 {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-2);
    margin-bottom: 10px;
}

.sidebar-desc {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-1);
    margin-bottom: 14px;
}

.sidebar-stats {
    display: flex;
    gap: 20px;
}

.stat {
    font-size: 0.78rem;
    color: var(--text-2);
}

.stat span {
    font-weight: 700;
    color: var(--text-0);
}


/* ── Flairs sidebar ── */

.flair-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.flair-btn {
    background: none;
    border: none;
    padding: 7px 12px;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-1);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}

.flair-btn:hover {
    background: var(--bg-warm);
    color: var(--text-0);
}

.flair-btn.active {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
}


/* ── Sidebar links ── */

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-links a {
    font-size: 0.8rem;
    color: var(--text-1);
    text-decoration: none;
    padding: 5px 0;
    transition: color var(--transition);
}

.sidebar-links a:hover {
    color: var(--accent);
}


/* ── Profile ── */

.profile-username {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-0);
    margin-bottom: 4px;
}

.profile-karma {
    font-size: 0.78rem;
    color: var(--text-2);
}

.profile-mod {
    font-size: 0.72rem;
    color: var(--teal);
    font-weight: 600;
    margin-top: 4px;
}


/* ═══════════════════════════════════════════════
   SORT BAR
   ═══════════════════════════════════════════════ */

.sort-bar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.sort-tabs {
    display: flex;
    gap: 4px;
}

.sort-tab {
    padding: 7px 16px;
    border: none;
    border-radius: 20px;
    background: none;
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition);
}

.sort-tab:hover {
    background: var(--bg-warm);
    color: var(--text-0);
}

.sort-tab.active {
    background: var(--accent-bg);
    color: var(--accent);
}


/* ═══════════════════════════════════════════════
   THREAD CARDS
   ═══════════════════════════════════════════════ */

.thread-card {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
}

.thread-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.vote-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 12px;
    background: var(--bg-warm);
    gap: 2px;
    min-width: 48px;
}

.vote-btn {
    background: none;
    border: none;
    font-size: 0.7rem;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}

.vote-btn:hover {
    color: var(--text-1);
}

.vote-btn.up:hover,
.vote-btn.up.voted {
    color: var(--upvote);
}

.vote-btn.down:hover,
.vote-btn.down.voted {
    color: var(--downvote);
}

.vote-score {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-0);
    line-height: 1;
}

.thread-content-preview {
    flex: 1;
    padding: 14px 18px;
    min-width: 0;
}

.thread-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.flair-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: capitalize;
}

.flair-discussion {
    background: hsl(210, 50%, 94%);
    color: hsl(210, 60%, 45%);
}

.flair-question {
    background: hsl(45, 80%, 93%);
    color: hsl(35, 70%, 40%);
}

.flair-show-and-tell {
    background: hsl(145, 40%, 93%);
    color: hsl(145, 50%, 35%);
}

.flair-blueprint {
    background: var(--accent-bg);
    color: var(--accent);
}

.flair-bug {
    background: hsl(0, 50%, 95%);
    color: hsl(0, 60%, 45%);
}

.flair-announcement {
    background: hsl(15, 80%, 94%);
    color: hsl(15, 70%, 42%);
}

.thread-author {
    font-size: 0.72rem;
    color: var(--text-2);
    font-weight: 500;
}

.thread-time {
    font-size: 0.72rem;
    color: var(--text-3);
}

.thread-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-0);
    margin-bottom: 4px;
    line-height: 1.35;
}

.thread-preview {
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.thread-stats {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-3);
}


/* ═══════════════════════════════════════════════
   THREAD DETAIL
   ═══════════════════════════════════════════════ */

.btn-back {
    margin-bottom: 12px;
    font-size: 0.78rem;
}

.thread-full {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.vote-col-lg {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    background: var(--bg-warm);
    gap: 4px;
    min-width: 56px;
}

.vote-score-lg {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-0);
}

.thread-full-content {
    flex: 1;
    padding: 20px 24px;
    min-width: 0;
}

.thread-title-lg {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-0);
    margin-bottom: 14px;
    line-height: 1.3;
}

.thread-body {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-1);
}

.thread-body h2,
.thread-body h3,
.thread-body h4 {
    color: var(--text-0);
    margin: 16px 0 8px;
}

.thread-body p {
    margin: 8px 0;
}

.thread-body code {
    background: var(--bg-soft);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--accent);
}

.thread-body ul {
    padding-left: 20px;
    margin: 8px 0;
}

.thread-body li {
    margin: 4px 0;
    line-height: 1.6;
}

.thread-body strong {
    color: var(--text-0);
}


/* ═══════════════════════════════════════════════
   REPLIES
   ═══════════════════════════════════════════════ */

#reply-section {
    margin-top: 0;
}

#reply-section h4 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-2);
    margin-bottom: 12px;
}

.reply-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 8px;
    transition: border-color var(--transition);
}

.reply-card:hover {
    border-color: var(--border-hover);
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.reply-author {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-0);
}

.op-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-bg);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.reply-time {
    font-size: 0.7rem;
    color: var(--text-3);
}

.reply-votes {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-2);
}

.vote-btn-sm {
    background: none;
    border: none;
    font-size: 0.6rem;
    color: var(--text-3);
    cursor: pointer;
    padding: 2px 4px;
    transition: color var(--transition);
}

.vote-btn-sm.up:hover,
.vote-btn-sm.up.voted {
    color: var(--upvote);
}

.vote-btn-sm.down:hover,
.vote-btn-sm.down.voted {
    color: var(--downvote);
}

.reply-body {
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--text-1);
}

.reply-body p {
    margin: 4px 0;
}

.reply-body code {
    background: var(--bg-soft);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.78rem;
}

.reply-link {
    background: none;
    border: none;
    font-size: 0.72rem;
    color: var(--text-3);
    cursor: pointer;
    margin-top: 6px;
    font-family: var(--sans);
    transition: color var(--transition);
}

.reply-link:hover {
    color: var(--accent);
}

.reply-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 6px;
}

.action-link {
    background: none;
    border: none;
    font-size: 0.72rem;
    color: var(--text-3);
    cursor: pointer;
    font-family: var(--sans);
    transition: color var(--transition);
    padding: 0;
}

.action-link:hover {
    color: var(--accent);
}

.action-danger:hover {
    color: hsl(0, 60%, 50%);
}

.nested-replies {
    margin-left: 28px;
    border-left: 2px solid var(--border);
    padding-left: 16px;
}


/* ═══════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════ */

.new-thread-form,
.reply-form,
.username-setup,
.auth-prompt {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.new-thread-form h3,
.username-setup h3,
.auth-prompt h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.username-setup p,
.auth-prompt p {
    font-size: 0.82rem;
    color: var(--text-2);
    margin-bottom: 12px;
    line-height: 1.5;
}

.auth-sub {
    font-size: 0.75rem !important;
    margin-top: 10px !important;
    color: var(--text-3) !important;
}

.auth-sub a {
    color: var(--accent);
}

.input {
    width: 100%;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-0);
    font-family: var(--sans);
    font-size: 0.85rem;
    padding: 10px 14px;
    margin-bottom: 10px;
    transition: border-color var(--transition);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px hsla(245, 58%, 56%, 0.08);
}

.textarea {
    resize: vertical;
    min-height: 100px;
    font-family: var(--sans);
    line-height: 1.6;
}

.input-select {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--sans);
    font-size: 0.82rem;
    color: var(--text-0);
    cursor: pointer;
}

.flair-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.flair-selector label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-2);
}

.auth-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.auth-row .input {
    flex: 1;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}


/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px hsla(245, 58%, 56%, 0.2);
}

.btn-primary:hover {
    background: hsl(245, 58%, 50%);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--bg-white);
    border-color: var(--border);
    color: var(--text-0);
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    background: var(--bg-warm);
}


/* ═══════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════ */

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.page-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
    transition: all var(--transition);
}

.page-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-warm);
}

.page-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}


/* ═══════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    font-size: 0.88rem;
    color: var(--text-3);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}


/* ═══════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════ */

.toast {
    position: fixed;
    bottom: 32px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-0);
    background: var(--bg-white);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(10px);
    transition: all 250ms ease;
    pointer-events: none;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: hsl(0, 60%, 85%);
    background: hsl(0, 50%, 97%);
    color: hsl(0, 60%, 45%);
}


/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 800px) {
    .forum-layout {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }

    .forum-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .forum-sidebar .sidebar-card {
        flex: 1;
        min-width: 240px;
    }

    .vote-col,
    .vote-col-lg {
        padding: 10px 8px;
        min-width: 40px;
    }

    .thread-content-preview {
        padding: 10px 12px;
    }

    .nested-replies {
        margin-left: 14px;
        padding-left: 10px;
    }
}


/* ═══════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-soft);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}