/* ============================================================================
 * RemotePass Blog Typography
 * ----------------------------------------------------------------------------
 * Modern, readable blog chrome — single posts, listing/card grid, byline,
 * pagination, related-posts grid. Scoped to .rp-blog-* hooks emitted by the
 * shortcodes in inc/blog-setup.php so we never bleed onto the rest of the
 * site (homepage, country hubs, product pages all keep their existing
 * Mulish-driven look).
 *
 * Design tokens mirror the global RemotePass palette:
 *   --brand-blue       #114ef7
 *   --brand-dark-blue  #0f1035  (also text-primary)
 *   --text-secondary   #5a6a85
 *   --border-light     #e3e8f1
 *
 * Font: Inter for LTR, Tajawal for RTL/Arabic. Both are already self-hosted
 * via assets/css/fonts.min.css; this file declares fallbacks but does not
 * @import or @font-face them again.
 *
 * Phase C — 2026-04-30
 * ========================================================================= */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
.rp-blog-post-content,
.rp-blog-hero,
.rp-blog-pagination,
.rp-related-posts-grid,
.rp-related-posts-section,
.rp-byline,
.rp-blog-card,
.rp-blog-cards-wrapper {
    --rp-brand-blue:      #114ef7;
    --rp-brand-blue-soft: #e8efff;
    --rp-brand-dark-blue: #0f1035;
    --rp-text-primary:    #0f1035;
    --rp-text-secondary:  #5a6a85;
    --rp-border-light:    #e3e8f1;
    --rp-bg-light:        #f7f9fc;
    --rp-bg-code:         #f3f5f9;
    --rp-bg-pre:          #0f1035;
    --rp-radius-sm:       6px;
    --rp-radius-md:       8px;
    --rp-radius-lg:       12px;
    --rp-shadow-card:     0 1px 2px rgba(15, 16, 53, 0.04);
    --rp-shadow-hover:    0 12px 32px rgba(15, 16, 53, 0.10);
    --rp-font-body:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --rp-font-ar:         'Tajawal', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* RTL switches the body family. Applied at the root scope so it cascades
   into headings, body copy, byline, and the card grid uniformly. */
[dir="rtl"] .rp-blog-post-content,
[dir="rtl"] .rp-blog-hero,
[dir="rtl"] .rp-blog-pagination,
[dir="rtl"] .rp-related-posts-grid,
[dir="rtl"] .rp-byline,
[dir="rtl"] .rp-blog-card,
[dir="rtl"] .rp-blog-cards-wrapper,
:lang(ar) .rp-blog-post-content,
:lang(ar) .rp-blog-hero,
:lang(ar) .rp-blog-pagination,
:lang(ar) .rp-related-posts-grid,
:lang(ar) .rp-byline,
:lang(ar) .rp-blog-card,
:lang(ar) .rp-blog-cards-wrapper {
    font-family: var(--rp-font-ar);
}

/* ── Body / paragraphs ─────────────────────────────────────────────────── */
.rp-blog-post-content {
    font-family: var(--rp-font-body);
    color: var(--rp-text-primary);
    font-size: 18px;
    line-height: 1.7;
    font-weight: 400;
}

.rp-blog-post-content p {
    margin: 0 0 1.5em;
    font-size: 18px;
    line-height: 1.7;
    max-width: 70ch; /* readable measure on wide single-post layouts */
}

/* Headings — opinionated scale, tighter leading at the top */
.rp-blog-post-content h1 {
    font-size: 40px;
    line-height: 1.1;
    font-weight: 700;
    color: var(--rp-text-primary);
    margin: 1.4em 0 0.5em;
    letter-spacing: -0.01em;
}
.rp-blog-post-content h2 {
    font-size: 32px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--rp-text-primary);
    margin: 1.6em 0 0.6em;
    letter-spacing: -0.01em;
}
.rp-blog-post-content h3 {
    font-size: 24px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--rp-text-primary);
    margin: 1.6em 0 0.6em;
}
.rp-blog-post-content h4 {
    font-size: 20px;
    line-height: 1.4;
    font-weight: 600;
    color: var(--rp-text-primary);
    margin: 1.6em 0 0.5em;
}

/* Links inside post body — subtle in resting state, underline on interaction */
.rp-blog-post-content a {
    color: var(--rp-brand-blue);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.rp-blog-post-content a:hover,
.rp-blog-post-content a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.rp-blog-post-content a:focus-visible {
    outline: 2px solid var(--rp-brand-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Strong / em / mark */
.rp-blog-post-content strong { font-weight: 700; color: var(--rp-text-primary); }
.rp-blog-post-content em     { font-style: italic; }
.rp-blog-post-content mark   { background: #fff4c2; padding: 0 2px; border-radius: 2px; }

/* ── Blockquote ────────────────────────────────────────────────────────── */
.rp-blog-post-content blockquote {
    margin: 2em 0;
    padding: 0.5em 1.5em;
    border-left: 4px solid var(--rp-brand-blue);
    background: var(--rp-brand-blue-soft);
    color: var(--rp-text-primary);
    font-size: 20px;
    line-height: 1.6;
    font-style: italic;
    border-radius: 0 var(--rp-radius-md) var(--rp-radius-md) 0;
}
.rp-blog-post-content blockquote p { font-size: 20px; margin: 0.5em 0; }
.rp-blog-post-content blockquote cite {
    display: block;
    margin-top: 0.75em;
    font-size: 14px;
    font-style: normal;
    color: var(--rp-text-secondary);
}

/* RTL: flip blockquote border to the right edge */
[dir="rtl"] .rp-blog-post-content blockquote,
:lang(ar) .rp-blog-post-content blockquote {
    border-left: 0;
    border-right: 4px solid var(--rp-brand-blue);
    border-radius: var(--rp-radius-md) 0 0 var(--rp-radius-md);
}

/* ── Inline code + preformatted blocks ─────────────────────────────────── */
.rp-blog-post-content code,
.rp-blog-post-content kbd,
.rp-blog-post-content samp {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    font-size: 0.9em;
    background: var(--rp-bg-code);
    color: var(--rp-brand-dark-blue);
    padding: 2px 6px;
    border-radius: var(--rp-radius-sm);
    border: 1px solid var(--rp-border-light);
}
.rp-blog-post-content pre {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    background: var(--rp-bg-pre);
    color: #f5f7ff;
    border-radius: var(--rp-radius-md);
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.6;
}
.rp-blog-post-content pre code {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* ── Lists ─────────────────────────────────────────────────────────────── */
.rp-blog-post-content ul,
.rp-blog-post-content ol {
    margin: 1em 0 1.5em;
    padding-left: 1.5em;
}
.rp-blog-post-content ul { list-style: disc; }
.rp-blog-post-content ol { list-style: decimal; }
.rp-blog-post-content li {
    margin: 0.5em 0;
    line-height: 1.7;
}
.rp-blog-post-content li > ul,
.rp-blog-post-content li > ol {
    margin: 0.5em 0;
}
[dir="rtl"] .rp-blog-post-content ul,
[dir="rtl"] .rp-blog-post-content ol,
:lang(ar) .rp-blog-post-content ul,
:lang(ar) .rp-blog-post-content ol {
    padding-left: 0;
    padding-right: 1.5em;
}

/* ── Tables ────────────────────────────────────────────────────────────── */
.rp-blog-post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 16px;
}
.rp-blog-post-content thead th {
    background: var(--rp-bg-light);
    color: var(--rp-text-primary);
    font-weight: 600;
    text-align: start;
    padding: 12px 16px;
    border-bottom: 2px solid var(--rp-border-light);
}
.rp-blog-post-content tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rp-border-light);
    vertical-align: top;
}
.rp-blog-post-content tbody tr:nth-child(even) td {
    background: var(--rp-bg-light);
}

/* ── Figure / images ───────────────────────────────────────────────────── */
.rp-blog-post-content img,
.rp-blog-post-content figure img {
    max-width: 100%;
    height: auto;
    border-radius: var(--rp-radius-md);
    margin-bottom: 1.5em;
    display: block;
}
.rp-blog-post-content figure {
    margin: 2em 0;
}
.rp-blog-post-content figcaption {
    font-size: 14px;
    color: var(--rp-text-secondary);
    font-style: italic;
    text-align: center;
    margin-top: 0.5em;
}

/* ── Horizontal rule ───────────────────────────────────────────────────── */
.rp-blog-post-content hr {
    border: 0;
    border-top: 1px solid var(--rp-border-light);
    margin: 2em 0;
}

/* ============================================================================
 * Blog Hero
 * ========================================================================= */
.rp-blog-hero {
    font-family: var(--rp-font-body);
    color: var(--rp-text-primary);
}
.rp-blog-hero h1 {
    font-size: 48px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--rp-text-primary);
}
@media (max-width: 768px) {
    .rp-blog-hero h1 { font-size: 32px; }
}

/* ============================================================================
 * Byline
 *   <span class="rp-byline">
 *     <span class="rp-byline-avatar-wrap"><img class="rp-byline-avatar"></span>
 *     <span class="rp-byline-author">By <a>Name</a></span>
 *     <span class="rp-byline-sep">·</span>
 *     <span class="rp-byline-date">Apr 30, 2026</span>
 *     <span class="rp-byline-sep">·</span>
 *     <span class="rp-byline-reading">5 min read</span>
 *   </span>
 * ========================================================================= */
.rp-byline {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-family: var(--rp-font-body);
    font-size: 14px;
    color: var(--rp-text-secondary);
    line-height: 1.5;
}
.rp-byline-avatar-wrap {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
}
[dir="rtl"] .rp-byline-avatar-wrap,
:lang(ar) .rp-byline-avatar-wrap {
    margin-right: 0;
    margin-left: 4px;
}
.rp-byline-avatar,
.rp-byline img.rp-byline-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--rp-border-light);
}
.rp-byline-author-link {
    color: var(--rp-text-primary);
    text-decoration: none;
    font-weight: 600;
}
.rp-byline-author-link:hover { color: var(--rp-brand-blue); text-decoration: underline; }
.rp-byline-sep { color: var(--rp-border-light); margin: 0 2px; }

