/* General reset */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Hack', 'Courier New', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    line-height: 1.6;
    background-color: #f4f4f4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Container for the layout */
.container {
    display: flex;
    flex-direction: row-reverse;
    /* Place the sidebar on the right */
    flex: 1;
    /* Take remaining space after header */
    overflow: hidden;
    /* Prevent container from scrolling */
    width: 100%;
    /* Full width */
}

/* Navigation container */
.nav-container {
    overflow-y: auto;
    /* Scroll if content overflows */
    width: 250px;
    /* Fixed width */
    flex-shrink: 0;
    /* Prevent shrinking */
    flex-grow: 0;
    /* Prevent growing */
    position: relative;
    /* Ensure it stays in place */
}

.nav-container.hidden {
    display: none;
    /* Hide the navigation bar */
}

/* Toggle button */
#toggle-nav {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #35424a;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    text-align: center;
    padding: 0;
    font-size: 1.2rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#toggle-nav:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode #toggle-nav {
    background-color: #2d2d2d;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

body.dark-mode #toggle-nav:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* Sidebar navigation */
.sidebar {
    flex: 1;
    overflow-y: auto;
    /* Scroll if content overflows */
    padding: 20px 15px;
    /* Add padding to the sidebar container */
}

/* Tag filter section in sidebar */
.tag-filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ddd;
}

body.dark-mode .tag-filter-section {
    border-bottom-color: #444;
}

.tag-filter-section h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tag-filter-section h3:hover {
    background-color: #f4f4f4;
}

body.dark-mode .tag-filter-section h3 {
    color: #e0e0e0;
}

body.dark-mode .tag-filter-section h3:hover {
    background-color: #2d2d2d;
}

.tag-filter-section h3::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.3s;
    opacity: 0.6;
}

.tag-filter-section.collapsed h3::after {
    transform: rotate(-90deg);
}

#tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-height: 250px;
    overflow-y: auto;
    padding: 0.25rem 0;
    transition: max-height 0.3s ease;
}

.tag-filter-section.collapsed #tag-list {
    display: none;
}

.tag-filter-btn {
    padding: 0.3rem 0.75rem;
    background: transparent;
    border: 1.5px solid #35424a;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
    color: #35424a;
    white-space: nowrap;
    font-weight: 500;
}

body.dark-mode .tag-filter-btn {
    border-color: #64b5f6;
    color: #64b5f6;
}

.tag-filter-btn:hover {
    background: #35424a;
    color: white;
    transform: translateY(-1px);
}

body.dark-mode .tag-filter-btn:hover {
    background: #64b5f6;
    color: #1a1a1a;
}

.tag-filter-btn.active {
    background: #35424a;
    color: white;
    border-color: #35424a;
    font-weight: 600;
}

body.dark-mode .tag-filter-btn.active {
    background: #64b5f6;
    color: #1a1a1a;
    border-color: #64b5f6;
}

/* Posts section in sidebar */
.posts-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: #333;
}

body.dark-mode .posts-section h3 {
    color: #e0e0e0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    padding-left: 0;
    /* Remove default left padding */
}

.sidebar ul li {
    margin-bottom: 10px;
}

