/* ============================================================
   MarketPersian CMS v3 — assets/blog.css
   Blog index/single/category + Developers directory + the shared
   post-card component (.mpb-post-card — also used by the
   blog_latest builder block on the home page).
   Theme-agnostic contract:
   - never sets page/body background or font-family (themes own those)
   - neutral semi-transparent surfaces work on dark AND light themes
   - accent = var(--primary) / var(--secondary) (set by every theme)
   - color-mix() lines always come AFTER a plain rgba fallback
   - RTL-first: logical properties only (site is dir="rtl")
   Breakpoints: 1200 / 992 / 768 / 600 / 560 / 400 + reduced-motion
   ============================================================ */

/* ---------- scoped resets & shared bits ---------- */
.mp-blog-page,
.mp-blog-page *,
.mp-post-page,
.mp-post-page *,
.mp-dev-page,
.mp-dev-page * { box-sizing: border-box; }

.mp-blog-page img,
.mp-post-page img,
.mp-dev-page img { max-width: 100%; }

.mp-ic { flex: 0 0 auto; vertical-align: middle; }

.mp-blog-page a:focus-visible,
.mp-post-page a:focus-visible,
.mp-post-page button:focus-visible,
.mp-post-page input:focus-visible,
.mp-post-page textarea:focus-visible,
.mp-dev-page a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   Blog index — head, category chips
   ============================================================ */
.mp-blog-head { margin: 8px 0 24px; }
.mp-blog-head h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.5;
  color: inherit;
  overflow-wrap: anywhere;
}
.mp-blog-head > p {
  margin: 6px 0 0;
  font-size: 14.5px;
  line-height: 1.9;
  opacity: .65;
}
.mp-blog-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.mp-blog-cats a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 18px;
  border-radius: 99px;
  background: rgba(127,127,127,.07);
  border: 1px solid rgba(127,127,127,.14);
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .2s, color .2s, background-color .2s, transform .2s;
}
.mp-blog-cats a:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.mp-blog-cats a.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-color: transparent;
  color: #fff;
}

/* ============================================================
   Blog index — main/sidebar layout
   ============================================================ */
.mp-blog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 26px;
  align-items: start;
}
.mp-blog-main { min-width: 0; }
.mp-blog-side {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

/* ---------- sidebar widgets ---------- */
.mp-blog-widget {
  padding: 18px;
  border-radius: 18px;
  background: rgba(127,127,127,.06);
  border: 1px solid rgba(127,127,127,.14);
}
.mp-blog-widget h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: inherit;
}
.mp-blog-widget h4 .mp-ic { color: var(--primary); }

.mp-bw-cats a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  color: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .2s, color .2s;
}
.mp-bw-cats a:hover { background: rgba(127,127,127,.08); }
.mp-bw-cats a.active {
  color: var(--primary);
  background: rgba(127,127,127,.07);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.mp-bw-cats a small {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 99px;
  background: rgba(127,127,127,.1);
  font-size: 11px;
  font-weight: 700;
  opacity: .75;
}
.mp-bw-recent a {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 12px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: background-color .2s;
}
.mp-bw-recent a:hover { background: rgba(127,127,127,.08); }
.mp-bw-recent a span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.7;
}
.mp-bw-recent a small { font-size: 11.5px; opacity: .6; }
.mp-bw-empty {
  display: block;
  padding: 8px 2px;
  font-size: 12.5px;
  opacity: .6;
}

/* ---------- empty state (blog + developers) ---------- */
.mp-blog-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 44px 20px;
  border: 2px dashed rgba(127,127,127,.3);
  border-radius: 18px;
  text-align: center;
}
.mp-blog-empty .mp-ic { opacity: .5; color: var(--primary); }
.mp-blog-empty h3 {
  margin: 10px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: inherit;
}
.mp-blog-empty p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.9;
  opacity: .65;
}

/* ============================================================
   Single post
   ============================================================ */
