/*
==================================================================
COMMUNITY.CSS
Production Stylesheet for The Systematic Thinker PWA
Contains: Theme Variables, Glassmorphism, Modals, Buttons, & Community Components
==================================================================
*/

:root {
    /* --- CORE PALETTE --- */
    --color-background: #111827; /* Dark blue-gray */
    --color-text: #e5e7eb; /* Light gray */
    --color-text-muted: #9ca3af; /* Medium gray */

    /* --- NEON SYSTEM DEFAULTS (Overridden by header.js) --- */
    --neon-primary: #38bdf8; /* Default Sky Blue */
    --neon-glow: rgba(56, 189, 248, 0.2);
    
    /* --- FONTS --- */
    --font-sans: 'Inter', sans-serif;
}

/* --- COMPATIBILITY FIX --- */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/* --- BASE STYLES --- */
body {
    background-color: var(--color-background);
    color: var(--color-text);
    font-family: var(--font-sans);
    margin: 0;
    overflow-x: hidden; 
}

/* --- GLASSMORPHISM UTILITY --- */
.glass-card {
    background: rgba(31, 41, 55, 0.6); /* Slightly more opaque for readability */
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* --- TEXT EFFECTS --- */
.text-glow {
    text-shadow: 0 0 10px var(--neon-glow), 0 0 20px var(--neon-glow);
    transition: text-shadow 0.3s ease;
}

/* --- BUTTONS (Using Neon Variables) --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    /* Dynamic Gradient based on Neon Color */
    background: linear-gradient(135deg, var(--neon-primary), #1f2937); 
    border: 1px solid var(--neon-primary);
    box-shadow: 0 0 15px var(--neon-glow);
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--neon-primary);
    filter: brightness(1.1);
}

.btn-primary:disabled {
    background: #374151;
    border-color: #4b5563;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(55, 65, 81, 0.5);
    border: 1px solid rgba(107, 114, 128, 0.5);
    color: var(--color-text);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
    background-color: rgba(75, 85, 99, 0.8);
    border-color: var(--neon-primary);
    color: white;
}

.action-button {
    /* Used for full-width actions */
    background-color: var(--neon-primary);
    color: #111827; /* Dark text on bright button */
    font-weight: 800;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px var(--neon-glow);
}

.action-button:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px var(--neon-glow);
}

/* --- FORM INPUTS --- */
.form-input {
    width: 100%;
    background-color: #1f2937;
    border: 1px solid #4b5563;
    color: var(--color-text);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--neon-primary);
    box-shadow: 0 0 0 2px var(--neon-glow);
}

.form-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    background-color: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 0.25rem;
    display: inline-block;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.form-checkbox:checked {
    background-color: var(--neon-primary);
    border-color: var(--neon-primary);
}

.form-checkbox:checked::after {
    content: '✓';
    color: #111827;
    font-size: 0.875rem;
    font-weight: bold;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* --- MODAL SYSTEM (Fixed for Reliability) --- */
.modal {
    position: fixed;
    z-index: 100;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: hidden; /* Prevent background scroll */
    background-color: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    
    /* Default State: Hidden but ready to flex */
    display: none; 
    align-items: center;
    justify-content: center;
    
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

/* When JS adds 'flex' via style.display, this handles the fade-in */
.modal[style*="display: flex"] {
    opacity: 1;
}

.modal-content {
    /* Responsive Sizing */
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    
    background: #1f2937; /* Solid fallback */
    background: rgba(31, 41, 55, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    
    /* Scroll handling */
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
    
    /* Animation */
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal[style*="display: flex"] .modal-content {
    transform: scale(1);
}

.close-button {
    transition: all 0.2s;
}
.close-button:hover {
    color: white;
    transform: rotate(90deg);
}

/* --- SCROLLBARS (Custom Webkit) --- */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #111827; 
}
::-webkit-scrollbar-thumb {
    background: #4b5563; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--neon-primary); 
}

/* --- HEADER COMPONENTS --- */
.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color 0.3s;
}
/* Header avatar border matches user tier color */
#header-user-avatar {
    border-color: var(--neon-primary);
}

.notification-bell {
    position: relative;
    cursor: pointer;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid #1f2937;
}

.notifications-dropdown {
    display: none; /* Toggled by JS */
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.75rem;
    width: 320px;
    max-width: 90vw;
    max-height: 400px;
    overflow-y: auto;
    z-index: 60;
    
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* --- CHAT WINDOW --- */
#chat-window {
    width: 350px;
    max-width: 95vw;
    height: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    z-index: 70; /* Above footer, below modal */
}

#chat-window .glass-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-color: var(--neon-primary); /* Highlight active chat */
}

/* --- POST & REACTION STYLES --- */
.reaction-button, .comment-button, .share-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    background: rgba(55, 65, 81, 0.3);
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.reaction-button:hover, .comment-button:hover, .share-button:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--neon-primary);
}

.reaction-button.has-reacted {
    background: rgba(56, 189, 248, 0.2);
    color: var(--neon-primary);
    border: 1px solid var(--neon-primary);
}

.reaction-picker {
    /* JS toggles the .hidden class, flex handles layout */
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #374151;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 0.5rem;
    z-index: 10;
    border: 1px solid #4b5563;
}

/* --- UTILITIES --- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }