/*
 * Long-form article typography for .prose blocks (blog posts, comparison copy).
 *
 * Tailwind is loaded from the CDN without @tailwindcss/typography, and Preflight
 * resets heading sizes, paragraph margins and list markers — so rich HTML stored
 * in the database needs these styles to render as readable prose.
 *
 * Logical properties (padding-inline-start, border-inline-start) keep this
 * working in RTL without a mirrored ruleset.
 */

.prose {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: #3a4050;
}

/* Two classes so this wins over Tailwind's .max-w-none utility, which the
   templates use to let the article fill its grid column. ~72 characters is the
   comfortable reading measure; the column itself is much wider. */
.prose,
.prose.max-w-none {
    max-width: 72ch;
}

.prose.prose-lg {
    font-size: 1.1875rem;
}

.prose.prose-sm {
    font-size: 0.9375rem;
    line-height: 1.7;
}

@media (max-width: 640px) {
    .prose,
    .prose.prose-lg {
        font-size: 1.0625rem;
        line-height: 1.7;
    }
}

/* Collapse outer margins so the block aligns with its container */
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

/* --- Paragraphs --- */

.prose p {
    margin: 0 0 1.3em;
}

/* --- Headings --- */

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    color: #20242e;
    font-weight: 700;
    line-height: 1.25;
    text-wrap: balance;
    /* Clear the sticky site header when jumping to a TOC anchor */
    scroll-margin-top: 5.5rem;
}

.prose h2 {
    font-size: 1.7em;
    margin: 2.5em 0 0.8em;
    padding-top: 1.6em;
    border-top: 1px solid #e8e6e3;
}

.prose > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.prose h3 {
    font-size: 1.3em;
    margin: 2em 0 0.6em;
}

.prose h4 {
    font-size: 1.1em;
    margin: 1.8em 0 0.5em;
}

.prose h5,
.prose h6 {
    font-size: 1em;
    margin: 1.6em 0 0.4em;
}

/* Heading immediately after a heading shouldn't get the full gap */
.prose h2 + h3,
.prose h3 + h4 {
    margin-top: 1em;
}

/* --- Lists --- */

.prose ul,
.prose ol {
    margin: 0 0 1.3em;
    padding-inline-start: 1.5em;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li {
    margin: 0.4em 0;
    padding-inline-start: 0.2em;
}

.prose li::marker {
    color: #e4573d;
}

.prose ol > li::marker {
    font-weight: 600;
}

.prose li > ul,
.prose li > ol {
    margin: 0.5em 0 0.5em;
}

.prose li > ul { list-style: circle; }

.prose li > p {
    margin-bottom: 0.6em;
}

/* --- Inline elements --- */

.prose strong,
.prose b {
    color: #20242e;
    font-weight: 700;
}

.prose em { font-style: italic; }

.prose a {
    color: #d0432a;
    text-decoration: underline;
    text-decoration-color: #f0a190;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s, text-decoration-color 0.15s;
}

.prose a:hover {
    color: #8f2f20;
    text-decoration-color: #d0432a;
}

/* --- Quotes, rules, figures --- */

.prose blockquote {
    margin: 1.8em 0;
    padding: 0.2em 0 0.2em 1.2em;
    border-inline-start: 3px solid #e4573d;
    color: #3a4050;
    font-style: italic;
}

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

.prose hr {
    margin: 3em 0;
    border: 0;
    border-top: 1px solid #e8e6e3;
}

.prose img,
.prose video {
    max-width: 100%;
    height: auto;
    margin: 2em 0;
    border-radius: 0.75rem;
}

.prose figure { margin: 2em 0; }
.prose figure img { margin: 0; }

.prose figcaption {
    margin-top: 0.6em;
    font-size: 0.875em;
    color: #6b7280;
    text-align: center;
}

/* --- Definition lists --- */

.prose dt {
    font-weight: 700;
    color: #20242e;
    margin-top: 1.2em;
}

.prose dd {
    margin: 0.3em 0 0;
    padding-inline-start: 1.2em;
}

/* --- Code --- */

.prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
    background-color: #f4f2f0;
    color: #8f2f20;
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
}

.prose pre {
    margin: 1.8em 0;
    padding: 1.1em 1.3em;
    background-color: #20242e;
    color: #f3f4f6;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.875em;
    line-height: 1.6;
}

.prose pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* --- Tables ---
   Wrapped in .prose-table-wrap by the wrap_tables filter so wide tables scroll
   inside the article instead of the whole page. */

.prose-table-wrap {
    margin: 2em 0;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
}

.prose-table-wrap > table {
    margin: 0;
    border: 0;
}

.prose table {
    width: 100%;
    margin: 2em 0;
    border-collapse: collapse;
    font-size: 0.9375em;
    line-height: 1.5;
    text-align: start;
}

.prose thead th {
    background-color: #f9fafb;
    color: #20242e;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.8125em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: start;
    padding: 0.75em 1em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.prose tbody td {
    padding: 0.75em 1em;
    border-bottom: 1px solid #f0eeec;
    vertical-align: top;
}

.prose tbody tr:last-child td {
    border-bottom: 0;
}

.prose tbody tr:hover {
    background-color: #fdfcfb;
}

.prose tbody th {
    padding: 0.75em 1em;
    color: #20242e;
    font-weight: 700;
    text-align: start;
    border-bottom: 1px solid #f0eeec;
}

[dir="rtl"] .prose thead th,
[dir="rtl"] .prose tbody td,
[dir="rtl"] .prose tbody th {
    text-align: right;
}

/* Letter-spacing breaks Arabic letter joining */
[dir="rtl"] .prose thead th {
    font-family: 'Cairo', sans-serif;
    letter-spacing: normal;
}
