/*
 * باکس «دریافت شماره برای مشاوره/رزرو» — consult-card.js. کارتی کوچک و مینیمال، شناور وسط پایین
 * صفحه، هم‌خانواده‌ی کارت اعلان (شیشه‌ی تیره + طلایی بافت‌دار، نه رنگ تخت) با چند جزئیات ظریف:
 * قاب طلاییِ آرام‌چرخان، نشان تلفنِ سونار‌دار و نوار طلایی زیر فیلد که با هر رقم پر می‌شود.
 * پاپ‌آپ نیست: پس‌زمینه‌ی تیره ندارد، اسکرول را قفل نمی‌کند؛ از پایین بالا می‌آید.
 * footer.php این فایل را فقط وقتی لود می‌کند که باکس از پنل روشن باشد.
 */
.consult-card {
  --cc-ease: cubic-bezier(.16, 1, .3, 1);
  --cc-gold-1: #f6dc9c;
  --cc-gold-2: #d9a846;
  --cc-gold-3: #b98a2f;
  --cc-kb: 0px;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1150;
  display: flex;
  justify-content: center;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom) + var(--cc-kb));
  font-family: inherit;
  color: #f4efe3;
  pointer-events: none;
}

.consult-card[hidden] {
  display: none;
}

.consult-card ::selection {
  background: rgba(233, 190, 102, .45);
  color: #fff;
}

/* ---------- قاب طلایی ---------- */
.consult-card__dialog {
  position: relative;
  width: min(380px, 100%);
  padding: 1.5px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(241, 207, 131, .5), rgba(233, 190, 102, .12) 45%, rgba(233, 190, 102, .3));
  box-shadow: 0 28px 60px -22px rgba(0, 0, 0, .75), 0 0 50px -26px rgba(233, 190, 102, .6);
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  transition: transform 1.05s cubic-bezier(.22, 1.12, .36, 1), opacity .45s ease;
  pointer-events: auto;
}

.consult-card.is-open .consult-card__dialog {
  transform: translateY(0);
  opacity: 1;
}

/* هاله‌ی نفس‌کشیدن پشت کارت — فقط opacity، پس روان می‌ماند. */
.consult-card__dialog::before {
  content: "";
  position: absolute;
  inset: -22px;
  z-index: -1;
  border-radius: 40px;
  background: radial-gradient(60% 70% at 50% 100%, rgba(233, 190, 102, .3), transparent 70%);
  opacity: .5;
  filter: blur(14px);
  pointer-events: none;
  animation: consult-breathe 5s ease-in-out infinite;
}

@keyframes consult-breathe {
  0%, 100% { opacity: .35; }
  50% { opacity: .75; }
}

.consult-card__frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.consult-card__frame::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 240%;
  aspect-ratio: 1;
  background: conic-gradient(from 0deg, transparent 0 60%, rgba(241, 207, 131, .05) 64%, var(--cc-gold-1) 82%, var(--cc-gold-3) 90%, transparent 100%);
  transform: translate(-50%, -50%) rotate(0deg);
  animation: consult-spin 9s linear infinite;
}

.consult-card__frame::after {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 100%;
  width: 45%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, #fff6dc, transparent);
  opacity: 0;
}

.consult-card.is-open .consult-card__frame::after {
  animation: consult-streak 1.5s cubic-bezier(.4, 0, .2, 1) .9s 1 both;
}

@keyframes consult-streak {
  0% { transform: translateX(0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateX(-340%); opacity: 0; }
}

@keyframes consult-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.consult-card__panel {
  position: relative;
  overflow: hidden;
  border-radius: 20.5px;
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(233, 190, 102, .18), transparent 62%),
    linear-gradient(160deg, #28261f, #11110e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 -26px 40px -32px rgba(233, 190, 102, .22);
}

/* دانه‌ی ریز فلزی — بافت لمسی، نه رنگ تخت. */
.consult-card__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .6 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .1;
  mix-blend-mode: screen;
  pointer-events: none;
}

.consult-card__content {
  z-index: 1;
}

.consult-card__panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(170px circle at var(--mx, 50%) var(--my, 0%), rgba(246, 220, 156, .13), transparent 70%);
  opacity: 0;
  transition: opacity .45s ease;
  pointer-events: none;
}

