/* ============================================================
   PARSI-MOKEL ANIMATIONS — production stylesheet
   ------------------------------------------------------------
   فقط transform & opacity · RTL-aware · prefers-reduced-motion
   حجم اضافه‌شده: ~۸KB · بدون وابستگی خارجی
   ============================================================ */

/* ---------- standard timing tokens ---------- */
:root{
  /* easings */
  --ease-out-quint: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-standard:  cubic-bezier(0.4, 0, 0.2, 1);

  /* durations */
  --t-fast:   200ms;
  --t-mid:    300ms;
  --t-slow:   600ms;
  --t-reveal: 800ms;
  --t-count:  1500ms;
}

/* ---------- universal reduced-motion ---------- */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   ۱. HERO — صفحهٔ اصلی
   ============================================================ */

/* ۱.۱  Stagger fade-in ------------------------------------- */
.hero-el{
  opacity: 0;
  transform: translateY(12px);
  will-change: transform, opacity;
}
.hero.is-in .hero-el{
  animation: heroRise var(--t-slow) var(--ease-out-quint) forwards;
}
@keyframes heroRise{
  to{ opacity: 1; transform: translateY(0); }
}
.hero.is-in .hero-eyebrow  { animation-delay:   0ms; }
.hero.is-in .hero-title    { animation-delay:  80ms; }
.hero.is-in .hero-subtitle { animation-delay: 160ms; }
.hero.is-in .hero-cta      { animation-delay: 240ms; }
.hero.is-in .hero-metrics  { animation-delay: 320ms; }
.hero.is-in .hero-side     { animation-delay: 200ms; }  /* کارت‌های مکالمه */

