/* ====================================
   ARTICLE PAGE STYLES
   Complete styling for article templates
   ==================================== */

/* ====================================
   LAYOUT & CONTAINER
   ==================================== */

/* 1. Global Box Sizing Reset (Crucial for sizing) */
*, *::before, *::after {
    box-sizing: border-box;
}

/* 2. Force Body to handle overflow */
html, body {
    width: 100%;
    overflow-x: hidden; /* Hide horizontal scrollbar */
    margin: 0;
    padding: 0;
}

.article-container {
    max-width: 1400px;
    margin: 140px auto 0;
    padding: 0 30px 150px; /* Desktop padding */
    position: relative;
    z-index: 1;
}

.article-layout {
    display: grid;
    grid-template-columns: 60px 1fr 250px;
    gap: 40px;
    align-items: start;
}

.article-hero {
    grid-column: 1 / -1;
    margin-bottom: 40px;
}

/* Desktop specific - ensure proper spacing */
@media (min-width: 769px) {
    .article-hero,
    .article-content {
        padding: 0; /* No extra padding on desktop */
    }
    
    .article-hero-image {
        border-radius: 20px; /* Rounded on desktop */
    }
}

/* ====================================
   READING PROGRESS BAR
   ==================================== */

#article-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    z-index: 10000;
    transition: width 0.1s ease;
}

/* ====================================
   HERO SECTION
   ==================================== */

.article-hero-image {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    border-radius: 20px;
    margin-bottom: 30px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.article-category {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.article-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-excerpt {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ====================================
   SHARE SIDEBAR
   ==================================== */

.share-sidebar {
    position: sticky;
    top: 120px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.share-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
}

.share-btn:hover {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.3);
}

.share-btn.saved {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

/* ====================================
   ARTICLE CONTENT
   ==================================== */

.article-content {
    max-width: 680px; /* Narrower for better readability */
    font-size: 1.15rem;
    line-height: 1.9;
    color: var(--text-primary);
}

.article-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 50px;
    margin-bottom: 20px;
    color: var(--text-primary);
    max-width: 100%;
}

.article-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 40px;
    margin-bottom: 15px;
    color: var(--text-primary);
    max-width: 100%;
}

.article-content p {
    margin-bottom: 25px;
}

.article-content ul,
.article-content ol {
    margin-bottom: 25px;
    padding-left: 30px;
}

.article-content li {
    margin-bottom: 10px;
}

.article-content code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent-cyan);
}

.article-content pre {
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    overflow-x: auto;
}

.article-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.95rem;
}

.article-content blockquote {
    border-left: 4px solid var(--accent-cyan);
    padding-left: 25px;
    margin: 30px 0;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* ====================================
   COPY CODE BUTTON
   ==================================== */

.copy-code-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.copy-code-btn:hover {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.copy-code-btn.copied {
    background: #4ade80;
    color: white;
}

/* ====================================
   TABLE OF CONTENTS (Desktop)
   ==================================== */

.toc {
    position: sticky;
    top: 120px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 20px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.toc-list {
    list-style: none;
    padding: 0;
}

.toc-item {
    margin-bottom: 8px;
}

.toc-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.2s;
    display: block;
    padding: 5px 0;
}

.toc-link:hover,
.toc-link.active {
    color: var(--accent-cyan);
    transform: translateX(5px);
}

.toc-link.active {
    font-weight: 600;
}

/* ====================================
   MOBILE TOC
   ==================================== */

#mobile-toc-btn {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    align-items: center;
    justify-content: center;
}

.mobile-toc-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
}

.mobile-toc-overlay.active {
    display: block;
}

.mobile-toc-panel {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 30px;
    z-index: 9999;
    transition: bottom 0.3s ease;
    overflow-y: auto;
}

.mobile-toc-panel.active {
    bottom: 0;
}

.mobile-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mobile-toc-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-toc-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ====================================
   TAGS SECTION
   ==================================== */

.article-tags {
    margin: 60px 0;
    padding: 30px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tags-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s;
}

.tag:hover {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: white;
    transform: translateY(-2px);
}

/* ====================================
   SUGGESTIONS SECTIONS
   ==================================== */

