/* --- General Setup --- */
:root {
    --color-black: #0a0a0a;
    --color-surface: rgba(26, 26, 26, 0.7);
    --color-white: #f5f5f5;
    --color-deep-red: #8B0000;
    --color-neon-red: #ff073a;
    --font-family-fa: 'Vazirmatn', sans-serif;
    --font-family-en: 'Roboto', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%;
    scroll-behavior: smooth;
    background-color: var(--color-black);
    color: var(--color-white);
    line-height: 1.7;
    overflow-x: hidden;
}
/* Hide scrollbar for various browsers */
body::-webkit-scrollbar { width: 0; background: transparent; }
body { -ms-overflow-style: none; scrollbar-width: none; }
[lang="fa"] { font-family: var(--font-family-fa); }
[lang="en"] { font-family: var(--font-family-en); }

/* --- 1. Preloader --- */
#preloader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--color-black);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}
#preloader.hidden {
    opacity: 0;
    visibility: hidden;
}
.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.preloader-text {
    font-size: 10vw;
    font-weight: 900;
    color: var(--color-neon-red);
    text-shadow: 0 0 25px var(--color-neon-red);
    margin: 0;
    line-height: 1;
}
.loading-dots {
    display: inline-block;
    color: var(--color-white);
    font-family: var(--font-family-fa);
    font-size: 2vw;
    letter-spacing: 5px;
    margin-top: 1rem;
}
.loading-dots span {
    opacity: 0;
    animation: typing-dot-fade 1.5s infinite;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot-fade {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* --- Background Canvas --- */
#galactic-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}
#main-content {
    position: relative;
    z-index: 1;
    width: 100%;
}
.section-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: auto;
    padding: 0 5%;
}
.fullpage-section {
    padding: 100px 0;
}
.section-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.section-content h2 {
    font-size: 3.8rem;
    font-weight: 900;
    color: var(--color-neon-red);
    margin-bottom: 0.5rem;
}
.section-content p {
    font-size: 1.8rem;
    color: #ccc;
    margin-bottom: 1rem;
}

/* --- Header & Navigation --- */
header {
    position: fixed;
    top: 0; width: 100%;
    padding: 0.5rem 2%;
    background-color: rgba(10, 0, 44, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-deep-red);
    z-index: 1000;
    display: flex; justify-content: space-between; align-items: center;
}
.logo-container img { height: 50px; }
.controls { display: flex; align-items: center; gap: 20px; }
.lang-switcher a { color: var(--color-white); text-decoration: none; margin: 0 5px; }
.lang-switcher a.active { color: var(--color-neon-red); font-weight: bold; }
#menu-toggle { font-size: 2rem; cursor: pointer; color: var(--color-neon-red); }

