/*
 * CNC Floating Contact Bar - front end styles.
 *
 * Carried over from the Cloudflare fleet template (jedibuilders.co.nz, assets/jedi.css) so a
 * WordPress site and a static site in the fleet look identical. Colours ride on the --fb-*
 * custom properties, which PHP sets inline on the container; the values below are the defaults
 * when nothing has been configured.
 *
 * Everything is scoped under .cnc-floatbar / .cnc-phonepop. The rules a theme is most likely to
 * fight over - anchors and buttons - are written as element+class so they win on specificity
 * rather than on !important.
 */

.cnc-floatbar {
  --fb-bg: #1a1d21;
  --fb-icon: #ffffff;
  --fb-hover-bg: #ffffff;
  --fb-hover-icon: #1a1d21;
  --fb-size: 52px;
  --fb-gap: 10px;
  --fb-ease: cubic-bezier(.22, 1, .36, 1);

  position: fixed;
  right: clamp(.85rem, 2vw, 1.5rem);
  bottom: clamp(.85rem, 2vw, 1.5rem);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--fb-gap);
  margin: 0;
  padding: 0;
  line-height: 1;
}

.cnc-floatbar,
.cnc-floatbar *,
.cnc-phonepop,
.cnc-phonepop * { box-sizing: border-box; }

.cnc-floatbar__list {
  display: flex;
  flex-direction: column;
  gap: var(--fb-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cnc-floatbar a.cnc-floatbar__btn,
.cnc-floatbar button.cnc-floatbar__toggle,
.cnc-floatbar span.cnc-floatbar__btn,
.cnc-floatbar span.cnc-floatbar__toggle {
  -webkit-appearance: none;
  appearance: none;
  width: var(--fb-size);
  height: var(--fb-size);
  min-width: var(--fb-size);          /* themes that force a min-width on buttons */
  min-height: var(--fb-size);
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--fb-bg);
  color: var(--fb-icon);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transition: background .25s var(--fb-ease), color .25s var(--fb-ease), transform .25s var(--fb-ease);
}

.cnc-floatbar a.cnc-floatbar__btn:hover,
.cnc-floatbar a.cnc-floatbar__btn:focus-visible,
.cnc-floatbar button.cnc-floatbar__toggle:hover,
.cnc-floatbar button.cnc-floatbar__toggle:focus-visible {
  background: var(--fb-hover-bg);
  color: var(--fb-hover-icon);
  transform: scale(1.08);
  text-decoration: none;
}

.cnc-floatbar svg { display: block; width: 21px; height: 21px; }

/* Collapsed. Items stay in the DOM but out of the tab order: `visibility` rather than `display`
   so the transition can run, and so nothing hidden is focusable.
   Gated on .cnc-js - without JavaScript the toggle cannot fire, so a visitor with scripts off
   (and any crawler) gets the whole stack rather than an empty bar. */
html.cnc-js .cnc-floatbar a.cnc-floatbar__btn,
html.cnc-js .cnc-floatbar span.cnc-floatbar__btn {
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.8);
  pointer-events: none;
  /* Stagger: --i counts DOWN from the top item, so opening cascades from the toggle upward. */
  transition: opacity .28s var(--fb-ease), transform .28s var(--fb-ease), visibility .28s,
              background .25s var(--fb-ease), color .25s var(--fb-ease);
  transition-delay: calc(var(--i, 1) * 35ms);
}

html.cnc-js .cnc-floatbar[data-open] a.cnc-floatbar__btn,
html.cnc-js .cnc-floatbar[data-open] span.cnc-floatbar__btn {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

/* Restated at higher specificity than the open state above, which would otherwise reset the
   hover scale back to `none`. */
html.cnc-js .cnc-floatbar[data-open] a.cnc-floatbar__btn:hover,
html.cnc-js .cnc-floatbar[data-open] a.cnc-floatbar__btn:focus-visible {
  transform: scale(1.08);
}

.cnc-floatbar .cnc-floatbar__toggle svg { transition: transform .3s var(--fb-ease); }
.cnc-floatbar[data-open] .cnc-floatbar__toggle svg { transform: rotate(180deg); }

/* No JavaScript: the stack is already open, so the toggle has nothing to do. */
html:not(.cnc-js) .cnc-floatbar__toggle { display: none; }

@media (max-width: 560px) {
  .cnc-floatbar { --fb-size: 46px; --fb-gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html.cnc-js .cnc-floatbar a.cnc-floatbar__btn,
  html.cnc-js .cnc-floatbar span.cnc-floatbar__btn { transition-delay: 0ms; }
}

/* ---------- phone popup ----------
   Shown on tablet and desktop, where a tel: link has nowhere useful to go. On a handset the
   click is never intercepted, so this never appears there. The panel wears the same two colours
   as the icons, which keeps it legible whatever the client picks. */
.cnc-phonepop {
  --fb-bg: #1a1d21;
  --fb-icon: #ffffff;
  --fb-ease: cubic-bezier(.22, 1, .36, 1);

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 7, 9, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.cnc-phonepop[data-open] { display: flex; animation: cnc-phonepop-in .2s var(--fb-ease); }
@keyframes cnc-phonepop-in { from { opacity: 0; } to { opacity: 1; } }

.cnc-phonepop__panel {
  position: relative;
  background: var(--fb-bg);
  color: var(--fb-icon);
  border-radius: 10px;
  padding: 2.4rem 3rem 2.1rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  max-width: min(92vw, 26rem);
}

.cnc-phonepop .cnc-phonepop__label {
  margin: 0 0 .3rem;
  padding: 0;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: inherit;
  opacity: .62;
}

.cnc-phonepop a.cnc-phonepop__num {
  display: inline-block;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
  color: var(--fb-icon);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .2s var(--fb-ease);
}
.cnc-phonepop a.cnc-phonepop__num:hover { opacity: .78; text-decoration: none; }

.cnc-phonepop button.cnc-phonepop__close {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: .55rem;
  right: .55rem;
  width: 34px;
  height: 34px;
  min-width: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--fb-icon);
  opacity: .62;
  cursor: pointer;
  transition: background .2s var(--fb-ease), opacity .2s var(--fb-ease);
}
.cnc-phonepop button.cnc-phonepop__close:hover,
.cnc-phonepop button.cnc-phonepop__close:focus-visible {
  background: rgba(127, 127, 127, .25);
  opacity: 1;
}
.cnc-phonepop button.cnc-phonepop__close svg { display: block; width: 17px; height: 17px; }
