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

:root {
    --bg: #eee8e1;
    --bg-card: #eee8e1;
    --text: #5c5248;
    --text-muted: #a09688;
    --primary: #c4a3a3;
    --primary-hover: #b08989;
    --primary-light: #e8d8d8;
    --white: #ffffff;
    --shadow-dark: #cac5bc;
    --shadow-light: #ffffff;
    --shadow-pressed-dark: #d4cfc7;
    --shadow-pressed-light: #faf7f3;
    --radius: 18px;
    --radius-sm: 12px;
    --max-width: 1100px;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #d4cdc4, #c8c0b6);
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(135deg, #c8c0b6, #b8afa4); }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover { color: var(--primary-hover); }

img {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Neumorphic Mixins ===== */
.nm-raised {
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    transition: box-shadow var(--transition), transform var(--transition);
}
.nm-raised:hover {
    box-shadow: 10px 10px 20px var(--shadow-dark), -10px -10px 20px var(--shadow-light);
    transform: translateY(-3px);
}
.nm-inset {
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}
.nm-flat {
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: 2px 2px 4px var(--shadow-dark), -2px -2px 4px var(--shadow-light);
}

/* ===== Header ===== */
.site-header {
    background: var(--bg);
    padding: 40px 0 0;
    text-align: center;
}

.site-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: 2px;
}

.site-title a {
    color: var(--text);
    transition: color var(--transition);
}
.site-title a:hover { color: var(--primary); }

.site-tagline {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.site-nav {
    display: inline-flex;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 24px;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.site-nav a {
    font-size: 0.88rem;
    color: var(--text-muted);
    padding: 8px 24px;
    border-radius: 12px;
    font-weight: 500;
    transition: all var(--transition);
}

.site-nav a:hover {
    color: var(--text);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.site-nav a.active {
    color: var(--primary);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

/* ===== Main Layout ===== */
main.container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 36px;
    padding-top: 16px;
    padding-bottom: 48px;
    flex: 1;
}

/* ===== Post List ===== */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 80px 0;
    font-size: 1.1rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.post-card {
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    padding: 28px 34px;
    transition: box-shadow var(--transition), transform var(--transition);
    animation: fadeInUp 0.5s ease both;
    position: relative;
    overflow: hidden;
}

.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    border-radius: 4px 0 0 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.post-card:hover { box-shadow: 12px 12px 24px var(--shadow-dark), -12px -12px 24px var(--shadow-light); transform: translateY(-4px); }
.post-card:hover::before { opacity: 1; }

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.12s; }
.post-card:nth-child(3) { animation-delay: 0.19s; }
.post-card:nth-child(4) { animation-delay: 0.26s; }
.post-card:nth-child(5) { animation-delay: 0.33s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.post-card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.post-card-title a {
    color: var(--text);
    transition: color var(--transition);
}
.post-card-title a:hover { color: var(--primary); }

.post-card-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.post-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.post-card-excerpt {
    color: var(--text-muted);
    font-size: 0.93rem;
    margin-bottom: 16px;
    line-height: 1.7;
}

.post-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    background: var(--bg-card);
    color: var(--primary);
    font-size: 0.78rem;
    padding: 5px 14px;
    border-radius: 16px;
    font-weight: 500;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all var(--transition);
    cursor: pointer;
}

.tag:hover {
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    color: var(--primary-hover);
    transform: scale(0.96);
}

/* ===== Sidebar ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.widget {
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    padding: 24px;
    transition: box-shadow var(--transition);
}

.widget h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    position: relative;
    color: var(--text);
}

.widget h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 36px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.widget p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.archive-list {
    list-style: none;
}

.archive-list li {
    padding: 8px 0;
    font-size: 0.9rem;
}

.archive-list li + li {
    border-top: 1px solid var(--shadow-dark);
}

.archive-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    transition: all var(--transition);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.archive-list a:hover {
    color: var(--primary);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

.archive-list .count {
    color: var(--text-muted);
    font-size: 0.82rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 600;
}

/* ===== Back Link ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all var(--transition);
}
.back-link:hover {
    color: var(--primary);
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
}

/* ===== Post Full Page ===== */
.post-full {
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    padding: 42px 48px;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.5s ease both;
}

.post-full-header {
    margin-bottom: 36px;
    padding-bottom: 22px;
    border-bottom: none;
    position: relative;
}

.post-full-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-light), transparent);
    border-radius: 2px;
}

.post-full-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 14px;
    line-height: 1.3;
    letter-spacing: 1px;
}

