body {
    font-family: 'Manrope', sans-serif;
    margin: 0;
    background-color: #121212; /* Dark background */
    color: #e0e0e0; /* Light text */
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.light-mode {
    background-color: #fff; /* Light background */
    color: #333; /* Dark text */
}

header {
    border-bottom: 1px solid #333;
}

body.light-mode header {
    border-bottom: 1px solid #eaeaea;
}

nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem 2rem;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    justify-self: start;
}

.logo a {
    text-decoration: none;
    color: #e0e0e0;
}

body.light-mode .logo a {
    color: #333;
}

/* Hamburger menu button */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #e0e0e0;
    margin: 5px 0;
    transition: 0.3s;
    transform-origin: center;
}

body.light-mode .hamburger span {
    background-color: #333;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Navigation menu container */
.nav-menu {
    display: contents; /* On desktop, let grid handle positioning */
}

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

nav ul li {
    margin: 0 1rem;
}

nav ul li:first-child {
    margin-left: 0;
}

nav ul li:last-child {
    margin-right: 0;
}

nav ul li a {
    text-decoration: none;
    color: #e0e0e0;
    text-transform: uppercase;
    position: relative;
    padding-bottom: 5px;
    font-weight: bold;
    font-size: 1.1rem;
}

nav ul li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    display: block;
    margin-top: 5px;
    right: 0;
    background: #FF8C00;
    transition: width 0.3s ease;
    -webkit-transition: width 0.3s ease;
}

body.light-mode nav ul li a::after {
    background: #FF8C00;
}

nav ul li a:hover::after,
nav ul li a.active::after {
    width: 100%;
    left: 0;
    background: #FF8C00;
}

body.light-mode nav ul li a:hover::after,
body.light-mode nav ul li a.active::after {
    background: #FF8C00;
}

body.light-mode nav ul li a {
    color: #333;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex-grow: 1;
}

.hero {
    text-align: center;
    padding: 0.1rem 0 4rem 0;  /* Reduced top padding from 4rem to 2rem */
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    color: #aaa;
}

body.light-mode .hero p {
    color: #666;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-self: end;
}

/* Search button */
#search-btn {
    background: none;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    transition: color 0.3s ease;
}

#search-btn:hover {
    color: #FF8C00;
}

body.light-mode #search-btn {
    color: #333;
}

body.light-mode #search-btn:hover {
    color: #FF8C00;
}

#logout-btn {
    background: none;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
}

body.light-mode #logout-btn {
    color: #333;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 40px;
}

.theme-switch input {
    display:none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
}

.slider:before {
    background-color: #fff;
    bottom: 3px;
    content: "";
    height: 18px;
    left: 3px;
    position: absolute;
    transition: .4s;
    width: 18px;
}

input:checked + .slider {
    background-color: #FF8C00;
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

footer {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid #333;
}

body.light-mode footer {
    border-top: 1px solid #eaeaea;
}

.social-icons a {
    color: #e0e0e0;
    margin: 0 1rem;
    font-size: 1.5rem;
}

body.light-mode .social-icons a {
    color: #333;
}

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

#add-post-btn {
    font-size: 2rem;
    background: none;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
}

body.light-mode #add-post-btn {
    color: #333;
}

.modal {
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #1e1e1e;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
}

body.light-mode .modal-content {
    background-color: #fefefe;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: #e0e0e0;
    text-decoration: none;
    cursor: pointer;
}

body.light-mode .close-btn:hover,
body.light-mode .close-btn:focus {
    color: #000;
}


.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    border: 1px solid #333;
    border-radius: 5px;
}

.login-container h1 {
    text-align: center;
}

.login-container input {
    width: 100%;
    padding: 10px;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

.login-container button {
    width: 100%;
    padding: 10px;
    background-color: #FF8C00;
    color: white;
    border: none;
    cursor: pointer;
}

/* Grid Layout for Posts */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    column-gap: 2rem;
    row-gap: 3.5rem;
    margin-top: 2rem;
    width: 100%;
}

@media (max-width: 1400px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .posts-grid {
        grid-template-columns: 1fr;
    }
}

