/* ==========================================================================
   CSS Variables & Global Configuration
   ========================================================================== */
   :root {
    /* Typography Stack: Prioritizing local fonts for speed, falling back to system fonts */
    --font-primary: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Single Theme Palette: Warm, reading-friendly background */
    --bg-body: #FCFAF8;       /* Warm Cream/White */
    --bg-surface: #FFFFFF;    /* Pure white for cards/boxes */
    --text-primary: #1A1A1A;  /* High contrast almost-black */
    --text-secondary: #5C5C5C;/* Gray for secondary text */
    --border-subtle: rgba(0, 0, 0, 0.08);
    
    /* Semantic Brand Colors */
    --clr-ochre: #D49A00;     /* Primary Brand: Ochre Yellow */
    --clr-blue: #34AAE1;      /* Accent Blue */
    --clr-red: #D94848;       /* Accent Red */

    /* Scrollbar Config */
    --scrollbar-thumb: rgba(0, 0, 0, 0.2);
    --scrollbar-thumb-hover: rgba(212, 154, 0, 0.6);

    /* Animation Timings */
    --transition-fast: 0.2s ease;
    --transition-standard: 0.3s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Scrollbar Customization
   ========================================================================== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ==========================================================================
   Resets & Accessibility Foundations
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { 
    font-size: 100%; 
    scroll-behavior: smooth; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale;
}

/* A11y: Global Keyboard Focus Indicator */
:focus-visible {
    outline: 2px solid var(--clr-ochre);
    outline-offset: 3px;
    border-radius: 4px;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh; 
    overflow-y: scroll;
}

a, button { 
    text-decoration: none; border: none; background: transparent; 
    font-family: inherit; cursor: pointer; color: inherit; 
}

sup { font-size: 0.75em; line-height: 0; position: relative; vertical-align: baseline; top: -0.5em; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ==========================================================================
   Smart Header & Branding
   ========================================================================== */
.smart-header {
    position: sticky; top: 0; left: 0; width: 100%;
    background-color: #FDFBF2; 
    z-index: 1000;
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.smart-header.scroll-down { transform: translateY(-100%); box-shadow: none; }
.smart-header.scroll-up { transform: translateY(0); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); }

.header-art { width: 100%; height: 40px; display: flex; justify-content: center; margin-bottom: 1rem; }
.branding-container { display: flex; justify-content: center; align-items: center; padding-bottom: 1rem; }
.branding { display: flex; align-items: center; gap: 1.2rem; }
.branding-logo { width: 90px; height: 90px; object-fit: contain; }
.branding-text { display: flex; flex-direction: column; justify-content: center; }

.branding-title { 
    color: var(--text-primary); font-size: 2.4rem; font-weight: 900; 
    letter-spacing: -1px; line-height: 1; 
}

.slogan-wrapper { display: flex; align-items: center; margin-top: 0.5rem; }
.branding-slogan {
    color: var(--text-secondary); font-size: 1rem; font-weight: 700; 
    letter-spacing: 1px; position: relative; display: inline-block;
}
.branding-slogan::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    background-color: var(--clr-ochre); border-radius: 50%;
    margin-left: 8px; vertical-align: middle;
}

/* ==========================================================================
   Primary Navigation & Icons
   ========================================================================== */
.primary-nav { width: 100%; padding-bottom: 1.5rem; }
.hamburger-btn { display: none; }
.nav-links { display: flex; justify-content: center; gap: 2.5rem; list-style: none; }

.nav-item {
    display: flex; align-items: center; color: var(--text-secondary); 
    font-weight: 600; font-size: 1rem; position: relative; 
    transition: color var(--transition-fast); padding: 0.5rem 0;
}

.nav-icon { width: 18px; height: 18px; margin-left: 6px; transition: transform var(--transition-fast); }
.nav-item:hover, .nav-item.active { color: var(--clr-ochre); }
.nav-item:hover .nav-icon { transform: translateY(-2px); }

.nav-item::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px;
    background-color: transparent; transition: background-color var(--transition-fast), transform var(--transition-fast);
    transform: scaleX(0);
}
.nav-item:hover::after, .nav-item.active::after { background-color: var(--clr-ochre); transform: scaleX(1); }

/* ==========================================================================
   Main Content Layout (Landing Pages)
   ========================================================================== */
.page-content { flex-grow: 1; display: flex; flex-direction: column; width: 100%; }
.landing-section { padding: 5rem 0; text-align: center; }

