/* 
   Central Stylesheet for Personal Blog
   Features: Light & Dark Theme, Fluid Typography, Micro-animations, and Modern Clean Layout
*/

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

/* --- Design Tokens (CSS Variables) --- */
:root {
    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: 'Playfair Display', Georgia, Cambria, "Times New Roman", Times, serif;

    /* Light Theme Palette */
    --bg-primary: #fcfcfd;
    --bg-secondary: #f4f5f6;
    --bg-card: #ffffff;
    --text-primary: #1a1f26;
    --text-secondary: #4b5563;
    --text-muted: #8e9aa8;
    --accent: #5046e5;
    --accent-hover: #3b31c4;
    --accent-light: #eef2ff;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Layout Constants */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition-speed: 0.3s;
    --transition-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme Palette overrides */
[data-theme="dark"] {
    --bg-primary: #0a0e17;
    --bg-secondary: #131924;
    --bg-card: #182030;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: #1e2238;
    --border-color: #242f41;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

/* --- Base & Reset Styles --- */
html {
    scroll-padding-top: 5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background-color var(--transition-speed) var(--transition-curve), 
                color var(--transition-speed) var(--transition-curve);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-speed) var(--transition-curve);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Layout Structure --- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section {
    padding: 5rem 0;
}

/* --- Header & Navigation --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-primary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Re-apply background color correctly with alpha using RGB variable if needed, or simply fallback to variable */
header.sticky-scrolled {
    box-shadow: var(--shadow);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4.5rem;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    padding: 0.25rem 0;
}

.nav-links a:hover, 
.nav-links a.active {
    color: var(--text-primary);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent);
    transition: width var(--transition-speed) var(--transition-curve);
}

.nav-links a:hover::after, 
.nav-links a.active::after {
    width: 100%;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Theme Toggle Button */
.theme-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) var(--transition-curve);
}

.theme-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.theme-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-btn .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-btn .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-btn .sun-icon {
    display: block;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
}

/* --- Hero Section (Featured Post) --- */
.hero-wrapper {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 3.5rem;
    align-items: center;
}

.hero-img-box {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition-speed) var(--transition-curve);
}

.hero-img-box img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    transition: transform 0.6s var(--transition-curve);
}

.hero-img-box:hover img {
    transform: scale(1.03);
}

.post-meta-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: var(--accent-light);
    color: var(--accent);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.25rem;
}

.hero-content h1 {
    font-family: var(--font-serif);
    font-size: 2.75rem;
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

.hero-content h1 a:hover {
    color: var(--accent);
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.meta-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.meta-author {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Grid Section (Recent Posts) --- */
.section-title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.section-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    position: relative;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
}

.post-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all var(--transition-speed) var(--transition-curve);
}

.post-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}

.card-img-box {
    overflow: hidden;
    height: 240px;
    position: relative;
}

.card-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--transition-curve);
}

.post-card:hover .card-img-box img {
    transform: scale(1.05);
}

.card-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-body h3 {
    font-family: var(--font-sans);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.card-body h3 a:hover {
    color: var(--accent);
}

.card-body p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

/* --- About Page Layout --- */
.about-wrapper {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
    align-items: flex-start;
}

.about-img-box {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    position: sticky;
    top: 6rem;
}

.about-content h2 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.about-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.stat-item h4 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- Post Article Page --- */
#article-section {
    padding-top: 2.5rem;
    padding-bottom: 5rem;
}

.article-header {
    text-align: center;
    padding: 0 0 2.5rem 0;
    max-width: 760px;
    margin: 0 auto;
}

.article-header h1 {
    font-family: var(--font-serif);
    font-size: 2.75rem;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    letter-spacing: -0.5px;
}

.article-header .meta-info {
    justify-content: center;
}

.article-hero-img {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
}

.article-hero-img img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
}

.article-body {
    max-width: 680px;
    margin: 0 auto;
    font-size: 1.075rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.article-body p {
    margin-bottom: 1rem;
}

.article-body p + p {
    margin-top: 0;
}

.article-body p:has(em):not(:has(strong)) {
    margin-bottom: 0.4rem;
}

.article-body h2,
.article-body h3 {
    color: var(--text-primary);
    font-weight: 700;
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
}

.article-body h2 {
    font-family: var(--font-serif);
    font-size: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.article-body h3 {
    font-size: 1.5rem;
}

.article-body blockquote {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.35rem;
    border-left: 4px solid var(--accent);
    padding-left: 1.5rem;
    margin: 2.5rem 0;
    color: var(--text-primary);
}

.article-body pre {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    margin: 2rem 0;
}

.article-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}

.article-body pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.article-body ul, 
.article-body ol {
    margin-bottom: 1.75rem;
    padding-left: 1.5rem;
}

.article-body li {
    margin-bottom: 0.5rem;
}

/* --- Footer & Newsletter --- */
.newsletter-section {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 4rem;
    text-align: center;
    max-width: 800px;
    margin: 4rem auto 0 auto;
    border: 1px solid var(--border-color);
}

.newsletter-section h3 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.newsletter-section p {
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.newsletter-form {
    display: flex;
    gap: 0.75rem;
    max-width: 500px;
    margin: 0 auto;
}

.newsletter-input {
    flex-grow: 1;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all var(--transition-speed) var(--transition-curve);
}

.newsletter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.15);
}

.btn-primary {
    background-color: var(--accent);
    color: #ffffff;
    border: none;
    padding: 0.8rem 1.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: background-color var(--transition-speed) var(--transition-curve),
                transform var(--transition-speed) var(--transition-curve);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

footer {
    border-top: 1px solid var(--border-color);
    padding: 3rem 0;
    margin-top: 6rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    list-style: none;
    margin-bottom: 1.5rem;
}

.footer-links a {
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--text-primary);
}

/* --- Responsive Adaptations --- */
@media (max-width: 900px) {
    .hero-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .hero-img-box img {
        height: 300px;
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    
    .about-wrapper {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    
    .about-img-box {
        position: relative;
        top: 0;
        max-width: 400px;
        margin: 0 auto;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 1.25rem;
    }
    
    .section {
        padding: 3.5rem 0;
    }
    
    .hero-content h1 {
        font-size: 2.2rem;
    }
    
    .article-header h1 {
        font-size: 2.4rem;
    }
    
    .newsletter-section {
        padding: 2rem;
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    .nav-links {
        display: none; /* In a production layout, we can build a mobile menu toggle toggle */
    }
    
    .menu-toggle {
        display: block;
    }
}
