/* ==========================================================================
   وب‌سایت شخصی — Modern Editorial + Swiss Minimalism (نسخه ۳: بازطراحی بصری)
   ساختار: tokens → base → layout → header → hero → sections → components
           → motion → utilities
   ساختار محتوایی و کلاس‌های اصلی حفظ شده‌اند؛ تغییرات فقط ظاهری‌اند.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* روشن: کرم گرم، سرمه‌ای عمیق و آبی نفتی به‌عنوان تأکید */
  --bg: #f7f4ee;
  --surface: #efebe2;
  --text: #1b2433;
  --text-muted: #4a5568;
  --border: #d9d3c6;
  --accent: #1f5f73;
  --accent-ink: #f7f4ee;
  --accent-hover: #174b5b;
  --focus: #b45309;
  --header-shadow: rgba(27, 36, 51, .14);

  /* رنگ هر حوزه‌ی فعالیت: فقط برای خط‌ها و نشانه‌ها (نه متن) */
  --d1: #1f5f73;   /* حقوق و مسائل اجتماعی */
  --d2: #a86b1f;   /* ارتباطات، نگارش و پژوهش */
  --d3: #3f5f9a;   /* فناوری اطلاعات و زیرساخت دیجیتال */

  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, -apple-system, sans-serif;

  --fs-base: 1.0625rem;      /* 17px */
  --lh-body: 1.95;           /* فارسی: فاصله‌ی خط بیشتر از لاتین */
  --measure: 38rem;          /* عرض مطلوب خط برای مطالعه */
  --gutter: 1.25rem;
  --header-h: 3.5rem;
  --radius: 4px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

/* تیره: پالت مستقل، نه معکوس؛ سطح‌ها کمی روشن‌تر، متن کرم کم‌نور */
:root[data-theme="dark"] {
  --bg: #11161e;
  --surface: #18202b;
  --text: #e6e8ec;
  --text-muted: #a9b3c1;
  --border: #2a3443;
  --accent: #8ccfdf;
  --accent-ink: #0f1a20;
  --accent-hover: #a6dce8;
  --focus: #f0b45c;
  --header-shadow: rgba(0, 0, 0, .5);

  --d1: #8ccfdf;
  --d2: #e0ae68;
  --d3: #9db8ee;
}

/* ---------- Base ---------- */
/* ::before و ::after: فقط برای reset، شمارنده‌ی فهرست علایق و خاموش‌کردن انیمیشن. محتوای تزئینی دیگری ساخته نشده */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
}
html[data-theme="dark"] { color-scheme: dark; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-feature-settings: "kern", "liga";
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* انتقال رنگ‌ها فقط پس از بارگذاری؛ تم بدون پرش عوض می‌شود */
@media (prefers-reduced-motion: no-preference) {
  html.theme-ready body,
  html.theme-ready .site-header,
  html.theme-ready .section-alt,
  html.theme-ready .chips li,
  html.theme-ready .btn,
  html.theme-ready .note-empty {
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
  }
}

h1, h2, h3 { margin: 0; line-height: 1.5; font-weight: 700; text-wrap: balance; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
  transition: color .2s ease;
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* اصطلاحات انگلیسی داخل متن فارسی */
[lang="en"] { unicode-bidi: isolate; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 62rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--gutter);
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .6rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
}
.skip-link:focus { top: .5rem; color: var(--accent-ink); }

/* نوار پیشرفت مطالعه: با scroll-driven animation (فقط مرورگرهایی که پشتیبانی می‌کنند) */
.progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right center;
  z-index: 60;
  pointer-events: none;
}
@supports (animation-timeline: scroll()) {
  .progress {
    transform: none;
    animation: progress-grow linear both;
    animation-timeline: scroll(root block);
  }
}
@keyframes progress-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: box-shadow .25s ease, border-color .25s ease;
}
/* هدر هنگام اسکرول: فقط خط و سایه‌ی بسیار ملایم؛ ارتفاع ثابت می‌ماند */
.site-header.is-scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 8px 18px -16px var(--header-shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}
.logotype {
  color: var(--text);
  font-weight: 800;
  font-size: 1.125rem;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  position: relative;
}
.logotype:hover { color: var(--accent); }

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--accent); }
.icon-btn:active { background: var(--border); }