/* ============================================================================
 * Card Grid (listing + related)
 * ========================================================================= */
.rp-blog-cards-wrapper { font-family: var(--rp-font-body); }

/* Shared card chrome — applies to both .rp-blog-card and the related grid */
.rp-blog-card,
.rp-related-post-card {
    background: #ffffff;
    border-radius: var(--rp-radius-lg);
    overflow: hidden;
    box-shadow: var(--rp-shadow-card);
    border: 1px solid var(--rp-border-light);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    display: flex;
    flex-direction: column;
}
.rp-blog-card:hover,
.rp-related-post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rp-shadow-hover);
    border-color: transparent;
}

/* Card image: 5:3 aspect ratio (600 × 360 source crop) */
.rp-blog-card .thumb-wrap,
.rp-related-post-card .thumb-wrap {
    width: 100%;
    aspect-ratio: 5 / 3;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--rp-bg-light);
}

/* Card body padding — 20px all sides */
.rp-blog-card > a,
.rp-related-post-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}
.rp-related-post-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
}
.rp-blog-card .blog-new-rp-h3,
.rp-related-post-title {
    font-size: 18px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--rp-text-primary);
    margin: 12px 16px 0;
}
.rp-related-post-title { margin: 0; }

.rp-blog-card .blog-new-rp-p,
.rp-related-post-excerpt {
    font-size: 14px;
    line-height: 1.55;
    color: var(--rp-text-secondary);
    margin: 0;
}
.rp-related-post-excerpt { font-size: 14px; }

.rp-related-post-readmore {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rp-brand-blue);
}

/* Related-posts grid: 4-up on desktop matches design (count default = 4) */
.rp-related-posts-section {
    margin: 4em 0 3em;
    padding: 0 16px;
}
.rp-related-posts-heading {
    font-family: var(--rp-font-body);
    font-size: 28px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--rp-text-primary);
    margin: 0 0 1em;
}
.rp-related-posts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}
@media (max-width: 1024px) {
    .rp-related-posts-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 768px) {
    .rp-related-posts-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
    .rp-related-posts-grid { grid-template-columns: 1fr; }
}

/* Listing card grid (3-col desktop / 2-col tablet / 1-col mobile) */
.rp-blog-cards-wrapper #blog-card-grid,
.rp-blog-cards-wrapper .blogs-index {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}
@media (max-width: 1024px) {
    .rp-blog-cards-wrapper #blog-card-grid,
    .rp-blog-cards-wrapper .blogs-index { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .rp-blog-cards-wrapper #blog-card-grid,
    .rp-blog-cards-wrapper .blogs-index { grid-template-columns: 1fr; }
}

/* ============================================================================
 * Pagination
 * ========================================================================= */
.rp-blog-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 3em 0 2em;
    font-family: var(--rp-font-body);
    font-size: 15px;
}
.rp-blog-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--rp-border-light);
    border-radius: var(--rp-radius-sm);
    color: var(--rp-text-primary);
    text-decoration: none;
    font-weight: 500;
    background: #ffffff;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rp-blog-pagination .page-numbers:hover {
    background: var(--rp-brand-blue-soft);
    border-color: var(--rp-brand-blue-soft);
    color: var(--rp-brand-dark-blue);
}
.rp-blog-pagination .page-numbers.current {
    background: var(--rp-brand-blue);
    border-color: var(--rp-brand-blue);
    color: #ffffff;
    cursor: default;
}
.rp-blog-pagination .page-numbers.dots {
    border-color: transparent;
    background: transparent;
    cursor: default;
    color: var(--rp-text-secondary);
}
.rp-blog-pagination .page-numbers.prev,
.rp-blog-pagination .page-numbers.next {
    font-weight: 600;
}