.hero-headline {
    font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900; 
    color: var(--text-primary); opacity: 0; animation: fadeUp 1s ease forwards; margin-bottom: 1rem;
}
.hero-subtext { font-size: 1.2rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto; }

.section-title { font-size: 2rem; font-weight: 800; margin-bottom: 2rem; position: relative; display: inline-block; }
.section-title::after {
    content: ''; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 3px; background-color: var(--clr-ochre); border-radius: 2px;
}

@keyframes fadeUp { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Content Grids (Archive & Tags Pages)
   ========================================================================== */
.content-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2rem; width: 100%; max-width: 1100px; margin: 2rem auto 0 auto; justify-content: center;
}

.post-card {
    background-color: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: 12px; overflow: hidden;
    transition: transform var(--transition-standard), box-shadow var(--transition-standard);
}
.post-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0,0,0,0.05); }

.post-card a {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 2rem 1.5rem; height: 100%;
}

.post-cover {
    width: 85px; height: 85px; object-fit: cover; object-position: center top;
    border-radius: 50%; margin-bottom: 1.2rem; box-shadow: 0 4px 10px var(--border-subtle);
}

.post-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 0.5rem; color: var(--text-primary); }
.post-author { font-size: 0.9rem; color: var(--text-secondary); margin-top: auto; }
.empty-state { padding: 3rem; color: var(--text-secondary); font-size: 1.2rem; }

/* ==========================================================================
   Story Reading Layout (Articles)
   ========================================================================== */
.story-reading-layout { padding-top: 3rem; padding-bottom: 5rem; align-items: flex-start; }

.story-article {
    width: 100%; max-width: 760px; margin: 0 auto; background-color: var(--bg-surface);
    padding: 3.5rem 4rem; border-radius: 16px; border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

/* Flexbox Header for Single Stories */
.story-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px dashed var(--border-subtle);
}
.story-meta-container { display: flex; flex-direction: column; align-items: flex-start; text-align: right; }
.story-title { font-size: 2.2rem; font-weight: 900; color: var(--text-primary); margin-bottom: 0.8rem; line-height: 1.4; }
.story-meta { display: flex; gap: 1.5rem; font-size: 0.95rem; color: var(--text-secondary); font-weight: 500; }
.story-author-image { flex-shrink: 0; margin-right: 1.5rem; }
.story-cover {
    width: 80px; height: 80px; object-fit: cover; object-position: center top;
    border-radius: 50%; border: 2px solid var(--border-subtle); box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Markdown Content Styling */
.story-body { font-size: 1.15rem; line-height: 2.2; color: var(--text-primary); text-align: justify; }
.story-body p { margin-bottom: 0; }
.story-body p + p { text-indent: 2.5rem; margin-top: 0; }
.story-body h1 { font-size: 1.6rem; font-weight: 800; margin: 2rem 0 1rem 0; }
.story-body h2 { font-size: 1.4rem; font-weight: 800; margin: 1.8rem 0 1rem 0; }
.story-body h3 { font-size: 1rem; font-weight: 700; margin: 2rem 0 1rem 0; color: var(--text-secondary); }
.story-body hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 3rem 0; }
.story-body strong { color: var(--text-primary); }
.story-body em { font-style: italic; opacity: 0.9; }

/* ==========================================================================
   Poetry & Footnotes Styling
   ========================================================================== */
/* Poetry Styling */
.poem {
    text-align: center;
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 500;
    margin: 1.5rem auto;
    padding: 0.5rem 2rem;
    background-color: var(--bg-body);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    white-space: pre-line;
    line-height: 2.2;
    font-style: italic;
}

/* Footnotes inside stories */
.footnotes-en { 
    font-size: 0.85rem; 
    color: var(--text-secondary); 
    text-align: left; 
    margin-top: 2rem; 
    margin-bottom: 0;
    font-family: system-ui, sans-serif; 
    white-space: pre-line; 
    line-height: 1.8;
}

.footnotes-fa { 
    font-size: 0.85rem; 
    color: var(--text-secondary); 
    margin-top: 0.5rem;
    white-space: pre-line; 
    line-height: 1.8;
}

/* Tags Section */
.story-tags-section {
    margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border-subtle);
    display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
}
.tags-fa {
    display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-start; flex: 1;
}
.tags-en {
    display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; flex: 1; direction: ltr;
}
.tag-link {
    background-color: var(--bg-body); color: var(--text-secondary); padding: 0.35rem 0.8rem;
    border-radius: 8px; font-size: 0.85rem; font-weight: 500; border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast); display: inline-block;
}
.tag-link:hover { color: var(--clr-ochre); border-color: var(--clr-ochre); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }

