/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Light Mode Default */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #e0e7ff;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Code Highlighting - Light */
    --code-bg: #f1f5f9;
    --code-text: #0f172a;

    /* Layout */
    --container-max-width: 1200px;
    --container-narrow-width: 760px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #0f172a;
    --bg-card: #131b2e;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-color: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(99, 102, 241, 0.15);
    --border-color: #1e293b;
    --border-hover: #334155;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

    /* Code Highlighting - Dark */
    --code-bg: #0f172a;
    --code-text: #38bdf8;
}

/* ==========================================================================
   BASE & TYPOGRAPHY
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 24px;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

main {
    padding: 2px 10px 0px 10px !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.25;
}

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

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

/* ==========================================================================
   LAYOUT PARTS
   ========================================================================== */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 24px;
}

.container-narrow {
    max-width: var(--container-narrow-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* Header & Navbar */
.navbar {
    background-color: rgba(var(--bg-secondary), 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 0;
    transition: var(--transition-smooth);
}

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

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-color), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-dot {
    width: 8px;
    height: 8px;
    background-color: #ec4899;
    border-radius: 50%;
    display: inline-block;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

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

.theme-btn:hover {
    border-color: var(--accent-color);
    background-color: var(--accent-light);
    color: var(--accent-color);
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

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

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

/* Reading Progress Bar */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: transparent;
    z-index: 101;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-color), #ec4899);
    width: 0%;
}

/* Footer */
.footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 48px 0;
    margin-top: 80px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.footer p {
    margin-bottom: 8px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
}

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

/* ==========================================================================
   HOMEPAGE COMPONENTS
   ========================================================================== */
/* Hero Section */
.hero-section {
    padding: 60px 0 40px 0;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 40px;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
}

.hero-grid:hover {
    box-shadow: var(--card-shadow-hover);
    border-color: var(--border-hover);
}

.hero-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    overflow: hidden;
}

.hero-image {
    width: 100%;
    height: 100%;
    min-height: 400px;
    object-fit: cover;
    transition: transform 0.8s ease;
}

.hero-grid:hover .hero-image {
    transform: scale(1.03);
}

.hero-content {
    padding: 40px;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--accent-light);
    color: var(--accent-color);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.hero-title {
    font-size: 2.25rem;
    margin-bottom: 16px;
    line-height: 1.2;
}

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

.hero-excerpt {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.meta-info {
    display: flex;
    flex-direction: column;
}

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

/* Post Grid Section */
.section-title {
    font-size: 1.75rem;
    margin-bottom: 32px;
    position: relative;
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(to right, var(--accent-color), #ec4899);
    border-radius: 2px;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

.blog-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: var(--transition-smooth);
}

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

.card-image-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background-color: var(--border-color);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.blog-card:hover .card-image {
    transform: scale(1.05);
}

.card-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 12px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.card-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: auto;
}

/* ==========================================================================
   POST DETAIL PAGES
   ========================================================================== */
.post-detail-wrapper {
    padding: 60px 0;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 30px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
    transition: var(--transition-smooth);
}

.btn-back:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateX(-4px);
}

.post-header {
    margin-bottom: 40px;
    text-align: center;
}

.post-header .badge {
    margin-bottom: 16px;
}

.post-main-title {
    font-size: 3rem;
    line-height: 1.15;
    margin-bottom: 24px;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.post-header .post-meta {
    justify-content: center;
    margin-bottom: 20px;
}

.post-featured-image-wrapper {
    position: relative;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    margin-bottom: 50px;
}

.post-featured-image {
    width: 100%;
    max-height: 550px;
    object-fit: cover;
}

/* WordPress Rendered Content Styling */
.post-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.post-content p {
    margin-bottom: 24px;
}

.post-content h2 {
    font-size: 2rem;
    margin: 48px 0 20px 0;
    color: var(--text-primary);
    position: relative;
}

.post-content h3 {
    font-size: 1.5rem;
    margin: 36px 0 16px 0;
    color: var(--text-primary);
}

.post-content h4 {
    font-size: 1.25rem;
    margin: 28px 0 12px 0;
    color: var(--text-primary);
}

/* Blockquotes */
.post-content blockquote,
.post-content .wp-block-quote {
    border-left: 4px solid var(--accent-color);
    background-color: var(--bg-card);
    padding: 24px 30px;
    margin: 32px 0;
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    font-style: italic;
    color: var(--text-primary);
    font-size: 1.2rem;
    box-shadow: var(--card-shadow);
}

.post-content blockquote p {
    margin-bottom: 0;
}

.post-content blockquote cite {
    display: block;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    font-style: normal;
}

/* Figures & Images in Content */
.post-content figure {
    margin: 32px 0;
}

.post-content figure.aligncenter,
.post-content figure.alignwide {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

.post-content figure img {
    border-radius: var(--border-radius-md);
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.post-content figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
    font-style: italic;
}

/* Lists */
.post-content ul,
.post-content ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 8px;
}

/* Links inside content */
.post-content a {
    color: var(--accent-color);
    border-bottom: 1.5px solid var(--accent-light);
    font-weight: 500;
}

.post-content a:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-color);
    background-color: var(--accent-light);
}

