/* ═══════════════════════════════════════════════════════════════════
   GUIDE TYPOGRAPHY — readability + per-language fonts + colored links
   Loads AFTER style.css so these rules win on conflicts.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Per-language font stacks ────────────────────────────────────── */
:root {
    --font-latin: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-he: 'Heebo', 'Assistant', 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-ar: 'Noto Sans Arabic', 'Tajawal', 'IBM Plex Sans Arabic', 'Geeza Pro', 'Segoe UI', 'Tahoma', sans-serif;
    --font-hi: 'Noto Sans Devanagari', 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    /* Link palette — AA-contrast on dark bg, brighter & more saturated than v1.0 */
    --link-color: #5BB7FF;
    --link-hover: #9FD4FF;
    --link-visited: #C9B0FF;
    --link-underline: rgba(91, 183, 255, 0.45);
}

html[lang="ar"] body,
html[lang="ar"] .article-body { font-family: var(--font-ar); }
html[lang="he"] body,
html[lang="he"] .article-body { font-family: var(--font-he); }
html[lang="hi"] body,
html[lang="hi"] .article-body { font-family: var(--font-hi); }

/* ─── Article body: bigger, airier, easier to read ────────────────── */
.article-body {
    font-size: 17.5px;
    line-height: 1.8;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
    hanging-punctuation: first allow-end;
}

html[lang="ar"] .article-body {
    font-size: 19px;
    line-height: 2.0;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1, "init" 1, "medi" 1, "fina" 1;
    word-spacing: 0.04em;
    /* Arabic prefers slightly heavier base weight for readability on dark bg */
    font-weight: 400;
}

html[lang="he"] .article-body {
    font-size: 17.5px;
    line-height: 1.9;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
    /* Heebo renders better with explicit medium weight for body */
    font-weight: 400;
}

.article-body p {
    margin-block-end: 20px;
    color: var(--text);
}

/* limit line length for prose readability — ~75ch is the sweet spot */
.article-body > p,
.article-body > ul,
.article-body > ol {
    max-width: 75ch;
}
html[lang="ar"] .article-body > p,
html[lang="ar"] .article-body > ul,
html[lang="ar"] .article-body > ol { max-width: 70ch; }

/* ─── Headings: confident, clear hierarchy ────────────────────────── */
.article-body h2 {
    font-size: 32px;
    font-weight: 800;
    margin-block: 56px 20px;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--text);
    text-wrap: balance;
    position: relative;
    padding-block-end: 12px;
    border-block-end: 2px solid rgba(91, 183, 255, 0.18);
}
.article-body h3 {
    font-size: 23px;
    font-weight: 700;
    margin-block: 38px 14px;
    line-height: 1.35;
    letter-spacing: -0.005em;
    color: var(--text);
    text-wrap: balance;
}
.article-body h4 {
    font-size: 18px;
    font-weight: 700;
    margin-block: 24px 10px;
    color: var(--text);
    letter-spacing: 0;
}
html[lang="ar"] .article-body h2 { font-size: 32px; font-weight: 700; letter-spacing: 0; line-height: 1.45; }
html[lang="ar"] .article-body h3 { font-size: 24px; font-weight: 700; letter-spacing: 0; line-height: 1.5; }
html[lang="he"] .article-body h2 { letter-spacing: 0; font-weight: 800; }
html[lang="he"] .article-body h3 { letter-spacing: 0; font-weight: 700; }

/* ─── Links: ALWAYS visibly colored, accessible, language-agnostic ── */
.article-body a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: color .15s ease, text-decoration-color .15s ease, background-color .15s ease;
    word-break: break-word;
    font-weight: 500;
    border-radius: 2px;
}
.article-body a:hover,
.article-body a:focus-visible {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
    text-decoration-thickness: 2px;
    background-color: rgba(91, 183, 255, 0.08);
}
.article-body a:visited { color: var(--link-visited); }
.article-body a:focus-visible {
    outline: 2px solid var(--link-hover);
    outline-offset: 3px;
}

/* External link indicator (subtle) */
.article-body a[href^="http"]:not([href*="polymarkets.co.il"])::after {
    content: " ↗";
    font-size: 0.85em;
    opacity: 0.7;
    margin-inline-start: 1px;
}

/* ─── Lists: better spacing & marker color ────────────────────────── */
.article-body ul,
.article-body ol {
    margin-block: 18px;
    padding-inline-start: 26px;
}
.article-body li {
    margin-block-end: 8px;
    line-height: 1.8;
}
.article-body ul li::marker { color: var(--link-color); }
.article-body ol li::marker { color: var(--link-color); font-weight: 600; }

/* ─── Strong / em: subtle emphasis ────────────────────────────────── */
.article-body strong { color: var(--text); font-weight: 700; }
.article-body em { color: var(--text); font-style: italic; }

