/* Light mode (default) and dark mode variables */
:root {
    /* Light theme colors */
    --background-color: #f7f9fc;
    --main-background: #fff;
    --text-color: #333;
    --heading-color: #394867;
    --border-color: #eaeaea;
    --link-color: #212A3E;
    --link-hover-color: #394867;
    --header-bg: linear-gradient(to right, #394867, #212A3E);
    --footer-bg: linear-gradient(to right, #394867, #212A3E);
    --border-highlight-color: #9ba4b4;
    --date-color: #6c757d;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Theme-aware inline code styles */
    --code-bg-inline: #f6f8fa; /* Was --code-bg */
    --code-text-inline: #24292e; /* Was --code-text */

    /* Static dark theme for code blocks (<pre>) */
    --code-block-bg: #2d2d2d;    /* Always dark */
    --code-block-text: #f8f8f2; /* Always light for default text in blocks */

    --button-bg: #e0e0e0;
    --button-hover: #d0d0d0;
}

/* Dark mode variables */
html[data-theme="dark"] {
    --background-color: #1a1a2e;
    --main-background: #16213e;
    --text-color: #e6e6e6;
    --heading-color: #9ba4b4;
    --border-color: #394867;
    --link-color: #9ba4b4;
    --link-hover-color: #e6e6e6;
    --header-bg: linear-gradient(to right, #0f3460, #0a1931);
    --footer-bg: linear-gradient(to right, #0f3460, #0a1931);
    --border-highlight-color: #4a5b8c;
    --date-color: #9ba4b4;
    --shadow-color: rgba(0, 0, 0, 0.3);

    /* Theme-aware inline code styles for dark mode */
    --code-bg-inline: #1e1e1e; /* Darker for inline code in dark theme */
    --code-text-inline: #d4d4d4; /* Lighter for inline code in dark theme */

    /* --code-block-bg and --code-block-text remain as defined in :root for consistency */

    --button-bg: #444;
    --button-hover: #555;
}

/* Apply theme variables */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: 80px; /* Adjust based on your header height */
}

header {
    background: var(--header-bg);
    color: #fff;
    padding: 1rem 0;
    text-align: center;
    box-shadow: 0 2px 5px var(--shadow-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.site-title a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
}

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

header.header-hidden {
    transform: translateY(-100%);
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
}

nav ul li {
    margin: 0 15px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Social links in header */
.social-links {
    display: flex;
    align-items: center;
}

.social-links a {
    color: #fff;
    font-size: 1.2rem;
    margin: 0 0.5rem;
    transition: color 0.3s ease;
}

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

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
}

#theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

#theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.light-icon {
    display: none;
}

.dark-icon {
    display: inline-block;
}

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

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

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 2rem 7rem 2rem;
    background-color: var(--main-background);
    box-shadow: 0 0 20px var(--shadow-color);
    min-height: calc(100vh - 200px);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

section {
    margin-bottom: 2.5rem;
}

h1 {
    color: var(--heading-color);
    border-bottom: 2px solid var(--border-highlight-color);
    padding-bottom: 0.5rem;
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}

h2, h3 {
    color: var(--heading-color);
    transition: color 0.3s ease;
}

h3 a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

h3 a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

article {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    transition: border-bottom-color 0.3s ease;
}

footer {
    background: var(--footer-bg);
    color: #fff;
    text-align: center;
    padding: 0.75rem 0;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-shadow: 0 -2px 5px var(--shadow-color);
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

footer.footer-hidden {
    transform: translateY(100%);
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Back to top button */
#back-to-top {
    background: var(--link-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#back-to-top:hover {
    background: var(--link-hover-color);
    transform: translateY(-3px);
}

/* Title and date container to improve layout */
.title-date-container {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
}

.title-date-container h3 {
    margin-right: 0.75rem;
    margin-bottom: 0.25rem;
}

.title-date-container .post-date {
    margin-top: 0;
    margin-left: 1rem; /* Increased spacing */
}

.post-date {
    color: var(--date-color);
    font-size: 0.9rem;
    transition: color 0.3s ease;
    display: inline-block; /* Keep it on the same line as the title when possible */
}

/* Single post title and date container */
article > .title-date-container {
    margin-bottom: 1.5rem;
}

article > .title-date-container h1 {
    margin-bottom: 0;
    margin-right: 1rem;
}

article > .title-date-container .post-date {
    font-size: 1rem;
    margin-left: 1rem;
}

/* Image and video styling */
.featured-image {
    margin: 1rem 0 2rem 0;
}

.featured-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.featured-video {
    margin: 1rem 0 2rem 0;
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.featured-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.post-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.post-header h3 {
    margin-right: 1rem; /* Add space between title and date */
    margin-bottom: 0;
}

.post-thumbnail {
    margin-right: 1.5rem;
    flex: 0 0 150px;
}

.post-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Code block styling */
pre {
    position: relative;
    background-color: var(--code-block-bg); /* ALWAYS DARK */
    padding: 1.5rem; /* Overall padding for the block */
    border-radius: 8px;
    overflow: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

/* General inline code style */
code {
    font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
    color: var(--code-text-inline); /* Theme-aware */
    background-color: var(--code-bg-inline); /* Theme-aware */
    padding: 0.2em 0.4em;
    margin: 0 0.2em;
    font-size: 85%; /* Standard size for inline code */
    border-radius: 3px;
    transition: background-color 0.3s ease, color 0.3s ease; /* Keep transition */
    outline: none; /* Keep outline none */
}

/* Code within <pre> blocks */
pre > code {
    font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace; /* Ensure font consistency */
    color: var(--code-block-text); /* ALWAYS LIGHT (default text within block) */
    background-color: transparent; /* No separate background for the code tag itself inside pre */
    padding: 0; /* Padding is on pre */
    margin: 0;
    font-size: 1em; /* Reset font size modification from general code tag */
    border-radius: 0; /* No border radius for the code tag itself if pre has it */
    display: block; /* Make it fill the pre */
    outline: none;
    /* transition is inherited or not strictly needed here if pre handles it */
}


code[contenteditable="true"] {
    cursor: text;
}

/* Language label */
.language-label {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-family: 'Consolas', 'Monaco', 'Andale Mono', monospace;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    z-index: 10;
    /* Theme-specific styles will be added below */
}

/* Copy button */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none; /* Default to no border, can be added per theme */
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    z-index: 10;
    /* Theme-specific styles will be added below */
}

/* Theme-specific styles for language label and copy button */
html:not([data-theme="dark"]) .language-label {
    background-color: #e1e4e8; /* Lighter gray, GitHub-like */
    color: #24292e; /* Dark text */
}
html:not([data-theme="dark"]) .copy-button {
    background-color: #f0f0f0; /* Slightly off-white */
    color: #24292e; /* Dark text */
    border: 1px solid #d1d5da; /* Subtle border */
}
html:not([data-theme="dark"]) .copy-button:hover {
    background-color: #e1e4e8;
}

html[data-theme="dark"] .language-label {
    background-color: var(--border-highlight-color);
    color: #fff; /* Explicitly white for contrast */
}
html[data-theme="dark"] .copy-button {
    background-color: var(--button-bg);
    color: var(--text-color);
    border: 1px solid #444d56; /* Darker border for dark mode */
}
html[data-theme="dark"] .copy-button:hover {
    background-color: var(--button-hover);
}


/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .post-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .post-thumbnail {
        margin-right: 0;
        margin-bottom: 1rem;
        flex-basis: 100%;
    }
}

/* Custom styling for links in the Projects section */
#projects ul {
    list-style: none; /* Optional: remove bullets if not already done */
    padding-left: 0;  /* Optional: remove default padding if using custom layout */
}

#projects ul li {
    margin-bottom: 0.5rem; /* Add some space between project links */
}

#projects ul li a {
    color: var(--link-color);
    text-decoration: none; /* Remove underline by default */
    font-weight: 500; /* Slightly bolder if desired, adjust as needed */
    transition: color 0.3s ease, text-decoration 0.3s ease;
    padding: 0.2rem 0; /* Add a little vertical padding if needed */
    border-bottom: 1px solid transparent; /* Prepare for a subtle border effect on hover */
}

#projects ul li a:hover,
#projects ul li a:focus { /* Added :focus for accessibility */
    color: var(--link-hover-color);
    text-decoration: underline; /* Underline on hover/focus for clarity */
    /* Alternative hover: border-bottom: 1px solid var(--link-hover-color); */
}

/* If you want a more "block" or "button-like" appearance, you could add: */
/*
#projects ul li a {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--main-background); // or a subtle custom background
}

#projects ul li a:hover {
    background-color: var(--background-color); // or a subtle hover background
    border-color: var(--link-hover-color);
    text-decoration: none; // Often no underline if it looks like a button
}
*/
