/* ═══════════════════════════════════════════════════════════════
   Professional Article Typography System
   For Kurdish Diaspora Magazine
   ═══════════════════════════════════════════════════════════════

   Features:
   - Modern newspaper/magazine typography
   - Perfect readability with optimized line-height and spacing
   - Professional heading hierarchy
   - Beautiful blockquotes
   - Responsive tables
   - RTL support for Kurdish/Arabic
   - Mobile-friendly layout
   ═══════════════════════════════════════════════════════════════ */

/* ─── RTL / LTR Direction Helpers ───────────────────────────── */
.ltr-content {
    direction: ltr;
    text-align: left;
}

.rtl-content {
    direction: rtl;
    text-align: right;
}

/* ─── Base Article Container ─────────────────────────────────── */
.article-content {
    font-family: var(--font-primary, 'Inter', system-ui, sans-serif);
    font-size: 1.125rem; /* 18px */
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 720px;
    margin: 0 auto;
}

/* RTL specific adjustments */
[dir="rtl"] .article-content {
    font-family: var(--font-ku, 'Noto Naskh Arabic', 'Segoe UI', sans-serif);
    line-height: 2;
    word-spacing: 0.05em;
    letter-spacing: 0.01em;
}

/* ─── Paragraphs ─────────────────────────────────────────────── */
.article-content p {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: justify;
}

.article-content p:first-of-type {
    font-size: 1.25rem;
    line-height: 1.75;
    font-weight: 400;
}

[dir="rtl"] .article-content p {
    text-align: justify;
}

/* ─── Line Break Preservation ────────────────────────────────── */
/* CRITICAL: Preserve line breaks in poems, lyrics, and formatted text */

/* Ensure br tags create visible line breaks with proper spacing */
.article-content br {
    content: "";
    display: block;
    margin-bottom: 0.25em;
}

/* Preserve spacing for adjacent br tags (blank lines) */
.article-content br + br {
    margin-bottom: 0.75em;
}

/* For poetry and formatted content - center aligned with preserved line breaks */
.article-content.poetry,
.article-content.formatted {
    text-align: center;
    line-height: 2.2;
}

[dir="rtl"] .article-content.poetry,
[dir="rtl"] .article-content.formatted {
    text-align: center;
}

/* ─── Headings ───────────────────────────────────────────────── */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    font-family: var(--font-primary);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    scroll-margin-top: 120px;
}

[dir="rtl"] .article-content h1,
[dir="rtl"] .article-content h2,
[dir="rtl"] .article-content h3,
[dir="rtl"] .article-content h4 {
    font-family: var(--font-ku);
    font-weight: 700;
    line-height: 1.5;
}

.article-content h1 {
    font-size: 2.5rem; /* 40px */
    margin-top: 3rem;
}

.article-content h2 {
    font-size: 2rem; /* 32px */
    border-bottom: 3px solid var(--accent);
    padding-bottom: 0.5rem;
    margin-top: 3rem;
}

.article-content h3 {
    font-size: 1.5rem; /* 24px */
    margin-top: 2rem;
}

.article-content h4 {
    font-size: 1.25rem; /* 20px */
}

.article-content h5 {
    font-size: 1.125rem; /* 18px */
}