.post-full-meta {
    color: var(--text-muted);
    font-size: 0.88rem;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.post-content { color: var(--text); }

.post-content h2 {
    font-size: 1.45rem;
    margin: 32px 0 14px;
    font-weight: 700;
}

.post-content h3 {
    font-size: 1.15rem;
    margin: 24px 0 10px;
    font-weight: 600;
    color: var(--primary);
}

.post-content p {
    margin-bottom: 18px;
    line-height: 1.85;
}

.post-content ul, .post-content ol {
    margin-bottom: 18px;
    padding-left: 26px;
}

.post-content li {
    margin-bottom: 8px;
}

.post-content code {
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.87em;
    color: var(--primary-hover);
    box-shadow: inset 1px 1px 2px var(--shadow-dark), inset -1px -1px 2px var(--shadow-light);
}

.post-content pre {
    background: #3b3648;
    color: #e8e2f0;
    padding: 20px 24px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 20px;
    line-height: 1.6;
    box-shadow: inset 4px 4px 8px rgba(0,0,0,0.25), inset -2px -2px 4px rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
}

.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    box-shadow: none;
    font-size: 0.9em;
}

.post-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 14px 20px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    color: var(--text-muted);
}

.post-content blockquote blockquote {
    margin: 12px 0 0;
    background: transparent;
    box-shadow: none;
}

.post-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
}

.post-content th {
    background: var(--primary-light);
    color: var(--primary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.post-content td {
    padding: 10px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--shadow-dark);
    background: var(--bg-card);
}

.post-content tr:last-child td {
    border-bottom: none;
}

.post-content hr {
    border: none;
    height: 2px;
    margin: 32px 0;
    background: linear-gradient(90deg, transparent, var(--shadow-dark), transparent);
    border-radius: 1px;
}

/* ===== Footer ===== */
.site-footer {
    background: var(--bg);
    padding: 24px 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
    border-top: 1px solid var(--shadow-dark);
}

.site-footer a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    main.container {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 16px 20px 40px;
    }

    .sidebar {
        order: 1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }

    .widget:last-child {
        grid-column: 1 / -1;
    }

    .post-full {
        padding: 32px 28px;
    }

    .post-full-title {
        font-size: 1.7rem;
    }

    .post-card {
        padding: 24px 24px;
    }

    .post-card-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 640px) {
    .site-title {
        font-size: 1.6rem;
    }

    .site-nav a {
        padding: 8px 16px;
        font-size: 0.82rem;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .post-full {
        padding: 24px 18px;
        border-radius: var(--radius-sm);
    }

    .post-full-title {
        font-size: 1.4rem;
    }

    .post-full-meta {
        font-size: 0.8rem;
        gap: 12px;
    }

    .post-card {
        padding: 20px 18px;
    }

    .post-card-title {
        font-size: 1.1rem;
    }

    .post-card-meta {
        font-size: 0.78rem;
        gap: 12px;
    }

    .post-card-excerpt {
        font-size: 0.85rem;
    }

    .post-content h2 {
        font-size: 1.25rem;
    }

    .post-content h3 {
        font-size: 1.05rem;
    }

    .post-content pre {
        padding: 14px 16px;
        font-size: 0.85em;
    }

    .post-content table {
        font-size: 0.82rem;
    }

    .post-content th,
    .post-content td {
        padding: 8px 10px;
    }

    .site-footer {
        padding: 18px 0;
        font-size: 0.78rem;
    }
}
