/* CSS Variables for Light/Dark Theme */
:root {
    --bg-primary: #FAF9F6;
    --bg-secondary: #f5f5f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --link-color: #7851A9;
    --link-hover: #9860dc;
    --border-color: #dee2e6;
    --code-bg: #f8f9fa;
    --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #e9ecef;
        --text-secondary: #adb5bd;
        --link-color: #6B3FA0;
        --link-hover: #7851A9;
        --border-color: #495057;
        --code-bg: #343a40;
        --shadow: rgba(0, 0, 0, 0.3);
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}


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

header hgroup {
    margin-bottom: 0;
    flex: 0 0 auto;
}

header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

/* Adjust header for logo */
header hgroup h1 {
    line-height: 1;
    display: flex;
    align-items: center;
}

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

header h1 a:hover {
    color: var(--link-color);
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Logo Styles */
.logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.site-logo {
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.site-logo:hover {
    opacity: 0.8;
}

/* Search Container */
.search-container {
    width: 100%;
    max-width: 500px;
    margin: 1rem 0;
    position: relative;
    order: 3;
    z-index: 1002;
}


#search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--link-color);
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-top: 0.5rem;
    max-height: 400px;
    width: 500px;
    max-width: calc(100vw - 40px);
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); /* Stronger shadow */
    z-index: 10000; /* Even higher z-index */
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.search-result-item:hover {
    background-color: var(--bg-secondary);
}

.search-result-item h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.search-result-item h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.search-result-item h3 a:hover {
    color: var(--link-color);
}

.search-result-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.search-result-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Navigation - Right aligned */
nav {
    margin-top: 0;
    margin-left: auto;
}

nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

nav li {
    display: inline-block;
}

nav a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

nav a:hover {
    background-color: var(--bg-primary);
    color: var(--link-color);
}

nav a[aria-current="page"] {
    background-color: var(--link-color);
    color: #ffffff;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    margin-left: auto;
}

@media (max-width: 768px) {
 .site-logo {
        max-height: 40px;
    }

    .menu-toggle {
        display: block;
    }

    header .container {
        position: relative;
    }

    nav {
        flex-basis: 100%;
        width: 100%;
        margin-top: 1rem;
    }

    nav ul {
        display: none;
        flex-direction: column;
        width: 100%;
    }

    nav ul.active {
        display: flex;
    }

    nav a {
        width: 100%;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .search-container {
        max-width: 100%;
    }
}

/* Main Content */
main {
    flex: 1 0 auto;
    padding: 2rem 0;
    position: relative;
    z-index: 1;
}

/* Article Styles */
article {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    position: relative; /* Add this */
    z-index: 1; /* Add this */
}

article h2 {
    margin-bottom: 0.5rem;
}

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

article h2 a:hover {
    color: var(--link-color);
}

.entry-content {
    margin-top: 1rem;
}

.post-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.post-info time {
    font-style: italic;
}

/* Links */
a {
    color: var(--link-color);
    transition: color 0.2s ease;
    text-decoration: none;
}

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

/* Code Blocks */
code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background: none;
    padding: 0;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Footer */
footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
    text-align: center;
    flex-shrink: 0;
}

footer address {
    font-style: normal;
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
}

.pagination a:hover {
    background-color: var(--bg-secondary);
}

.pagination .current {
    background-color: var(--link-color);
    color: #ffffff;
    border-color: var(--link-color);
}

/* Responsive Typography */
@media (max-width: 768px) {
    body {
        font-size: 0.95rem;
    }

    .container {
        padding: 0 15px;
    }

    main {
        padding: 1rem 0;
    }

    article {
        padding: 1rem;
    }
}
