/* ==========================================================================
   Changan Elements – Floating Buttons
   ========================================================================== */

.changan-fsb {
  --fsb-size: 56px;
  --fsb-expanded: 220px;
  --fsb-radius: 6px;
  --fsb-offset: 0px;
  --fsb-icon-gap: 8px;

  position: fixed;
  /* Deliberately kept well below the Hamburger Nav drawer (z-index 99999)
     and its overlay (99998), so this widget never sits on top of the
     open nav menu. Confirmed on-site: 98 is the sweet spot. */
  z-index: 98;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ── Screen edge ───────────────────────────────────────────────────────── */
/* The container is anchored by ONE edge only (right OR left). Because the
   opposite edge is left free ("auto"), growing a button's width pushes
   outward away from the anchored edge instead of off-screen. */
.changan-fsb-side-right .changan-fsb {
  right: 0;
  left: auto;
}

.changan-fsb-side-left .changan-fsb {
  left: 0;
  right: auto;
}

/* ── Vertical position ────────────────────────────────────────────────── */
.changan-fsb-valign-top .changan-fsb {
  top: var(--fsb-offset);
}

.changan-fsb-valign-middle .changan-fsb {
  top: calc(50% + var(--fsb-offset));
  transform: translateY(-50%);
}

.changan-fsb-valign-bottom .changan-fsb {
  top: auto;
  bottom: var(--fsb-offset);
}

/* Buttons hug whichever edge the widget is anchored to, independent of
   each other's current width. Without this, a button growing wider on
   hover briefly widens the shared flex column, and — since flex items
   with an explicit width default to flex-start alignment, not stretch —
   the OTHER (unhovered) buttons would drift toward the left instead of
   staying pinned to the right edge. */
.changan-fsb-side-right .changan-fsb {
  align-items: flex-end;
}

.changan-fsb-side-left .changan-fsb {
  align-items: flex-start;
}

/* ── Button ───────────────────────────────────────────────────────────── */
/* Single `width` transition only (collapsed → expanded). Do NOT pair this
   with a separate `max-width` at the same value — an explicit `width`
   below `max-width` always wins, which silently cancels the animation. */
/* Icon always renders first (left), label second (right) — for BOTH
   sides. Only the anchored edge changes (via align-items above and
   border-radius below); the internal icon/label order never flips. */
.changan-fsb__btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--fsb-icon-gap);
  width: var(--fsb-size);
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
  background-color: var(--fsb-bg, #3c4650);
  transition: width 0.35s ease;
}

.changan-fsb__btn:hover,
.changan-fsb__btn:focus-visible {
  width: var(--fsb-expanded);
}

.changan-fsb__btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -3px;
}

/* Right edge: button is flush right, so only its left (open) side rounds. */
.changan-fsb-side-right .changan-fsb__btn {
  border-radius: var(--fsb-radius) 0 0 var(--fsb-radius);
}

/* Left edge: button is flush left, so only its right (open) side rounds. */
.changan-fsb-side-left .changan-fsb__btn {
  border-radius: 0 var(--fsb-radius) var(--fsb-radius) 0;
}

/* ── Icon ─────────────────────────────────────────────────────────────── */
/* Fixed square regardless of Button Padding — padding adds extra room
   around this box rather than shrinking it, so the icon never gets
   squeezed. border-radius/overflow default to a plain square (0) and
   are only activated by the Icon Border Radius control. */
.changan-fsb__icon {
  flex: 0 0 var(--fsb-size);
  width: var(--fsb-size);
  height: var(--fsb-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}

.changan-fsb__icon i,
.changan-fsb__icon svg {
  display: block;
  font-size: 22px;
  width: 22px;
  height: 22px;
}

/* ── Text ─────────────────────────────────────────────────────────────── */
/* Only trailing-edge padding here — the space between the icon and the
   text itself is the button's own `gap` (Icon/Text Gap control), not
   this padding, so the two stay independently adjustable. */
.changan-fsb__text {
  padding-right: 16px;
  opacity: 0;
  transition: opacity 0.2s ease 0.08s;
}

.changan-fsb__btn:hover .changan-fsb__text,
.changan-fsb__btn:focus-visible .changan-fsb__text {
  opacity: 1;
}

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .changan-fsb__btn,
  .changan-fsb__text {
    transition: none !important;
  }
}
