Files
portfolio/app/assets/css/blog-content.css
mahdiarghyani 5f28eaa179 feat(blog): Enhance blog content styling and readability
- Add comprehensive blog content CSS with RTL support
- Implement responsive typography and layout improvements
- Create dedicated CSS for blog prose and content styling
- Optimize code blocks, headings, and typography for better readability
- Add scroll padding and responsive design considerations
- Improve dark mode color contrast and styling
- Enhance code and blockquote styling with better visual hierarchy
2025-11-11 16:52:54 +03:30

343 lines
6.0 KiB
CSS

/* Blog Content Styles - Optimized for Persian/RTL */
/* Base typography */
.blog-content {
font-size: 1.125rem; /* 18px */
line-height: 2; /* خط‌فاصله بیشتر */
letter-spacing: 0.01em;
color: rgb(55, 65, 81);
max-width: 75ch;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
}
.dark .blog-content {
color: rgb(229, 231, 235);
}
/* RTL-specific improvements */
.blog-content-rtl {
line-height: 2.2 !important; /* فارسی نیاز به فاصله بیشتری داره */
letter-spacing: 0.02em !important;
}
/* Force LTR for code blocks in RTL */
.blog-content-rtl pre,
.blog-content-rtl code {
direction: ltr;
text-align: left;
}
/* Headings */
.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4 {
scroll-margin-top: 2.5rem;
}
.blog-content h1 {
margin-top: 3rem;
margin-bottom: 2rem;
line-height: 1.4;
font-weight: 700;
font-size: 2.25em;
color: rgb(17, 24, 39);
}
.dark .blog-content h1 {
color: rgb(243, 244, 246);
}
.blog-content h2 {
margin-top: 3rem;
margin-bottom: 1.75rem;
line-height: 1.5;
font-weight: 700;
font-size: 1.875em;
color: rgb(17, 24, 39);
}
.dark .blog-content h2 {
color: rgb(243, 244, 246);
}
.blog-content h3 {
margin-top: 2.5rem;
margin-bottom: 1.5rem;
line-height: 1.6;
font-weight: 600;
font-size: 1.5em;
color: rgb(17, 24, 39);
}
.dark .blog-content h3 {
color: rgb(243, 244, 246);
}
.blog-content h4 {
margin-top: 2rem;
margin-bottom: 1.25rem;
line-height: 1.6;
font-weight: 600;
font-size: 1.25em;
color: rgb(17, 24, 39);
}
.dark .blog-content h4 {
color: rgb(243, 244, 246);
}
/* Paragraphs - فاصله زیاد برای خوانایی بهتر */
.blog-content p {
margin-top: 2rem;
margin-bottom: 2rem;
line-height: inherit;
}
/* First paragraph after heading */
.blog-content h1 + p,
.blog-content h2 + p,
.blog-content h3 + p,
.blog-content h4 + p {
margin-top: 1.25rem;
}
/* Lists */
.blog-content ul,
.blog-content ol {
margin-top: 2.25rem;
margin-bottom: 2.25rem;
padding-left: 2rem;
}
.blog-content-rtl ul,
.blog-content-rtl ol {
padding-left: 0;
padding-right: 2rem;
}
.blog-content li {
margin-top: 1rem;
margin-bottom: 1rem;
line-height: 2;
}
.blog-content-rtl li {
line-height: 2.2;
}
.blog-content li p {
margin-top: 0.75rem;
margin-bottom: 0.75rem;
}
/* Nested lists */
.blog-content ul ul,
.blog-content ol ol,
.blog-content ul ol,
.blog-content ol ul {
margin-top: 1rem;
margin-bottom: 1rem;
}
/* Strong text */
.blog-content strong {
font-weight: 700;
color: rgb(17, 24, 39);
}
.dark .blog-content strong {
color: rgb(243, 244, 246);
}
/* Code blocks */
.blog-content pre {
margin-top: 3rem;
margin-bottom: 3rem;
line-height: 1.7;
font-size: 0.9375rem;
overflow-x: auto;
max-width: 100%;
}
@media (max-width: 1024px) {
.blog-content pre {
font-size: 0.875rem;
}
}
/* Inline code */
.blog-content code:not(pre code) {
padding: 0.25em 0.5em;
background-color: rgba(99, 102, 241, 0.1);
border-radius: 0.375rem;
font-size: 0.9em;
font-weight: 500;
color: rgb(79, 70, 229);
}
.dark .blog-content code:not(pre code) {
background-color: rgba(99, 102, 241, 0.2);
color: rgb(165, 180, 252);
}
/* Blockquotes */
.blog-content blockquote {
margin-top: 3rem;
margin-bottom: 3rem;
padding: 1.75rem;
border-left: 4px solid rgb(99, 102, 241);
background-color: rgba(99, 102, 241, 0.05);
border-radius: 0.75rem;
font-style: italic;
line-height: 2;
}
.blog-content-rtl blockquote {
border-left: none;
border-right: 4px solid rgb(99, 102, 241);
}
.dark .blog-content blockquote {
background-color: rgba(99, 102, 241, 0.1);
border-left-color: rgb(129, 140, 248);
}
.dark .blog-content-rtl blockquote {
border-right-color: rgb(129, 140, 248);
}
.blog-content blockquote p {
margin-top: 1rem;
margin-bottom: 1rem;
}
/* Links */
.blog-content a {
color: rgb(99, 102, 241);
text-decoration: underline;
text-decoration-color: rgba(99, 102, 241, 0.3);
text-underline-offset: 0.25em;
font-weight: 500;
transition: all 0.2s ease;
}
.blog-content a:hover {
color: rgb(79, 70, 229);
text-decoration-color: rgba(99, 102, 241, 0.8);
}
.dark .blog-content a {
color: rgb(129, 140, 248);
}
.dark .blog-content a:hover {
color: rgb(165, 180, 252);
}
/* Horizontal rule */
.blog-content hr {
margin-top: 3.5rem;
margin-bottom: 3.5rem;
border-color: rgba(148, 163, 184, 0.3);
}
.dark .blog-content hr {
border-color: rgba(71, 85, 105, 0.5);
}
/* Images */
.blog-content img {
margin-top: 3rem;
margin-bottom: 3rem;
border-radius: 0.75rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
/* Tables */
.blog-content table {
margin-top: 3rem;
margin-bottom: 3rem;
width: 100%;
border-collapse: collapse;
font-size: 0.9375rem;
display: block;
overflow-x: auto;
max-width: 100%;
}
@media (max-width: 1024px) {
.blog-content table {
font-size: 0.875rem;
}
}
.blog-content th,
.blog-content td {
padding: 0.875rem 1rem;
border: 1px solid rgba(148, 163, 184, 0.3);
line-height: 1.8;
}
.blog-content th {
background-color: rgba(99, 102, 241, 0.1);
font-weight: 600;
color: rgb(17, 24, 39);
}
.dark .blog-content th {
background-color: rgba(99, 102, 241, 0.15);
color: rgb(243, 244, 246);
}
.dark .blog-content td {
border-color: rgba(71, 85, 105, 0.4);
}
/* Images - prevent overflow */
.blog-content img {
max-width: 100%;
height: auto;
}
/* Prevent horizontal scroll on all elements */
.blog-content * {
max-width: 100%;
}
.blog-content pre,
.blog-content code,
.blog-content table {
max-width: 100%;
}
/* Responsive */
@media (max-width: 640px) {
.blog-content {
font-size: 1rem;
}
.blog-content h1 {
font-size: 2em;
}
.blog-content h2 {
font-size: 1.625em;
}
.blog-content h3 {
font-size: 1.375em;
}
.blog-content pre {
font-size: 0.8125rem;
margin-left: -1rem;
margin-right: -1rem;
padding-left: 1rem;
padding-right: 1rem;
border-radius: 0;
}
}