.consult-card__panel.is-hot::after {
  opacity: 1;
}

.consult-card__close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #bdb5a2;
  background: rgba(255, 255, 255, .07);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .35s var(--cc-ease);
}

.consult-card__close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.consult-card__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, .14);
  transform: rotate(90deg);
}

/* ---------- محتوا ---------- */
.consult-card__content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 12px;
}

.consult-card__content[hidden] {
  display: none;
}

.consult-card.is-open .consult-card__content > * {
  animation: consult-rise .8s var(--cc-ease) both;
  animation-delay: calc(.25s + var(--n, 0) * 70ms);
}

.consult-card__content > :nth-child(1) { --n: 0; }
.consult-card__content > :nth-child(2) { --n: 1; }
.consult-card__content > :nth-child(3) { --n: 2; }

@keyframes consult-rise {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.consult-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline-end: 30px;
}

.consult-card__head > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.consult-card__badge {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: #2a2418;
  background: linear-gradient(145deg, var(--cc-gold-1), var(--cc-gold-2) 55%, var(--cc-gold-3));
  box-shadow: 0 12px 22px -12px rgba(233, 190, 102, .9), inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -6px 10px -6px rgba(120, 78, 12, .45);
}

.consult-card__badge svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: consult-ring 3.6s ease-in-out 1.4s infinite;
}

.consult-card__badge i {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1.5px solid rgba(241, 207, 131, .7);
  animation: consult-sonar 2.8s ease-out 1.2s infinite;
}

.consult-card__badge i + i {
  animation-delay: 2.2s;
}

@keyframes consult-sonar {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes consult-ring {
  0%, 70%, 100% { transform: rotate(0); }
  74% { transform: rotate(-16deg); }
  80% { transform: rotate(13deg); }
  86% { transform: rotate(-9deg); }
  92% { transform: rotate(5deg); }
}

.consult-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #e9c373;
}

.consult-card__eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  background: linear-gradient(135deg, var(--cc-gold-1), var(--cc-gold-3));
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(246, 220, 156, .8);
}

.consult-card__title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.6;
  color: #fffaf0;
}

.consult-card__title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--cc-gold-1), #e2b350 50%, var(--cc-gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- فرم ---------- */
.consult-card__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.consult-card__row {
  display: flex;
  gap: 8px;
}

.consult-card__field {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  direction: ltr;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: rgba(255, 255, 255, .055);
  transition: border-color .25s ease, background .25s ease, box-shadow .35s ease;
}

.consult-card__field:focus-within {
  border-color: rgba(241, 207, 131, .7);
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 3px rgba(233, 190, 102, .13);
}

.consult-card__field svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #e9c373;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.consult-card__tick {
  display: none;
  stroke-width: 2.4;
}

.consult-card__field.is-valid .consult-card__phone {
  display: none;
}

.consult-card__field.is-valid .consult-card__tick {
  display: block;
  animation: consult-pop .45s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes consult-pop {
  from { transform: scale(.3) rotate(-25deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.consult-card__field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  caret-color: var(--cc-gold-1);
}

.consult-card__field input::placeholder {
  font-weight: 500;
  color: rgba(255, 255, 255, .26);
}

/* نوار طلایی زیر فیلد — با هر رقم پر می‌شود، با ۱۱ رقمِ درست کامل. */
.consult-card__meter {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, .07);
}

.consult-card__meter b {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cc-gold-3), var(--cc-gold-1));
  transition: width .3s var(--cc-ease);
}

/* ۱۱ قطعه‌ی جدا (به‌اندازه‌ی ارقام شماره)، نه یک نوار یکدست. */
.consult-card__meter,
.consult-card__meter b {
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(9.0909% - 2px), transparent calc(9.0909% - 2px) 9.0909%);
  mask: repeating-linear-gradient(90deg, #000 0 calc(9.0909% - 2px), transparent calc(9.0909% - 2px) 9.0909%);
}

.consult-card__field.is-valid {
  border-color: rgba(241, 207, 131, .5);
}

.consult-card__field.is-invalid {
  border-color: rgba(255, 140, 120, .75);
  animation: consult-shake .45s var(--cc-ease);
}

