/* Mehrafarin Blog — Read mode, light/dark, RTL/LTR */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf8;
  --bg-deep: #f0efe9;
  --surface: #ffffff;
  --ink: #1a1a1f;
  --muted: #5c5c68;
  --line: rgba(26, 26, 31, 0.1);
  --accent: #1f6f5f;
  --accent-soft: rgba(31, 111, 95, 0.12);
  --accent-ink: #163f37;
  --warm: #b86b32;
  --header-h: 70px;
  --measure: 42rem;
  --prose-size: 1.0625rem;
  --font-ui: "Vazirmatn", system-ui, sans-serif;
  --font-body: "Vazirmatn", system-ui, sans-serif;
  --font-serif: "Source Serif 4", "Vazirmatn", Georgia, serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 18px 48px rgba(20, 20, 26, 0.08);
  --progress: 0%;
}

[data-theme="dark"] {
  --bg: #0c0c10;
  --bg-deep: #121218;
  --surface: #16161c;
  --ink: #f2f2f5;
  --muted: rgba(242, 242, 245, 0.58);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #4db8a0;
  --accent-soft: rgba(77, 184, 160, 0.14);
  --accent-ink: #d8f3eb;
  --warm: #e0a06a;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 18px);
}

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(900px 480px at 88% -10%, rgba(31, 111, 95, 0.09), transparent 55%),
    radial-gradient(700px 400px at -8% 8%, rgba(184, 107, 50, 0.07), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

[data-theme="dark"] body {
  background:
    radial-gradient(900px 480px at 88% -10%, rgba(77, 184, 160, 0.1), transparent 55%),
    radial-gradient(700px 400px at -8% 8%, rgba(224, 160, 106, 0.06), transparent 50%),
    var(--bg);
}

body.is-ltr {
  --font-body: var(--font-serif);
}

body.is-ltr .prose {
  font-family: var(--font-body);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* Reading progress */
.read-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}

.read-progress__bar {
  height: 100%;
  width: var(--progress);
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: width 0.08s linear;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  backdrop-filter: blur(16px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.site-header__inner {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.brand img {
  width: 96px;
  height: auto;
}

.brand .logo-dark { display: none; }
[data-theme="dark"] .brand .logo-light { display: none; }
[data-theme="dark"] .brand .logo-dark { display: block; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem 0.75rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem 1.1rem;
}

.site-nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.3rem 0;
  position: relative;
}

.site-nav a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s var(--ease);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after { transform: scaleX(1); }

.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.lang-btn {
  min-width: 2rem;
  height: 1.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lang-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg) !important;
  font-weight: 700;
  font-size: 0.84rem;
  transition: transform 0.25s var(--ease), opacity 0.2s;
}

.nav-cta::after { display: none !important; }
.nav-cta:hover { transform: translateY(-1px); opacity: 0.92; color: var(--bg) !important; }

@media (max-width: 860px) {
  .site-nav .nav-about,
  .nav-cta { display: none; }
  .brand img { width: 78px; }
}

@media (max-width: 560px) {
  .site-nav a:not([aria-current]) { display: none; }
}

/* Page shell */
.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.25rem 0 4.5rem;
}

.blog-intro {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: end;
  padding: 1.25rem 0 2.75rem;
  animation: rise 0.75s var(--ease) both;
}

.blog-intro h1 {
  font-size: clamp(2.35rem, 6vw, 4rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 800;
  max-width: 11ch;
}

.blog-intro .lede {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 30ch;
  justify-self: end;
  padding-bottom: 0.35rem;
}

@media (max-width: 820px) {
  .blog-intro { grid-template-columns: 1fr; gap: 0.85rem; }
  .blog-intro .lede { justify-self: start; max-width: 38ch; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* Featured */
.featured {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  min-height: 400px;
  margin-bottom: 3rem;
  border-radius: 28px;
  overflow: hidden;
  background: #15151b;
  color: #f4f3ee;
  box-shadow: var(--shadow);
  animation: rise 0.85s var(--ease) 0.06s both;
  text-decoration: none;
  transition: transform 0.35s var(--ease);
}

.featured:hover { transform: translateY(-2px); }

.featured__visual {
  min-height: 240px;
  background:
    linear-gradient(135deg, rgba(31, 111, 95, 0.5), rgba(20, 20, 26, 0.4)),
    url("/assets/brand/og-cover.png") center / cover no-repeat;
}

.featured__body {
  padding: clamp(1.5rem, 4vw, 2.4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(244, 243, 238, 0.62);
}

.chip {
  display: inline-flex;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e8f5f1;
  font-size: 0.75rem;
  font-weight: 700;
}

.featured h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.featured p {
  color: rgba(244, 243, 238, 0.72);
  font-size: 0.98rem;
  max-width: 34ch;
}

.featured .read-link {
  margin-top: 0.35rem;
  align-self: flex-start;
  font-weight: 700;
  border-bottom: 2px solid rgba(255, 255, 255, 0.35);
  padding-bottom: 2px;
}

@media (max-width: 860px) {
  .featured { grid-template-columns: 1fr; }
}

/* Feed */
.section-label {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.post-feed { animation: rise 0.95s var(--ease) 0.1s both; }

.post-item {
  display: grid;
  grid-template-columns: 7rem 1fr auto;
  gap: 1rem 1.5rem;
  align-items: baseline;
  padding: 1.45rem 0;
  border-top: 1px solid var(--line);
  text-decoration: none !important;
}

.post-item:last-child { border-bottom: 1px solid var(--line); }
.post-item * { text-decoration: none !important; }

.post-item__date {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.post-item__title {
  font-size: clamp(1.1rem, 2.3vw, 1.35rem);
  line-height: 1.4;
  font-weight: 750;
  margin-bottom: 0.4rem;
  transition: color 0.2s;
}

.post-item:hover .post-item__title { color: var(--accent); }

.post-item__excerpt {
  color: var(--muted);
  font-size: 0.94rem;
  max-width: 48ch;
}

.post-item__meta {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .post-item { grid-template-columns: 1fr; gap: 0.3rem; }
  .post-item__meta { order: -1; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent);
  padding: 2.4rem 0 2rem;
}

.site-footer__inner {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  gap: 0.65rem;
}

.site-footer p { color: var(--muted); font-size: 0.92rem; }
.site-footer a {
  color: var(--ink);
  font-weight: 650;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
}
.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Article layout */
.article-layout {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 4.5rem;
  display: grid;
  grid-template-columns: 15rem minmax(0, var(--measure));
  gap: 2.5rem;
  align-items: start;
  justify-content: center;
}

.article-main { min-width: 0; max-width: var(--measure); }

.toc {
  position: sticky;
  top: calc(var(--header-h) + 1.25rem);
  padding: 0.25rem 0;
  animation: rise 0.7s var(--ease) both;
}

.toc__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

.toc nav {
  display: grid;
  gap: 0.45rem;
}

.toc a {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.toc a.is-active,
.toc a:hover {
  color: var(--ink);
  border-inline-start-color: var(--accent);
}

.toc-mobile {
  display: none;
  margin: 0 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.toc-mobile summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.toc-mobile summary::-webkit-details-marker { display: none; }

.toc-mobile nav {
  display: grid;
  gap: 0.35rem;
  padding: 0 1rem 1rem;
}

@media (max-width: 980px) {
  .article-layout {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }
  .toc { display: none; }
  .toc-mobile { display: block; }
  .article-main { max-width: none; margin-inline: auto; width: min(720px, 100%); }
}

.article-hero { animation: rise 0.75s var(--ease) both; margin-bottom: 1.25rem; }

.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 1.1rem;
}

.crumb a { color: var(--accent); }
.crumb a:hover { text-decoration: underline; }

.article-hero h1 {
  font-size: clamp(1.8rem, 4.4vw, 2.7rem);
  line-height: 1.28;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin-bottom: 0.9rem;
}

.article-hero .deck {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 1.2rem;
  max-width: 38em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.15rem;
  align-items: center;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.reading-time {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-weight: 700;
}

.reader-tools {
  display: inline-flex;
  gap: 0.25rem;
  margin-inline-start: auto;
}

.reader-tools button {
  min-width: 2rem;
  height: 1.85rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

.reader-tools button:hover,
.reader-tools button.is-active {
  color: var(--ink);
  background: var(--accent-soft);
}

.article-cover {
  margin: 1.5rem 0 2rem;
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(31, 111, 95, 0.42), rgba(20, 20, 26, 0.5)),
    url("/assets/brand/og-cover.png") center / cover no-repeat;
  box-shadow: var(--shadow);
  animation: rise 0.85s var(--ease) 0.05s both;
}

/* Prose */
.prose {
  font-size: var(--prose-size);
  line-height: 1.82;
  animation: rise 0.9s var(--ease) 0.08s both;
  color: color-mix(in srgb, var(--ink) 92%, var(--muted));
}

.prose > * + * { margin-top: 1.15em; }

.prose h2 {
  margin-top: 2.4em;
  margin-bottom: 0.55em;
  font-size: 1.32rem;
  line-height: 1.4;
  letter-spacing: -0.015em;
  color: var(--ink);
  font-family: var(--font-ui);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.prose h3 {
  margin-top: 1.75em;
  font-size: 1.1rem;
  color: var(--ink);
  font-family: var(--font-ui);
}

.prose p { margin: 0; }
.prose ul, .prose ol { padding-inline-start: 1.25rem; }
.prose li + li { margin-top: 0.4em; }
.prose strong { font-weight: 750; color: var(--ink); }
.prose a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pull {
  margin: 1.85rem 0;
  padding: 1.2rem 1.35rem;
  background: var(--accent-soft);
  border-radius: 16px;
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.65;
  color: var(--accent-ink);
  font-family: var(--font-ui);
}

.tip {
  margin: 1.75rem 0;
  padding: 1.1rem 1.25rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--font-ui);
}

.tip__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.tip p { margin: 0; color: var(--ink); font-size: 0.95rem; line-height: 1.65; }

.soft-cta {
  margin: 2rem 0;
  padding: 1.15rem 1.25rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--warm) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warm) 28%, transparent);
  font-family: var(--font-ui);
}

.soft-cta a {
  color: var(--ink);
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cta-band {
  margin-top: 2.75rem;
  padding: 1.5rem 1.4rem;
  border-radius: 20px;
  background: #15151b;
  color: #f4f3ee;
  font-family: var(--font-ui);
}

[data-theme="dark"] .cta-band {
  background: #1e1e28;
  border: 1px solid var(--line);
}

.cta-band h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: #fff;
}

.cta-band p {
  margin: 0 0 1rem;
  color: rgba(244, 243, 238, 0.7);
  font-size: 0.94rem;
}

.cta-band .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none !important;
  transition: transform 0.25s var(--ease);
}

.btn:hover { transform: translateY(-1px); }
.btn-light { background: #f4f3ee; color: #15151b; }
.btn-ghost {
  background: transparent;
  color: #f4f3ee;
  border: 1px solid rgba(244, 243, 238, 0.28);
}

.related {
  margin-top: 2.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
}

.related h2 {
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.related-list { display: grid; gap: 0; }

.related-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  text-decoration: none !important;
  transition: color 0.2s;
}

.related-list a:hover { color: var(--accent); }
.related-list span { color: var(--muted); font-weight: 600; font-size: 0.84rem; white-space: nowrap; }

.back-blog {
  display: inline-flex;
  margin-top: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-ui);
}

.back-blog:hover { text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
