/* Article-specific styles */

.article-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 100px 2rem 4rem;
    background-color: var(--bg-primary);
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Back Button */
.article-back-button {
    margin-bottom: 2rem;
    padding-top: 0.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    background-color: transparent;
}

.back-link:hover {
    color: var(--accent);
    background-color: var(--bg-secondary);
    transform: translateX(-4px);
}

.back-link svg {
    transition: transform 0.2s ease;
}

.back-link:hover svg {
    transform: translateX(-2px);
}

.article-header {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.article-meta {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.article-date::before {
    content: "📅 ";
}

.article-reading-time::before {
    content: "⏱ ";
}

.article-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.article-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.article-author {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.author-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
}

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

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

.author-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Article Content */
.article-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* Prevent horizontal overflow on mobile */
.article-content img,
.article-content svg,
.article-content video {
    max-width: 100%;
    height: auto;
}

.article-content pre,
.article-content code {
    max-width: 100%;
    overflow-x: auto;
}

.article-section {
    margin-bottom: 4rem;
}

.article-section h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 3rem 0 1.5rem;
    letter-spacing: -0.02em;
    scroll-margin-top: 90px;
}

.article-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2.5rem 0 1rem;
    scroll-margin-top: 90px;
}

.article-section h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2rem 0 0.75rem;
}

.article-section p {
    margin-bottom: 1.5rem;
}

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

.article-section li {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.article-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

.article-section em {
    font-style: italic;
}

.article-section a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.article-section a:hover {
    border-bottom-color: var(--accent);
}

.article-section sup {
    font-size: 0.75em;
    color: var(--accent);
    font-weight: 600;
}

/* Table of Contents */
.table-of-contents {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 3rem;
}

.table-of-contents h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 1rem;
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.table-of-contents li {
    margin-bottom: 0.5rem;
}

.table-of-contents a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: block;
    padding: 0.25rem 0;
}

.table-of-contents a:hover {
    color: var(--accent);
    border-bottom-color: transparent;
}

/* Callout Boxes */
.callout {
    padding: 1.5rem;
    border-radius: 12px;
    margin: 2rem 0;
    border-left: 4px solid;
}

.callout h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.callout p:last-child {
    margin-bottom: 0;
}

.callout ul, .callout ol {
    margin-bottom: 0;
}

.callout-info {
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.callout-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
}

.callout-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
}

/* Key Findings Box */
.key-findings {
    background-color: var(--accent-light);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.key-findings h4 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.key-findings ul {
    margin-bottom: 0;
}

/* Example Box */
.example-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.example-box h4 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 1rem;
}

