/* --- Global Reset & Box Sizing --- */
* {
    box-sizing: border-box;
}

html {
    overflow-y: scroll; /* Always show vertical scrollbar to prevent layout shifts */
}

/* General Body Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f4f4f9;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header and Navigation Styles */
header {
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('../images/my-background.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    /* New styles */
    background: linear-gradient(45deg, #ccc, #fff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent; /* Fallback */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    will-change: transform; /* Performance hint for the browser */
}

header h1:hover {
    transform: scale(1.02) translateZ(0); /* Smoother animation by promoting to a new layer */
}

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

#about-button {
    position: absolute;
    right: 2rem;
    background-color: #0059b3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

#about-button:hover {
    background-color: #004080;
}

#main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    background-color: #002244;
    border-bottom: 1px solid #003366;
    /* New styles for sticky nav */
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease-in-out; /* Add transition for smooth hiding */
}

#main-nav.nav-hidden {
    transform: translateY(-100%); /* Hides the nav bar upwards */
}

#category-buttons {
    display: flex;
    justify-content: center;
    flex-grow: 1;
}

#main-nav button {
    background: none;
    border: none;
    color: white;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

#main-nav button:hover, #main-nav button.active {
    background-color: #0059b3;
}

/* Main Content Styles */
main {
    padding: 2rem;
    flex: 1; /* Allows main to grow and fill available space */
    padding-bottom: 80px; /* Add padding to prevent footer overlap */
}

.breadcrumb-container {
    text-align: center; /* Center the inline-block child */
    margin-bottom: 1.5rem;
}

#current-category-title {
    /* margin-bottom is now on the container */
    font-size: 1.6em; /* Slightly smaller font size */
    color: #ddd;
    text-align: center;
    font-weight: 300;
    /* New styles for the container */
    padding: 0.75rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.05); /* Subtle background */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px; /* Rounded corners */
    display: inline-block; /* Fit content width */
    /* Centering margins are no longer needed here */
}

#current-category-title .breadcrumb-link {
    color: #00aaff;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.3s ease;
}

#current-category-title .breadcrumb-link:hover {
    color: #00eeff;
    text-decoration: underline;
}

#navigation-controls {
    margin-bottom: 1rem;
}

#back-button {
    position: absolute;
    left: 2rem;
    background-color: #0059b3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

#back-button:hover {
    background-color: #004080;
}

.hidden {
    display: none !important;
}

/* Categories Section */
#categories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.category-tile {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    width: 200px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.3s, transform 0.3s;
}

.category-tile:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-5px);
}

.category-tile img {
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 5px;
}

/* Articles Section */
#articles-container {
    margin: 2rem auto 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 1200px; /* Or another value that fits your design */
}

.article-tile {
    background-color: white;
    border: 1px solid #0059b3;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: box-shadow 0.3s, transform 0.3s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

.article-tile:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-5px);
}

.article-details {
    flex-grow: 1;
}

.article-tile h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #003366;
}

.article-tile .article-summary-full {
    display: none;
}

.article-summary-short, .article-summary-full {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-top: 0.5rem;
}

.expand-abstract {
    color: white;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    margin-top: 0.5rem;
    background-color: #0059b3;
    padding: 8px 12px;
    border-radius: 5px;
}

.expand-abstract:hover {
    background-color: #004080;
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.arxiv-link {
    color: #0059b3;
    text-decoration: none;
    font-weight: bold;
}

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

/* Loader Styles */
#loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #003366;
    z-index: 1000;
}

.spinner {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid #0059b3; /* Blue */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 2s linear infinite;
    margin: 0 auto 1rem auto;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #ffffff; /* White background */
    margin: 10% auto;
    padding: 2.5rem;
    width: 90%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
    border: 2px solid #0077cc; /* Blue border */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    color: #333; /* Dark text for readability */
}

.modal-content h2 {
    margin-top: 0;
    color: #000; /* Black heading */
}

