/* CSS Variables for theming */
:root {
    --bg-color: #fafafa;
    --text-color: #1a1a1a;
    --text-secondary: #666;
    --link-color: #1a1a1a;
    --link-hover: #555;
    --border-color: #e0e0e0;
    --code-bg: #f4f4f4;
    --nav-bg: #fafafa;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e8e8e8;
    --text-secondary: #a0a0a0;
    --link-color: #e8e8e8;
    --link-hover: #b0b0b0;
    --border-color: #333;
    --code-bg: #2a2a2a;
    --nav-bg: #1a1a1a;
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: 'EB Garamond', Georgia, serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
header {
    margin-bottom: 3rem;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.nav-name {
    font-size: 1.1rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-color);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--text-color);
}

/* Theme toggle button */
#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

#theme-toggle:hover {
    color: var(--text-color);
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: inline;
}

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

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

/* Main content */
main {
    flex: 1;
}

/* Post styles */
article h1 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.post-header {
    margin-bottom: 2rem;
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.post-meta time {
    color: var(--text-secondary);
}

.view-count {
    color: var(--text-secondary);
}

.post-header time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.post-content h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin: 2rem 0 1rem;
}

.post-content h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 1.5rem 0 0.75rem;
}

.post-content p {
    margin-bottom: 1.25rem;
}

.post-content a {
    color: var(--text-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-content a:hover {
    color: var(--link-hover);
}

.post-content ul, .post-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.post-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background-color: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.post-content pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

.post-content img.profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    float: right;
    margin: 0 0 1rem 1.5rem;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
}

.post-content th, .post-content td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.post-content th {
    background-color: var(--code-bg);
}

/* Blog list */
.post-list h1 {
    margin-bottom: 2rem;
}

.posts {
    list-style: none;
}

.posts li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.posts li.has-thumbnail {
    align-items: flex-start;
    gap: 1rem;
}

.post-thumbnail {
    flex-shrink: 0;
}

.post-thumbnail img {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.post-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.has-thumbnail .post-info {
    justify-content: space-between;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
}

.posts li:last-child {
    border-bottom: none;
}

.posts a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.1rem;
}

.posts a:hover {
    text-decoration: underline;
}

.post-date {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Contact form */
.contact-page h1 {
    margin-bottom: 0.75rem;
}

.contact-page > p {
    margin-bottom: 2rem;
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 500px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.05rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--text-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group textarea:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.form-group textarea {
    resize: vertical;
    min-height: 180px;
    line-height: 1.6;
}

.form-group .error {
    color: #c0392b;
    font-size: 0.85rem;
}

.submit-btn {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.05rem;
    font-weight: 500;
    padding: 0.85rem 2rem;
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    align-self: flex-start;
    margin-top: 0.5rem;
}

.submit-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(0);
}

.success-message {
    color: #27ae60;
    font-size: 1.1rem;
    padding: 1.5rem;
    background-color: rgba(39, 174, 96, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

/* My Feed page */
.feed-page h1 {
    margin-bottom: 0.5rem;
}

.feed-page > p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

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

.feed-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.feed-item:last-child {
    border-bottom: none;
}

.feed-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.feed-title {
    font-size: 1.1rem;
    color: var(--text-color);
    text-decoration: none;
    line-height: 1.4;
}

.feed-title:hover {
    text-decoration: underline;
}

.feed-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.feed-source {
    font-weight: 500;
}

.feed-date {
    color: var(--text-secondary);
}

.feed-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.25rem;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

footer p {
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.footer-links a:hover {
    color: var(--text-color);
    border-color: var(--text-secondary);
    background-color: var(--code-bg);
}

/* Responsive */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .container {
        padding: 1.5rem 1rem;
    }

    article h1 {
        font-size: 1.75rem;
    }

    .posts li {
        flex-direction: column;
        gap: 0.25rem;
    }

    .posts li.has-thumbnail {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .post-thumbnail img {
        width: 80px;
        height: 54px;
    }

    .has-thumbnail .post-info {
        flex-direction: column;
    }

    footer {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}