/* آیکن تم: در تم روشن «ماه» (رفتن به تیره)، در تم تیره «خورشید» */
.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ناوبری: لینک فعال با خط زیر ظریف مشخص می‌شود */
.site-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding-inline: .25rem;
  color: var(--text);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0 2px;
  background-position: 100% 100%;
  transition: background-size .3s var(--ease-out), color .2s ease;
}
.site-nav a:hover,
.site-nav a[aria-current="location"] { color: var(--accent); }
.site-nav a:hover { background-size: 100% 2px; background-position: 0 100%; }
.site-nav a[aria-current="location"] { background-size: 100% 2px; background-position: 0 100%; }

.menu-btn { display: none; }

@media (max-width: 47.99rem) {
  .js .menu-btn { display: inline-flex; }
  .js .site-nav {
    display: none;
    position: absolute;
    inset-inline: 0;
    top: 100%;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: .5rem var(--gutter) 1rem;
    box-shadow: 0 16px 24px -20px var(--header-shadow);
  }
  .js .site-nav.is-open { display: block; }
  .js .site-nav li + li { border-top: 1px solid var(--border); }
  .js .site-nav a { min-height: 48px; font-size: 1.0625rem; }

  /* بدون JS: لینک‌ها در ردیف‌های شکسته‌شونده قرار می‌گیرند؛ نوار افقی اسکرول‌دار نداریم */
  html:not(.js) .site-nav { order: 3; width: 100%; }
  html:not(.js) .header-inner { flex-wrap: wrap; }
  html:not(.js) .site-nav ul { display: flex; flex-wrap: wrap; gap: 0 1rem; }
}

@media (min-width: 48rem) {
  .site-nav { margin-inline-start: auto; margin-inline-end: 1rem; }
  .site-nav ul { display: flex; gap: 1.5rem; }
  .header-inner { gap: 1.5rem; }
}

/* ---------- Domain accents (هر حوزه یک هویت بصری ظریف دارد) ---------- */
.domain-1 { --dom: var(--d1); }
.domain-2 { --dom: var(--d2); }
.domain-3 { --dom: var(--d3); }

/* ---------- Hero ---------- */
.hero { padding-block: 3rem 3.5rem; }

.eyebrow {
  color: var(--text-muted);
  font-size: .9375rem;
  margin-bottom: 1.25rem;
  letter-spacing: 0;
}

/* نشانه‌ی گرافیکی: سه خط با طول‌های متفاوت، هر کدام رنگ یک حوزه */
.hero-rule {
  display: flex;
  gap: .4rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.hero-rule span {
  display: block;
  height: 3px;
  border-radius: 2px;
}
.hero-rule .d1 { width: 3.5rem; background: var(--d1); }
.hero-rule .d2 { width: 1.75rem; background: var(--d2); }
.hero-rule .d3 { width: .875rem; background: var(--d3); }

.hero h1 { display: block; }
.hero-name {
  display: block;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: .6rem;
}
.hero-title {
  display: block;
  font-size: clamp(1.9rem, 7.5vw, 3.1rem);
  font-weight: 800;
  line-height: 1.45;
  max-width: 19ch;
}
.hero-lead {
  margin-top: 1.5rem;
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: 1.0625rem;
}

/* فهرست سه حوزه: خط‌های جداکننده و نشانه‌ی رنگی هر حوزه */
.domains {
  display: grid;
  margin-top: 2.25rem;
  border-top: 1px solid var(--border);
  max-width: 44rem;
}
.domains li { border-bottom: 1px solid var(--border); }
.domains a {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  min-height: 52px;
  padding-block: .85rem;
  padding-inline: .75rem 0;
  color: var(--text);
  text-decoration: none;
  border-inline-start: 3px solid var(--dom);
  transition: background-color .2s ease;
}
.domains a:hover { background: var(--surface); color: var(--text); }
.domains a:hover .domain-name { color: var(--accent); }
.domain-num {
  color: var(--text-muted);
  font-size: .9375rem;
  min-width: 2rem;
}
.domain-name { font-weight: 600; transition: color .2s ease; }

.hero-actions { margin-top: 2.25rem; display: flex; flex-wrap: wrap; gap: .75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .5rem 1.5rem;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.4;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--surface); color: var(--accent-hover); }

