/* --- General & Variables --- */
:root {
    --bg-color: #f4f4f5;
    --card-bg-color: #ffffff;
    --text-color: #18181b;
    --text-muted: #52525b;
    --link-color: #007bff;
    --border-color: #e4e4e7;
    --social-bg: #fafafa;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
    --bg-color: #18181b;
    --card-bg-color: #27272a;
    --text-color: #fafafa;
    --text-muted: #a1a1aa;
    --link-color: #60a5fa;
    --border-color: #3f3f46;
    --social-bg: #3f3f46;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

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

a:hover {
    text-decoration: underline;
}


/* --- Generic Card --- */
.card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    color: var(--link-color);
    border-color: var(--link-color);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.theme-toggle .moon-icon {
    fill: currentColor;
    stroke: none;
}

/* Show sun in light mode, moon in dark mode */
.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Blog post: header with back link and theme toggle */
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.post-header .back-link {
    margin-bottom: 0;
}

.post-header .theme-toggle {
    position: static;
}

/* --- Homepage Specific: Profile & About --- */
.profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 25px;
}

.profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-info .name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.profile-info h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
}

.profile .social-links {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--social-bg);
}

.profile .social-links a {
    color: var(--text-muted);
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.profile .social-links a:hover {
    color: var(--link-color);
}

.profile .social-links svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.profile-info .tagline {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.profile-info .intro {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.profile-info p {
    margin: 4px 0;
    font-size: 1rem;
    color: var(--text-muted);
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
}

/* --- Homepage: Post Cards --- */
.post-card {
    display: block;
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 20px;
    margin-bottom: 20px;
    text-decoration: none;
    transition: border-color 0.2s;
}

.post-card:hover {
    border-color: var(--link-color);
    text-decoration: none;
}

.post-card h2 {
    margin: 0 0 12px 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    border-bottom: none;
    padding-bottom: 0;
}

.post-card .post-excerpt {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card .post-meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* --- Blog Page: Post List --- */
.blog-post {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.blog-post h2 {
    margin-top: 0;
    margin-bottom: 5px;
    border-bottom: none;
}

.blog-post h2 a {
    color: var(--text-color);
}

.blog-post .post-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.blog-post p {
    margin-top: 0;
}

/* --- Single Post Page: Content --- */
.post-content {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 35px;
    line-height: 1.7;
}

.post-content h1 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 2.2rem;
    line-height: 1.3;
}

.post-content .post-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.post-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5em;
}

.post-content blockquote {
    border-left: 4px solid var(--link-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: var(--social-bg);
}

.post-content code {
    background-color: var(--social-bg);
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    border-radius: 6px;
}

.post-content {
    position: relative;
}

.post-content h2 {
    font-size: 1.4rem;
    margin-top: 2em;
    margin-bottom: 0.8em;
    border-bottom: none;
    padding-bottom: 0;
}

.post-content ul {
    margin: 1em 0 1.5em 0;
    padding-left: 1.5em;
}

.post-content li {
    font-size: 1.1rem;
    margin-bottom: 0.5em;
}

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

.back-link {
    display: inline-block;
    margin-bottom: 25px;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--link-color);
    text-decoration: none;
}

/* --- Blog Page Layout (sidebar fixed, topbar scrolls) --- */
.blog-sidebar {
    position: fixed;
    left: max(20px, calc(50% - 360px - 180px));
    top: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    z-index: 100;
}

.blog-sidebar .title-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.blog-sidebar .blog-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    flex-shrink: 0;
}

.blog-sidebar .blog-title:hover {
    text-decoration: none;
    color: var(--link-color);
}

.blog-sidebar .theme-toggle {
    position: static;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}

.blog-sidebar .theme-toggle:hover {
    color: var(--link-color);
}

.blog-sidebar .theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.blog-sidebar .theme-toggle .moon-icon {
    fill: currentColor;
    stroke: none;
}

.blog-sidebar .sidebar-home {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
}

.blog-sidebar .sidebar-home:hover {
    color: var(--link-color);
    text-decoration: none;
}

.blog-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
}

.blog-nav a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
}

.blog-nav a:hover {
    color: var(--link-color);
    text-decoration: none;
}

.blog-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 20px 20px;
}

.blog-layout .site-footer {
    margin-top: 50px;
}

.blog-article {
    line-height: 1.7;
    font-family: Georgia, "Times New Roman", serif;
}

.blog-article h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    line-height: 1.3;
    font-family: var(--font-family);
}

.blog-article .post-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
    font-family: var(--font-family);
}

.blog-article p {
    font-size: 1.05rem;
    margin-bottom: 1.4em;
}

.blog-article h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    padding-top: 0.2em;
    padding-bottom: 0.2em;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-family);
}

.blog-article p + ul {
    margin-top: -1em;
}

.blog-article ul {
    margin: 0 0 1.5em 0;
    padding-left: 1.5em;
}

.blog-article li {
    font-size: 1.05rem;
    margin-bottom: 0.5em;
}

.blog-article strong {
    color: var(--text-color);
}

.blog-article blockquote {
    border-left: 4px solid var(--link-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: var(--social-bg);
}

.blog-article code {
    background-color: var(--social-bg);
    padding: .2em .4em;
    font-size: 85%;
    border-radius: 6px;
}

/* --- Share Bar --- */
.share-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 20px;
    margin-top: 40px;
    background-color: var(--social-bg);
    border-radius: 8px;
}

.share-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background-color: var(--text-color);
    color: var(--card-bg-color);
    transition: transform 0.2s, opacity 0.2s;
}

.share-btn:hover {
    transform: scale(1.1);
    opacity: 0.85;
    text-decoration: none;
}

.share-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* CSS Tooltips for instant display */
.share-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    margin-bottom: 8px;
    background-color: var(--text-color);
    color: var(--card-bg-color);
    font-family: var(--font-family);
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

.share-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* --- Site Footer --- */
.site-footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 60px;
}

.site-footer p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Responsive Design --- */
@media (max-width: 1100px) {
    .blog-sidebar {
        position: static;
        max-width: 720px;
        margin: 0 auto;
        padding: 20px 20px 0 20px;
    }
    .blog-topbar {
        padding-top: 10px;
    }
}

@media (max-width: 600px) {
    .profile {
        flex-direction: column;
        text-align: center;
    }
    header {
        flex-direction: column;
        gap: 15px;
    }
    .post-content {
        padding: 20px;
    }
    .blog-article h1 {
        font-size: 1.6rem;
    }
    .blog-sidebar {
        padding: 15px 15px 0 15px;
    }
    .blog-sidebar .blog-title,
    .blog-nav a {
        font-size: 1.1rem;
    }
    .blog-topbar {
        padding: 10px 15px;
    }
}