.article-content h6 {
    font-size: 1rem; /* 16px */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

/* ─── Lists ──────────────────────────────────────────────────── */
.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

[dir="rtl"] .article-content ul,
[dir="rtl"] .article-content ol {
    padding-left: 0;
    padding-right: 2rem;
}

.article-content ul {
    list-style-type: disc;
}

.article-content ol {
    list-style-type: decimal;
}

.article-content li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.article-content li::marker {
    color: var(--accent);
    font-weight: 600;
}

.article-content ul ul,
.article-content ol ol,
.article-content ul ol,
.article-content ol ul {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

/* ─── Blockquotes ────────────────────────────────────────────── */
.article-content blockquote {
    position: relative;
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    background: var(--bg-tertiary);
    border-left: 5px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 1.125rem;
    font-style: italic;
    color: var(--text-secondary);
    quotes: """ """ "'" "'";
}

[dir="rtl"] .article-content blockquote {
    border-left: none;
    border-right: 5px solid var(--accent);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.article-content blockquote::before {
    content: open-quote;
    font-size: 4rem;
    line-height: 0.1em;
    margin-right: 0.25rem;
    vertical-align: -0.4em;
    color: var(--accent);
    opacity: 0.3;
}

.article-content blockquote p {
    display: inline;
    margin: 0;
}

.article-content blockquote footer,
.article-content blockquote cite {
    display: block;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-style: normal;
    color: var(--text-tertiary);
}

.article-content blockquote footer::before,
.article-content blockquote cite::before {
    content: "— ";
}

/* ─── Links ──────────────────────────────────────────────────── */
.article-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1.5px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.article-content a:hover {
    color: var(--accent-hover);
    text-decoration-thickness: 2.5px;
}

.article-content a:visited {
    color: #8b5cf6;
}

/* ─── Images ─────────────────────────────────────────────────── */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: 2rem auto;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.article-content figure {
    margin: 2rem 0;
}

.article-content figure img {
    margin: 0 auto 1rem;
}

.article-content figcaption {
    text-align: center;
    font-size: 0.875rem;
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

/* Image alignment classes */
.article-content .image-left {
    float: left;
    margin-right: 1.5rem;
    margin-bottom: 1rem;
    max-width: 45%;
}

[dir="rtl"] .article-content .image-left {
    float: right;
    margin-right: 0;
    margin-left: 1.5rem;
}

.article-content .image-right {
    float: right;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    max-width: 45%;
}

[dir="rtl"] .article-content .image-right {
    float: left;
    margin-left: 0;
    margin-right: 1.5rem;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.article-content table {
    width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.article-content thead {
    background: var(--accent);
    color: white;
}

.article-content th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8125rem;
    letter-spacing: 0.05em;
}

[dir="rtl"] .article-content th {
    text-align: right;
}

.article-content td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

[dir="rtl"] .article-content td {
    text-align: right;
}

.article-content tbody tr:hover {
    background: var(--bg-secondary);
}

.article-content tbody tr:last-child td {
    border-bottom: none;
}

/* Responsive table wrapper */
.article-content .table-wrapper {
    overflow-x: auto;
    margin: 2rem 0;
}

/* ─── Code Blocks ────────────────────────────────────────────── */
.article-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 2rem 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.article-content code {
    background: var(--bg-tertiary);
    color: var(--accent);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
}

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

/* ─── Horizontal Rules ───────────────────────────────────────── */
.article-content hr {
    border: none;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    margin: 3rem 0;
}

/* ─── Strong & Emphasis ──────────────────────────────────────── */
.article-content strong,
.article-content b {
    font-weight: 700;
    color: var(--text-primary);
}

.article-content em,
.article-content i {
    font-style: italic;
}

.article-content u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.article-content s,
.article-content del {
    text-decoration: line-through;
    opacity: 0.7;
}

.article-content mark {
    background: var(--color-highlight, #fef08a);
    color: #854d0e;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

/* ─── Embedded Content ───────────────────────────────────────── */
.article-content iframe,
.article-content video {
    max-width: 100%;
    border-radius: var(--radius-lg);
    margin: 2rem auto;
    display: block;
    aspect-ratio: 16/9;
}

/* ─── Special Elements ───────────────────────────────────────── */
.article-content abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

.article-content sub,
.article-content sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.article-content sup {
    top: -0.5em;
}

.article-content sub {
    bottom: -0.25em;
}

/* ─── Keyboard & Output ──────────────────────────────────────── */
.article-content kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-family: monospace;
    font-size: 0.875rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ─── Definition Lists ───────────────────────────────────────── */
.article-content dl {
    margin: 2rem 0;
}

.article-content dt {
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 1rem;
}

.article-content dd {
    margin-left: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

[dir="rtl"] .article-content dd {
    margin-left: 0;
    margin-right: 2rem;
}

/* ─── Drop Cap (First Letter) ────────────────────────────────── */
.article-content.drop-cap > p:first-of-type::first-letter {
    float: left;
    font-size: 4rem;
    line-height: 0.85;
    margin: 0.1rem 0.5rem 0 0;
    font-weight: 800;
    color: var(--accent);
}

[dir="rtl"] .article-content.drop-cap > p:first-of-type::first-letter {
    float: right;
    margin: 0.1rem 0 0 0.5rem;
}

/* ─── Responsive Design ──────────────────────────────────────── */
@media (max-width: 768px) {
    .article-content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .article-content h1 {
        font-size: 1.875rem;
    }

    .article-content h2 {
        font-size: 1.5rem;
    }

    .article-content h3 {
        font-size: 1.25rem;
    }

    .article-content h4 {
        font-size: 1.125rem;
    }

    .article-content .image-left,
    .article-content .image-right {
        float: none;
        max-width: 100%;
        margin: 1.5rem 0;
    }

    .article-content blockquote {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }

    .article-content table {
        font-size: 0.875rem;
    }

    .article-content th,
    .article-content td {
        padding: 0.75rem;
    }
}

/* ─── Dark Mode Support ──────────────────────────────────────── */
.dark .article-content blockquote {
    background: var(--bg-card);
}

.dark .article-content pre {
    background: #0f172a;
}

.dark .article-content table thead {
    background: var(--accent);
}

.dark .article-content tbody tr:hover {
    background: var(--bg-card);
}

/* ─── Print Styles ───────────────────────────────────────────── */
@media print {
    .article-content {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }

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

    .article-content img {
        max-width: 100%;
        page-break-inside: avoid;
    }

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

    .article-content pre {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* ─── Accessibility ──────────────────────────────────────────── */
.article-content :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ─── Selection Style ────────────────────────────────────────── */
.article-content ::selection {
    background: var(--accent);
    color: white;
}
