@import url("https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #1f2937;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --notice-bg: #fff7ed;
  --notice-border: #fed7aa;
  --radius: 8px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
}

body.rtl {
  direction: rtl;
  text-align: right;
  font-family: "Vazirmatn", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}

body.ltr {
  direction: ltr;
  text-align: left;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.container {
  width: min(100% - 40px, 1180px);
  margin: 0 auto;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  padding: 18px 0;
}

nav a {
  color: #334155;
  font-weight: 650;
  text-decoration: none;
}

nav a:hover { color: var(--accent); }

body.rtl nav,
body.ltr nav {
  justify-content: flex-start;
}

body.lang-fa,
body.lang-fa main,
body.lang-fa .content-flow,
body.lang-fa .hero,
body.lang-fa .card,
body.lang-fa .post,
body.lang-fa h1,
body.lang-fa h2,
body.lang-fa h3,
body.lang-fa p,
body.lang-fa li,
body.lang-fa a,
body.lang-fa footer,
:lang(fa) {
  direction: rtl;
  text-align: right;
}

body.lang-fa,
body.lang-fa .persian,
body.lang-fa .rtl-block,
:lang(fa) {
  font-family: "Vazirmatn", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}

main {
  flex: 1;
  padding: 46px 0 58px;
}

.content-flow > *:first-child,
.post > *:first-child {
  margin-top: 0;
}

.hero {
  padding: 32px 0 20px;
}

.compact-hero {
  padding: 18px 0 10px;
}

h1,
h2,
h3 {
  color: #0f172a;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.2;
  margin: 0 0 12px;
}

h2 {
  font-size: 1.65rem;
  line-height: 1.35;
  margin: 44px 0 14px;
}

h3 {
  font-size: 1.25rem;
  line-height: 1.45;
  margin: 30px 0 10px;
}

.subtitle {
  max-width: 70ch;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1.15rem;
}

.card,
.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.card {
  padding: 22px;
  margin: 18px 0;
}

.card h3 { margin-top: 0; }

.card p:last-child,
.post p:last-child {
  margin-bottom: 0;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 28px;
}

.file-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.home-grid {
  display: grid;
  gap: 32px;
  align-items: start;
  margin-top: 8px;
}

.resources-left {
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
}

.resources-right {
  grid-template-columns: minmax(0, 1fr) minmax(190px, 260px);
}

.home-with-quote {
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
}

.resources-left .link-library,
.resources-right .notes-section {
  grid-column: 1;
}

.resources-left .notes-section,
.resources-right .link-library {
  grid-column: 2;
}

.home-with-quote .home-sidebar {
  grid-column: 1;
  display: grid;
  gap: 28px;
}

.home-with-quote .notes-section {
  grid-column: 2;
  min-width: 0;
}

.resource-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.resource-list li {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.resource-row {
  display: grid;
  gap: 8px;
}

.home-sidebar > section > h2 a,
.resource-row > a:first-child,
.resource-card h2,
.resource-card h2 a {
  color: #0f172a;
}

.home-section-link,
.home-section-link:visited {
  color: #0f172a !important;
}

.home-sidebar > section > h2 a,
.resource-row > a:first-child {
  text-decoration-line: underline;
  text-decoration-color: #94a3b8;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.home-sidebar > section > h2 a:hover,
.resource-row > a:first-child:hover {
  color: #334155;
  text-decoration-color: #334155;
}

.home-section-link:hover {
  color: #334155 !important;
}

.review-link {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.review-link:hover {
  color: var(--accent);
}

.resource-list span {
  color: var(--muted);
  font-size: 0.95rem;
}

.resource-page,
.resource-review {
  width: 100%;
}

.resource-catalog {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.resource-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.04);
}

.resource-card h2 {
  margin-top: 0;
}

.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 14px;
}

.resource-review {
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.resource-review .section-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-body {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.quote-column blockquote,
.quote-catalog blockquote {
  margin: 12px 0 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.04);
}

.quote-column p,
.quote-catalog p {
  margin: 0;
  color: #334155;
  font-size: 0.98rem;
  line-height: 1.75;
}

.quote-column cite,
.quote-catalog cite {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: normal;
  font-weight: 700;
}

.quote-column cite::before,
.quote-catalog cite::before {
  content: "- ";
}

.quote-column blockquote + blockquote {
  margin-top: 16px;
}

.quote-column blockquote p + p,
.quote-catalog blockquote p + p {
  margin-top: 12px;
}

.quote-page {
  width: 100%;
}

.quote-catalog {
  display: grid;
  gap: 0;
  margin-top: 24px;
}

.quote-catalog blockquote {
  margin: 0 0 24px;
}

.quote-catalog blockquote:last-child {
  margin-bottom: 0;
}

.post {
  width: 100%;
  padding: 34px;
}

.post-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.content-flow p,
.content-flow li,
.content-flow blockquote,
.content-flow figcaption,
.post p,
.post li,
.post blockquote,
.post figcaption {
  unicode-bidi: plaintext;
}

[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

.ltr-block,
.english {
  direction: ltr;
  text-align: left;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rtl-block,
.persian {
  direction: rtl;
  text-align: right;
  font-family: "Vazirmatn", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}

.about-page {
  width: 100%;
  padding: 18px 0 28px;
}

.about-section {
  padding: 28px 0;
}

.about-section + .about-section {
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.about-section h1,
.about-section h2 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0;
}

.about-section p {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 2;
  unicode-bidi: plaintext;
}

.about-section.english p {
  line-height: 1.8;
}

.about-section .section-kicker {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post p { margin: 18px 0; }

.post ul,
.post ol {
  padding-inline-start: 1.5rem;
}

.post blockquote {
  margin: 24px 0;
  padding: 10px 18px;
  color: #475569;
  background: var(--surface-soft);
  border-inline-start: 4px solid #cbd5e1;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post figure {
  margin: 32px 0;
  text-align: center;
}

.post img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.post figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.comments-section {
  margin-top: 42px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.comments-section h2 {
  margin-top: 0;
}

.comments-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.comments-fallback {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

code,
pre {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

pre {
  overflow-x: auto;
  padding: 16px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
}

.post mjx-container[display="true"] {
  direction: ltr !important;
  text-align: center !important;
  unicode-bidi: isolate !important;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 4px 0;
}

.post mjx-container {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

.post mjx-container * {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  background: var(--surface);
}

.footer-inner {
  display: grid;
  gap: 8px;
}

.footer-email {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.footer-email a {
  color: var(--muted);
  text-decoration: none;
}

.footer-email a:hover {
  color: var(--accent);
}

@media (max-width: 600px) {
  .container {
    width: min(100% - 28px, 900px);
  }

  main {
    padding-top: 30px;
  }

  nav {
    gap: 8px 13px;
    padding: 14px 0;
    font-size: 0.95rem;
  }

  .post,
  .card {
    padding: 20px;
  }

  .home-grid,
  .resources-left,
  .resources-right {
    grid-template-columns: 1fr;
  }

  .resources-left .link-library,
  .resources-left .notes-section,
  .home-with-quote .home-sidebar,
  .home-with-quote .quote-column,
  .resources-right .link-library,
  .resources-right .notes-section {
    grid-column: 1;
  }
}
