/* High5Expert - Performance-optimized CSS */
/* No external fonts loaded = faster load times */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #ffffff;
    --bg-alt: #f9fafb;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --max-width: 1200px;
    --content-width: 760px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }

/* Layout */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
.container-narrow { max-width: var(--content-width); margin: 0 auto; padding: 0 1.5rem; }

/* Header */
.header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.logo:hover { color: var(--primary); }
.logo { display: flex; align-items: center; }
.nav-links { display: flex; list-style: none; gap: 1.25rem; }
.nav-links a { color: var(--text); font-weight: 500; font-size: 0.9rem; white-space: nowrap; }
.nav-links a:hover { color: var(--primary); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; flex-direction: column; gap: 5px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--text); transition: 0.3s; }

/* Hero */
.hero {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 1rem; font-weight: 800; }
.hero p { font-size: 1.2rem; opacity: 0.9; max-width: 600px; margin: 0 auto; }

/* Categories */
.categories-nav { display: flex; gap: 0.5rem; padding: 2rem 0 1rem; flex-wrap: wrap; }
.cat-tag {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-alt);
    color: var(--text-light);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.cat-tag:hover, .cat-tag.active { background: var(--primary); color: white; border-color: var(--primary); }
.cat-tag.small { font-size: 0.75rem; padding: 0.2rem 0.6rem; }

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}
.article-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.article-card:hover { box-shadow: var(--shadow-md); }
.article-card-img { width: 100%; height: 200px; object-fit: cover; }
.article-card-body { padding: 1.5rem; }
.article-card h2 { font-size: 1.2rem; margin: 0.5rem 0; line-height: 1.4; }
.article-card h2 a { color: var(--text); }
.article-card h2 a:hover { color: var(--primary); }
.article-card h3 { font-size: 1.1rem; margin: 0.5rem 0; line-height: 1.4; }
.article-card h3 a { color: var(--text); }
.article-card h3 a:hover { color: var(--primary); }
.article-card p { color: var(--text-light); font-size: 0.95rem; margin-bottom: 1rem; }
.article-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-light); }
.read-more { font-weight: 600; color: var(--primary); }

/* Article Page */
.article-page { padding: 2rem 0; }
.article-header { margin-bottom: 2rem; }
.article-header h1 { font-size: 2.2rem; line-height: 1.3; margin: 0.75rem 0; }
.article-header .article-meta { margin-top: 1rem; }
.article-hero-img { width: 100%; border-radius: var(--radius); margin-bottom: 2rem; }

/* Prose - Article content */
.prose { font-size: 1.05rem; line-height: 1.8; }
.prose h2 { font-size: 1.5rem; margin: 2.5rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.prose h3 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }
.prose p { margin-bottom: 1.25rem; }
.prose ul, .prose ol { margin: 1rem 0 1.5rem 1.5rem; }
.prose li { margin-bottom: 0.5rem; }
.prose strong { color: var(--text); }
.prose blockquote {
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: var(--bg-alt);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.prose code {
    background: var(--bg-alt);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}
.prose pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1.5rem 0;
}
.prose pre code { background: none; padding: 0; color: inherit; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.prose th, .prose td { padding: 0.75rem 1rem; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--bg-alt); font-weight: 600; }
.prose img { border-radius: var(--radius); margin: 1.5rem 0; }

/* Page headers */
.page-header { padding: 2.5rem 0 1.5rem; }
.page-header h1 { font-size: 2rem; }
.page-header p { color: var(--text-light); margin-top: 0.5rem; }

/* Related */
.related-section { background: var(--bg-alt); padding: 3rem 0; margin-top: 3rem; }
.related-section h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }

/* Empty state */
.empty-state { text-align: center; color: var(--text-light); padding: 3rem; grid-column: 1 / -1; }

/* Footer */
.footer { background: #1f2937; color: #d1d5db; padding: 3rem 0 1.5rem; margin-top: 4rem; }
.footer h3 { color: white; margin-bottom: 0.75rem; font-size: 1.1rem; }
.footer h4 { color: white; margin-bottom: 0.75rem; font-size: 0.95rem; }
.footer-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 3rem; }
.footer-about p { font-size: 0.9rem; line-height: 1.6; }
.footer-about a:hover, .footer-bottom a:hover { color: white; }
.footer-bottom {
    padding-top: 1.5rem;
    margin-top: 2rem;
    border-top: 1px solid #374151;
    font-size: 0.85rem;
    color: #9ca3af;
}

/* SVG Illustrations — Tech / Cyberpunk */
.illustration-hero {
    border-radius: var(--radius);
    margin-bottom: 2rem;
    text-align: center;
    overflow: hidden;
}
.illustration-inline {
    border-radius: var(--radius);
    margin: 2.5rem 0;
    text-align: center;
    overflow: hidden;
}
.article-illustration {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* ============ Discussion Section ============ */
.discussion-section {
    padding: 3rem 0;
    margin-top: 2rem;
    border-top: 2px solid var(--border);
}
.discussion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.discussion-title { display: flex; align-items: center; gap: 0.5rem; }
.discussion-title h2 { font-size: 1.3rem; margin: 0; }
.discussion-title svg { color: var(--text-light); }
.discussion-count { font-size: 0.85rem; color: var(--text-light); background: var(--bg-alt); padding: 4px 12px; border-radius: 20px; }

/* Composer (form) */
.comment-composer {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 2rem;
}
.composer-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.composer-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.composer-textarea-wrap { position: relative; }
.composer-textarea {
    width: 100%;
    padding: 0.65rem 3rem 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.composer-submit {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.composer-submit:hover { background: var(--primary-dark); transform: scale(1.05); }
.composer-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Reply chip */
.reply-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 4px 10px;
    background: #dbeafe;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #1e40af;
    margin-bottom: 0.75rem;
}
.chip-close {
    background: none;
    border: none;
    color: #1e40af;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 4px;
}

/* Toast success */
.comment-toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius);
    color: #166534;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.comment-toast svg { flex-shrink: 0; color: #16a34a; }

/* Comment thread */
.comment-thread { display: flex; flex-direction: column; gap: 0; }

/* Comment item — step indentation */
.comment-item { position: relative; }
.comment-reply-thread {
    margin-left: 2rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

.comment-card {
    display: flex;
    gap: 0.85rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.comment-item:last-child > .comment-card { border-bottom: none; }

.comment-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
}
.staff-avatar { background: #1e293b !important; }

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

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}
.comment-author { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.comment-time { font-size: 0.78rem; color: var(--text-light); }

.comment-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag-question { background: #dbeafe; color: #1e40af; }
.tag-staff { background: #fef3c7; color: #92400e; }

.comment-text {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text);
    margin: 0;
}

.staff-reply .comment-text { color: var(--text-light); }

.comment-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 0.4rem;
    transition: color 0.15s;
}
.comment-reply-btn:hover { color: var(--primary); }
.comment-reply-btn svg { opacity: 0.7; }

/* Mobile */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.75rem; }
    .hero p { font-size: 1rem; }
    .articles-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
    .article-header h1 { font-size: 1.6rem; }
    .nav-toggle { display: flex; }
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg);
        flex-direction: column;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border);
        gap: 0;
    }
    .nav-links li { padding: 0.75rem 0; }
    .nav.nav-open .nav-links { display: flex; }
}
