/* Font Face Declarations - Load first for optimal performance */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono-v23-latin-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap; /* Better loading performance */
}

@font-face {
    font-family: 'Press Start 2P';
    src: url('/fonts/press-start-2p-v15-latin-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Base styles - already defined in critical CSS, but kept for completeness */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0a0a1a 0%, #0d1117 50%, #060609 100%);
    min-height: 100vh;
    font-family: 'JetBrains Mono', monospace, system-ui, -apple-system, sans-serif;
    color: #c9d1d9;
    overflow-x: hidden;
}

/* Animated background elements - moved to end for better performance */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(88, 28, 135, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 69, 19, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(25, 42, 86, 0.05) 0%, transparent 50%);
    animation: float 25s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
    will-change: transform; /* Optimize for animations */
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-15px) rotate(0.5deg); }
    66% { transform: translateY(8px) rotate(-0.5deg); }
}

.container {
    max-width: 580px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 15px;
    background: linear-gradient(45deg, #8b2635, #2d5a27, #1a365d, #4a5568);
    background-size: 400% 400%;
    animation: gradientShift 12s ease infinite;
    border: 3px solid #0d1117;
    box-shadow: 
        0 0 0 1px #30363d,
        0 0 0 4px #0d1117,
        0 6px 15px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
    will-change: background-position; /* Optimize for gradient animation */
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(255,255,255,0.02) 8px,
        rgba(255,255,255,0.02) 16px
    );
    animation: scan 4s linear infinite;
    will-change: transform;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes scan {
    0% { transform: translateX(-100%) translateY(-100%); }
    100% { transform: translateX(50%) translateY(50%); }
}

.header h1 {
    font-family: 'Press Start 2P', cursive, monospace;
    font-size: clamp(1.2rem, 3.5vw, 1.8rem);
    color: #c9d1d9;
    text-shadow: 
        1px 1px 0 #21262d,
        2px 2px 0 #8b2635,
        3px 3px 0 #2d5a27;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
}

.header p {
    font-size: 0.85rem;
    color: #8b949e;
    font-weight: 400;
    position: relative;
    z-index: 2;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
}

.chat-container {
    background: rgba(13, 17, 23, 0.85);
    border: 2px solid #30363d;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 
        0 0 20px rgba(139, 38, 53, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.05),
        0 8px 25px rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b2635, #2d5a27, #1a365d, #4a5568);
    background-size: 400% 100%;
    animation: borderGlow 4s ease infinite;
    will-change: background-position;
}

@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.post {
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.4) 0%, rgba(33, 38, 45, 0.4) 100%);
    border: 1px solid rgba(48, 54, 61, 0.6);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
    position: relative;
    transition: all 0.3s ease;
    animation: slideIn 0.6s ease forwards;
    opacity: 0;
    transform: translateY(15px);
    will-change: transform, opacity; /* Optimize for animations */
}

.post:hover {
    transform: translateY(-1px);
    box-shadow: 
        0 3px 15px rgba(139, 38, 53, 0.2),
        0 0 0 1px rgba(139, 38, 53, 0.4);
    border-color: rgba(139, 38, 53, 0.7);
    background: linear-gradient(135deg, rgba(139, 38, 53, 0.1) 0%, rgba(33, 38, 45, 0.6) 100%);
}

.post:nth-child(even) {
    background: linear-gradient(135deg, rgba(45, 90, 39, 0.3) 0%, rgba(33, 38, 45, 0.4) 100%);
    border-color: rgba(45, 90, 39, 0.5);
}

.post:nth-child(even):hover {
    border-color: rgba(45, 90, 39, 0.7);
    box-shadow: 
        0 3px 15px rgba(45, 90, 39, 0.2),
        0 0 0 1px rgba(45, 90, 39, 0.4);
    background: linear-gradient(135deg, rgba(45, 90, 39, 0.15) 0%, rgba(33, 38, 45, 0.6) 100%);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 10px;
    color: #e6edf3;
}

.post-content p {
    margin-bottom: 1em;
}

.post-content p:last-child {
    margin-bottom: 0;
}

/* Ordered and unordered lists in post content */
.post-content ol,
.post-content ul {
    margin: 1em 0;
    padding-left: 1.5em; /* Ensure enough space for markers */
    list-style-position: inside; /* Keep markers inside the content area */
}

.post-content ol {
    list-style-type: decimal; /* Standard numbering */
}

.post-content ul {
    list-style-type: disc; /* Standard bullet points */
}

.post-content li {
    margin-bottom: 0.5em;
    line-height: 1.4;
    color: #e6edf3; /* Match your post content color */
}

.post-content li:last-child {
    margin-bottom: 0;
}

/* Nested lists */
.post-content ol ol,
.post-content ul ul,
.post-content ol ul,
.post-content ul ol {
    margin: 0.5em 0;
    padding-left: 1.2em;
}