/* --- Fullscreen Menu --- */
#slide-out-menu {
    position: fixed; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(15px);
    z-index: 2000;
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}
[dir="rtl"] #slide-out-menu { right: 0; transform: translateX(100%); }
[dir="ltr"] #slide-out-menu { left: 0; transform: translateX(-100%); }
#slide-out-menu.open { transform: translateX(0); }
#slide-out-menu ul { list-style: none; text-align: center; }
#slide-out-menu a {
    display: block; padding: 1rem 0;
    color: var(--color-white); text-decoration: none;
    font-size: 2.5rem; font-weight: bold;
    transition: color 0.3s ease, transform 0.3s ease;
}
#slide-out-menu a:hover { color: var(--color-neon-red); transform: scale(1.1); }
#menu-close {
    position: absolute;
    top: 20px;
    font-size: 3rem;
    color: var(--color-white);
    cursor: pointer;
}
[dir="rtl"] #menu-close { right: 20px; }
[dir="ltr"] #menu-close { left: 20px; }
/* --- Styles for Blog Page --- */
.posts-grid-container {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    margin-top: 4rem;
    width: 100%;
}
.post-card {
    background-color: var(--color-surface);
    backdrop-filter: blur(5px);
    border: 1px solid var(--color-deep-red);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* تغییرات جدید */
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 400px;
}
.post-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(255, 7, 58, 0.2);
}
.post-card img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}
.post-card h3 {
    color: var(--color-neon-red);
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
    line-height: 1.2;
}
.post-card p {
    color: var(--color-white); /* رنگ متن یکپارچه شد */
    font-size: 1.3rem;
    line-height: 2;
}
.post-card .post-content {
    display: flex;
    flex-direction: column;
    text-align: right;
    flex-grow: 1; /* فضای خالی را پر می‌کند */
    justify-content: space-between; /* دکمه را به پایین فشار می‌دهد */
}
.post-card .read-more-btn {
    display: inline-block;
    color: var(--color-white);
    background-color: var(--color-neon-red);
    border: 1px solid var(--color-neon-red);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s;
    /* تغییر جدید */
    margin-top: auto; /* دکمه را به پایین ترین نقطه ممکن هل می‌دهد */
}
.post-card .read-more-btn:hover {
    background-color: transparent;
    color: var(--color-neon-red);
}
/* --- Hero Post Styles --- */
#hero-post-container {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
}
#hero-post-container .post-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2rem;
    text-align: right;
    padding: 3rem;
    width: 100%;
    max-width: 1200px;
    transition: all 0.5s ease;
}
#hero-post-container .post-card .post-content {
    flex: 1;
}
#hero-post-container .post-card img {
    width: 50%;
    height: auto;
    object-fit: cover;
    border-radius: 15px;
    margin-bottom: 0;
}
@media (max-width: 960px) {
    #hero-post-container .post-card {
        flex-direction: column;
        text-align: center;
    }
    #hero-post-container .post-card img {
        width: 100%;
    }
}
/* --- Regular Posts Grid --- */
#regular-posts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
}
/* --- Filter & Search Styles --- */
.filter-and-search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}
#search-input {
    background-color: var(--color-surface);
    color: var(--color-white);
    border: 1px solid var(--color-deep-red);
    border-radius: 50px;
    padding: 0.75rem 1.5rem;
    width: 100%;
    max-width: 500px;
    font-size: 1.1rem;
    text-align: right;
}
.category-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}
.filter-button {
    background-color: var(--color-surface);
    color: var(--color-white);
    border: 1px solid var(--color-deep-red);
    border-radius: 50px;
    padding: 0.5rem 1.2rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}
.filter-button:hover, .filter-button.active {
    background-color: var(--color-neon-red);
    border-color: var(--color-neon-red);
    color: var(--color-white);
}
/* --- Pagination Controls --- */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-bottom: 3rem;
}
.page-button {
    background-color: var(--color-surface);
    color: var(--color-neon-red);
    border: 2px solid var(--color-neon-red);
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.page-button:hover:not(:disabled) {
    background-color: var(--color-neon-red);
    color: var(--color-white);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 7, 58, 0.4);
}
.page-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #555;
    color: #888;
}
.current-page {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-white);
}
@media (max-width: 960px) {
    .page-button {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}
/* --- Overlay for Single Post View --- */
.post-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(15px);
    z-index: 9998;
    display: none; /* Initially hidden */
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 2rem;
    direction: rtl; /* For RTL content */
}
.post-overlay.visible {
    display: flex;
}
.overlay-content {
    background-color: var(--color-surface);
    backdrop-filter: blur(5px);
    border: 1px solid var(--color-deep-red);
    border-radius: 15px;
    padding: 3rem;
    max-width: 900px;
    width: 100%;
    position: relative;
}
#close-overlay {
    position: sticky;
    top: 20px;
    display: block;
    width: 30px;
    height: 30px;
    color: var(--color-white);
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
    text-align: left;
    margin-right: -1rem;
    margin-bottom: 2rem;
    z-index: 10000;
}
#overlay-post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin-bottom: 2rem;
}
#overlay-post-content h1 {
    font-size: 3rem;
    color: var(--color-neon-red);
    margin-bottom: 1rem;
    text-align: center;
}
#overlay-post-content p {
    font-size: 1.2rem;
    line-height: 2.2;
    text-align: justify;
    margin-bottom: 1.5rem;
}
@media (max-width: 768px) {
    .overlay-content { padding: 1.5rem; }
    #overlay-post-content h1 { font-size: 2rem; }
}
/* --- New Overlay Styles for better image handling --- */
#post-overlay.visible .overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 900px; /* Adjust as needed */
    margin: auto;
}

#post-overlay.visible img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
/* Styling for post excerpt in the main blog page */
.post-content p {
    font-style: italic;
    font-size: 0.95rem;
    color: var(--color-white); /* رنگ متن یکپارچه شد */
    margin-top: 0.5rem;
}