.mp-post-page {
  max-width: 860px; /* overrides .mpb-container on the same div (blog.css loads after mpb.css) */
  margin-block: 26px;
}
.mp-post {
  padding: clamp(20px, 4vw, 38px);
  border-radius: 22px;
  background: rgba(127,127,127,.05);
  border: 1px solid rgba(127,127,127,.14);
}
.mp-post-crumbs {
  font-size: 12.5px;
  line-height: 2;
  opacity: .7;
}
.mp-post-crumbs a {
  color: inherit;
  text-decoration: none;
}
.mp-post-crumbs a:hover { color: var(--primary); }
.mp-post-head h1 {
  margin: 10px 0 0;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  line-height: 1.6;
  color: inherit;
  overflow-wrap: anywhere;
}
.mp-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
  font-size: 13px;
  opacity: .75;
}
.mp-post-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.mp-post-cover { margin-block: 18px; }
.mp-post-cover img {
  display: block;
  width: 100%;
  border-radius: 16px;
}

/* ---------- article typography ---------- */
.mp-post-content { overflow-wrap: break-word; }
.mp-post-content p {
  margin: 0 0 1.1em;
  font-size: 15.5px;
  line-height: 2.15;
}
.mp-post-content h2 {
  position: relative;
  margin: 1.6em 0 .6em;
  padding-inline-start: 14px;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.6;
  color: inherit;
}
.mp-post-content h2::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 7px;
  bottom: 7px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.mp-post-content h3 {
  margin: 1.4em 0 .6em;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.6;
  color: var(--primary);
}
.mp-post-content ul,
.mp-post-content ol {
  margin: 0 0 1.1em;
  padding-inline-start: 1.3em;
  line-height: 2;
}
.mp-post-content li { margin: .3em 0; }
.mp-post-content a { color: var(--primary); }
.mp-post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
}
.mp-post-content blockquote {
  margin: 1.2em 0;
  padding: 14px 18px;
  border-inline-start: 4px solid var(--primary);
  border-radius: 12px;
  background: rgba(127,127,127,.06);
}
.mp-post-content blockquote p { margin: 0; }
.mp-post-content code,
.mp-post-content pre {
  direction: ltr;
  unicode-bidi: embed;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(127,127,127,.12);
  border-radius: 8px;
}
.mp-post-content code { display: inline-block; padding: 2px 7px; font-size: .85em; }
.mp-post-content pre {
  margin: 0 0 1.2em;
  padding: 14px;
  overflow-x: auto;
  text-align: start;
  font-size: 13px;
  line-height: 1.9;
}
.mp-post-content pre code { display: block; padding: 0; background: transparent; }
.mp-post-content table {
  width: 100%;
  margin: 1.2em 0;
  border-collapse: collapse;
  font-size: 14px;
}
.mp-post-content th,
.mp-post-content td {
  padding: 9px 12px;
  border: 1px solid rgba(127,127,127,.18);
  text-align: start;
}
.mp-post-content th { background: rgba(127,127,127,.06); font-weight: 800; }
.mp-post-content hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px dashed rgba(127,127,127,.3);
}
.mp-post-content iframe {
  max-width: 100%;
  border: 0;
  border-radius: 14px;
}
.mp-post-content figcaption {
  margin-top: 6px;
  font-size: 12.5px;
  text-align: center;
  opacity: .6;
}

/* ---------- tags ---------- */
.mp-post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed rgba(127,127,127,.2);
}
.mp-post-tags a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid rgba(127,127,127,.35);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color .2s, transform .2s;
}
.mp-post-tags a:hover {
  background: rgba(127,127,127,.08);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  transform: translateY(-1px);
}

/* ============================================================
   Post cards (shared: blog grids + mpb blog_latest block)
   ============================================================ */
.mpb-post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.mpb-post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(127,127,127,.06);
  border: 1px solid rgba(127,127,127,.14);
  color: inherit;
  text-decoration: none;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.mpb-post-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 14px 30px rgba(0,0,0,.12);
}
.mpb-pc-cover {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: rgba(127,127,127,.08);
}
.mpb-pc-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}
.mpb-post-card:hover .mpb-pc-cover img { transform: scale(1.05); }
.mpb-pc-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  padding: 16px;
}
.mpb-pc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 12px;
}
.mpb-pc-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: .65;
}
.mpb-pc-cat {
  padding: 2px 9px;
  border-radius: 99px;
  color: var(--primary);
  font-weight: 700;
  background: rgba(127,127,127,.08);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.mpb-pc-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.7;
  transition: color .2s;
}
.mpb-post-card:hover .mpb-pc-title { color: var(--primary); }
.mpb-pc-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.8;
  opacity: .65;
}
.mpb-pc-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  transition: gap .25s;
}
.mpb-post-card:hover .mpb-pc-more { gap: 9px; }