/* Link styling for better visibility on dark background */
.post-content a {
    color: #4ecdc4; /* Cyan color that matches your theme */
    text-decoration: underline;
    text-decoration-color: rgba(78, 205, 196, 0.5);
    text-underline-offset: 2px;
    transition: all 0.3s ease;
}

.post-content a:hover {
    color: #6ee7df;
    text-decoration-color: #4ecdc4;
    text-shadow: 0 0 8px rgba(78, 205, 196, 0.3);
}

.post-content a:visited {
    color: #b794f6; /* Purple for visited links */
}

.post-content a:visited:hover {
    color: #d6bcfa;
    text-shadow: 0 0 8px rgba(183, 148, 246, 0.3);
}

/* Image styling within posts */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 10px auto;
    border: 1px solid rgba(48, 54, 61, 0.6);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    display: block;
}

.post-content img:hover {
    transform: scale(1.02);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(139, 38, 53, 0.3),
        0 0 20px rgba(139, 38, 53, 0.1);
    border-color: rgba(139, 38, 53, 0.4);
}

/* Handle GIFs and animated images */
.post-content img[src$=".gif"], 
.post-content img[src*=".gif?"] {
    border: 2px solid rgba(45, 90, 39, 0.6);
}

.post-content img[src$=".gif"]:hover,
.post-content img[src*=".gif?"]:hover {
    border-color: rgba(45, 90, 39, 0.8);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(45, 90, 39, 0.4),
        0 0 20px rgba(45, 90, 39, 0.1);
}

/* Lazy Loading Styles */
.post-content img.lazy-image {
    transition: all 0.4s ease;
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.3) 0%, rgba(33, 38, 45, 0.3) 100%);
    background-size: 200% 200%;
    animation: shimmer 1.5s infinite;
}

/* Shimmer effect while loading */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading state */
.post-content img.lazy-image.loading {
    opacity: 0.6;
    transform: scale(0.98);
    filter: blur(1px);
}

/* Loaded state */
.post-content img.lazy-image.loaded {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
    background: none;
    animation: fadeInUp 0.6s ease forwards;
}

/* Error state */
.post-content img.lazy-image.error {
    opacity: 0.5;
    background: linear-gradient(135deg, rgba(139, 38, 53, 0.2) 0%, rgba(33, 38, 45, 0.3) 100%);
    position: relative;
}

.post-content img.lazy-image.error::after {
    content: '⚠️ Failed to load image';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #f85149;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    pointer-events: none;
}

/* Fade in animation for loaded images */
@keyframes fadeInUp {
    from {
        opacity: 0.8;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Performance optimization for lazy images */
.post-content img.lazy-image {
    will-change: transform, opacity, filter;
}

/* Remove will-change after loading to optimize performance */
.post-content img.lazy-image.loaded {
    will-change: auto;
}

/* Loading placeholder for very slow connections */
.post-content img.lazy-image[src*="data:image/gif"] {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-content img.lazy-image[src*="data:image/gif"]::before {
    content: '📷 Loading image...';
    position: absolute;
    color: #7d8590;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.post-time {
    font-size: 0.7rem;
    color: #7d8590;
    font-family: 'Press Start 2P', cursive, monospace;
    text-align: right;
    opacity: 0.7;
    font-weight: normal;
}

.post::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.post:hover::before {
    opacity: 1;
}

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

::-webkit-scrollbar-track {
    background: rgba(13, 17, 23, 0.8);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #30363d, #8b2635);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #484f58, #a73441);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .post-content img.lazy-image,
    .post,
    body::before,
    .header,
    .header::before,
    .chat-container::before {
        animation: none;
        transition: opacity 0.2s ease;
    }
    
    .post {
        opacity: 1;
        transform: none;
    }
    
    @keyframes shimmer {
        0%, 100% { background-position: 0 0; }
    }
    
    @keyframes fadeInUp {
        from { opacity: 0.8; }
        to { opacity: 1; }
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        max-width: 95%;
        padding: 12px;
    }
    
    .header {
        padding: 16px 12px;
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }
    
    .header p {
        font-size: 0.75rem;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .post {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .post-content {
        font-size: 0.9rem;
    }
    
    .post-time {
        font-size: 0.65rem;
    }
    
    .post-content img {
        margin: 8px 0;
        border-radius: 4px;
    }
    
    .post-content img.lazy-image[src*="data:image/gif"] {
        min-height: 150px;
    }
    
    .post-content img.lazy-image[src*="data:image/gif"]::before {
        font-size: 0.8rem;
    }
}

/* Post footer styling */
.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 10px;
}

/* Copy link button - styled like the date/time text */
.copy-link-btn {
    background: none;
    border: none;
    color: #7d8590;
    cursor: pointer;
    font-size: 1.9rem;
    font-family: 'Press Start 2P', cursive, monospace;
    opacity: 0.7;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
    line-height: 1;
    vertical-align: baseline;
}

.copy-link-btn:hover {
    color: #c9d1d9;
    opacity: 1;
}

.copy-link-btn:active {
    opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .post-footer {
        margin-top: 8px;
    }
    
    .copy-link-btn {
        font-size: 0.65rem;
    }
}

/* File download styling within posts */
.post-content a[href^="/files/"] {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #4ecdc4;
    text-decoration: none;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.1) 0%, rgba(78, 205, 196, 0.05) 100%);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.3s ease;
    margin: 4px 0;
    word-break: break-all;
    max-width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    vertical-align: baseline;
}

.post-content a[href^="/files/"]:hover {
    color: #6ee7df;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0.1) 100%);
    border-color: rgba(78, 205, 196, 0.5);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.2),
        0 0 12px rgba(78, 205, 196, 0.2);
    text-shadow: 0 0 8px rgba(78, 205, 196, 0.3);
}

.post-content a[href^="/files/"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Remove the paper clip emoji styling */
.post-content a[href^="/files/"]::before {
    content: '';
    display: none;
}

/* Style for the paragraph containing file downloads to align size text properly */
.post-content p:has(a[href^="/files/"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Style the size text that appears after file links */
.post-content a[href^="/files/"] + * {
    color: #7d8590;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    vertical-align: middle;
}

/* Responsive adjustments for file links */
@media (max-width: 768px) {
    .post-content a[href^="/files/"] {
        padding: 6px 10px;
        font-size: 0.85rem;
        border-radius: 4px;
    }
    
    .post-content p:has(a[href^="/files/"]) {
        gap: 6px;
    }
    
    .post-content a[href^="/files/"] + * {
        font-size: 0.75rem;
    }
}

/* Pagination Styles */
.pagination-container {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.4) 0%, rgba(33, 38, 45, 0.4) 100%);
    border: 1px solid rgba(48, 54, 61, 0.6);
    border-radius: 8px;
    backdrop-filter: blur(8px);
}

/* Top pagination - more compact */
.pagination-top {
    margin-top: 0;
    margin-bottom: 20px;
    padding: 15px 20px;
}

.pagination-top .pagination-info {
    display: none; /* Hide the "Showing posts X-Y of Z" info at the top */
}

.pagination-info {
    text-align: center;
    margin-bottom: 15px;
}

.page-info {
    font-size: 0.8rem;
    color: #8b949e;
    font-family: 'JetBrains Mono', monospace;
}

.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.1) 0%, rgba(78, 205, 196, 0.05) 100%);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 4px;
    color: #4ecdc4;
    text-decoration: none;
    font-family: 'Press Start 2P', cursive, monospace;
    font-size: 0.6rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pagination-link:hover {
    color: #6ee7df;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0.1) 100%);
    border-color: rgba(78, 205, 196, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.2);
}

