/* ===== WordPress core requirements: alignment, captions, galleries ===== */

.alignleft { float: none; }
.alignright { float: none; }
[dir='rtl'] .alignleft { float: right; margin: 0 0 var(--space-4) var(--space-6); }
[dir='rtl'] .alignright { float: left; margin: 0 var(--space-6) var(--space-4) 0; }
.aligncenter { display: block; margin-inline: auto; }
.alignwide { width: 100%; max-width: calc(var(--content-narrow) + 160px); margin-inline: auto; }
.alignfull { width: 100vw; max-width: 100vw; margin-inline-start: calc(50% - 50vw); }

.wp-caption { max-width: 100%; }
.wp-caption-text,
.entry-content figcaption,
.gallery-caption {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.gallery { display: grid; grid-template-columns: repeat(var(--gallery-columns, 3), 1fr); gap: var(--space-3); margin-block: var(--space-6); }
.gallery-item { margin: 0; }
.gallery-icon img { border-radius: var(--radius-md); width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4/3; }

/* Sticky posts */
.archive .sticky .tag-pill::after, .blog .sticky .tag-pill::after { content: ' · مثبّت'; }

/* Screen-reader text (WP requirement) */
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.screen-reader-text:focus {
  background: var(--color-surface); color: var(--color-text);
  display: block; height: auto; width: auto; padding: var(--space-3) var(--space-4);
  clip: auto; position: fixed; top: var(--space-2); inset-inline-start: var(--space-2);
  z-index: 999999; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}

/* ===== Pagination ===== */
.pagination-nav, .post-navigation, .nav-links {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
  margin-block: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
}
.page-numbers {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding-inline: var(--space-3);
  border-radius: var(--radius-md); border: 1px solid var(--color-border);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text);
  background: var(--color-surface);
}
.page-numbers.current { background: var(--color-navy-surface); color: #fff; border-color: var(--color-navy-surface); }
.page-numbers.dots { border: none; background: none; }
a.page-numbers:hover { border-color: var(--color-accent); color: var(--color-accent-hover); }
.pagination-list { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ===== Single post navigation (prev/next) ===== */
.post-nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.post-nav-links .nav-previous, .post-nav-links .nav-next { min-width: 0; }
.post-nav-links a {
  display: block; padding: var(--space-4); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); background: var(--color-surface);
}
.post-nav-links a:hover { border-color: var(--color-accent); }
.post-nav-links .nav-label { font-size: var(--text-xs); color: var(--color-text-muted); display: block; margin-bottom: var(--space-1); }
.post-nav-links .nav-title { font-size: var(--text-sm); font-weight: 700; line-height: 1.4; }
@media (max-width: 640px) { .post-nav-links { grid-template-columns: 1fr; } }

/* ===== Comments ===== */
.comments-area { margin-top: var(--space-16); }
.comments-title, .comment-reply-title { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-primary); margin-bottom: var(--space-6); }
[data-theme='dark'] .comments-title, [data-theme='dark'] .comment-reply-title { color: var(--color-text); }
.comment-list { list-style: none; }
.comment-list .children { list-style: none; margin-inline-start: var(--space-8); }
.comment-body {
  display: flex; gap: var(--space-4);
  padding-block: var(--space-6);
  border-bottom: 1px solid var(--color-divider);
}
.comment-body .avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.comment-meta { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.comment-author .fn { font-weight: 700; font-size: var(--text-sm); font-style: normal; }
.comment-metadata { font-size: var(--text-xs); color: var(--color-text-faint); }
.comment-content p { font-size: var(--text-sm); color: var(--color-text-muted); }
.reply a { font-size: var(--text-xs); font-weight: 700; color: var(--color-accent-hover); }
[data-theme='dark'] .reply a { color: var(--color-accent); }

.comment-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: var(--content-narrow); }
.comment-form p { display: flex; flex-direction: column; gap: var(--space-2); }
.comment-form label { font-size: var(--text-sm); font-weight: 600; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.comment-form textarea { min-height: 140px; resize: vertical; }
.comment-form .form-submit input[type="submit"] {
  background: var(--color-navy-surface); color: #fff; font-weight: 700;
  padding: var(--space-3) var(--space-8); border-radius: var(--radius-md);
  font-size: var(--text-sm); width: fit-content;
}
.comment-form .form-submit input[type="submit"]:hover { background: var(--color-accent); color: var(--color-navy-surface); }
.comment-notes, .logged-in-as { font-size: var(--text-xs); color: var(--color-text-faint); }

/* ===== 404 & search-no-results ===== */
.error-404, .no-results {
  text-align: center;
  padding-block: var(--space-24);
  max-width: var(--content-narrow);
  margin-inline: auto;
}
.error-404 .error-code { font-family: var(--font-display); font-size: var(--text-3xl); color: var(--color-accent); }
.error-404 h1, .no-results h1 { font-family: var(--font-display); font-size: var(--text-xl); margin-block: var(--space-4); color: var(--color-primary); }
[data-theme='dark'] .error-404 h1, [data-theme='dark'] .no-results h1 { color: var(--color-text); }
.error-404 p, .no-results p { color: var(--color-text-muted); margin-bottom: var(--space-6); }
.error-404 .search-form-wrap { max-width: 420px; margin-inline: auto; }

/* ===== Search form (widget + template) ===== */
.search-form { display: flex; gap: var(--space-2); }
.search-form input[type="search"] {
  flex: 1; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); font-size: var(--text-sm);
}
.search-form button {
  background: var(--color-navy-surface); color: #fff; padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
}
.search-form button:hover { background: var(--color-accent); color: var(--color-navy-surface); }

