/**
 * Front-end CSS — Desktop floating menu
 *
 * Provides the styles for the sticky anchor menu on the front-end:
 * - Floating appearance and toggle button
 * - Active link highlighting
 * - Accessibility states
 * - Responsive adjustments
 *
 * @package anchorflow-menu
 * @since 1.0.0
 */


/* === MAIN FIXED CONTAINER ON PAGE === */
#menu-ancrage-container {
  position: fixed !important;
  top: 25vh;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: fit-content;
  background: transparent;
  z-index: 9999;
  box-sizing: border-box;
  padding: 0;
  transition: top 0.1s ease, left 0.1s ease;
}


/* === MENU INNER CONTENT === */
#menu-ancrage-content {
  background: #ffffff;
  padding: 0;
  border-radius: 8px;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
  max-width: 230px;
  min-width: 170px;
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* === WHEN MENU IS HIDDEN === */
#menu-ancrage-content.hidden {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

/* === TOGGLE BUTTON (SHOW / HIDE) === */
#menu-ancrage-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 2px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #1f5daa;
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: background-color 0.3s ease;
}

/* === Specific adjustment for toggle button SVGs === */
#menu-ancrage-toggle-btn svg {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}

/* === Override for anchor.svg (default icon more visible) === */
#menu-ancrage-toggle-btn svg.anchor-icon {
  width: 100%;
  height: 100%;
}

/* === TOOLTIP BOUTON TOGGLE === */
#menu-ancrage-toggle-btn:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 30%;
  background: #000000;
  color: #ffffff;
  padding: 3px 8px;
  /* reduces the visual height */
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  margin-right: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  opacity: 1;
  visibility: visible;
  height: auto;
  max-height: none;
  line-height: normal;
}

#menu-ancrage-toggle-btn::after {
  opacity: 0;
  visibility: hidden;
  transition: none;
  content: '';
  position: absolute;
}

/* Default state: arrow points DOWN (menu is visible) */
#menu-ancrage-toggle-btn .toggle-icon--arrow {
  transform: rotate(180deg);
  transition: transform .2s ease;
}

/* Collapsed state: arrow points UP (menu is hidden) */
#menu-ancrage-toggle-btn.is-collapsed .toggle-icon--arrow {
  transform: rotate(0deg);
}

/* Accessibility: disable the animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  #menu-ancrage-toggle-btn .toggle-icon--arrow {
    transition: none;
  }
}

/* === WRAPPER DRAG === */
.menu-ancrage-drag-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 46px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}


/* === DRAG BUTTON === */
#menu-ancrage-drag-btn {
  position: relative;
  width: 32px;
  height: 28px;
  padding: 2px 4px;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #666;
  border-radius: 2px;
  background: transparent;
  border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

#menu-ancrage-drag-btn:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

#menu-ancrage-drag-btn::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: -8px;
  right: -8px;
  z-index: 9999;
}

#menu-ancrage-drag-btn:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 100%;
  background: #000;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  margin-right: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  opacity: 1;
  visibility: visible;
}

#menu-ancrage-drag-btn::after {
  opacity: 0;
  visibility: hidden;
  transition: none;
  content: '';
  position: absolute;
}

#menu-ancrage-drag-btn.dragging::after {
  display: none !important;
}

#menu-ancrage-drag-btn:active,
#menu-ancrage-drag-btn:focus {
  cursor: grabbing;
  outline: none;
}

#menu-ancrage-drag-btn>svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* === MENU TITLE === */
#menu-ancrage-title {
  margin: 0;
  padding: 6px 15px;
  font-size: 14px;
  font-weight: bold;
  color: #000000;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: left;
  line-height: 24px;
  /* aligns perfectly with drag button */
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#menu-ancrage-title:focus {
  outline: 2px solid #ff7f50;
  outline-offset: 3px;
  box-shadow: 0 0 5px #ff7f50;
}


/* === LINKS LIST === */
#menu-ancrage-content .menu-ancrage-list {
  list-style: none;
  margin: 0;
  padding: 10px 10px 15px 15px;
}

.menu-ancrage-list li {
  margin-bottom: 4px;
}

/* === LINKS */
#menu-ancrage-content a {
  font-size: 12px;
  text-decoration: none;
  color: #333;
  position: relative;
  padding: 4px 10px 4px 20px;
  display: block;
  transition: color 0.3s ease;
  cursor: pointer;
  line-height: 1;
  max-width: 100%;
  /* truncate if too long */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


#menu-ancrage-content a.active {
  color: #1F5DAA;
  font-weight: bold;
}

#menu-ancrage-content a:hover {
  color: #3C76C1;
}


/* Invisible bullet to avoid layout shift */
#menu-ancrage-content a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: transparent;
}

#menu-ancrage-content a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background-color: #1F5DAA;
  border-radius: 50%;
}

/* === ACCESSIBILITY: visible outline when using keyboard === */
#menu-ancrage-content a:focus-visible,
#menu-ancrage-toggle-btn:focus-visible {
  outline: 2px solid #ff7f50;
  outline-offset: 3px;
  box-shadow: 0 0 5px #ff7f50;
}

#menu-ancrage-content a:focus:not(:focus-visible),
#menu-ancrage-toggle-btn:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* === HIDE desktop menu below 1024px ===
   -> max-width: 1024px included to activate mobile bar on tablets ≤1024px */
@media (max-width: 1024px) {
  #menu-ancrage-container {
    display: none !important;
  }
}

/* === TOOLTIP: activated on click only for touch devices === */
@media (hover: none) and (pointer: coarse) {

  #menu-ancrage-toggle-btn:hover::after,
  #menu-ancrage-drag-btn:hover::after,
  #menu-ancrage-toggle-btn:hover::before,
  #menu-ancrage-drag-btn:hover::before {
    opacity: 0 !important;
    visibility: hidden !important;
  }

  #menu-ancrage-toggle-btn.show-tip::after,
  #menu-ancrage-toggle-btn.show-tip::before,
  #menu-ancrage-drag-btn.show-tip::after,
  #menu-ancrage-drag-btn.show-tip::before {
    opacity: 1 !important;
    visibility: visible !important;
  }
}