/* ─── Inline code: monospace, language-aware ──────────────────────── */
.article-body code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.92em;
    color: #FFD580;
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: isolate;
}

/* ─── Blockquote: logical-property based, RTL safe ────────────────── */
.article-body blockquote {
    border: none;
    border-inline-start: 3px solid var(--accent);
    padding: 14px 20px;
    margin-block: 24px;
    background: var(--bg-surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}
html[dir="rtl"] .article-body blockquote {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ─── Tables: logical alignment, striped rows, hover state ────────── */
.article-body table {
    margin-block: 28px;
    font-size: 15px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border-collapse: collapse;
    width: 100%;
}
.article-body th {
    background: rgba(91, 183, 255, 0.10);
    color: var(--text);
    font-weight: 700;
    border-block-end: 2px solid rgba(91, 183, 255, 0.25);
}
.article-body th,
.article-body td {
    text-align: start;
    padding: 12px 16px;
    border-block-end: 1px solid var(--border);
    vertical-align: top;
}
.article-body tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}
.article-body tbody tr {
    transition: background .12s ease;
}
.article-body tbody tr:hover {
    background: rgba(91, 183, 255, 0.06);
}
html[lang="ar"] .article-body table { font-size: 16px; }
html[lang="he"] .article-body table { font-size: 15.5px; }

/* ─── Callout boxes: tinted backgrounds, logical borders ──────────── */
.info-box, .warning-box, .success-box, .example-box {
    border-inline-start: 4px solid var(--accent);
    border-right: none;
    border-left: none;
    padding: 18px 22px;
    line-height: 1.8;
    font-size: 15.5px;
    border-radius: var(--radius-sm);
    margin-block: 22px;
}
.info-box {
    border-inline-start-color: #5BB7FF;
    background: rgba(91, 183, 255, 0.07);
}
.warning-box {
    border-inline-start-color: var(--yellow, #FFC857);
    background: rgba(255, 200, 87, 0.07);
}
.success-box {
    border-inline-start-color: var(--green, #4ADE80);
    background: rgba(74, 222, 128, 0.07);
}
.example-box {
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--text-secondary);
    background: rgba(255, 255, 255, 0.025);
}

.info-box h3, .warning-box h3, .success-box h3, .example-box h3 {
    margin-block: 4px 10px !important;
    font-size: 17px !important;
    padding-block-end: 0 !important;
    border-block-end: none !important;
}
html[lang="ar"] .info-box, html[lang="ar"] .warning-box,
html[lang="ar"] .success-box, html[lang="ar"] .example-box { font-size: 17px; line-height: 1.95; }
html[lang="he"] .info-box, html[lang="he"] .warning-box,
html[lang="he"] .success-box, html[lang="he"] .example-box { font-size: 16px; line-height: 1.9; }

.info-box ul, .warning-box ul, .success-box ul, .example-box ul,
.info-box ol, .warning-box ol, .success-box ol, .example-box ol {
    margin-block: 8px;
}
.info-box a, .warning-box a, .success-box a, .example-box a {
    color: var(--link-hover);
}

/* ─── Screenshots: caption polish ─────────────────────────────────── */
.guide-screenshot {
    margin-block: 28px;
}
.guide-screenshot img {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.screenshot-caption {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-block-start: 8px;
    line-height: 1.6;
    font-style: italic;
}

/* ─── Chapter break: more presence ───────────────────────────────── */
.pm-chapter-break {
    margin-block: 56px 32px;
}
.chapter-number {
    color: var(--text-secondary);
    font-size: 13px;
    margin-block-end: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
html[lang="ar"] .chapter-number,
html[lang="he"] .chapter-number {
    text-transform: none;
    letter-spacing: 0;
}

/* ─── Mobile: scale headings down gracefully ──────────────────────── */
@media (max-width: 600px) {
    .article-body { font-size: 16.5px; line-height: 1.75; }
    html[lang="ar"] .article-body { font-size: 18px; line-height: 1.95; }
    html[lang="he"] .article-body { font-size: 16.5px; line-height: 1.85; }
    .article-body h2 { font-size: 25px; margin-block: 40px 14px; padding-block-end: 8px; }
    html[lang="ar"] .article-body h2 { font-size: 26px; line-height: 1.4; }
    .article-body h3 { font-size: 19.5px; margin-block: 30px 10px; }
    html[lang="ar"] .article-body h3 { font-size: 21px; line-height: 1.45; }
    .article-body p { margin-block-end: 16px; }
    .article-body table { font-size: 14px; }
    html[lang="ar"] .article-body table { font-size: 15px; }
    .article-body th, .article-body td { padding: 10px 11px; }
    /* Bigger tap targets for mobile links */
    .article-body a { padding-block: 2px; }
}

/* ─── Reduced motion: respect user preference ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .article-body a,
    .article-body tbody tr {
        transition: none;
    }
}
