/* Base variables for light / dark themes */
:root {
    --bg-body: #f5f5f5;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --border-soft: #e5e5e5;
    --border-card: #e7e7e7;
    --text-main: #222222;
    --text-muted: #777777;
    --text-softer: #999999;
    --link: #2563eb;
    --link-soft: rgba(37, 99, 235, 0.25);
    --shadow-soft: 0 8px 18px rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-header: #020617;
    --bg-card: #020617;
    --bg-sidebar: #020617;
    --border-soft: #1f2937;
    --border-card: #1f2937;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --text-softer: #6b7280;
    --link: #60a5fa;
    --link-soft: rgba(96, 165, 250, 0.4);
    --shadow-soft: 0 10px 22px rgba(15, 23, 42, 0.8);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-body);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.7;
    color: var(--text-main);
}

/* Header */

.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.site-header-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.site-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.site-title {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.site-title a {
    color: var(--text-main);
    text-decoration: none;
}

.site-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Header right: nav, search, toggle */

.site-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    white-space: nowrap;
}

.header-nav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.header-nav a:hover {
    border-color: var(--border-soft);
    color: var(--text-main);
}

.header-nav a.active {
    border-color: var(--link-soft);
    background: var(--link-soft);
    color: var(--link);
}

.header-search {
    position: relative;
}

.header-search input {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    font-size: 0.85rem;
    min-width: 150px;
    background: var(--bg-body);
    color: var(--text-main);
}

.header-search input:focus {
    outline: none;
    border-color: var(--link-soft);
}

/* Theme toggle */

.theme-toggle {
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    cursor: pointer;
    font-size: 0.9rem;
}

.theme-toggle:hover {
    box-shadow: var(--shadow-soft);
}

/* Page container */

.page {
    max-width: 1080px;
    margin: 28px auto 40px auto;
    padding: 0 16px;
}

/* Layout with sidebar */

.layout {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 22px;
}

/* Content column */

.content-column {
    min-width: 0;
}

.page-heading {
    margin: 0 0 14px 0;
    font-size: 1.4rem;
    font-weight: 600;
}

/* Post list */

.post-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card {
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border-card);
    padding: 16px 17px 14px 17px;
    transition: border 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
}

.post-card:hover {
    border-color: var(--border-soft);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

/* Generic safety for any image inside a card */
.post-card img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    object-fit: cover;
}

/* Card thumbnails */

.post-card-thumb-link {
    display: block;
    margin: -4px -4px 8px -4px;
    border-radius: 12px;
    overflow: hidden;
}

.post-card-thumb {
    width: 100%;
    display: block;
    max-height: 210px;
    object-fit: cover;
}

.post-card-title {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.post-card-title a {
    text-decoration: none;
    color: var(--text-main);
}

.post-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.post-card-excerpt {
    font-size: 0.93rem;
    color: var(--text-main);
}

/* Single post */

.post-header {
    margin-bottom: 14px;
}

.post-title {
    margin: 0 0 8px 0;
    font-size: 1.8rem;
    font-weight: 650;
}

.post-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Single post hero image */

.post-hero {
    margin: 14px 0 8px 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-card);
}

.post-hero img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: cover;
}

/* Breadcrumbs */

.breadcrumbs {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.breadcrumbs a {
    text-decoration: none;
    color: var(--text-muted);
}

.breadcrumbs a:hover {
    color: var(--link);
}

.breadcrumbs-sep {
    margin: 0 4px;
}

.breadcrumbs-current {
    color: var(--text-softer);
}

.post-tags {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.post-tags span {
    margin-right: 6px;
}

/* Article body */

.post-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-card);
    padding: 22px 20px;
    font-size: 0.98rem;
    color: var(--text-main);
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin-top: 1.4em;
    margin-bottom: 0.4em;
    line-height: 1.3;
}

.post-content p {
    margin: 0 0 1em 0;
}

.post-content a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid var(--link-soft);
}

.post-content a:hover {
    border-bottom-color: rgba(37, 99, 235, 0.55);
}

.post-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.86em;
    background: rgba(148, 163, 184, 0.25);
    padding: 2px 4px;
    border-radius: 4px;
}

/* Any image inside article body – keep responsive */
.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px auto;
    border-radius: 10px;
}

/* Author box */

.author-box {
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-card);
}

.author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--link-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    color: var(--link);
}

.author-meta {
    font-size: 0.9rem;
}

.author-name {
    font-weight: 600;
    margin-bottom: 3px;
}

.author-bio {
    margin: 0;
    color: var(--text-muted);
}

/* Related posts */

.related-posts {
    margin-top: 22px;
}

.related-posts h2 {
    font-size: 1rem;
    margin: 0 0 8px 0;
}

.related-posts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.related-posts li + li {
    margin-top: 4px;
}

.related-posts a {
    text-decoration: none;
    font-size: 0.9rem;
    color: var(--link);
}

/* Sidebar */

.sidebar {
    background: var(--bg-sidebar);
    border-radius: 16px;
    border: 1px solid var(--border-card);
    padding: 16px 16px 18px 16px;
    align-self: start;
    position: sticky;
    top: 88px;
}

.sidebar-section + .sidebar-section {
    margin-top: 18px;
}

.sidebar-section h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.sidebar-section p {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-main);
}

.sidebar-section form input {
    width: 100%;
    padding: 6px 9px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    font-size: 0.86rem;
    background: var(--bg-body);
    color: var(--text-main);
}

.sidebar-section form input:focus {
    outline: none;
    border-color: var(--link-soft);
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-list li + li {
    margin-top: 4px;
}

.sidebar-list a {
    text-decoration: none;
    font-size: 0.9rem;
    color: var(--text-main);
    display: inline-flex;
    justify-content: space-between;
    width: 100%;
}

.sidebar-list a:hover {
    color: var(--link);
}

.sidebar-count {
    font-size: 0.78rem;
    color: var(--text-softer);
}

/* Tag cloud */

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-cloud a {
    text-decoration: none;
    color: var(--link);
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--link-soft);
}

/* Load more */

.load-more {
    margin-top: 22px;
    text-align: center;
}

.load-more a {
    display: inline-block;
    padding: 9px 22px;
    border-radius: 999px;
    background: var(--link);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.94rem;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
}

.load-more a:hover {
    opacity: 0.94;
}

/* Footer */

.site-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-softer);
    padding: 18px 0 22px 0;
}

/* Responsive */

@media (max-width: 960px) {
    .site-header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .site-header-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .header-nav {
        overflow-x: auto;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        margin-top: 20px;
    }
}

@media (max-width: 640px) {
    .site-title {
        font-size: 1.25rem;
    }

    .post-title {
        font-size: 1.45rem;
    }

    .header-search input {
        min-width: 130px;
    }

    /* Better horizontal scroll nav on mobile */
    .header-nav {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }

    .header-nav::-webkit-scrollbar {
        display: none;
    }

    /* Ensure header stays above content */
    .site-header {
        z-index: 9999;
    }

    /* Slightly more breathing room below header */
    .page {
        margin-top: 20px;
    }

    /* Limit card image height on small screens */
    .post-card img,
    .post-card-thumb {
        max-height: 200px;
        object-fit: cover;
    }

    /* Also cap hero image height a bit on phones */
    .post-hero img {
        max-height: 260px;
    }
}