/* Code and Code Blocks */
.post-content pre {
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 20px;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.post-content code {
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.post-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
}

/* Tables */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.post-content th,
.post-content td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.post-content th {
    background-color: var(--bg-card);
    font-weight: 600;
}

.post-content tr:nth-child(even) {
    background-color: rgba(var(--border-color), 0.1);
}

/* WordPress Utilities */
.wp-block-embed {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    margin-bottom: 28px;
    border-radius: var(--border-radius-md);
}

.wp-block-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Post Sharing Section */
.post-share {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 0;
    margin: 48px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.share-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.share-buttons {
    display: flex;
    gap: 12px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.share-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background-color: var(--accent-light);
    transform: translateY(-3px);
}

/* Copy success toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--accent-color);
    box-shadow: var(--card-shadow);
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================================
   ANIMATIONS & SCROLL UTILS
   ========================================================================== */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS
   ========================================================================== */
@media (max-width: 992px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .hero-image-wrapper,
    .hero-image {
        min-height: 300px;
    }

    .hero-content {
        padding: 32px 24px;
    }

    .post-main-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {

    /* Touch Gutter Adjustments */
    .container {
        padding: 0 16px;
    }

    .container-narrow {
        padding: 0 24px;
        /* Comfortably wider gutters for article pages on mobile */
    }

    .navbar {
        padding: 12px 0;
    }

    .logo {
        font-size: 1.3rem;
    }

    /* Layout Spacing */
    .hero-section {
        padding: 24px 0;
    }

    .hero-title {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }

    .blog-grid {
        gap: 20px;
        margin-bottom: 40px;
    }

    .post-detail-wrapper {
        padding: 32px 0;
    }

    .btn-back {
        margin-bottom: 24px;
        padding: 10px 18px;
        /* Larger touch area */
        font-size: 0.9rem;
    }

    /* Typography & Content Scaling */
    .post-main-title {
        font-size: 1.85rem;
        margin-bottom: 16px;
        padding: 0 4px;
    }

    .post-header {
        margin-bottom: 28px;
    }

    .post-featured-image-wrapper {
        margin-bottom: 32px;
        border-radius: var(--border-radius-md);
    }

    .post-featured-image {
        max-height: 300px;
    }

    .post-content {
        font-size: 1.05rem;
        line-height: 1.7;
    }

    .post-content p {
        margin-bottom: 20px;
    }

    .post-content h2 {
        font-size: 1.5rem;
        margin: 36px 0 16px 0;
    }

    .post-content h3 {
        font-size: 1.3rem;
        margin: 28px 0 12px 0;
    }

    /* WordPress Gutenberg Block Optimizations on Mobile */
    .post-content blockquote,
    .post-content .wp-block-quote {
        padding: 16px 20px;
        margin: 24px 0;
        font-size: 1.1rem;
    }

    /* Force tables to be horizontally scrollable without breaking page layouts */
    .post-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Force long code lines to wrap or scroll cleanly */
    .post-content pre {
        padding: 16px;
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    /* Responsive media alignments */
    .post-content figure,
    .post-content figure.aligncenter,
    .post-content figure.alignwide,
    .post-content figure.alignfull {
        margin: 20px 0;
        max-width: 100%;
        width: 100%;
    }

    .post-content figure img {
        border-radius: var(--border-radius-sm);
        width: 100%;
        height: auto;
    }

    /* Stack sharing buttons cleanly */
    .post-share {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 20px 0;
        margin: 32px 0;
    }

    .share-btn {
        width: 48px;
        /* Optimal mobile touch size */
        height: 48px;
    }

    /* UI Toast adjustments for mobile viewport */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 576px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }

    .hero-content {
        padding: 20px 16px;
    }

    .hero-excerpt {
        font-size: 0.95rem;
        margin-bottom: 16px;
    }

    .footer {
        padding: 32px 0;
        margin-top: 60px;
    }
}

/* Fix for ultra-small touch devices */
@media (max-width: 380px) {
    .logo {
        font-size: 1.15rem;
    }

    .post-main-title {
        font-size: 1.6rem;
    }
}