/* =========================================================
   Phone numbers on mouse devices: display-only text.
   Every number is a real <a class="tel-link" href="tel:…"> so touch devices can call (and crawlers /
   no-JS visitors see the link). On fine-pointer devices `.tel-link--static` numbers are neutralized:
   this rule blocks clicks while the href is still there, and js/contact-fab.js removes the href and
   sets tabindex="-1" (keyboard activation blocked, text selectable/copyable). Which numbers get
   `.tel-link--static` is the one-line switch PHONES_DISPLAY_ONLY_ON_DESKTOP in includes/functions.php.
   ========================================================= */
/* Visible numbers never break across lines. */
.tel-link bdi { white-space: nowrap; }

@media (hover: hover) and (pointer: fine) {
  .tel-link--static { cursor: default; }
  .tel-link--static[href] { pointer-events: none; }
  .tel-link--static:not([href]) { text-decoration: none; background-image: none; -webkit-user-select: text; user-select: text; }
  .dock-btn.tel-link--static:not([href]):hover { background: transparent; }
  .tel-link--static:not([href]):active { transform: none; filter: none; }
}

/* =========================================================
   Mobile floating contact button (≤900px only)
   Replaces the docked contact strip on mobile; desktop keeps the contact tab under the nav
   (base.css / theme.css), untouched. Behavior: js/contact-fab.js.

   Layout (fixed, bottom-right corner of the viewport):
     above the button  — landline (top), mobile (just above the button): tel: links (.tel-link, see above)
     left of the button — WhatsApp (closer), free consultation (further, opens the lead modal)
   Geometry is in px from the button's bottom-right corner so labels never collide at 375px.
   ========================================================= */
.contact-fab { display: none; }

@media (max-width: 900px) {
  .contact-fab {
    --fab: 58px;
    --act: 48px;
    --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 90;               /* under the header (100), so the open mobile menu's backdrop covers it */
    display: block;
    width: var(--fab);
    height: var(--fab);
  }

  /* ---- Main button: same treatment as the old "تماس" button — petrol with the gold phone icon ---- */
  .contact-fab__toggle {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--fab);
    height: var(--fab);
    padding: 0;
    border: 1px solid rgba(234, 242, 243, 0.14);
    border-radius: 50%;
    background: var(--grad-petrol-soft);
    color: var(--gold-500);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(210, 171, 94, 0.18);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s var(--pop), box-shadow 0.2s ease;
  }
  .contact-fab__toggle:active { transform: scale(0.94); }
  .contact-fab__toggle:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 3px; }
  .contact-fab__toggle svg { grid-area: 1 / 1; transition: opacity 0.18s ease, transform 0.22s var(--pop); }
  .contact-fab__icon-close { opacity: 0; transform: rotate(-90deg) scale(0.6); color: var(--text-on-dark); }
  .contact-fab.is-open .contact-fab__icon-open { opacity: 0; transform: rotate(90deg) scale(0.6); }
  .contact-fab.is-open .contact-fab__icon-close { opacity: 1; transform: none; }
  .contact-fab.is-open .contact-fab__toggle { box-shadow: var(--shadow-lg), 0 0 0 6px rgba(210, 171, 94, 0.22); }

  /* ---- Action buttons ---- */
  .fab-action {
    --dx: 0px;
    --dy: 0px;
    --in-delay: 0ms;
    --out-delay: 0ms;
    position: absolute;
    display: grid;
    place-items: center;
    width: var(--act);
    height: var(--act);
    border-radius: 50%;
    background: var(--petrol-700);
    color: #FFFFFF;
    box-shadow: var(--shadow-md);
    -webkit-tap-highlight-color: transparent;
    /* Collapsed: tucked into the main button, invisible and not focusable/clickable. */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    transition:
      transform 0.15s ease-in var(--out-delay),
      opacity 0.15s ease-in var(--out-delay),
      visibility 0s linear calc(0.15s + var(--out-delay));
  }
  .contact-fab.is-open .fab-action {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition:
      transform 0.2s var(--pop) var(--in-delay),
      opacity 0.16s ease var(--in-delay),
      visibility 0s linear var(--in-delay);
  }
  .fab-action:active { filter: brightness(1.12); }
  .fab-action:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }

  /* Positions + pop-in order (nearest first) and reverse order on close. */
  .fab-action--mobile   { right: 5px;  bottom: 92px;  --dy: 92px;  --in-delay: 0ms;   --out-delay: 120ms; }
  .fab-action--wa       { right: 74px; bottom: 5px;   --dx: 69px;  --in-delay: 40ms;  --out-delay: 80ms; }
  .fab-action--landline { right: 5px;  bottom: 156px; --dy: 156px; --in-delay: 80ms;  --out-delay: 40ms; }
  .fab-action--consult  { right: 150px; bottom: 5px;  --dx: 145px; --in-delay: 120ms; --out-delay: 0ms; }

  .fab-action--wa svg { color: #6FDCA0; }
  .fab-action--consult { background: var(--gold-500); color: var(--text-on-gold); box-shadow: var(--shadow-gold); }

  /* ---- Labels: phone options show their number to the left; side options show a caption above ---- */
  .fab-action__label {
    position: absolute;
    display: grid;
    gap: 0;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    background: rgba(7, 20, 26, 0.9);
    color: var(--text-on-dark);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
    text-align: center;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
  }
  .fab-action__label [dir="ltr"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  /* Phone options: number-only pill (no caption), part of the same link as the round button —
     tapping the pill calls too. The open state re-enables hit-testing on the pill. */
  .fab-action--landline .fab-action__label,
  .fab-action--mobile .fab-action__label {
    right: calc(100% + 8px);
    top: 50%;
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 0.85rem;
    border-radius: 999px;
    font-size: 0.875rem;
    transform: translateY(-50%);
  }
  .contact-fab.is-open .fab-action--landline .fab-action__label,
  .contact-fab.is-open .fab-action--mobile .fab-action__label { pointer-events: auto; }
  .fab-action--wa .fab-action__label,
  .fab-action--consult .fab-action__label { bottom: calc(100% + 8px); right: 50%; transform: translateX(50%); }

  /* Keep the last footer line clear of the button. */
  .footer-bottom { padding-bottom: calc(var(--space-2) + 72px); }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .fab-action,
  .contact-fab.is-open .fab-action { transform: none; transition: opacity 0.12s linear, visibility 0s linear 0.12s; }
  .contact-fab.is-open .fab-action { transition: opacity 0.12s linear; }
  .contact-fab__toggle, .contact-fab__toggle svg { transition: opacity 0.12s linear; transform: none !important; }
}
