
:root {
    /* Light theme colors */
    --background-color: #ffffff;
    --text-color: #242424;
    --primary-color: #0a66c2; /* A Medium-like blue */
    --secondary-text-color: #6b6b6b;
    --border-color: #e0e0e0;
    --card-background: #ffffff;
    --code-background: #f6f8fa;
    --code-text-color: #24292e;
    --highlight-color: #fce83a; /* Subtle yellow for highlights */

    /* Shadows */
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body[data-theme="dark"] {
    /* Dark theme colors */
    --background-color: #1a1a1a;
    --text-color: #e6e6e6;
    --primary-color: #4da6ff; /* Lighter blue for dark theme */
    --secondary-text-color: #b0b0b0;
    --border-color: #333333;
    --card-background: #2a2a2a;
    --code-background: #2d2d2d;
    --code-text-color: #f8f8f2;
    --highlight-color: #c9b300; /* Darker yellow for highlights */

    /* Shadows (can be subtle or removed in dark theme) */
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

html {
    font-size: 100%; /* Base for rem units */
    scroll-behavior: smooth;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container for max-width content */
.container {
    max-width: 768px; /* Medium-like article width */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Header */
.site-header {
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
    box-shadow: var(--shadow-small);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-logo:hover {
    color: var(--primary-color);
}

.logo-icon {
    font-size: 1.5rem;
}

.theme-toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.05);
}

body[data-theme="dark"] .theme-toggle-button:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.theme-toggle-button .icon-moon {
    display: none;
}

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

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

.theme-toggle-button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Main Content */
main {
    flex-grow: 1;
    padding: 2rem 0;
}

.article-container {
    background-color: var(--card-background);
    padding: 2rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-small);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Article Header */
.article-header {
    margin-bottom: 2.5rem;
    text-align: left;
}

#article-title {
    font-size: 2.25rem;
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 800;
    color: var(--text-color);
}

.article-meta {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-meta .author {
    font-weight: 600;
    color: var(--text-color);
}

/* Article Body */
.article-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    line-height: 1.3;
    color: var(--text-color);
}

.article-body h3 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    color: var(--text-color);
}

.article-body p {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--text-color);
}

.article-body strong {
    font-weight: 700;
}

.article-body em {
    font-style: italic;
}

.article-body a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-body a:hover,
.article-body a:focus {
    text-decoration: underline;
    color: var(--primary-color); /* Ensure consistent hover color */
}

.article-body ul,
.article-body ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    list-style-position: outside;
    font-size: 1.1rem;
    color: var(--text-color);
}

.article-body ul li,
.article-body ol li {
    margin-bottom: 0.5rem;
}

.article-body ul li:last-child,
.article-body ol li:last-child {
    margin-bottom: 0;
}

/* Code Blocks */
.article-body pre {
    background-color: var(--code-background);
    color: var(--code-text-color);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.4;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.article-body pre code {
    display: block; /* Ensures code takes up full pre width */
    white-space: pre-wrap; /* Allows long lines to wrap */
    word-break: break-all; /* Breaks words if necessary */
}

.article-body :not(pre) > code {
    background-color: var(--code-background);
    color: var(--code-text-color);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.9em;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Footer */
.site-footer {
    margin-top: 3rem;
    padding: 2rem 0;
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
    color: var(--secondary-text-color);
    font-size: 0.9rem;
    text-align: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-footer .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--secondary-text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover,
.footer-links a:focus {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
    main {
        padding: 3rem 0;
    }

    .article-container {
        padding: 3rem;
    }

    #article-title {
        font-size: 2.75rem;
    }

    .article-body h2 {
        font-size: 2rem;
    }

    .article-body h3 {
        font-size: 1.5rem;
    }

    .site-footer .container {
        flex-direction: row;
        justify-content: space-between;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 800px;
    }
}