/* RTL: reverse the visual order so prev/next semantics still feel native */
[dir="rtl"] .rp-blog-pagination,
:lang(ar) .rp-blog-pagination {
    flex-direction: row-reverse;
}

/* ============================================================================
 * Load more — client-side reveal button (replaces URL pagination)
 * Filtering spans the whole set; this only governs the unfiltered view.
 * ========================================================================= */
.rp-blog-loadmore-wrap {
    display: flex;
    justify-content: center;
    margin: 2.5em 0 1em;
}
.rp-blog-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 32px;
    border: 1px solid var(--rp-brand-blue);
    border-radius: var(--rp-radius-sm);
    background: var(--rp-brand-blue);
    color: #ffffff;
    font-family: var(--rp-font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.rp-blog-load-more:hover {
    background: var(--rp-brand-dark-blue);
    border-color: var(--rp-brand-dark-blue);
}
.rp-blog-load-more:active { opacity: 0.9; }

/* TOC click-through: headings carry slug IDs (added server-side); this keeps a
   clicked/deep-linked heading clear of the fixed header (JS also offsets on click). */
.rp-blog-prose-content :where(h2, h3),
.rp-blog-post-content :where(h2, h3) { scroll-margin-top: 110px; }

/* ============================================================================
 * Print styles — clean output for blog posts
 * Hide nav chrome, broaden type, drop hover/transitions
 * ========================================================================= */
@media print {
    .rp-blog-pagination,
    .rp-byline,
    .rp-related-posts-section,
    .rp-related-posts-grid,
    .blog-filter-bar,
    .blog-search-bar,
    .blog-category-tabs {
        display: none !important;
    }

    .rp-blog-post-content {
        font-size: 12pt;
        line-height: 1.55;
        color: #000;
        max-width: none;
    }
    .rp-blog-post-content h1 { font-size: 22pt; }
    .rp-blog-post-content h2 { font-size: 18pt; }
    .rp-blog-post-content h3 { font-size: 14pt; }
    .rp-blog-post-content h4 { font-size: 12pt; }
    .rp-blog-post-content a {
        color: #000;
        text-decoration: underline;
    }
    .rp-blog-post-content blockquote {
        background: transparent;
        border-left-color: #000;
    }
    .rp-blog-post-content pre,
    .rp-blog-post-content code {
        background: #f5f5f5;
        color: #000;
        border-color: #ccc;
    }
    .rp-blog-post-content img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* ───────────────────────────────────────────────────────────────────
   404 Popular Pages — Phase E (2026-04-30)
   The popular-pages link cards on /404 previously rendered as inline
   <a> tags concatenated without separators, producing a wall of
   smushed text. Wrapped each link in a <li> of a <ul>, restyled here
   as a 2-column grid of bordered cards.
   ─────────────────────────────────────────────────────────────────── */
.rp-404-popular {
    max-width: 720px;
    margin: 32px auto;
}
.rp-404-popular-heading {
    font-size: 20px;
    font-weight: 600;
    color: var(--brand-dark-blue, #0f1035);
    margin-bottom: 16px;
}
.rp-404-popular-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.rp-404-popular-link {
    display: block;
    padding: 16px 20px;
    border: 1px solid var(--border-light, #e3e8f1);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}
.rp-404-popular-link:hover {
    border-color: var(--brand-blue, #114ef7);
    background: var(--brand-soft-blue, #f0f4fe);
}
.rp-404-popular-link strong {
    display: block;
    font-size: 16px;
    color: var(--brand-dark-blue, #0f1035);
    margin-bottom: 4px;
}
.rp-404-popular-link span {
    display: block;
    font-size: 14px;
    color: var(--text-secondary, #5a6a85);
}
@media (max-width: 600px) {
    .rp-404-popular-list { grid-template-columns: 1fr; }
}