.modal-content p {
    font-size: 1.1em; /* Larger font size for paragraphs */
    line-height: 1.6; /* Improved line spacing */
}

.close-button {
    color: #888;
    float: right;
    font-size: 2rem;
    cursor: pointer;
}

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

/* --- Donate Modal Specific Styles --- */
.wallet-info {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #f4f4f9;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.wallet-info hr {
    border: none;
    border-top: 1px solid #ccc;
    margin: 1rem 0;
}

.wallet-info p {
    font-size: 1em;
    margin: 0.5rem 0;
}

.wallet-address {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    flex-wrap: wrap; /* For mobile */
}

.wallet-address p {
    word-break: break-all; /* Ensure long address wraps */
    margin-right: 1rem; /* Space between address and button */
}

#copy-wallet-button {
    padding: 0.5rem 1rem;
    font-size: 0.9em;
    background-color: #0077cc;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#copy-wallet-button:hover {
    background-color: #0055aa;
}

.thank-you-message {
    margin-top: 1.5rem;
    text-align: center;
    font-style: italic;
    color: #555;
}


/* Footer Styles */
footer {
    background-color: #111;
    color: #fff;
    padding: 1rem 2rem;
    text-align: center;
    border-top: 1px solid #333;
    /* New styles for static footer */
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.donate-button {
    background-color: #0059b3;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.donate-button:hover {
    background-color: #004080;
}

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

/* Responsive Design */
@media (max-width: 800px) {
    #main-nav {
        flex-direction: column;
        padding: 1rem;
    }

    #back-button, #about-button {
        position: static;
        left: auto;
        right: auto;
        margin-bottom: 1rem;
        width: auto;
    }

    #about-button {
        order: -1; /* Move About button to the top on mobile */
    }

    #category-buttons {
        order: 1; /* Ensure categories are below the buttons */
        flex-wrap: wrap;
        justify-content: center;
    }
}

.article {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.article h3 {
    margin-top: 0;
}

.article-meta {
    font-size: 0.8rem;
    color: #333;
    font-weight: bold;
    text-align: right;
    margin-left: 1rem;
    flex-shrink: 0;
}

.article-authors {
    font-size: 0.9rem;
    font-style: italic;
    color: #555;
    margin-bottom: 1rem;
}

.article-details hr {
    border: 0;
    border-top: 1px solid #0059b3;
    margin: 1rem 0;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    body {
        font-size: 14px; /* Adjust base font size for mobile */
    }

    header h1 {
        font-size: 2em; /* Reverted */
        text-align: center;
    }

    #main-nav {
        flex-direction: column;
        padding: 0.5rem;
    }

    #main-nav #category-buttons {
        order: 2;
        margin: 0.5rem 0;
        flex-wrap: nowrap; /* Prevent wrapping */
        justify-content: flex-start; /* Align buttons to the start */
        overflow-x: auto; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding-bottom: 8px; /* Space for scrollbar */
        width: 100%; /* Ensure it takes full width to allow scrolling */
    }

    #main-nav #back-button { order: 1; }
    #main-nav #about-button { order: 3; }

    #main-nav button {
        padding: 0.6rem 1rem;
        font-size: 0.9em;
    }

    main {
        padding: 1rem;
        padding-bottom: 150px; /* More padding for taller footer */
    }

    #current-category-title {
        font-size: 1.2em;
        padding: 0.5rem 1rem;
        width: 90%;
    }

    .category-tile {
        flex-basis: 100%; /* Single column layout */
    }

    .article-tile {
        flex-direction: column;
        padding: 1rem;
    }

    .article-details {
        padding-right: 0;
    }

    .article-meta {
        padding-left: 0;
        margin-top: 1rem;
        text-align: left;
    }

    .modal-content {
        width: 95%;
        margin: 25% auto;
        padding: 1.5rem;
        font-size: 1em;
    }

    footer {
        padding: 1rem;
    }

    .footer-content {
        flex-direction: column;
    }

    .footer-content p,
    .footer-content .social-links {
        margin-bottom: 0.8rem;
    }
}