/* ===== Breadcrumbs ===== */
.breadcrumbs {
  font-size: var(--text-xs); color: var(--color-text-faint);
  padding-block: var(--space-4);
}
.breadcrumbs a { color: var(--color-text-muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--color-accent-hover); }
.breadcrumbs span { color: var(--color-text); }

/* ===== Archive / category header ===== */
.page-header {
  padding-block: var(--space-8);
  border-bottom: 2px solid var(--color-primary);
  margin-bottom: var(--space-10);
}
.page-header .page-title {
  font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; color: var(--color-primary);
}
[data-theme='dark'] .page-header .page-title { color: var(--color-text); }
.page-header .archive-description { color: var(--color-text-muted); margin-top: var(--space-2); font-size: var(--text-sm); }

/* ===== Single article content ===== */
.single-article { padding-block: var(--space-10); }
.single-article .article-header { max-width: var(--content-narrow); margin-inline: auto; margin-bottom: var(--space-8); text-align: center; }
.single-article .article-title {
  font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; line-height: 1.25;
  color: var(--color-text); margin-block: var(--space-4);
}
.single-article .article-excerpt { font-size: var(--text-lg); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.single-article .article-meta {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--color-text-faint);
}
.single-article .article-meta .author-avatar { width: 28px; height: 28px; border-radius: 50%; }
.single-article .article-meta strong { color: var(--color-text); font-weight: 700; }
.single-article .featured-media { max-width: var(--content-wide); margin-inline: auto; margin-bottom: var(--space-10); border-radius: var(--radius-lg); overflow: hidden; }
.single-article .featured-media img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

.entry-content {
  max-width: var(--content-narrow);
  margin-inline: auto;
  font-size: var(--text-lg);
  line-height: 1.85;
}
.entry-content > * + * { margin-top: var(--space-6); }
.entry-content h2 { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-primary); margin-top: var(--space-10); }
[data-theme='dark'] .entry-content h2 { color: var(--color-text); }
.entry-content h3 { font-size: var(--text-lg); font-weight: 700; margin-top: var(--space-8); }
.entry-content a { color: var(--color-accent-hover); text-decoration: underline; text-underline-offset: 3px; }
[data-theme='dark'] .entry-content a { color: var(--color-accent); }
.entry-content blockquote {
  border-inline-start: 4px solid var(--color-accent);
  padding-inline-start: var(--space-6);
  font-family: var(--font-display); font-size: var(--text-xl); font-style: italic;
  color: var(--color-text); line-height: 1.5;
}
.entry-content ul, .entry-content ol { padding-inline-start: var(--space-8); }
.entry-content ul { list-style: disc; }
.entry-content ol { list-style: decimal; }
.entry-content img { border-radius: var(--radius-lg); }
.entry-content hr { border: none; border-top: 1px solid var(--color-divider); }
.entry-content table { font-size: var(--text-sm); }
.entry-content table th, .entry-content table td { border: 1px solid var(--color-border); padding: var(--space-3); }
.entry-content table th { background: var(--color-surface-offset); }

.article-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); max-width: var(--content-narrow); margin: var(--space-10) auto 0; }
.article-share { display: flex; align-items: center; gap: var(--space-3); max-width: var(--content-narrow); margin: var(--space-6) auto 0; }
.article-share span { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 700; }
.article-share a { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--color-surface-offset); color: var(--color-text-muted); }
.article-share a:hover { background: var(--color-navy-surface); color: #fff; }

.author-box {
  display: flex; gap: var(--space-4);
  max-width: var(--content-narrow); margin: var(--space-10) auto 0;
  padding: var(--space-6); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
}
.author-box img { width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; }
.author-box h4 { font-size: var(--text-base); font-weight: 700; }
.author-box p { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }

.related-posts { max-width: var(--content-wide); margin-inline: auto; margin-top: var(--space-16); }

/* ===== Widgets (sidebar.php) ===== */
.widget { margin-bottom: var(--space-6); }
.widget_search .search-form { margin: 0; }
.widget ul { display: flex; flex-direction: column; gap: var(--space-2); }
.widget_categories li, .widget_archive li, .widget_meta li, .widget_pages li, .widget_recent_entries li {
  display: flex; justify-content: space-between; font-size: var(--text-sm);
  padding-block: var(--space-2); border-bottom: 1px solid var(--color-divider);
}
.widget_tag_cloud .tagcloud { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.widget_tag_cloud .tagcloud a {
  font-size: var(--text-xs) !important; padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset); border-radius: var(--radius-full); color: var(--color-text-muted); font-weight: 600;
}
.widget_calendar table { font-size: var(--text-xs); text-align: center; }
.widget_calendar caption { font-weight: 700; padding-bottom: var(--space-2); }

/* ===== Skip link ===== */
.skip-link {
  position: absolute; top: -100px; inset-inline-start: 0;
  background: var(--color-navy-surface); color: #fff;
  padding: var(--space-3) var(--space-5); z-index: 999999; border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus { top: 0; }

/* ===== Site branding via customizer (logo image fallback) ===== */
.custom-logo-link img { max-height: 56px; width: auto; }
