/* View transitions for navigation */
@view-transition {
    navigation: auto;
}

::view-transition-old(root) {
    animation: fade-out 0.25s ease-in-out;
}

::view-transition-new(root) {
    animation: fade-in 0.25s ease-in-out;
}

@keyframes fade-out {
    from { 
        opacity: 1;
    }
    to { 
        opacity: 0;
    }
}

@keyframes fade-in {
    from { 
        opacity: 0;
    }
    to { 
        opacity: 1;
    }
}

/* Smooth transitions for interactive elements */
a, button {
    transition: all 0.2s ease-out;
}

/* CSS Variables for theming */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-code: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-color: #e5e7eb;
    --link-color: #059669;
    --link-hover: #047857;
    --accent-color: #059669;
    --nav-link: #6b7280;
    --nav-link-hover: #111827;
    --code-bg: #f3f4f6;
    --code-text: #374151;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-code: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #334155;
    --link-color: #34d399;
    --link-hover: #6ee7b7;
    --accent-color: #34d399;
    --nav-link: #94a3b8;
    --nav-link-hover: #f1f5f9;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
}

/* 1. General resets and typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family:
        ui-monospace,
        SFMono-Regular,
        "SF Mono",
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        "Courier New",
        monospace;
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container to center content and control width */
.container {
    max-width: 736px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* 2. Navigation and footer */
nav {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 1rem 0;
    margin-bottom: 3rem;
}

/* Header and nav combined layout */
.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.site-title {
    flex: 0 0 auto;
}

.site-title h1 {
    margin: 0;
    font-size: 1.75rem !important;
    font-weight: 900;
    white-space: nowrap;
    letter-spacing: -0.025em;
}

.site-title-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.site-nav {
    flex: 1 1 auto;
    display: flex;
    justify-content: flex-end;
}

.nav-links {
    display: flex;
    gap: 2rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.nav-links a {
    color: var(--nav-link);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.25rem 0;
    transition: color 0.15s ease;
    position: relative;
}

/* Hover: subtle color change */
.nav-links a:hover {
    color: var(--nav-link-hover);
    text-decoration: none;
}

/* Active navigation link */
.nav-links a.active {
    color: var(--text-primary);
    font-weight: 600;
    position: relative;
}

/* Active link underline indicator */
.nav-links a.active::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: 1px;
}

/* For narrow screens, stack nav links vertically */
@media only screen and (max-width: 767px) {
    .header-nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-title {
        margin-bottom: 0.5rem;
    }

    .site-nav {
        width: 100%;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .nav-links a {
        display: block;
        margin: 0;
        padding: 0.5rem;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    footer {
        text-align: center;
    }
}

/* 3. Headers */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    line-height: 1.25;
}

h1 {
    font-size: 1.875rem;
    margin: 1rem 0 1.5rem;
    line-height: 1.2;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

h3 {
    font-size: 1.125rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

/* 4. Content blocks, paragraphs, etc. */
main {
    flex: 1; /* push footer to bottom for shorter pages */
    background-color: transparent;
    padding: 0;
    width: 100%;
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

/* 5. Code blocks or inline code styling */
pre {
    background-color: var(--bg-code);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 6px;
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", monospace;
    margin: 1.5rem 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    line-height: 1.5;
    font-size: 0.875rem;
}

/* Override Chroma syntax highlighting background */
.chroma {
    background-color: var(--bg-code) !important;
    color: var(--text-primary) !important;
    padding: 0;
    margin: 0;
}

/* Ensure the actual code container uses our theme colors */
pre.chroma {
    background-color: var(--bg-code) !important;
    padding: 1rem;
}

/* Syntax highlighting theme overrides for light/dark mode compatibility */
[data-theme="light"] .chroma .k { color: #d73a49; } /* Keywords */
[data-theme="light"] .chroma .s { color: #032f62; } /* Strings */
[data-theme="light"] .chroma .c { color: #6a737d; } /* Comments */
[data-theme="light"] .chroma .nf { color: #6f42c1; } /* Functions */
[data-theme="light"] .chroma .m { color: #005cc5; } /* Numbers */
[data-theme="light"] .chroma .o { color: #d73a49; } /* Operators */

[data-theme="dark"] .chroma .k { color: #f97583; } /* Keywords */
[data-theme="dark"] .chroma .s { color: #9ecbff; } /* Strings */
[data-theme="dark"] .chroma .c { color: #6a737d; } /* Comments */
[data-theme="dark"] .chroma .nf { color: #b392f0; } /* Functions */
[data-theme="dark"] .chroma .m { color: #79b8ff; } /* Numbers */
[data-theme="dark"] .chroma .o { color: #f97583; } /* Operators */

code {
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", monospace;
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.875em;
}

/* 6. Project containers */
.project-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.project-list {
    border: 1px solid var(--border-color);
    padding: 1.5rem 1.75rem;
    background-color: var(--bg-secondary);
    border-radius: 6px;
}

.project-list ul {
    list-style-type: none;
    padding-left: 0;
}

.project-list li {
    margin: 1rem 0;
}

.project-list a {
    color: #3182ce;
    text-decoration: none;
    transition: all 0.2s ease;
}

.project-list a:hover {
    color: #2b6cb0;
    text-decoration: underline;
}

.project {
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    background-color: var(--bg-primary);
    margin: 1.25rem 0;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.projects {
    margin: 2rem 0;
}

/* Subtle hover effect on the entire box */
.project:hover {
    border-color: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

/* 7. The .oss grid from opensource.html */
.oss {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.oss article {
    border: 1px solid var(--border-color);
    padding: 1.1rem;
    box-sizing: border-box;
    background-color: var(--bg-primary);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.oss article:hover {
    border-color: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

.oss article h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.oss article h3 a {
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.oss article h3 a:hover {
    color: #3182ce;
    text-decoration: none;
}

/* 8. Footer */
footer {
    margin-top: 1.5rem;
    padding: 0.5rem 0 1.5rem 0;
    text-align: left;
    border-top: 1px solid var(--border-color);
}

/* Float image styles */
.float-left {
    float: left;
    margin: 0 1.5rem 1rem 0;
    max-width: 200px;
    height: auto;
}

.float-right {
    float: right;
    margin: 0 0 1rem 1.5rem;
    max-width: 200px;
    height: auto;
}

footer small {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* 9. Lists */
ul, ol {
    margin-bottom: 1.25rem;
}

/* Unordered lists */
ul {
    list-style-type: none;
    padding-left: 1.25rem;
}

/* Ordered lists */
ol {
    list-style-type: decimal;
    padding-left: 2rem;
}

/* List items */
li {
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 0.5rem;
}

/* Bullet points for unordered lists */
ul > li::before {
    content: "•";
    color: var(--accent-color);
    position: absolute;
    left: -0.6rem;
    top: 0;
    font-size: 1em;
}

/* Nested lists */
ul ul, ol ol, ul ol, ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Override bullet for post list items */
.post-list {
    padding-left: 0;
}

.post-list li {
    padding-left: 0;
}

/* 10. Links - global override to keep coloring consistent */
a,
a:visited {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover,
a:focus {
    color: var(--link-hover);
    text-decoration: underline;
}
a:active {
    color: var(--link-hover);
}

/* Post title links should use link colors */
article h3 a,
.post-list article h3 a,
.post-list h3 a {
    color: var(--link-color) !important;
}

article h3 a:hover,
.post-list article h3 a:hover,
.post-list h3 a:hover {
    color: var(--link-hover) !important;
    text-decoration: none;
}

/* Post page title (h2) should also use link color */
article header h2,
article h2:first-child,
main article > header h2 {
    color: var(--link-color);
}

/* 11. Responsive adjustments for larger screens */
@media only screen and (min-width: 768px) {
    .project-container {
        flex-direction: row;
    }
    .project-list {
        width: 25%;
        margin-right: 2rem;
    }
    .project {
        flex: 1;
    }
}

/* 12. Additional styling for better reading experience */
blockquote {
    margin: 1.5rem 0;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent-color);
    background-color: var(--bg-secondary);
    font-style: italic;
    color: var(--text-secondary);
}

hr {
    border: 0;
    height: 1px;
    background-color: var(--border-color);
    margin: 3rem 0;
}

/* View all link styling */
.view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--link-color);
    font-weight: 500;
    margin-top: 1rem;
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.view-all::after {
    content: "";
    transition: transform 0.15s ease;
}

.view-all:hover::after {
    transform: translateX(4px);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 6px;
}

/* Aligned link shortcode styles */
.aligned-link {
    margin: -0.5rem 0 1.5rem 0;
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.aligned-link.align-left {
    text-align: left;
}

.aligned-link.align-right {
    text-align: right;
}

.aligned-link.align-center {
    text-align: center;
}

/* Post metadata styling */
.post-meta {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.post-meta span {
    color: var(--text-tertiary);
}

/* Post title styling */
.post-title {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
    font-weight: 500;
}

/* Post list styling */
.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list li {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

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

.post-list li::before {
    display: none;
}

/* Fix post title colors in dark mode */
.post-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.post-excerpt {
    color: var(--text-tertiary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 0.5rem;
    display: block;
}

/* Profile/Intro section styling */
.profile-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
    margin-top: 2rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-image {
    flex-shrink: 0;
}

.profile-image img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0;
}

.profile-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 600;
    margin: 0;
}

.profile-content {
    flex: 1;
    padding-top: 0.5rem;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.profile-header h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    color: var(--text-tertiary);
    transition: color 0.15s ease;
}

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

/* Fix social links text that shouldn't be visible */
.social-links a {
    text-decoration: none;
}

.social-links a:hover {
    text-decoration: none;
}

.social-links svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 640px) {
    .profile-section {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .profile-image {
        margin: 0 auto;
    }
    
    .profile-header {
        justify-content: center;
    }
    
    .social-links {
        justify-content: center;
    }
}

/* Tags styling */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 1.2rem 0;
}

.tag {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 16px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.tag:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

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

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Hide the opposite theme icon */
[data-theme="light"] .dark-icon {
    display: none;
}

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

/* Default: hide dark icon on light theme */
.dark-icon {
    display: none;
}

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

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

/* Ensure nav links align properly */
.nav-links {
    align-items: center;
}
