/* ============================================================
   Keric's Space - Warm Paper Theme
   Inspired by classic personal blogs
   ============================================================ */

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

:root {
    --bg: #faf6f0;
    --bg-warm: #f5efe3;
    --text: #3a3226;
    --text-light: #6b5e4a;
    --text-muted: #9c8d70;
    --text-faint: #c4b9a6;
    --accent: #8b7355;
    --accent-light: #a88b6c;
    --border: #e8dcc8;
    --border-light: #f0e8d5;
    --white: #fdfaf5;
    --radius: 4px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-serif: Georgia, "Noto Serif SC", "STSong", "Times New Roman", serif;
    --max-width: 700px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(139,115,85,0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139,115,85,0.02) 0%, transparent 50%);
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-light); text-decoration: underline; }

.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 28px;
}

/* ============================================================
   HEADER — Centered, stacked layout
   ============================================================ */
.site-header {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 56px 0 40px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 48px;
}

.site-branding {
    margin-bottom: 20px;
}

.site-title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.3;
    color: var(--text);
    margin-bottom: 6px;
}
.site-title a { color: var(--text); }
.site-title a:hover { text-decoration: none; color: var(--accent); }

.site-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.01em;
    line-height: 1.5;
}

/* --- Navigation (centered below title) --- */
.site-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 28px;
    padding-top: 4px;
}
.site-nav a,
.site-nav button {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-muted);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s;
    position: relative;
}
.site-nav a::after,
.site-nav button::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0; right: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.2s;
}
.site-nav a:hover,
.site-nav a.active,
.site-nav button:hover {
    color: var(--accent);
    text-decoration: none;
}
.site-nav a:hover::after,
.site-nav a.active::after,
.site-nav button:hover::after {
    transform: scaleX(1);
}

/* login is a button in nav, styled like a link */
.site-nav .login-btn {
    font-size: 0.88rem;
    color: var(--text-muted);
}
.site-nav .login-btn:hover { color: var(--accent); }

/* --- Main Content --- */
.site-main {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 0 80px;
    flex: 1;
}

/* ============================================================
   POSTS — category-based listing
   ============================================================ */
.category-group {
    margin-bottom: 40px;
    padding: 20px 24px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(58,50,38,0.03);
}
.category-group:first-child { margin-top: 0; }

.category-name {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.category-name a { color: var(--text); }
.category-name a:hover { color: var(--accent); text-decoration: none; }

.category-count {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    position: relative;
    top: -1px;
}

.article-list {
    list-style: none;
    padding-left: 0;
}
.article-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    gap: 16px;
}
.article-list li a {
    color: var(--text);
    font-size: 0.93rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.article-list li a:hover { color: var(--accent); text-decoration: none; }
.article-list li:before {
    content: '— ';
    color: var(--border);
    margin-right: 2px;
}

.article-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-family: var(--font-sans);
}

/* Category page full list */
.article-list-full { margin-top: 0; }
.article-list-full li { padding: 8px 0; }

/* ============================================================
   SINGLE ARTICLE
   ============================================================ */
.single-article {
    background: var(--white);
    padding: 32px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(58,50,38,0.03);
}

.article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px dashed var(--border);
}

.article-title {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 10px;
    color: var(--text);
}

.article-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 14px;
    align-items: center;
}

.article-category a {
    color: var(--accent);
    font-size: 0.8rem;
}
.article-category a:hover { color: var(--accent-light); }

.article-body {
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text);
}
.article-body p { margin-bottom: 1.1em; }
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 {
    font-family: var(--font-serif);
    margin: 1.6em 0 0.7em;
    color: var(--text);
}
.article-body h2 { font-size: 1.25rem; }
.article-body h3 { font-size: 1.1rem; }
.article-body img {
    max-width: 100%;
    height: auto;
    margin: 1.1em 0;
    border-radius: 2px;
}
.article-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.4em 1em;
    margin: 1.1em 0;
    color: var(--text-light);
    font-style: italic;
    background: rgba(139,115,85,0.04);
}
.article-body pre {
    background: #f8f5ee;
    padding: 1em 1.2em;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.article-body code {
    background: #f8f5ee;
    padding: 1px 5px;
    font-size: 0.88em;
    border-radius: 2px;
    color: var(--accent);
}
.article-body pre code { background: none; padding: 0; color: var(--text); }
.article-body ul, .article-body ol { margin: 0.8em 0; padding-left: 1.6em; }
.article-body li { margin-bottom: 0.25em; }

/* ============================================================
   ABOUT PAGE (dynamic content)
   ============================================================ */
.page-content {
    background: var(--white);
    padding: 32px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(58,50,38,0.03);
}
.page-title {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    font-weight: 700;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border);
    color: var(--text);
}
.page-content .about-body {
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text);
}
.page-content .about-body p { margin-bottom: 1.1em; }
.page-content .about-body h2 { font-family: var(--font-serif); font-size: 1.2rem; margin: 1.5em 0 0.6em; color: var(--text); }
.page-content .about-body h3 { font-family: var(--font-serif); font-size: 1.05rem; margin: 1.3em 0 0.5em; color: var(--text); }
.page-content .about-body a { color: var(--accent); text-decoration: underline; }
.page-content hr {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 2em 0;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 20px 0 48px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(58,50,38,0.35);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--white);
    padding: 36px 32px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 4px 32px rgba(58,50,38,0.12);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 8px; right: 14px;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-box h2 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 400;
    margin-bottom: 24px;
    text-align: center;
    color: var(--text);
    letter-spacing: 0.02em;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.87rem;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(139,115,85,0.1);
}

.form-error {
    color: #c0392b;
    font-size: 0.82rem;
    margin-bottom: 10px;
    text-align: center;
}

.btn {
    display: inline-block;
    padding: 9px 22px;
    border-radius: var(--radius);
    font-size: 0.87rem;
    font-family: var(--font-sans);
    cursor: pointer;
    border: none;
    text-align: center;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--accent);
    color: var(--white);
    border: 1px solid var(--accent);
}
.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
    color: var(--white);
    text-decoration: none;
}
.btn-outline {
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text-light);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.btn-danger {
    background: #e74c3c;
    color: #fff;
    border: 1px solid #e74c3c;
}
.btn-danger:hover { background: #c0392b; border-color: #c0392b; color: #fff; text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; display: block; margin-bottom: 8px; }

.modal-links {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .site-header {
        padding: 36px 0 28px;
        margin-bottom: 32px;
    }
    .site-nav { gap: 20px; }
    .site-title { font-size: 1.5rem; }
    .site-subtitle { font-size: 0.8rem; }
    .article-title { font-size: 1.25rem; }
    .article-body { font-size: 0.9rem; }
    .single-article { padding: 20px; }
    .page-content { padding: 20px; }
    .category-group { padding: 16px 18px; }
}