/* ---------- Sections ---------- */
.section { padding-block: 3.5rem; }
.section-alt { background: var(--surface); }

.section-index {
  font-size: .9375rem;
  color: var(--text-muted);
  margin-bottom: .25rem;
}
.section h2 {
  font-size: 1.625rem;
  margin-bottom: 1.75rem;
  padding-top: .75rem;
  border-top: 2px solid var(--text);
  max-width: 100%;
}
.section h3 { font-size: 1.125rem; margin-bottom: .75rem; }

/* فاصله‌ی پرش به بخش‌ها: ارتفاع هدر با main.js اندازه‌گیری می‌شود (--header-h) */
section[id],
.skill-group[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }

.prose p,
.prose-narrow { max-width: var(--measure); }
.prose p + p { margin-top: 1.25rem; }

/* ---------- Skills ---------- */
.skill-group {
  border-inline-start: 2px solid var(--dom, var(--border));
  padding-inline-start: 1.25rem;
}
.skill-group + .skill-group { margin-top: 2.75rem; }

.plain-list li {
  padding-block: .6rem;
  border-bottom: 1px solid var(--border);
  transition: color .2s ease;
}
.plain-list li:first-child { border-top: 1px solid var(--border); }
.plain-list li:hover { color: var(--accent); }

.tech { border-top: 1px solid var(--border); }
.tech-row {
  padding-block: 1rem;
  border-bottom: 1px solid var(--border);
}
.tech-row dt {
  font-weight: 600;
  margin-bottom: .6rem;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.chips li {
  direction: ltr;           /* هر نام فنی لاتین، ترتیب چپ‌به‌راست طبیعی خود را دارد */
  unicode-bidi: isolate;
  font-family: var(--font);
  font-size: .9375rem;
  line-height: 1.5;
  padding: .2rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  overflow-wrap: anywhere;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.chips li:hover {
  border-color: var(--dom, var(--accent));
  background: var(--surface);
  color: var(--text);
}

/* ---------- Interests ---------- */
.interest-list {
  counter-reset: interest;
  border-top: 1px solid var(--border);
}
.interest-list li {
  counter-increment: interest;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-block: .8rem;
  border-bottom: 1px solid var(--border);
  transition: color .2s ease;
}
.interest-list li::before {
  content: counter(interest, persian-digits);
  color: var(--text-muted);
  font-size: .9375rem;
  min-width: 2rem;
}
.interest-list li:hover { color: var(--accent); }

@counter-style persian-digits {
  system: numeric;
  symbols: "۰" "۱" "۲" "۳" "۴" "۵" "۶" "۷" "۸" "۹";
  suffix: " ";
}

/* ---------- Notes (قابل توسعه به وبلاگ) ---------- */
.note-list li { padding-block: 1.25rem; border-bottom: 1px solid var(--border); }
.note-item time { color: var(--text-muted); font-size: .9375rem; }
.note-item h3 { margin-block: .25rem; }

/* وضعیت خالی بخش نوشته‌ها: یک قاب ظریف و خط‌چین */
.note-empty {
  max-width: var(--measure);
  padding: 1.25rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* ---------- Contact ---------- */
.contact-list { margin-top: 1.5rem; max-width: var(--measure); border-top: 1px solid var(--border); }
.contact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem 1rem;
  padding-block: .75rem;
  border-bottom: 1px solid var(--border);
}
.contact-label { min-width: 5.5rem; color: var(--text-muted); }

/* لینک‌های تماس: خط زیر که از ابتدا به انتها کشیده می‌شود */
.contact-list a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  overflow-wrap: anywhere;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0 1px;
  background-position: 0 100%;
  transition: background-size .3s var(--ease-out), color .2s ease;
}
.contact-list a:hover { background-size: 100% 1px; }

/* ---------- Error page (404) ---------- */
.error-body { min-height: 100vh; display: flex; flex-direction: column; }
.error-page { flex: 1; display: flex; align-items: center; padding-block: 4rem; }
.error-code { font-size: clamp(4rem, 20vw, 7rem); font-weight: 800; line-height: 1; color: var(--accent); margin-bottom: 1rem; }
.error-page h1 { font-size: 1.75rem; margin-bottom: 1rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem;
  color: var(--text-muted);
  font-size: .9375rem;
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; }
.site-footer a { color: var(--text-muted); min-height: 44px; display: inline-flex; align-items: center; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Motion: ورود تدریجی بخش‌ها ---------- */
/* فقط وقتی JS و IntersectionObserver فعال‌اند پنهان می‌شود؛ بدون JS همه‌چیز نمایان است */
html.js-io .reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .6s ease-out, transform .6s ease-out;
}
html.js-io .reveal.is-visible {
  opacity: 1;
  transform: none;
}
html.js-io .interest-list > .reveal:nth-child(2),
html.js-io .domains > .reveal:nth-child(2),
html.js-io .contact-list > .reveal:nth-child(2) { transition-delay: .06s; }
html.js-io .interest-list > .reveal:nth-child(3),
html.js-io .domains > .reveal:nth-child(3),
html.js-io .contact-list > .reveal:nth-child(3) { transition-delay: .12s; }
html.js-io .interest-list > .reveal:nth-child(4),
html.js-io .contact-list > .reveal:nth-child(4) { transition-delay: .18s; }

/* ورود کوتاه عناصر اول صفحه */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.hero .eyebrow,
.hero-rule,
.hero h1,
.hero-lead,
.domains,
.hero-actions {
  animation: rise .7s var(--ease-out) both;
}
.hero h1 { animation-delay: .08s; }
.hero-lead { animation-delay: .16s; }
.domains { animation-delay: .24s; }
.hero-actions { animation-delay: .3s; }

/* ---------- Wider screens ---------- */
@media (min-width: 48rem) {
  :root { --gutter: 2rem; --fs-base: 1.125rem; }
  .section { padding-block: 5rem; }
  .hero { padding-block: 5.5rem 6.5rem; }
  .section h2 { font-size: 2rem; }
  .hero-name { font-size: 1.125rem; }

  .domains {
    grid-template-columns: repeat(3, 1fr);
    column-gap: 1.25rem;
    border-top: 0;
    max-width: 52rem;
  }
  .domains li { border-bottom: 0; }
  .domains a {
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    min-height: 0;
    height: 100%;
    padding: 1.1rem 1.1rem 1.2rem;
    border-top: 1px solid var(--border);
    border-inline-start: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 3px 0 var(--dom);
  }
  .domains a:hover { background: var(--surface); }
  .domain-name { font-size: 1.0625rem; line-height: 1.6; }

  .plain-list { columns: 2; column-gap: 3rem; }
  .plain-list li { break-inside: avoid; }
  .plain-list li:first-child { border-top: 0; }
  .plain-list { border-top: 1px solid var(--border); }

  .interest-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 3rem; }
  .interest-list li:nth-child(odd) { border-inline-end: 0; }

  .tech-row { display: grid; grid-template-columns: 14rem 1fr; gap: 1.5rem; align-items: baseline; }
  .tech-row dt { margin-bottom: 0; }
}

@media (min-width: 64rem) {
  .hero-title { font-size: 3.6rem; }
}

/* ---------- Reduced motion / Print ---------- */
/* !important فقط برای خاموش‌کردن عمدی انیمیشن و انتقال در حالت کاهش حرکت (تداخل عمدی با قوانین بالا) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .progress { display: none !important; }
  html.js-io .reveal { opacity: 1 !important; transform: none !important; }
}

@media print {
  .site-header, .skip-link, .hero-actions, .progress { display: none; }
  body { background: #fff; color: #000; }
  .section-alt { background: none; }
}
