/* === Fonts === */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/jetbrains-mono-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --serif: Georgia, "Times New Roman", Times, serif;
    --mono: 'JetBrains Mono', "SF Mono", Consolas, monospace;
    --width: 660px;
    --text: #333;
    --text-strong: #1a1a1a;
    --muted: #666;
    --light: #999;
    --rule: #ddd;
    --bg: #fff;
    --code-bg: #f5f5f5;
    --mint: #3eb489;
    --mint-light: #e6f7f0;
}

body {
    font-family: var(--serif);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text-strong); }
a:hover { color: var(--mint); }

/* === Header === */
header {
    border-bottom: 2px solid var(--mint);
    padding: 0.8rem 1.5rem;
}
nav {
    max-width: var(--width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-family: var(--sans);
    font-size: 1.3rem;
    font-weight: 800;
    text-decoration: none;
    color: var(--text-strong);
    letter-spacing: -0.5px;
}
.logo-accent { color: var(--mint); }
/* === Search === */
.search-bar {
    background: var(--code-bg);
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--rule);
}
.search-bar-inner {
    max-width: var(--width);
    margin: 0 auto;
}
.search-wrapper { position: relative; }
.search-input {
    font-family: var(--sans);
    font-size: 0.85rem;
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    border: 2px solid transparent;
    border-radius: 8px;
    width: 100%;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--light); }
.search-input:focus {
    border-color: var(--mint);
    box-shadow: 0 2px 12px rgba(62, 180, 137, 0.15);
}
.search-wrapper::before {
    content: "";
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--light);
    border-radius: 50%;
    pointer-events: none;
    transition: border-color 0.2s;
}
.search-wrapper::after {
    content: "";
    position: absolute;
    left: 1.7rem;
    top: calc(50% + 5px);
    width: 2px;
    height: 6px;
    background: var(--light);
    transform: rotate(-45deg);
    pointer-events: none;
    transition: background 0.2s;
}
.search-wrapper:focus-within::before { border-color: var(--mint); }
.search-wrapper:focus-within::after { background: var(--mint); }
.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
}
.search-item {
    display: block;
    padding: 0.7rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--code-bg);
    transition: background 0.15s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--mint-light); }
.search-title {
    display: block;
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-strong);
}
.search-meta {
    display: block;
    font-family: var(--sans);
    font-size: 0.7rem;
    color: var(--light);
    margin-top: 0.15rem;
}
.search-empty {
    padding: 1rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--light);
    text-align: center;
}

main { max-width: var(--width); margin: 0 auto; padding: 2rem 0; }

footer {
    border-top: 1px solid var(--rule);
    text-align: center;
    padding: 1.5rem;
    font-family: var(--sans);
    color: var(--light);
    font-size: 0.75rem;
}
footer a { color: var(--light); }
footer a:hover { color: var(--mint); }

/* === Featured Article === */
.featured {
    padding: 2rem 0;
    margin-bottom: 1.5rem;
}
.featured-link {
    display: block;
    text-decoration: none;
    color: var(--text);
}
.featured-link:hover h1 { color: var(--mint); }
.featured-label {
    font-family: var(--sans);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--mint);
}
.featured h1 {
    font-family: var(--sans);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-strong);
    letter-spacing: -0.5px;
    margin: 0.4rem 0;
    transition: color 0.2s;
}
.featured p {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

/* === Category Sections === */
.category-section { margin: 2rem 0; }
.category-section h2 {
    font-family: var(--sans);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--light);
    margin-bottom: 0.6rem;
    font-weight: 600;
    padding-bottom: 0.4rem;
}

.article-grid { display: grid; gap: 0; }
.article-card {
    display: block;
    padding: 0.8rem 0;
    color: var(--text);
    text-decoration: none;
}
.article-card:hover h3 { color: var(--mint); }
.article-card h3 {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 0.1rem;
    transition: color 0.2s;
}
.article-card p { color: var(--muted); font-size: 0.85rem; }
.card-date {
    font-family: var(--sans);
    font-size: 0.7rem;
    color: var(--light);
}
.card-tags { display: flex; gap: 0.35rem; margin-top: 0.4rem; flex-wrap: wrap; }

/* === Tags === */
.tag {
    font-family: var(--sans);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-strong);
    background: var(--code-bg);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}
.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* === Article Page === */
.article-header {
    margin-bottom: 1.5rem;
    padding: 0 0 1rem;
    border: none;
    border-bottom: 1px solid var(--rule);
}
.article-header h1 {
    font-family: var(--sans);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-strong);
    letter-spacing: -0.5px;
    margin: 0.3rem 0;
}
.article-meta {
    font-family: var(--sans);
    font-size: 0.72rem;
    color: var(--light);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.category-badge {
    font-family: var(--sans);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--mint);
}

/* === Answer Body === */
.answer-body {
    font-family: var(--serif);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
}
.answer-text { margin: 1rem 0; }
.answer-text h2,
.answer-text h3 {
    font-family: var(--sans);
    font-weight: 700;
    color: var(--text-strong);
    margin-top: 1.8rem;
    margin-bottom: 0.4rem;
}
.answer-text h2 { font-size: 1.15rem; }
.answer-text h3 { font-size: 0.95rem; }
.answer-text p {
    margin-bottom: 0.8rem;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}
.answer-text p:last-child { margin-bottom: 0; }



/* === Code === */
pre {
    background: #282a36;
    border-radius: 8px;
    margin-top: 0.7rem;
    overflow-x: auto;
}
pre code,
pre code.hljs {
    display: block;
    background: #282a36;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.6;
    padding: 1rem 1.2rem;
    border: none;
    border-radius: 0;
}
code { font-family: var(--mono); font-size: 0.88em; }
p code, li code, .answer-text code {
    background: var(--code-bg);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
    word-break: break-word;
}

/* === Related Articles === */
.related {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--mint);
}
.related h2 {
    font-family: var(--sans);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--mint);
    font-weight: 700;
    margin-bottom: 0.8rem;
}
.related-grid { display: grid; gap: 0; }
.related-card {
    display: block;
    padding: 0.7rem 0;
    text-decoration: none;
    color: var(--text);
}
.related-card:hover h3 { color: var(--mint); }
.related-card h3 {
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-strong);
    transition: color 0.2s;
}

/* === Ads === */
.ad-container {
    margin: 2rem 0;
}
.ad-container:empty,
.ad-container:not(:has(ins[data-ad-status="filled"])) {
    display: none;
}

/* === 404 === */
.not-found {
    text-align: center;
    padding: 4rem 0;
}
.not-found h1 {
    font-family: var(--sans);
    font-size: 4rem;
    font-weight: 800;
    color: var(--mint);
}
.not-found p {
    font-family: var(--sans);
    color: var(--muted);
    font-size: 1.1rem;
    margin: 0.5rem 0 1.5rem;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--light);
}
.back-link:hover { color: var(--mint); }

/* === Responsive === */
@media (max-width: 600px) {
    main { padding: 1.5rem 1rem; }
    .search-bar { padding: 0.7rem 1rem; }
    .featured h1 { font-size: 1.5rem; }
    .article-header h1 { font-size: 1.4rem; }
}