.pagination-link-disabled {
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.3) 0%, rgba(33, 38, 45, 0.3) 100%);
    border: 1px solid rgba(48, 54, 61, 0.5);
    color: #6e7681;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination-link-disabled:hover {
    color: #6e7681;
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.3) 0%, rgba(33, 38, 45, 0.3) 100%);
    border-color: rgba(48, 54, 61, 0.5);
    transform: none;
    box-shadow: none;
}

.pagination-current {
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(139, 38, 53, 0.2) 0%, rgba(139, 38, 53, 0.1) 100%);
    border: 1px solid rgba(139, 38, 53, 0.5);
    border-radius: 4px;
    color: #f85149;
    font-family: 'Press Start 2P', cursive, monospace;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pagination-numbers {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pagination-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, rgba(48, 54, 61, 0.6) 0%, rgba(33, 38, 45, 0.6) 100%);
    border: 1px solid rgba(48, 54, 61, 0.8);
    border-radius: 4px;
    color: #c9d1d9;
    text-decoration: none;
    font-family: 'Press Start 2P', cursive, monospace;
    font-size: 0.5rem;
    transition: all 0.3s ease;
}

.pagination-number:hover {
    color: #4ecdc4;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.15) 0%, rgba(78, 205, 196, 0.05) 100%);
    border-color: rgba(78, 205, 196, 0.4);
    transform: translateY(-1px);
}

.pagination-number-current {
    background: linear-gradient(135deg, rgba(139, 38, 53, 0.3) 0%, rgba(139, 38, 53, 0.2) 100%);
    border-color: rgba(139, 38, 53, 0.6);
    color: #f85149;
    cursor: default;
    box-shadow: 0 0 0 1px rgba(139, 38, 53, 0.4);
}

.pagination-number-current:hover {
    transform: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .pagination-container {
        margin-top: 20px;
        padding: 15px;
    }
    
    .pagination-nav {
        gap: 15px;
    }
    
    .pagination-links {
        gap: 10px;
    }
    
    .pagination-link,
    .pagination-current {
        padding: 6px 10px;
        font-size: 0.55rem;
    }
    
    .pagination-numbers {
        gap: 4px;
    }
    
    .pagination-number {
        width: 24px;
        height: 24px;
        font-size: 0.45rem;
    }
    
    .page-info {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .pagination-nav {
        flex-direction: column;
        gap: 12px;
    }
    
    .pagination-numbers {
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
}