@keyframes consult-shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.consult-card__submit {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid #e2b75e;
  border-radius: 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 800;
  color: #24231f;
  background: linear-gradient(135deg, var(--cc-gold-1), var(--cc-gold-2) 60%, #c9983a);
  box-shadow: 0 10px 20px -12px rgba(217, 168, 70, .85), inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -8px 12px -8px rgba(130, 84, 10, .4);
  cursor: pointer;
  transition: transform .3s var(--cc-ease), filter .2s ease;
}

.consult-card__submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .5) 50%, transparent 70%);
  transform: translateX(120%);
  animation: consult-shine 3.6s ease-in-out 1.8s infinite;
}

@keyframes consult-shine {
  0%, 55% { transform: translateX(120%); }
  100% { transform: translateX(-120%); }
}

.consult-card__submit span,
.consult-card__submit svg {
  position: relative;
  z-index: 1;
}

.consult-card__submit svg {
  width: 24px;
  height: 24px;
  padding: 6px;
  border-radius: 50%;
  background: #24231f;
  fill: none;
  stroke: var(--cc-gold-1);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .3s var(--cc-ease);
}

.consult-card__submit:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.consult-card__submit:hover svg {
  transform: translateX(-4px);
}

.consult-card__submit:active {
  transform: scale(.985);
}

.consult-card__submit:disabled {
  cursor: progress;
  filter: saturate(.75);
}

.consult-card__status {
  min-height: 1.4em;
  font-size: 11px;
  line-height: 1.6;
  color: #8f8878;
  transition: color .2s ease;
}

.consult-card__status.is-error {
  color: #ff9d8a;
}

/* ---------- حالت موفقیت ---------- */
.consult-card__done {
  align-items: center;
  text-align: center;
  padding-block: 22px 20px;
}

.consult-card__done .consult-card__title {
  font-size: 15px;
}

.consult-card__done .consult-card__check {
  display: inline-flex;
  width: 52px;
  height: 52px;
}

.consult-card__check {
  position: relative;
}

.consult-card__check::before,
.consult-card__check::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px solid rgba(246, 220, 156, .6);
  border-radius: 50%;
  opacity: 0;
  animation: consult-ripple 1.6s ease-out .5s 2 both;
}

.consult-card__check::after {
  animation-delay: .9s;
}

@keyframes consult-ripple {
  0% { transform: scale(.9); opacity: .8; }
  100% { transform: scale(1.9); opacity: 0; }
}

.consult-card__check svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--cc-gold-1);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(233, 190, 102, .5));
}

.consult-card__check circle {
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
  animation: consult-draw .8s var(--cc-ease) .1s forwards;
}

.consult-card__check path {
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  animation: consult-draw .5s var(--cc-ease) .6s forwards;
}

@keyframes consult-draw {
  to { stroke-dashoffset: 0; }
}

/* ---------- موبایل: ستونی و فشرده ---------- */
@media (max-width: 520px) {
  .consult-card {
    padding-inline: 10px;
  }

  .consult-card__dialog {
    width: 100%;
  }

  .consult-card__content {
    gap: 9px;
    padding: 16px 14px 12px;
  }

  .consult-card__field {
    gap: 8px;
    padding: 0 10px;
  }

  .consult-card__field input {
    font-size: 16px;
    letter-spacing: .02em;
  }

  .consult-card__submit {
    gap: 7px;
    padding: 0 10px 0 12px;
    font-size: 13px;
  }

  .consult-card__submit svg {
    width: 22px;
    height: 22px;
    padding: 5px;
  }
}

/* ---------- دسترس‌پذیری ---------- */
.consult-card button:focus-visible {
  outline: 2px solid var(--cc-gold-1);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .consult-card__dialog {
    transform: none;
    transition: opacity .2s ease;
  }

  .consult-card__frame::before,
  .consult-card__badge svg,
  .consult-card__badge i,
  .consult-card__submit::after,
  .consult-card__dialog::before,
  .consult-card.is-open .consult-card__frame::after,
  .consult-card__check::before,
  .consult-card__check::after,
  .consult-card.is-open .consult-card__content > * {
    animation: none;
  }

  .consult-card__check circle,
  .consult-card__check path {
    animation: none;
    stroke-dashoffset: 0;
  }
}