.suggestions-section,
.explore-section {
    margin: 60px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s;
    text-decoration: none;
    display: block;
}

.suggestion-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 217, 255, 0.15);
    border-color: var(--accent-cyan);
}

.suggestion-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.suggestion-card-content {
    padding: 20px;
}

.suggestion-card-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent-cyan);
    font-weight: 600;
    margin-bottom: 10px;
}

.suggestion-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.3;
}

.suggestion-card-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ====================================
   EXPLORE TOPICS
   ==================================== */

.explore-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
}

.explore-title {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.topic-pills {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.topic-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topic-pill:hover {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(176, 102, 255, 0.3);
}

.expanded-suggestions {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ====================================
   ARTICLE NAVIGATION
   ==================================== */

.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 60px 0;
}

.article-nav-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 25px;
    text-decoration: none;
    transition: all 0.3s;
    display: block;
}

.article-nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-cyan);
    transform: translateY(-3px);
}

.article-nav-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.article-nav-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ====================================
   RESPONSIVE DESIGN
   ==================================== */

/* Tablet */
@media (max-width: 1024px) {
    .article-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    /* Share sidebar styling moved to 768px breakpoint below */
    
    .toc {
        display: none;
    }
    
    #mobile-toc-btn {
        display: flex;
    }
    
    .article-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .article-nav-btn {
        text-align: left !important;
    }
    
    .suggestion-grid {
        grid-template-columns: 1fr;
    }
    
    .topic-pills {
        flex-direction: column;
        align-items: stretch;
    }
    
    .topic-pill {
        width: 100%;
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .article-container {
        margin: 90px auto 0;
        padding: 0 0 180px; /* Remove side padding, let content handle it */
        max-width: 100%;
        overflow-x: hidden;
        width: 100%;
    }
    
    .article-hero {
        margin-bottom: 20px;
        padding: 0 15px; /* Add padding here */
    }
    
    .article-meta {
        font-size: 0.8rem;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .article-meta-item {
        font-size: 0.8rem;
    }
    
    .article-category {
        font-size: 0.75rem;
        padding: 3px 10px;
    }
    
    .article-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
        line-height: 1.3;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .article-excerpt {
        font-size: 1rem;
        margin-bottom: 15px;
        line-height: 1.5;
    }
    
    .article-hero-image {
        max-height: 220px;
        margin-bottom: 15px;
        border-radius: 0; /* Full width image */
        width: 100vw;
        margin-left: -15px;
        margin-right: -15px;
        object-fit: cover;
    }
    
    .article-content {
        font-size: 1rem;
        max-width: 100%;
        line-height: 1.7;
        padding: 0 15px; /* Add padding to content */
        overflow-x: hidden;
        word-wrap: break-word;
    }
    
    .article-content h2 {
        font-size: 1.4rem;
        margin-top: 35px;
        margin-bottom: 15px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .article-content h3 {
        font-size: 1.15rem;
        margin-top: 25px;
        margin-bottom: 12px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .article-content p {
        margin-bottom: 20px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* CRITICAL: Fix code blocks to fit screen */
    .article-content pre {
        padding: 12px;
        font-size: 0.75rem; /* Smaller font */
        margin: 20px 0; /* No negative margins */
        border-radius: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .article-content pre code {
        font-size: 0.75rem;
        white-space: pre; /* Don't wrap */
        word-wrap: normal;
        overflow-wrap: normal;
    }
    
    .article-content code {
        font-size: 0.85em;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .article-content blockquote {
        font-size: 1.05rem;
        padding-left: 15px;
        margin: 20px 0;
        word-wrap: break-word;
    }
    
    .article-content ul,
    .article-content ol {
        padding-left: 20px;
    }
    
    .article-content img {
        max-width: 100%;
        height: auto;
    }
    
    .copy-code-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
        top: 8px;
        right: 8px;
    }
    
    .share-btn {
        width: 42px;
        height: 42px;
    }
    
    .article-tags {
        margin: 30px 0;
        padding: 15px;
    }
    
    .tags-list {
        gap: 8px;
    }
    
    .tag {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .suggestions-section {
        margin: 30px 0;
        padding: 0 15px;
    }
    
    .section-title {
        font-size: 1.3rem;
        line-height: 1.3;
    }
    
    .suggestion-card-content {
        padding: 15px;
    }
    
    .suggestion-card-title {
        font-size: 1.05rem;
        word-wrap: break-word;
    }
    
    .explore-section {
        padding: 25px 15px;
        margin: 30px 15px;
    }
    
    .explore-title {
        font-size: 1.1rem;
        margin-bottom: 20px;
        line-height: 1.3;
    }
    
    .topic-pill {
        font-size: 0.9rem;
        padding: 10px 20px;
    }
    
    .article-nav {
        margin: 40px 15px;
    }
    
    .article-nav-btn {
        padding: 15px;
    }
    
    .article-nav-label {
        font-size: 0.75rem;
    }
    
    .article-nav-title {
        font-size: 0.95rem;
        line-height: 1.3;
        word-wrap: break-word;
    }
    
    #mobile-toc-btn {
        bottom: 70px;
        left: 15px;
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .article-container {
        padding: 0 12px 180px; /* Reduced for compact bar */
    }
    
    .article-title {
        font-size: 1.35rem;
    }
    
    .article-excerpt {
        font-size: 0.95rem;
    }
    
    .article-content {
        font-size: 0.95rem;
    }
    
    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .share-sidebar {
        flex-wrap: wrap;
        max-width: calc(100vw - 80px);
        bottom: 15px;
        right: 12px;
        gap: 6px;
        padding: 8px;
    }
    
    .share-btn {
        width: 40px;
        height: 40px;
    }
    
    #mobile-toc-btn {
        left: 12px;
        bottom: 65px;
        width: 44px;
        height: 44px;
    }
}

/* Ensure no horizontal scroll */
body {
    overflow-x: hidden;
    width: 100%;
}

.article-layout,
.article-hero,
.article-content,
.article-content * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ====================================
   PRINT STYLES
   ==================================== */

@media print {
    @page {
        margin: 2cm;
    }
    
    body {
        background: white;
        color: black;
    }
    
    header, .share-sidebar, .toc, footer,
    .suggestions-section, .explore-section,
    .article-nav, .article-tags,
    #mobile-toc-btn, #article-progress {
        display: none !important;
    }
    
    .article-container {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }
    
    .article-content {
        max-width: 100%;
        font-size: 11pt;
        line-height: 1.6;
        color: black;
    }
    
    .article-title {
        color: black;
        background: none;
        -webkit-text-fill-color: black;
        page-break-after: avoid;
    }
    
    .article-meta {
        color: #666;
    }
    
    h2, h3 {
        page-break-after: avoid;
        color: black;
    }
    
    pre {
        page-break-inside: avoid;
        border: 1px solid #ddd;
        background: #f9f9f9 !important;
    }
    
    code {
        background: #f0f0f0;
        color: #333;
    }
    
    .copy-code-btn {
        display: none;
    }
    
    blockquote {
        color: #555;
    }
}

/* ====================================
   MOBILE HEADER FIX
   ==================================== */

/* Ensure header is visible and menu works on mobile */
@media (max-width: 768px) {
    header {
        padding: 15px 20px;
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    /* Make sure hamburger is visible */
    .hamburger {
        display: flex !important;
        z-index: 1001;
    }
    
    /* Mobile nav styles */
    #main-nav {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 30px 20px;
        gap: 0;
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    #main-nav.active {
        left: 0;
    }
    
    #main-nav .nav-link {
        width: 100%;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 1.1rem;
    }
    
    .theme-toggle {
        margin-left: auto;
    }
}

/* Viewport meta fix */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Prevent zoom on input focus (iOS) */
input, textarea, select {
    font-size: 16px !important;
}

/* ====================================
   SHARE BUTTONS - MOBILE FIX
   Compact bottom bar - minimal height
   ==================================== */

@media (max-width: 1024px) {
    /* Compact share bar at bottom */
    .share-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(20px);
        padding: 8px 15px; /* Smaller padding */
        border-radius: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 999;
        box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.3);
        gap: 12px; /* Tighter gap */
        max-width: 100%;
        height: auto; /* Auto height */
        min-height: 56px; /* Minimum height */
        max-height: 60px; /* Maximum height */
    }
    
    .share-btn {
        width: 40px; /* Smaller */
        height: 40px;
        border-radius: 8px;
        flex-shrink: 0; /* Don't shrink */
    }
    
    .share-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Move TOC button up to avoid bottom bar */
    #mobile-toc-btn {
        z-index: 998;
        bottom: 70px; /* Above bottom bar */
        left: 15px;
        width: 44px;
        height: 44px;
        transition: transform 0.3s ease, opacity 0.3s ease;
        transform: translateX(0);
        opacity: 1;
    }
    
    /* Hide TOC button when scrolling down */
    #mobile-toc-btn.hide {
        transform: translateX(-70px); /* Slide off screen */
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 480px) {
    .share-sidebar {
        padding: 6px 12px; /* Even more compact */
        gap: 10px;
        min-height: 52px;
        max-height: 56px;
    }
    
    .share-btn {
        width: 38px; /* Smaller on small screens */
        height: 38px;
    }
    
    .share-btn svg {
        width: 15px;
        height: 15px;
    }
    
    #mobile-toc-btn {
        left: 12px;
        bottom: 65px;
        width: 42px;
        height: 42px;
    }
}