/* ۱.۲  مکالمهٔ دو کارت ------------------------------------- */
.chat-card{
  opacity: 0;
  transform: translateY(16px);
  will-change: transform, opacity;
}
/* کارت سوال — همراه stagger کلی hero ظاهر می‌شود */
.hero.is-in .chat-q{
  animation: chatRise 500ms var(--ease-out-quint) forwards;
  animation-delay: 600ms;
}
/* تایپینگ بعد از سوال */
.hero.is-in .chat-typing{
  animation: chatRise 400ms var(--ease-out-quint) forwards;
  animation-delay: 1300ms;
  /* محو‌شدن بعد از پاسخ */
}
.hero.is-in .chat-typing.is-gone{
  animation: chatFade 200ms ease-in forwards;
}
/* کارت پاسخ */
.hero.is-in .chat-a{
  animation: chatRise 500ms var(--ease-out-quint) forwards;
  animation-delay: 2400ms;
}
@keyframes chatRise{
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes chatFade{
  to{ opacity: 0; transform: translateY(-4px); }
}

/* سه نقطهٔ typing داخل تایپینگ */
.typing-dot{
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal-2, #4A9494);
  margin: 0 2px;
  animation: typingBounce 1s ease-in-out infinite;
}
.typing-dot:nth-child(2){ animation-delay: .15s; }
.typing-dot:nth-child(3){ animation-delay: .3s; }
@keyframes typingBounce{
  0%, 60%, 100%{ transform: translateY(0); opacity: .4; }
  30%{ transform: translateY(-4px); opacity: 1; }
}

/* ۱.۳  شمارش متریک‌ها  (CSS فقط استایل می‌دهد، شمارش با JS) */
.counter{
  font-variant-numeric: tabular-nums;
  display: inline-block;
  /* جلوگیری از پرش layout موقع تغییر عرض اعداد */
  min-width: 2ch;
}

/* ۱.۴  خط زیر «زبان ساده» -- کشیده‌شدن از راست به چپ ----- */
.highlight{
  position: relative;
  display: inline-block;
  color: var(--teal, #2D6A6A);
  white-space: nowrap;
}
.highlight::after{
  content: '';
  position: absolute;
  right: 0; bottom: 2px;
  width: 0;            /* RTL: width رشد می‌کند، چون right=0 ثابت */
  height: 8px;
  background: color-mix(in oklch, var(--warm, #C9A961) 55%, transparent);
  border-radius: 3px;
  z-index: -1;
}
.hero.is-in .highlight::after{
  animation: drawUnder 800ms var(--ease-out-quint) forwards;
  animation-delay: 480ms; /* بعد از ظاهر شدن کامل title */
}
@keyframes drawUnder{
  to{ width: 100%; }
}

/* ============================================================
   ۲. SCROLL-TRIGGERED — Intersection Observer
   ============================================================ */

.reveal{
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--t-slow) var(--ease-out-quint),
              transform var(--t-slow) var(--ease-out-quint);
  will-change: transform, opacity;
}
.reveal.is-revealed{
  opacity: 1;
  transform: translateY(0);
}

/* استگر داخل گرید — هر فرزند با ۵۰ms تأخیر */
.reveal-stagger > *{
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms var(--ease-out-quint),
              transform 500ms var(--ease-out-quint);
  will-change: transform, opacity;
}
.reveal-stagger.is-revealed > *{
  opacity: 1;
  transform: translateY(0);
}
/* تأخیر در JS ست می‌شود تا تعداد فرزند مهم نباشد، ولی fallback تا ۱۲ ردیف: */
.reveal-stagger.is-revealed > *:nth-child(1){ transition-delay:   0ms; }
.reveal-stagger.is-revealed > *:nth-child(2){ transition-delay:  50ms; }
.reveal-stagger.is-revealed > *:nth-child(3){ transition-delay: 100ms; }
.reveal-stagger.is-revealed > *:nth-child(4){ transition-delay: 150ms; }
.reveal-stagger.is-revealed > *:nth-child(5){ transition-delay: 200ms; }
.reveal-stagger.is-revealed > *:nth-child(6){ transition-delay: 250ms; }
.reveal-stagger.is-revealed > *:nth-child(7){ transition-delay: 300ms; }
.reveal-stagger.is-revealed > *:nth-child(8){ transition-delay: 350ms; }

/* پارالاکس ظریف — JS فقط translateY می‌دهد، CSS کمکی نیاز ندارد */
[data-parallax]{ will-change: transform; }

/* ============================================================
   ۳. TRUST-BUILDING INTERACTIONS
   ============================================================ */

/* ۳.۱  کارت وکیل (شهرها) ----------------------------------- */
.lawyer-card{
  transition: transform 250ms var(--ease-spring),
              box-shadow 250ms ease,
              border-color 250ms ease;
  will-change: transform;
}
.lawyer-card .avatar{
  transition: transform 250ms var(--ease-spring);
  will-change: transform;
}
.lawyer-card:hover{
  transform: translateY(-4px);
  box-shadow: 0 12px 28px -8px rgba(26, 47, 47, .18);
  border-color: color-mix(in oklch, var(--teal, #2D6A6A) 30%, transparent);
}
.lawyer-card:hover .avatar{
  transform: scale(1.05);
}

/* ۳.۲  کارت ابزار/ماشین‌حساب -------------------------------- */
.tool-card{
  position: relative;
  background: #fff;
  transition: background-color 300ms ease,
              border-color 250ms ease,
              transform 250ms var(--ease-spring);
}
.tool-card .tool-icon{
  transition: transform 350ms var(--ease-spring),
              color 250ms ease;
  will-change: transform;
}
.tool-card:hover{
  background: var(--cream-2, #EAF4F4);
  border-color: color-mix(in oklch, var(--teal-2, #4A9494) 35%, transparent);
}
.tool-card:hover .tool-icon{
  transform: rotate(-5deg) scale(1.08);  /* RTL: چرخش به چپ طبیعی‌تر است */
  color: var(--teal, #2D6A6A);
}

/* ۳.۳  Active state دکمه‌ها — حس فیزیکی --------------------- */
.btn,
button.tap{
  transition: transform 200ms var(--ease-spring),
              background-color 200ms ease,
              box-shadow 200ms ease;
}
.btn:active,
button.tap:active{
  transform: scale(0.97);
}

/* ۳.۴  Focus-visible — outline تال جایگزین زرد مرورگر ------- */
*:focus{ outline: none; }
*:focus-visible{
  outline: 2px solid var(--teal, #2D6A6A);
  outline-offset: 3px;
  border-radius: 4px;
  animation: focusEnter 250ms var(--ease-out-quint);
}
@keyframes focusEnter{
  from{ outline-color: transparent; outline-offset: 6px; }
  to  { outline-color: var(--teal, #2D6A6A); outline-offset: 3px; }
}

/* ============================================================
   ۴. LOADING STATES
   ============================================================ */

/* ۴.۱  Skeleton + shimmer ---------------------------------- */
.skel{
  display: block;
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--teal-2, #4A9494) 8%, var(--cream, #F8F6F2)) 25%,
    color-mix(in oklch, var(--teal-2, #4A9494) 16%, var(--cream, #F8F6F2)) 50%,
    color-mix(in oklch, var(--teal-2, #4A9494) 8%, var(--cream, #F8F6F2)) 75%
  );
  background-size: 200% 100%;
  animation: skelShimmer 1.4s linear infinite;
  border-radius: 6px;
  /* اندازهٔ پیش‌فرض — می‌توان با width/height در style بازنویسی کرد */
}
@keyframes skelShimmer{
  0%  { background-position: -200% 0; }
  100%{ background-position:  200% 0; }
}

/* ۴.۲  Button loading state — هیچوقت disable نمی‌شود ------- */
.btn{
  position: relative;
}
.btn .btn-label{
  transition: opacity 150ms ease;
}
.btn .btn-spinner{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.btn .btn-spinner::before{
  content: '';
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
.btn.is-loading{
  pointer-events: none; /* جلوگیری از کلیک مجدد، بدون disable */
}
.btn.is-loading .btn-label  { opacity: 0; }
.btn.is-loading .btn-spinner{ opacity: 1; }
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ۴.۳  Page transition — fade خیلی سریع -------------------- */
body{
  animation: pageIn 150ms ease-out;
}
@keyframes pageIn{
  from{ opacity: 0; transform: translateY(4px); }
  to  { opacity: 1; transform: translateY(0); }
}
body.is-leaving{
  animation: pageOut 150ms ease-in forwards;
}
@keyframes pageOut{
  to  { opacity: 0; transform: translateY(-4px); }
}

/* ============================================================
   ۵. FORM — ماشین‌حساب‌ها
   ============================================================ */

/* ۵.۱  عدد خروجی — JS counter استفاده می‌کند ----------------- */
.calc-result-num{
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 4ch;
}

/* ۵.۲  Breakdown با stagger ۸۰ms --------------------------- */
.breakdown-item{
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 400ms var(--ease-out-quint),
              transform 400ms var(--ease-out-quint);
}
.breakdown.is-shown .breakdown-item{
  opacity: 1;
  transform: translateY(0);
}
.breakdown.is-shown .breakdown-item:nth-child(1){ transition-delay:   0ms; }
.breakdown.is-shown .breakdown-item:nth-child(2){ transition-delay:  80ms; }
.breakdown.is-shown .breakdown-item:nth-child(3){ transition-delay: 160ms; }
.breakdown.is-shown .breakdown-item:nth-child(4){ transition-delay: 240ms; }
.breakdown.is-shown .breakdown-item:nth-child(5){ transition-delay: 320ms; }
.breakdown.is-shown .breakdown-item:nth-child(6){ transition-delay: 400ms; }

/* ۵.۳  Input focus — gradient ظریف متحرک ------------------- */
.input-wrap{
  position: relative;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line, #E5DFD2);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.input-wrap:focus-within{
  border-color: var(--teal, #2D6A6A);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--teal, #2D6A6A) 12%, transparent);
}
/* gradient subtle که آرام جا‌به‌جا می‌شود */
.input-wrap::before{
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    110deg,
    transparent 30%,
    color-mix(in oklch, var(--teal-2, #4A9494) 40%, transparent) 50%,
    transparent 70%
  );
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
          mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}
.input-wrap:focus-within::before{
  opacity: 1;
  animation: borderShift 4s ease-in-out infinite;
}
@keyframes borderShift{
  0%, 100%{ background-position: 100% 0; }
  50%     { background-position:   0% 0; }
}
.input-wrap input{
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px;
  font: inherit;
  color: var(--teal-ink, #1A2F2F);
  font-variant-numeric: tabular-nums;
}

/* ۵.۴  Error shake ----------------------------------------- */
.input-wrap.is-error{
  border-color: #B95A4A;
  box-shadow: 0 0 0 4px rgba(185, 90, 74, .12);
  animation: errShake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes errShake{
  10%, 90%{ transform: translateX(-2px); }
  20%, 80%{ transform: translateX( 2px); }
  30%, 50%, 70%{ transform: translateX(-4px); }
  40%, 60%     { transform: translateX( 4px); }
}

/* ============================================================
   ۶. MOBILE
   ============================================================ */

/* ۶.۱  Mobile menu — slide-in از راست (RTL) ---------------- */
.m-menu{
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 86%;
  max-width: 360px;
  background: #fff;
  box-shadow: -8px 0 32px -8px rgba(26, 47, 47, .25);
  transform: translateX(100%); /* در RTL محور X معکوس می‌شود → از راست به سمت داخل */
  transition: transform 350ms var(--ease-spring);
  z-index: 200;
  overflow-y: auto;
}
.m-menu.is-open{
  transform: translateX(0);
}
.m-menu-backdrop{
  position: fixed; inset: 0;
  background: rgba(26, 47, 47, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  z-index: 199;
}
.m-menu-backdrop.is-open{
  opacity: 1;
  pointer-events: auto;
}

/* ۶.۲  Tap feedback — برای دستگاه‌های لمسی ----------------- */
@media (hover: none){
  .tap-feedback{
    transition: transform 100ms var(--ease-standard),
                background-color 100ms ease;
  }
  .tap-feedback:active{
    transform: scale(0.97);
    background-color: color-mix(in oklch, var(--teal-2, #4A9494) 8%, transparent);
  }
}

/* ۶.۳  Sticky bottom CTA — ظاهر می‌شود بعد از ۳۰٪ scroll -- */
.sticky-cta{
  position: fixed;
  right: 0; left: 0; bottom: 0;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line, #E5DFD2);
  transform: translateY(100%);
  transition: transform 400ms var(--ease-out-quint);
  z-index: 100;
  box-shadow: 0 -4px 16px -4px rgba(26, 47, 47, .08);
}
.sticky-cta.is-shown{
  transform: translateY(0);
}

/* ============================================================
   ۷. SUBTLE TOUCHES
   ============================================================ */

/* ۷.۱  چک‌مارک با stroke-draw ------------------------------- */
.check-icon{
  display: inline-flex;
  vertical-align: middle;
}
.check-icon path{
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
  transition: stroke-dashoffset 450ms var(--ease-out-quint);
}
.check-icon.is-drawn path,
.is-drawn .check-icon path{
  stroke-dashoffset: 0;
}

/* ۷.۲  Scroll progress indicator --------------------------- */
.scroll-progress{
  position: fixed;
  top: 0; right: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-2, #4A9494), var(--teal, #2D6A6A));
  transform: scaleX(0);
  transform-origin: right; /* RTL — رشد از راست */
  z-index: 300;
  pointer-events: none;
  transition: transform 80ms linear;
}

/* ۷.۳  Floating badge — pulse خیلی ظریف -------------------- */
.badge-update{
  position: relative;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--warm, #C9A961) 15%, transparent);
  color: var(--warm-dark, #8E7434);
}
.badge-update::before{
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--warm, #C9A961) 50%, transparent);
  z-index: -1;
  animation: badgePulse 2.5s ease-in-out infinite;
}
@keyframes badgePulse{
  0%, 100%{ transform: scale(1);   opacity: 0; }
  50%     { transform: scale(1.15); opacity: .6; }
}


/* ============================================================
   ۸. LOGO HOVER ANIMATION (header brand mark)
   انیمیشن فعال می‌شود وقتی روی pm-brand هاور می‌شود
   ============================================================ */
.pm-brand .logo-a,
.pm-brand .logo-b,
.pm-brand .logo-dot,
.pm-brand .logo-link {
  transform-box: fill-box;
  transform-origin: center;
}
.pm-brand .logo-a       { transform-origin: 15px 21px; }
.pm-brand .logo-b       { transform-origin: 33px 27px; }
.pm-brand .logo-link    { stroke-dasharray: 90; stroke-dashoffset: 0; }

/* trigger روی hover کل لوگو */
.pm-brand:hover .logo-a    { animation: hLogoA 1.8s ease-out; }
.pm-brand:hover .logo-b    { animation: hLogoB 1.8s ease-out; }
.pm-brand:hover .logo-dot-1{ animation: hLogoDot 1.8s ease-out; }
.pm-brand:hover .logo-dot-2{ animation: hLogoDot 1.8s ease-out; animation-delay: .15s; }
.pm-brand:hover .logo-link { animation: hLogoLink 1.8s ease-out; }

@keyframes hLogoA {
  0%   { transform: translate(-8px, 3px) rotate(-8deg); opacity: .4; }
  40%, 100% { transform: translate(0,0) rotate(0); opacity: 1; }
}
@keyframes hLogoB {
  0%   { transform: translate(8px, -3px) rotate(8deg); opacity: .4; }
  40%, 100% { transform: translate(0,0) rotate(0); opacity: .88; }
}
@keyframes hLogoDot {
  0%, 40%  { transform: scale(0); opacity: 0; }
  60%, 100%{ transform: scale(1); opacity: 1; }
}
@keyframes hLogoLink {
  0%, 55%  { stroke-dashoffset: 90; }
  85%, 100%{ stroke-dashoffset: 0; }
}

/* ============================================================
   ۹. HERO CONNECTION SCENE
   لحظه‌ی اتصال وکیل و موکل — تصویری
   ============================================================ */
.connection-scene {
  position: relative;
  background: radial-gradient(700px 360px at 50% 60%, #F2EBD9 0%, #F6F0E3 60%, #EFE6D2 100%);
  border-radius: 24px;
  padding: 60px 40px;
  margin: 0 auto;
  max-width: 880px;
  overflow: hidden;
  border: 1px solid var(--line, #E5DFD2);
}
.connection-svg {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.connection-caption {
  text-align: center;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.connection-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #C9A961;
  font-weight: 700;
  border: 1px solid #C9A961;
  padding: 4px 12px;
  border-radius: 999px;
}
.connection-caption strong {
  font-weight: 600;
  color: var(--ink, #1A2F2F);
  font-size: 16px;
}
.hero-person { transform-origin: center; opacity: 0; }
.hero-left   { animation: heroEnterL 3.4s ease-out infinite; }
.hero-right  { animation: heroEnterR 3.4s ease-out infinite; }
@keyframes heroEnterL {
  0%        { transform: translateX(-40px); opacity: 0; }
  20%, 90%  { transform: translateX(0); opacity: 1; }
  100%      { transform: translateX(0); opacity: 1; }
}
@keyframes heroEnterR {
  0%        { transform: translateX(40px); opacity: 0; }
  20%, 90%  { transform: translateX(0); opacity: 1; }
  100%      { transform: translateX(0); opacity: 1; }
}
.hero-line {
  stroke-dasharray: 4 6;
  animation: heroDash 3.4s linear infinite, heroFade 3.4s ease-out infinite;
}
@keyframes heroDash { to { stroke-dashoffset: -200; } }
@keyframes heroFade {
  0%, 25%   { opacity: 0; }
  40%, 100% { opacity: .7; }
}
.hero-halo  { transform-origin: 320px 160px; animation: heroHalo 3.4s ease-in-out infinite; }
@keyframes heroHalo {
  0%, 35%  { transform: scale(.6); opacity: 0; }
  60%      { transform: scale(1.05); opacity: 1; }
  100%     { transform: scale(1.15); opacity: 0; }
}
.hero-ring  { transform-origin: 320px 160px; opacity: 0; animation: heroRing 3.4s ease-out infinite; }
.hero-ring-2{ animation-delay: 1.7s; }
@keyframes heroRing {
  0%, 55%  { transform: scale(.4); opacity: 0; }
  65%      { opacity: .5; }
  100%     { transform: scale(2.2); opacity: 0; }
}

@media (max-width: 720px) {
  .connection-scene { padding: 36px 20px; }
}

/* ============================================================
   ۱۰. CALCULATOR ACCURACY WARNING (هشدار بالای صفحه)
   ============================================================ */
.calc-accuracy-warning {
  background: linear-gradient(135deg, #FFF5DA 0%, #FFEFC4 100%);
  border-right: 4px solid #C9A961;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 20px auto;
  max-width: 880px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.calc-accuracy-warning svg {
  width: 22px; height: 22px;
  flex-shrink: 0; margin-top: 2px;
  stroke: #8E7434; stroke-width: 2;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.calc-accuracy-warning .warn-content { flex: 1; }
.calc-accuracy-warning .warn-title {
  font-size: 14px; font-weight: 800; color: #5A4517;
  margin: 0 0 4px;
}
.calc-accuracy-warning .warn-text {
  font-size: 13px; line-height: 1.8; color: #6B5524; margin: 0;
}
.calc-accuracy-warning .warn-text a {
  color: #2D6A6A; font-weight: 700; text-decoration: underline;
}