/* Post Card Styles */
.post-card {
    background-color: #1e1e1e;
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

body.light-mode .post-card {
    background-color: #f9f9f9;
    border: 1px solid #eaeaea;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 140, 0, 0.2);
}

.post-title {
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.post-title a,
.post-title a:link,
.post-title a:visited {
    color: #FF8C00 !important;
    text-decoration: none;
    transition: color 0.3s ease;
}

.post-title a:hover,
.post-title a:active {
    color: #ff6600 !important;
}

body.light-mode .post-title a,
body.light-mode .post-title a:link,
body.light-mode .post-title a:visited {
    color: #FF8C00 !important;
}

body.light-mode .post-title a:hover,
body.light-mode .post-title a:active {
    color: #ff6600 !important;
}

.post-meta {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.post-summary {
    color: #aaa;
    line-height: 1.6;
    margin-bottom: 1rem;
    flex-grow: 1;
}

body.light-mode .post-summary {
    color: #666;
}

.read-more,
.read-more:link,
.read-more:visited {
    color: #FF8C00 !important;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    margin-top: auto;
    transition: transform 0.3s ease, color 0.3s ease;
}

.read-more:hover,
.read-more:active {
    color: #ff6600 !important;
    transform: translateX(5px);
}

body.light-mode .read-more,
body.light-mode .read-more:link,
body.light-mode .read-more:visited {
    color: #FF8C00 !important;
}

body.light-mode .read-more:hover,
body.light-mode .read-more:active {
    color: #ff6600 !important;
}

/* Back Button */
.back-button {
    margin-bottom: 2rem;
}

.back-button a {
    color: #FF8C00;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.back-button a:hover {
    transform: translateX(-5px);
}

/* Home page content styles */
.home-content {
    max-width: 1200px;
    margin: 1rem auto 3rem;  /* Reduced top margin from 3rem to 1rem */
    padding: 0 2rem;
    line-height: 1.7;
}

.home-content h2 {
    color: #FF8C00;
    margin: 3rem auto 1.5rem;
    font-size: 2rem;
    text-align: center;
    display: inline-block;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    border-bottom: 2px solid #FF8C00;
    padding-bottom: 0.5rem;
}

/* Special styling for the first h2 in home-content to reduce gap from hero section */
.home-content h2:first-child {
    margin-top: 0;  /* Remove top margin for first h2 (About Me) */
}

.home-content h3 {
    color: #e0e0e0;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    text-align: left;
}

body.light-mode .home-content h3 {
    color: #333;
}

.home-content p {
    margin-bottom: 1.25rem;
    text-align: left;
}

.home-content ul {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
    text-align: left;
}

.home-content li {
    margin-bottom: 0.75rem;
    text-align: left;
}

.home-content strong {
    color: #FF8C00;
}

.home-content a {
    color: #FF8C00;
    text-decoration: none;
    transition: color 0.3s ease;
}

.home-content a:hover {
    color: #ff6600;
    text-decoration: underline;
}

.home-content hr {
    border: none;
    border-top: 1px solid #333;
    margin: 2rem 0;
}

body.light-mode .home-content hr {
    border-top: 1px solid #eaeaea;
}

.home-content em {
    color: #aaa;
    font-style: italic;
}

body.light-mode .home-content em {
    color: #666;
}

/* Recent posts section */
.recent-posts {
    max-width: 1400px;
    margin: 4rem auto 2rem;
    padding: 0 2rem;
}

.recent-posts h2 {
    color: #FF8C00;
    margin-bottom: 2rem;
    font-size: 2rem;
    text-align: center;
}

.recent-posts .posts-grid {
    margin-top: 2rem;
}

.post-section {
    color: #FF8C00;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
}

/* Single post styles */
.single-post {
    max-width: 800px;
    margin: 0 auto;
}

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

.post-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.post-content {
    line-height: 1.7;
    margin-bottom: 3rem;
}

.post-content h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

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

.post-content pre {
    background-color: #1e1e1e;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

body.light-mode .post-content pre {
    background-color: #f5f5f5;
}

.post-content code {
    background-color: #1e1e1e;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

body.light-mode .post-content code {
    background-color: #f5f5f5;
}

.post-content pre code {
    background-color: transparent;
    padding: 0;
}

.post-content blockquote {
    border-left: 4px solid #FF8C00;
    padding-left: 1rem;
    margin-left: 0;
    font-style: italic;
    color: #aaa;
}

body.light-mode .post-content blockquote {
    color: #666;
}

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

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

.post-footer {
    border-top: 1px solid #333;
    padding-top: 2rem;
    margin-top: 3rem;
}

body.light-mode .post-footer {
    border-top: 1px solid #eaeaea;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
}

.post-navigation a {
    color: #FF8C00;
    text-decoration: none;
}

.post-navigation a:hover {
    text-decoration: underline;
}

.prev-post {
    margin-right: auto;
}

.next-post {
    margin-left: auto;
}

/* Mobile Navigation Styles */
@media (max-width: 768px) {
    nav {
        display: flex;
        justify-content: space-between;
        padding: 1rem;
    }

    .hamburger {
        display: block;
    }

    .nav-menu {
        display: flex; /* Reset from contents */
        position: fixed;
        right: -100%;
        top: 0;
        flex-direction: column;
        background-color: #1e1e1e;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        padding: 80px 2rem 2rem;
        transition: right 0.3s ease-in-out;
        z-index: 1000;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }

    body.light-mode .nav-menu {
        background-color: #fff;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .nav-menu.active {
        right: 0;
    }

    /* Overlay when menu is open */
    body.menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

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

    nav ul li {
        margin: 0;
        width: 100%;
    }

    nav ul li a {
        display: block;
        padding: 1rem 0;
        font-size: 1.2rem;
        border-bottom: 1px solid #333;
    }

    body.light-mode nav ul li a {
        border-bottom: 1px solid #eaeaea;
    }

    nav ul li:last-child a {
        border-bottom: none;
    }

    .nav-controls {
        margin-top: 2rem;
        padding-top: 2rem;
        border-top: 1px solid #333;
        width: 100%;
    }

    body.light-mode .nav-controls {
        border-top: 1px solid #eaeaea;
    }

    /* Adjust main content padding */
    main {
        padding: 1rem;
    }

    /* Adjust hero section for mobile */
    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    /* Adjust home content for mobile */
    .home-content {
        padding: 0 1rem;
        margin: 2rem auto;
    }

    .home-content h2 {
        font-size: 1.5rem;
    }

    .home-content h3 {
        font-size: 1.2rem;
    }

    /* Adjust recent posts for mobile */
    .recent-posts {
        padding: 0 1rem;
    }
}

/* Prevent scrolling when menu is open */
body.menu-open {
    overflow: hidden;
}

/* Smooth transitions for mobile menu items only */
@media (max-width: 768px) {
    .nav-menu ul li a {
        transition: background-color 0.3s ease, padding-left 0.3s ease;
    }
    
    .nav-menu ul li a:hover {
        background-color: rgba(255, 140, 0, 0.1);
        padding-left: 1rem;
    }
}

/* Search Modal Styles */
.search-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-modal-content {
    background-color: #1e1e1e;
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid #333;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    position: relative;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from { 
        transform: translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

body.light-mode .search-modal-content {
    background-color: #fff;
    border-color: #eaeaea;
}

.search-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.search-close:hover,
.search-close:focus {
    color: #FF8C00;
}

.search-container {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#search-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    background-color: #121212;
    color: #e0e0e0;
    border: 2px solid #333;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

#search-input:focus {
    border-color: #FF8C00;
}

body.light-mode #search-input {
    background-color: #f9f9f9;
    color: #333;
    border-color: #ddd;
}

body.light-mode #search-input:focus {
    border-color: #FF8C00;
}

#search-results {
    margin-top: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
}

.search-result-item {
    background-color: #121212;
    border: 1px solid #333;
    border-radius: 5px;
    margin-bottom: 1rem;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 140, 0, 0.2);
    border-color: #FF8C00;
}

body.light-mode .search-result-item {
    background-color: #f9f9f9;
    border-color: #eaeaea;
}

.search-result-item a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.search-result-section {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background-color: #FF8C00;
    color: #fff;
    border-radius: 3px;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.search-result-title {
    color: #e0e0e0;
    margin: 0.5rem 0;
    font-size: 1.2rem;
}

body.light-mode .search-result-title {
    color: #333;
}

.search-result-summary {
    color: #aaa;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
}

body.light-mode .search-result-summary {
    color: #666;
}

.no-results {
    text-align: center;
    color: #aaa;
    padding: 2rem;
    font-size: 1.1rem;
}

/* Highlight search matches */
mark {
    background-color: #FF8C00;
    color: #fff;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

/* Mobile adjustments for search */
@media (max-width: 768px) {
    .search-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }
    
    #search-input {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    #search-results {
        max-height: 300px;
    }
}