/* Mobile adjustments for tags */
@media (max-width: 768px) {
    .story-tags-section { flex-direction: column; gap: 1.5rem; }
    .tags-en { justify-content: flex-start; } /* Aligns English tags to left on mobile */
}

/* ==========================================================================
   Footer
   ========================================================================== */
.main-footer {
    width: 100%; flex-shrink: 0; background-color: #0F0F11; 
    border-top: 2px solid var(--clr-ochre); padding: 3rem 0; margin-top: auto; 
}
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.footer-actions { display: flex; gap: 1rem; }
.icon-btn {
    width: 45px; height: 45px; background-color: rgba(255, 255, 255, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 50%;
    display: flex; justify-content: center; align-items: center; color: #FFFFFF;
    transition: all var(--transition-fast);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background-color: var(--clr-ochre); color: #FFF; border-color: var(--clr-ochre); transform: translateY(-3px); }
.footer-copy { color: #888888; font-size: 0.9rem; }

/* ==========================================================================
   Back to Top Button
   ========================================================================== */
.back-to-top-btn {
    position: fixed; bottom: 2rem; left: 2rem; width: 45px; height: 45px;
    background-color: var(--clr-ochre); color: #FFFFFF; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 4px 15px rgba(212, 154, 0, 0.4); z-index: 999;
    opacity: 0; visibility: hidden; transform: translateY(20px); transition: all var(--transition-standard);
}
.back-to-top-btn svg { width: 24px; height: 24px; }
.back-to-top-btn:hover { background-color: #B8860B; transform: translateY(-3px); }
.back-to-top-btn.visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* ==========================================================================
   Mobile Responsiveness Breakdown
   ========================================================================== */
@media (max-width: 900px) {
    .header-art { height: 30px; }
    .branding-logo { width: 70px; height: 70px; }
    .branding-title { font-size: 1.8rem; }
    .branding-slogan { font-size: 0.9rem; }
    
    .primary-nav { padding-bottom: 0; position: relative; }
    .hamburger-btn { display: flex; justify-content: center; align-items: center; width: 100%; padding: 1rem 0; color: var(--text-primary); }
    .hamburger-btn svg { width: 26px; height: 26px; stroke-width: 2; }
    
    .nav-links {
        position: absolute; top: 100%; left: 0; width: 100%; background-color: var(--bg-surface); 
        border-bottom: 1px solid var(--border-subtle); box-shadow: 0 10px 20px rgba(0,0,0,0.05); 
        flex-direction: column; align-items: center; gap: 0; padding: 0.5rem 0; z-index: 999; 
        visibility: hidden; opacity: 0; transform: translateY(-10px); transition: all var(--transition-standard);
    }
    .nav-links.open { visibility: visible; opacity: 1; transform: translateY(0); }
    .nav-item { width: 100%; justify-content: center; padding: 1rem 0; }
    .nav-item::after { display: none; }
    
    .back-to-top-btn { bottom: 1.5rem; left: 1.5rem; width: 40px; height: 40px; }
}

@media (max-width: 768px) {
    /* Mobile adjustments for story reading layout */
    .story-article { padding: 2rem 1.5rem; border-radius: 12px; }
    .story-header { flex-direction: column-reverse; align-items: flex-start; gap: 1.5rem; }
    .story-author-image { margin-right: 0; }
    .story-title { font-size: 1.8rem; }
    .story-body { font-size: 1.05rem; }
    .story-body p + p { text-indent: 1.5rem; }
}

/* ==========================================================================
   Category Group Headers (Used in Homepage & Tags)
   ========================================================================== */
.category-group {
    width: 100%;
    margin-bottom: 3rem;
}

.category-group-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-subtle);
    color: var(--text-primary);
}

.category-group-header svg {
    width: 30px;
    height: 30px;
    stroke-width: 2.5;
}

.category-group-header h4 {
    font-size: 1.2rem;
    font-weight: 800;
}

/* Matching the header colors to the brand nav colors */
.cat-flashfictions { color: var(--clr-red); }
.cat-novels { color: var(--clr-blue); }
.cat-shortstories { color: var(--clr-pink); }
.cat-articles { color: var(--clr-ochre); }
