/* ===========================
   Reusable Article Styles
   =========================== */

/* Highlight.js Theme - Atom One Dark */
@import url('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css');

.blog-header { 
    background: var(--bg-main); 
    color: var(--text-primary); 
    padding: 3rem 0; 
    border-bottom: 1px solid var(--border); 
}

.blog-header .container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3rem;
    align-items: start;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem;
}

.blog-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blog-header-tags {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.blog-header-tag {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    white-space: nowrap;
    margin-right: 0.75rem;
}

.blog-header-tag:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.blog-header h1 { 
    font-size: 1.25rem; 
    font-weight: 600; 
    margin: 0;
    letter-spacing: -0.01em; 
}

.blog-subtitle {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.blog-header-right {
    display: flex;
    align-items: flex-end;
    gap: 2rem;
    justify-content: space-between;
    width: 100%;
}

.blog-meta { 
    display: flex; 
    gap: 1.5rem;
    font-size: 0.95rem; 
    color: var(--text-secondary);
    white-space: nowrap;
}

.blog-meta-item {
    display: flex;
    gap: 0.5rem;
}

.blog-share-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.blog-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.blog-share-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
}

.blog-share-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .blog-header .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .blog-header-right {
        text-align: left;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .blog-meta {
        flex-wrap: wrap;
        white-space: normal;
    }

    .blog-share-buttons {
        justify-content: flex-start;
    }

    .blog-meta-item {
        justify-content: flex-start;
    }

    .blog-subtitle {
        font-size: 1.75rem;
    }
}

.blog-content { 
    max-width: 800px; 
    margin: 0 auto; 
    padding: 3rem 2rem; 
}

.blog-content h2 { 
    font-size: 1.75rem; 
    font-weight: 700; 
    margin-top: 2.5rem; 
    margin-bottom: 1rem; 
    color: var(--text-primary); 
}

.blog-content h3 { 
    font-size: 1.375rem; 
    font-weight: 700; 
    margin-top: 1.75rem; 
    margin-bottom: 0.75rem; 
    color: var(--text-primary); 
}

.blog-content p { 
    font-size: 1rem; 
    line-height: 1.8; 
    color: var(--text-secondary); 
    margin-bottom: 1.5rem; 
}

.blog-content ul, .blog-content ol { 
    margin-left: 2rem; 
    margin-bottom: 1.5rem; 
}

.blog-content li { 
    font-size: 1rem; 
    line-height: 1.8; 
    color: var(--text-secondary); 
    margin-bottom: 0.75rem; 
}

.blog-content a { 
    color: var(--primary); 
    text-decoration: none; 
    font-weight: 600; 
    transition: var(--transition); 
}

.blog-content a:hover { 
    color: var(--primary-hover); 
    text-decoration: underline; 
}

.blog-content table { 
    width: 100%; 
    border-collapse: collapse; 
    margin: 1.5rem 0; 
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.blog-content table th, .blog-content table td { 
    border: 1px solid var(--border); 
    padding: 0.75rem; 
    text-align: left; 
}

.blog-content table th { 
    background: linear-gradient(135deg, var(--bg-secondary) 0%, color-mix(in srgb, var(--bg-secondary) 80%, var(--primary) 20%) 100%);
    font-weight: 700; 
    color: var(--text-primary); 
    padding: 1rem 0.75rem;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.blog-content table td {
    vertical-align: middle;
}

.blog-content table tr:nth-child(even) {
    background: color-mix(in srgb, var(--bg-secondary) 40%, transparent);
}

.blog-content table tr:hover {
    background: color-mix(in srgb, var(--bg-secondary) 60%, transparent);
    transition: var(--transition);
}

/* ===========================
   Code Block Styles
   =========================== */

.blog-content pre { 
    background: color-mix(in srgb, var(--bg-secondary) 30%, transparent); 
    padding: 1.5rem; 
    border-radius: var(--radius-lg); 
    overflow-x: auto; 
    margin: 1.5rem 0; 
    border: 1px solid var(--border); 
    font-size: 0.85rem; 
    position: relative; 
}

.blog-content code { 
    background: transparent; 
    padding: 0.2rem 0.4rem; 
    border-radius: 3px; 
    font-family: 'Courier New', monospace; 
    font-size: 0.9rem; 
    color: var(--primary); 
}

.blog-content pre code { 
    background: none; 
    padding: 0; 
    color: var(--text-secondary); 
}

.code-block-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 1rem; 
    font-size: 0.85rem; 
}

.code-block-header span { 
    color: var(--text-tertiary); 
    font-weight: 600; 
}

.code-block-actions { 
    display: flex; 
    gap: 0.75rem; 
}

.code-btn { 
    background: transparent; 
    color: var(--primary); 
    border: 1.5px solid var(--primary); 
    padding: 0.4rem 0.8rem; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 0.8rem; 
    font-weight: 600; 
    transition: var(--transition); 
    box-shadow: 0 0 8px rgba(255, 68, 68, 0.2);
}

.code-btn:hover { 
    background: rgba(255, 68, 68, 0.05);
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.4);
}

.code-btn.copied { 
    background: transparent;
    color: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.code-btn a { 
    color: inherit; 
    text-decoration: none; 
    display: flex; 
    align-items: center; 
    gap: 0.3rem; 
}

.code-btn a:hover { 
    color: inherit; 
}

/* ===========================
   Key Concept Boxes
   =========================== */

.key-concept { 
    background: var(--bg-secondary); 
    border-left: 4px solid var(--primary); 
    padding: 0.5rem 1.5rem; 
    margin: 0.5rem 0; 
    border-radius: 4px; 
}

.back-link { 
    display: inline-block; 
    margin-bottom: 0.5rem; 
    color: var(--primary); 
    text-decoration: none; 
    font-weight: 600; 
}

.blog-content strong { 
    color: var(--text-primary); 
    font-weight: 700; 
}


/* ===========================
   Share Section
   =========================== */

.article-share {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.share-title {
    color: var(--text-tertiary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.share-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.share-btn {
    display: none;
}

.blog-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.blog-share-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
}

.blog-share-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.share-btn svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.share-btn img {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ===========================
   Image Lightbox Modal
   =========================== */

.blog-content img {
    cursor: pointer;
    transition: var(--transition);
}

.blog-content img:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease-in-out;
}

.image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: slideUp 0.3s ease-in-out;
}

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

.image-modal-content img {
    width: 100%;
    height: auto;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: auto;
}

.image-modal-content img:hover {
    opacity: 1;
    transform: none;
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.image-modal-close:hover {
    color: var(--primary);
    transform: scale(1.2);
}

.image-modal-caption {
    color: white;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    max-width: 90vw;
    line-height: 1.5;
}

/* ===========================
   Responsive Design
   =========================== */

/* ===========================
   Article-Specific Components
   =========================== */

.image-placeholder {
    text-align: center;
    margin: 2rem 0;
    overflow: hidden;
    width: 100%;
}

.image-placeholder img {
    max-width: 100%;
    width: 90%;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

/* Main Article Header Image */
.article-header-image {
    text-align: center;
    margin: 1.5rem auto 2rem auto;
    overflow: hidden;
    width: 100%;
    max-width: 800px;
    padding: 0 2rem;
    box-sizing: border-box;
}

.article-header-image img {
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

/* Article Content Image (full height) */
.blog-content .article-image {
    text-align: center;
    margin: 2rem 0;
    width: 100%;
    height: auto !important;
    overflow: visible !important;
}

.blog-content .article-image img {
    max-width: 100%;
    width: auto;
    height: auto !important;
    object-fit: contain !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    margin: 0 auto;
}

.blog-content .article-image figcaption {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.75rem;
}

.article-header-image p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.article-header-image a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.article-header-image a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.image-placeholder p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.image-placeholder a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.image-placeholder a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ===========================
   YouTube Embed Styles
   =========================== */

.youtube-embed {
    position: relative;
    width: 90%;
    padding-bottom: 50.625%; /* 16:9 aspect ratio of 90% width */
    margin: 2rem auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius-lg);
}

@media (max-width: 768px) {
    .youtube-embed {
        width: 95%;
        padding-bottom: 53.4375%; /* 16:9 of 95% */
    }
}

@media (max-width: 480px) {
    .youtube-embed {
        width: 100%;
        padding-bottom: 56.25%; /* 16:9 of 100% */
    }
}

.key-points-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    background: none;
    border: none;
    padding: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    width: 100%;
    text-align: left;
}

.key-points-toggle:hover {
    opacity: 0.8;
}

.key-points-arrow {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 1.25rem;
}

.key-points-arrow.collapsed {
    transform: rotate(-90deg);
}

.key-points-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    margin-top: 0;
}

.key-points-content.expanded {
    max-height: 1000px;
    opacity: 1;
    margin-top: 1rem;
}

.stat-highlight {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--primary);
}

.callout-box {
    background: color-mix(in srgb, var(--primary) 5%, transparent);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin: 2rem 0;
    border: 1px solid var(--border);
}

.callout-box strong {
    color: var(--primary);
}

/* ===========================
   Citation Link Styles
   =========================== */

.citation-link {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    display: inline-block;
    margin-left: 0.5rem;
    background: color-mix(in srgb, var(--bg-secondary) 30%, transparent);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    vertical-align: middle;
}

.blog-content h4:has(+ .citation-link) {
    display: inline;
}

.blog-content h3:has(+ .citation-link) {
    display: inline;
}

.blog-content h3 + .citation-link,
.blog-content h4 + .citation-link {
    margin-bottom: 0.5rem;
}

.blog-content h3 + .citation-link + p,
.blog-content h4 + .citation-link + p {
    margin-top: 0.5rem;
}

.citation-link::after {
    content: " ↗";
    font-size: 0.55rem;
    vertical-align: super;
}

.citation-link:hover {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border-color: var(--primary);
}

/* ===========================
   Drop Cap Styles
   =========================== */

.blog-content p.drop-cap::first-letter {
    float: left;
    font-size: 3.5rem;
    line-height: 2.5rem;
    padding-right: 0.5rem;
    margin-top: 0.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
    .blog-content p.drop-cap::first-letter {
        font-size: 2.5rem;
        line-height: 2rem;
    }

    .blog-header h1 { 
        font-size: 1.75rem; 
    }
    
    .blog-content { 
        padding: 2rem 1.5rem; 
    }
    
    .blog-content h2 { 
        font-size: 1.5rem; 
    }
    
    .blog-content h3 { 
        font-size: 1.125rem; 
    }
    
    .blog-content p, .blog-content li { 
        font-size: 0.95rem; 
    }

    .blog-content table {
        font-size: 0.85rem;
    }

    .blog-content table th, .blog-content table td {
        padding: 0.5rem;
    }
    
    .code-block-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .code-block-actions {
        width: 100%;
    }
    
    .code-btn {
        flex: 1;
    }

    .image-placeholder img {
        width: 95%;
    }

    .article-header-image img {
        width: 100%;
        max-height: 300px;
    }

    .key-points-box {
        padding: 1.25rem;
    }
}

@media (max-width: 480px) {
    .image-placeholder img {
        width: 100%;
    }

    .image-placeholder {
        margin: 1.5rem 0;
    }

    .article-header-image img {
        width: 100%;
        max-height: 250px;
    }

    .key-points-box {
        padding: 1rem;
        margin: 1.5rem 0;
    }

    .key-points-box h2 {
        font-size: 1.25rem;
    }
}