/* ====================================
   CRITICAL FIX - PREVENT HORIZONTAL OVERFLOW
   ==================================== */

/* Force everything to fit screen width */
* {
    max-width: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Article specific fixes */
.article-container,
.article-layout,
.article-hero,
.article-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Force all children to respect width */
.article-content * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Code blocks - critical fix */
.article-content pre {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.article-content pre code {
    display: block;
    white-space: pre;
    word-wrap: normal;
    overflow-wrap: normal;
}

/* Images */
.article-content img {
    max-width: 100% !important;
    height: auto !important;
}

/* Tables */
.article-content table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

/* Mobile specific */
@media (max-width: 768px) {
    /* Tighter constraints */
    .article-container {
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .article-content {
        width: 100%;
        max-width: 100%;
        padding: 0;
        box-sizing: border-box;
    }
    
    /* Code blocks on mobile */
    .article-content pre {
        width: calc(100vw - 30px);
        max-width: calc(100vw - 30px);
        margin-left: -15px;
        margin-right: -15px;
        padding: 15px;
        border-radius: 0;
    }
    
    /* Headings */
    .article-title,
    .article-content h1,
    .article-content h2,
    .article-content h3 {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Blockquotes */
    .article-content blockquote {
        width: 100%;
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        box-sizing: border-box;
    }
}

/* ====================================
   AI SUMMARY STYLES
   ==================================== */

.ai-summary-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.3);
}

.ai-summary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 217, 255, 0.4);
}