.sidebar ul li a {
    text-decoration: none;
    color: #333;
    font-weight: bold;
    display: block;
    padding: 8px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.sidebar ul li a:hover {
    background-color: #ddd;
}

.sidebar .hidden {
    display: none;
    /* Hide the sidebar */
}

/* Main content */
main {
    flex-grow: 1;
    /* Take up the remaining space */
    padding: 40px 60px;
    padding-bottom: 60px;
    /* Extra bottom padding to ensure full scroll */
    overflow-y: auto;
    overflow-x: hidden;
    /* Scroll if content overflows */
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

main h1 {
    font-size: 2rem;
    line-height: 1.3;
}

/* Make emojis in titles smaller and consistent */
main h1::first-letter,
main h1>*:first-child {
    font-size: 0.7em;
}

main h2 {
    margin-top: 0;
}

header {
    background: #35424a;
    color: #ffffff;
    padding: 10px 20px;
    text-align: center;
    flex-shrink: 0;
    /* Prevent header from shrinking */
}

header h1 {
    margin: 0;
}

/* Logo styles */
header .site-logo {
    width: 100%;
    height: auto;
    max-width: 600px;
    display: block;
    margin: 0 auto;
}

header picture {
    display: block;
    width: 100%;
}

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

nav {
    margin: 20px 0;
}

nav a {
    color: #ffffff;
    text-decoration: none;
    padding: 10px 15px;
}

nav a:hover {
    background: #e8491d;
}

article {
    background: #ffffff;
    padding: 20px;
    margin: 20px 0;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Code block styling */
pre {
    background-color: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin: 16px 0;
}

pre code {
    background-color: transparent;
    padding: 0;
    border: none;
    font-size: 0.9em;
    line-height: 1.45;
    font-family: 'Courier New', Courier, monospace;
}

code {
    background-color: #f6f8fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Courier New', Courier, monospace;
}

/* Ensure syntax highlighting overrides work */
.hljs {
    background-color: inherit !important;
    padding: 0 !important;
}

footer {
    text-align: center;
    padding: 10px 0;
    background: #35424a;
    color: #ffffff;
    position: relative;
    bottom: 0;
    width: 100%;
}

/* Dark mode toggle button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 70px;
    background-color: #35424a;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .theme-toggle {
    background-color: #2d2d2d;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

body.dark-mode .theme-toggle:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* Dark mode styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode main {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode a {
    color: #6db3f2;
}

body.dark-mode a:hover {
    color: #9ecfff;
}

body.dark-mode code {
    background-color: #2d2d2d;
    color: #f8f8f2;
}

body.dark-mode pre {
    background-color: #2d2d2d;
    border-color: #404040;
}

body.dark-mode article {
    background-color: #252525;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

body.dark-mode .sidebar ul li a {
    color: #e0e0e0;
}

body.dark-mode .sidebar ul li a:hover {
    background-color: #2d2d2d;
}

body.dark-mode #toggle-nav {
    background-color: #252525;
    color: #e0e0e0;
}

body.dark-mode #toggle-nav:hover {
    color: #6db3f2;
}

/* Image styling */
main img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
}

body.dark-mode main img {
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* Figure and caption support */
main figure {
    margin: 20px 0;
    text-align: center;
}

main figcaption {
    font-style: italic;
    font-size: 0.9rem;
    color: #666;
    margin-top: 8px;
}

body.dark-mode main figcaption {
    color: #999;
}

/* Mobile responsive styles */
@media screen and (max-width: 768px) {

    /* Left-align header title to avoid button overlap */
    header {
        text-align: left;
        padding: 10px 20px;
    }

    header h1 {
        font-size: 1.5rem;
        padding-right: 100px;
        /* Make room for buttons on the right */
    }

    /* Reduce main content padding on mobile */
    main {
        padding: 20px;
        padding-bottom: 40px;
    }

    /* Make navigation overlay on mobile */
    .nav-container {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        background-color: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        z-index: 999;
        overflow-y: auto;
    }

    /* Dark mode navigation background */
    body.dark-mode .nav-container {
        background-color: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
    }

    /* Add padding to sidebar content on mobile */
    .sidebar {
        padding: 10px 15px;
        padding-top: 60px;
        /* Extra top padding to avoid buttons */
    }

    /* Ensure no extra left padding on ul */
    .sidebar ul {
        padding-left: 0;
    }
}

/* Extra small mobile devices */
@media screen and (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
        padding-right: 100px;
    }

    #toggle-nav {
        right: 10px;
        top: 15px;
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .theme-toggle {
        right: 55px;
        top: 15px;
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    main {
        padding: 15px;
    }
}

/* Loading dots animation */
.loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #666;
    animation: pulse 1.4s infinite ease-in-out;
}

body.dark-mode .loading-dots span {
    background-color: #aaa;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes pulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Commit History Styles */
.commit-history {
    margin: 2rem 0;
}

.commit-loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #35424a;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

body.dark-mode .spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #ffffff;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.commit-error {
    text-align: center;
    padding: 2rem;
    color: #d9534f;
    background-color: rgba(217, 83, 79, 0.1);
    border-radius: 8px;
    margin: 1rem 0;
}

.repo-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ddd;
}

body.dark-mode .repo-header {
    border-bottom-color: #444;
}

.repo-link {
    font-size: 0.9rem;
    color: #35424a;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

body.dark-mode .repo-link {
    color: #64b5f6;
}

.repo-link:hover {
    text-decoration: underline;
}

.commits-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.commit-item {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

body.dark-mode .commit-item {
    background: #2d2d2d;
    border-color: #444;
}

.commit-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark-mode .commit-item:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.commit-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.commit-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.commit-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #35424a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

body.dark-mode .commit-avatar-placeholder {
    background: #64b5f6;
    color: #1a1a1a;
}

.commit-info {
    flex: 1;
    min-width: 0;
}

.commit-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.commit-title a {
    color: #333;
    text-decoration: none;
}

body.dark-mode .commit-title a {
    color: #e0e0e0;
}

.commit-title a:hover {
    color: #35424a;
    text-decoration: underline;
}

body.dark-mode .commit-title a:hover {
    color: #64b5f6;
}

.commit-description {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    line-height: 1.5;
}

body.dark-mode .commit-description {
    color: #aaa;
}

.commit-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #666;
    flex-wrap: wrap;
    align-items: center;
}

body.dark-mode .commit-meta {
    color: #aaa;
}

.commit-separator {
    color: #999;
}

.commit-sha {
    background: #f4f4f4;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

body.dark-mode .commit-sha {
    background: #1a1a1a;
    color: #64b5f6;
}

.commit-pagination {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

body.dark-mode .commit-pagination {
    border-top-color: #444;
}

.commit-pagination button {
    padding: 0.75rem 1.5rem;
    background: #35424a;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.3s, transform 0.2s;
}

body.dark-mode .commit-pagination button {
    background: #64b5f6;
    color: #1a1a1a;
}

.commit-pagination button:hover {
    background: #2c353d;
    transform: translateY(-2px);
}

body.dark-mode .commit-pagination button:hover {
    background: #42a5f5;
}

.commit-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.page-info {
    font-size: 0.9rem;
    color: #666;
}

body.dark-mode .page-info {
    color: #aaa;
}

.no-commits {
    text-align: center;
    padding: 3rem;
    color: #666;
}

body.dark-mode .no-commits {
    color: #aaa;
}

/* Reactions Widget Styles */
.reactions-container {
    margin-top: 3rem;
    margin-bottom: 2rem;
    padding: 2rem 0;
    padding-bottom: 3rem;
    border-top: 2px solid #e0e0e0;
}

body.dark-mode .reactions-container {
    border-top-color: #444;
}

.reactions-widget {
    max-width: 600px;
}

.reactions-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #333;
}

body.dark-mode .reactions-title {
    color: #e0e0e0;
}

.reactions-emojis {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.reaction-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    min-width: 60px;
}

.reaction-button:hover {
    background-color: #e8f4f8;
    border-color: #4a9eff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.reaction-button.reacted {
    background-color: #4a9eff;
    border-color: #2980d9;
    color: #000;
}

.reaction-button .emoji {
    font-size: 1rem;
    line-height: 1;
}

.reaction-button .count {
    font-size: 0.9rem;
    font-weight: bold;
    color: #666;
    min-width: 20px;
    text-align: center;
}

.reaction-button.reacted .count {
    color: #000;
}

body.dark-mode .reaction-button {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode .reaction-button:hover {
    background-color: #1a3a52;
    border-color: #4a9eff;
}

body.dark-mode .reaction-button .count {
    color: #aaa;
}

body.dark-mode .reaction-button.reacted {
    background-color: #4a9eff;
    border-color: #2980d9;
}

body.dark-mode .reaction-button.reacted .count {
    color: #000;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .reactions-emojis {
        gap: 0.5rem;
    }

    .reaction-button {
        padding: 0.4rem 0.8rem;
        font-size: 1rem;
        min-width: 50px;
    }

    .reaction-button .emoji {
        font-size: 1.3rem;
    }

    .reaction-button .count {
        font-size: 0.8rem;
    }

    .logo svg,
    header svg,
    svg.site-logo {
        width: 100%;
        height: auto;
        max-width: 1152px;
        display: block;
    }
}