/* ---------- related posts ---------- */
.mp-post-related { margin-top: 30px; }
.mp-post-related h3 {
  position: relative;
  margin: 0 0 16px;
  padding-inline-start: 14px;
  font-size: 1.15rem;
  font-weight: 800;
  color: inherit;
}
.mp-post-related h3::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

/* ============================================================
   Comments
   ============================================================ */
.mp-comments { margin-top: 26px; }
.mp-comments h3 {
  position: relative;
  margin: 0 0 16px;
  padding-inline-start: 14px;
  font-size: 1.15rem;
  font-weight: 800;
  color: inherit;
}
.mp-comments h3::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.mp-comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mp-comment {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(127,127,127,.06);
  border: 1px solid rgba(127,127,127,.14);
}
.mp-c-av {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.mp-c-body { flex: 1; min-width: 0; }
.mp-c-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.mp-c-head b { font-size: 14px; overflow-wrap: anywhere; }
.mp-c-head small { font-size: 11.5px; opacity: .6; }
.mp-comment p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.mp-comments-empty { font-size: 13.5px; opacity: .65; }

/* ---------- comment form ---------- */
.mp-comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(127,127,127,.05);
  border: 1px solid rgba(127,127,127,.14);
}
.mp-cf-row {
  display: flex;
  gap: 10px;
}
.mp-cf-row .mp-input { flex: 1; min-width: 0; }
.mp-input,
.mp-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(127,127,127,.25);
  background: rgba(127,127,127,.06);
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.mp-input { min-height: 44px; }
.mp-textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.9;
}
.mp-input::placeholder,
.mp-textarea::placeholder { color: inherit; opacity: .55; }
.mp-input:focus,
.mp-textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(127,127,127,.15);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: flex-start;
  min-height: 44px;
  padding: 10px 22px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.6;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.18);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: transform .2s, box-shadow .25s;
}
.mp-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,.22);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 45%, transparent);
}
.mp-btn:active { transform: translateY(0); }

/* form result notices (mp-c-note.ok / mp-c-note.err) */
.mp-c-note {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.8;
}
.mp-c-note.ok {
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.4);
  color: #16a34a;
}
.mp-c-note.err {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.4);
  color: #dc2626;
}

/* ============================================================
   Developers directory
   ============================================================ */
.mp-dev-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.mp-dev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.mp-dev-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(127,127,127,.06);
  border: 1px solid rgba(127,127,127,.14);
  text-align: center;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.mp-dev-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 12px 26px rgba(0,0,0,.1);
}
.mp-dev-av {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
}
.mp-dev-info { min-width: 0; }
.mp-dev-info h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: inherit;
  overflow-wrap: anywhere;
}
.mp-dev-info small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: .65;
}
.mp-dev-apps {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.mp-dev-apps img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid rgba(127,127,127,.2);
}
.mp-dev-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 4px 2px;
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  transition: gap .25s;
}
.mp-dev-link:hover { gap: 10px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
  .mp-blog-layout { gap: 20px; }
}

@media (max-width: 992px) {
  .mp-blog-layout { grid-template-columns: 1fr; }
  .mp-blog-side { grid-template-columns: 1fr 1fr; } /* widgets become a 2-col row */
}

@media (max-width: 768px) {
  .mp-blog-head h1 { font-size: 1.5rem; }
  .mp-dev-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 600px) {
  .mpb-post-grid { grid-template-columns: 1fr; }
  .mp-blog-side { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .mp-cf-row { flex-direction: column; }
  .mp-comment-form .mp-btn { align-self: stretch; }
  .mp-post-meta { gap: 6px 12px; font-size: 12.5px; }
  .mp-post-related .mpb-post-grid { gap: 12px; }
}

@media (max-width: 400px) {
  .mp-post { padding: 18px 14px; }
  .mp-dev-grid { grid-template-columns: 1fr; }
  .mp-blog-cats a { padding: 8px 14px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .mpb-post-card:hover,
  .mp-dev-card:hover,
  .mp-post-tags a:hover,
  .mp-blog-cats a:hover,
  .mp-btn:hover {
    transform: none;
  }
  .mpb-pc-cover img { transition: none; }
  .mpb-post-card:hover .mpb-pc-cover img { transform: none; }
  .mpb-pc-more,
  .mp-dev-link { transition: none; }
}