.ai-summary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.ai-summary-btn svg {
    flex-shrink: 0;
}

.ai-summary-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--accent-cyan);
    border-radius: 12px;
    padding: 25px;
    margin: 20px 0 30px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-summary-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-summary-time {
    font-size: 0.85rem;
    color: var(--accent-cyan);
    font-weight: 600;
}

.ai-summary-content {
    margin-bottom: 20px;
    line-height: 1.8;
}

.summary-point {
    padding: 10px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.summary-point::before {
    content: "✓ ";
    color: var(--accent-cyan);
    font-weight: bold;
    margin-right: 8px;
}

.ai-summary-footer {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-summary-read-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-summary-read-btn:hover {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: white;
}

/* ====================================
   GAMIFICATION STYLES
   ==================================== */

.reading-stats-widget {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.1), rgba(176, 102, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    margin: 60px 0;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.stats-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.streak-display {
    font-size: 3rem;
}

.view-dashboard-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.view-dashboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 217, 255, 0.4);
}

/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.95), rgba(176, 102, 255, 0.95));
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    z-index: 10000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    animation: achievementPopup 0.5s ease forwards;
}

@keyframes achievementPopup {
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.achievement-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.achievement-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.achievement-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
    margin-bottom: 10px;
}

.achievement-description {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.achievement-xp {
    font-size: 1rem;
    font-weight: 700;
    color: #FFD700;
}

/* Streak Notification */
.streak-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    color: white;
    padding: 20px 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
    z-index: 9998;
    animation: slideInRight 0.4s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.streak-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.streak-text {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.streak-subtext {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .ai-summary-btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .achievement-popup {
        width: 90%;
        max-width: 400px;
        padding: 30px 20px;
    }
    
    .streak-notification {
        right: 15px;
        left: 15px;
        bottom: 80px;
    }
}

/* ====================================
   DESKTOP READABILITY FIX
   Constrain content width for better reading
   ==================================== */

@media (min-width: 769px) {
    /* Constrain hero section for readability */
    .article-hero {
        max-width: 900px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Title and excerpt narrower */
    .article-title,
    .article-excerpt,
    .article-meta,
    .ai-summary-btn,
    .ai-summary-container {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Image can be full width */
    .article-hero-image {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Content narrower for optimal reading */
    .article-content {
        max-width: 680px;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Tags and suggestions also constrained */
    .article-tags,
    .suggestions-section,
    .explore-section,
    .article-nav {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ====================================
   MOBILE LAYOUT FIX (Force Single Column)
   ==================================== */

@media (max-width: 1024px) {
    /* 1. Kill the Grid Layout */
    .article-layout {
        display: block !important; /* Forces items to stack vertically */
        grid-template-columns: 1fr !important;
    }

    /* 2. Move Share Sidebar to Bottom */
    .share-sidebar {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: auto !important;
        
        /* Layout */
        display: flex !important;
        flex-direction: row !important;
        justify-content: center;
        align-items: center;
        gap: 20px;
        
        /* Style */
        background: rgba(10, 10, 15, 0.95); /* Dark background */
        backdrop-filter: blur(15px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 15px !important;
        z-index: 2000 !important; /* Ensure it sits above content */
        box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
    }

    /* 3. Adjust Content Width */
    .article-content, 
    .article-hero {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 4. Hide TOC (Just in case) */
    .toc {
        display: none !important;
    }
}


/* 1. Force Code Blocks to Scroll Internally */
pre {
    max-width: 100%;      /* Don't exceed parent width */
    overflow-x: auto;     /* Add scrollbar only to the code block */
    white-space: pre;     /* Keep formatting */
    border-radius: 8px;   /* Optional: looks nicer */
}

/* 2. Prevent Grid Blowout */
/* This tells the grid column it's allowed to shrink below its content size */
.article-content {
    min-width: 0; 
}

/* 3. Fix Particles.js "Extra 4px" Bug */
/* Canvas elements are inline by default, creating a tiny vertical scrollbar */
#particles-js canvas {
    display: block;
}

/* 4. Ensure Body Hides Horizontal Overflow */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* ====================================
   MOBILE FIXES
   ==================================== */

@media (max-width: 768px) {
    /* 1. HIDE SHARE SIDEBAR ON MOBILE */
    /* This removes the floating icons covering your text */
    .share-sidebar {
        display: none !important;
    }

    /* 2. Fix Header Floating Issue */
    /* Ensures header has a solid background so text doesn't show through */
    header, .glass-panel {
        background: rgba(10, 10, 15, 0.95); /* Solid dark color */
        backdrop-filter: blur(20px);
    }

    /* 3. Ensure Content Grid expands to full width */
    .article-layout {
        display: block; /* Stack everything vertically */
    }
    
    .article-content {
        max-width: 100%;
        padding: 0 5px; /* Small breathing room */
    }
}

/* ====================================
   READING STATS WIDGET (Gamification)
   ==================================== */

.reading-stats-widget {
    background: rgba(10, 10, 15, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    margin: 60px 0 40px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUpFade 0.5s ease-out;
}

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.stats-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
}

.stats-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* The little blue square icon */
.stats-title::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background: var(--accent-cyan);
    border-radius: 2px;
    box-shadow: 0 0 10px var(--accent-cyan);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-item:hover {
    transform: translateY(-3px);
    border-color: var(--accent-cyan);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: var(--text-primary);
    line-height: 1;
}

.streak-display {
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* The big blue button */
.view-dashboard-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.view-dashboard-btn:hover {
    opacity: 0.9;
    transform: scale(1.01);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .reading-stats-widget {
        padding: 20px;
        margin: 40px 0;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr; /* 2x2 grid on mobile */
    }
    .stat-value {
        font-size: 1.5rem;
    }
}