/* --- ACCESSIBILITY & THEME VARIABLES --- */
:root {
    --primary-color: #0056b3; /* WCAG AA Compliant Blue */
    --dark-color: #222;
    --light-color: #f4f4f4;
    --text-color: #444;
    --grey-color: #666; /* WCAG AA Compliant Grey */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- BASIC RESET & DEFAULTS --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    line-height: 1.7;
    background-color: #fff;
    color: var(--text-color);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- ACCESSIBILITY: SKIP LINK --- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 10px;
    background: var(--dark-color);
    color: white;
    z-index: 9999;
    text-decoration: none;
    font-weight: bold;
}

/* --- HEADER & NAVIGATION --- */
.main-header {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #eee;
    padding: 0.5rem 0;
}
.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark-color);
    text-decoration: none;
}
.main-nav ul {
    list-style: none;
    display: none; /* Hidden by default on mobile */
}
.main-nav a {
    text-decoration: none;
    color: var(--dark-color);
    padding: 0.5rem 1rem;
    display: block;
}
#hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
}
.bar {
    height: 3px;
    width: 100%;
    background: var(--dark-color);
    border-radius: 10px;
}
.main-nav ul.nav-open {
    display: flex;
    flex-direction: column;
    background: white;
    position: absolute;
    top: 60px; /* Adjust based on header height */
    left: 0;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.main-nav ul.nav-open li {
    text-align: center;
    border-bottom: 1px solid var(--light-color);
}

/* --- BREADCRUMBS --- */
.breadcrumbs {
    display: flex;
    list-style: none;
    padding: 1.5rem 0 0.5rem 0;
    font-size: 0.9rem;
}
.breadcrumb-item a {
    text-decoration: none;
    color: var(--primary-color);
}
.breadcrumb-item a:hover {
    text-decoration: underline;
}
.breadcrumb-item::after {
    content: '>';
    margin: 0 0.5rem;
    color: var(--grey-color);
}
.breadcrumb-item:last-child::after {
    content: '';
}
.breadcrumb-item.active {
    color: var(--grey-color);
}

/* --- TOPIC HEADER --- */
.topic-header {
    text-align: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.topic-header h1 {
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}
.topic-header p {
    font-size: 1.1rem;
    color: var(--grey-color);
    max-width: 600px;
    margin: 0 auto;
}

/* --- POST GRID & CARDS --- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding-bottom: 2rem;
}
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 8px;
}
.card-link:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    height: 100%;
}
.card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}
.card-content {
    padding: 1rem;
}
.card-content h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}
.card-content p {
    font-size: 0.9rem;
    color: var(--grey-color);
}

/* --- FOOTER --- */
.main-footer {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--dark-color);
    color: #fff;
    margin-top: 2rem;
}
.main-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.footer-links a {
    color: #fff;
    text-decoration: none;
    margin-left: 1rem;
}
.footer-links a:hover {
    text-decoration: underline;
}

/* --- LOADER FOR INFINITE SCROLL --- */
.loader {
    border: 5px solid var(--light-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
    display: none; /* Initially hidden */
}

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

/* --- RESPONSIVE DESKTOP STYLES --- */
@media (min-width: 768px) {
    #hamburger-btn {
        display: none;
    }
    .main-nav ul {
        display: flex;
        flex-direction: row;
        position: static;
        background: none;
        box-shadow: none;
        width: auto;
    }
    .main-nav li {
        border: none;
    }
    .main-nav a:hover {
        color: var(--primary-color);
        background: none;
    }
}