.example-box blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.5rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.example-box code {
    background-color: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Code Blocks */
.code-block {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 2rem 0;
    overflow: hidden;
}

.code-header {
    background-color: var(--bg-tertiary);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.code-block pre {
    margin: 0;
    padding: 1.5rem;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Figures */
.figure {
    margin: 3rem 0;
    text-align: center;
}

.figure-placeholder {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1rem;
}

.figure-placeholder svg {
    width: 100%;
    height: auto;
    max-height: 400px;
}

.figure-caption {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.6;
    padding: 0 1rem;
}

/* Tables */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.comparison-table thead {
    background-color: var(--bg-secondary);
}

.comparison-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
}

.comparison-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.comparison-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

/* References */
.references-list {
    list-style: none;
    counter-reset: ref-counter;
    padding-left: 0;
}

.references-list li {
    counter-increment: ref-counter;
    margin-bottom: 1rem;
    padding-left: 3rem;
    position: relative;
    font-size: 0.95rem;
    scroll-margin-top: 100px;
    transition: background-color 0.2s ease;
}

.references-list li::before {
    content: "[" counter(ref-counter) "]";
    position: absolute;
    left: 0;
    font-weight: 600;
    color: var(--accent);
    min-width: 2.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .article-container {
        padding: 90px 1.5rem 3rem;
    }

    .article-back-button {
        margin-bottom: 1.5rem;
    }

    .back-link {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
        min-height: 44px; /* Touch target size */
    }

    .article-title {
        font-size: 1.75rem;
        line-height: 1.3;
        word-wrap: break-word;
    }

    .article-subtitle {
        font-size: 1rem;
        line-height: 1.5;
    }

    .article-content {
        font-size: 1rem;
        line-height: 1.7;
    }

    .article-section h2 {
        font-size: 1.5rem;
        margin: 2rem 0 1rem;
        line-height: 1.3;
    }

    .article-section h3 {
        font-size: 1.25rem;
        margin: 1.5rem 0 0.75rem;
        line-height: 1.3;
    }

    .article-section h4 {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    .table-of-contents {
        padding: 1.5rem;
        font-size: 0.95rem;
    }

    .table-of-contents a {
        padding: 0.5rem 0;
        min-height: 44px; /* Touch target size */
        display: flex;
        align-items: center;
    }

    .callout, .example-box, .key-findings {
        padding: 1.25rem;
        margin: 1.5rem 0;
    }

    .code-block {
        margin: 1.5rem 0;
    }

    .code-block pre {
        padding: 1rem;
        font-size: 0.8rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .comparison-table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.75rem 0.5rem;
    }

    /* Improve figure readability */
    .figure {
        margin: 1.5rem 0;
    }

    .figure-caption {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    /* Better touch targets for citation links */
    sup a {
        padding: 0.25rem;
        margin: 0 0.1rem;
    }

    /* Ensure images don't overflow */
    .article-content img {
        max-width: 100%;
        height: auto;
    }

    /* Author section on mobile */
    .article-author {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
    }

    .author-avatar {
        width: 60px;
        height: 60px;
    }

    /* Back to top button responsive */
    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 45px;
        height: 45px;
    }
    
    .back-to-top svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .article-container {
        padding: 80px 1rem 2rem;
    }

    .article-title {
        font-size: 1.5rem;
        line-height: 1.25;
    }

    .article-subtitle {
        font-size: 0.95rem;
    }

    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        font-size: 0.85rem;
    }

    .article-section {
        margin-bottom: 2rem;
    }

    .article-section h2 {
        font-size: 1.35rem;
        margin: 1.5rem 0 0.75rem;
    }

    .article-section h3 {
        font-size: 1.15rem;
        margin: 1.25rem 0 0.5rem;
    }

    .article-section h4 {
        font-size: 1rem;
    }

    .article-section p {
        font-size: 0.95rem;
        line-height: 1.7;
        margin-bottom: 1rem;
    }

    .article-section ul, .article-section ol {
        padding-left: 1.5rem;
        font-size: 0.95rem;
        line-height: 1.7;
    }

    .article-section ul li,
    .article-section ol li {
        margin-bottom: 0.75rem;
    }

    .table-of-contents {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .table-of-contents h3 {
        font-size: 1.1rem;
    }

    .callout, .example-box, .key-findings {
        padding: 1rem;
        margin: 1.25rem 0;
        font-size: 0.9rem;
    }

    .callout h4, .example-box h4, .key-findings h4 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .code-block {
        margin: 1.25rem 0;
    }

    .code-block pre {
        padding: 0.75rem;
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .code-header {
        font-size: 0.85rem;
        padding: 0.75rem;
    }

    .figure-placeholder {
        padding: 0.75rem;
    }

    .figure-placeholder svg {
        max-height: 250px;
    }

    .figure-caption {
        font-size: 0.8rem;
        padding: 0.75rem;
    }

    /* Make tables scroll horizontally on small screens */
    .comparison-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.8rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem 0.4rem;
    }

    /* References on mobile */
    .references-list {
        font-size: 0.85rem;
    }

    .references-list li {
        padding-left: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .references-list li::before {
        min-width: 2rem;
        font-size: 0.85rem;
    }

    /* Back link adjustments */
    .back-link {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    /* Improved spacing for better readability */
    .article-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Back to top button on mobile */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .back-to-top svg {
        width: 18px;
        height: 18px;
    }
}

/* Citation Links */
sup a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

sup a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Reference List Target Highlighting */
.references-list li:target {
    background-color: var(--accent-light);
    padding: 0.5rem 0.5rem 0.5rem 3rem;
    margin-left: -0.5rem;
    border-radius: 4px;
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background-color: var(--accent-light);
    }
    100% {
        background-color: transparent;
    }
}

/* Floating Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.back-to-top:active {
    transform: translateY(-2px);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* Print Styles */
@media print {
    .navbar,
    .footer,
    .back-to-top {
        display: none;
    }

    .article-container {
        padding: 0;
        max-width: 100%;
    }

    .article-section {
        page-break-inside: avoid;
    }

    .article-section h2,
    .article-section h3 {
        page-break-after: avoid;
    }

    .figure,
    .code-block,
    .example-box {
        page-break-inside: avoid;
    }

    .callout {
        border: 1px solid #ccc;
    }

    body {
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: white;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}
