/**
 * @file
 * Fix for contextual menu always being open in admin mode.
 * 
 * This CSS ensures that contextual menus can be properly toggled
 * and are not stuck in an always-open state.
 */

/* Ensure contextual links are hidden by default */
.contextual-links {
  display: none !important;
}

/* Only show contextual links when the contextual menu is explicitly open */
.contextual.open .contextual-links {
  display: block !important;
}

/* Ensure the trigger is properly visible when needed */
.contextual .trigger {
  position: relative;
  z-index: 1000;
}

/* Make sure the contextual trigger is clickable */
.contextual .trigger:not(.visually-hidden) {
  display: block;
  cursor: pointer;
}

/* Ensure proper layering and positioning */
.contextual {
  position: absolute;
  z-index: 500;
  top: 6px;
  right: 0;
}

.contextual.open {
  z-index: 501;
}

/* Fix for RTL languages */
[dir="rtl"] .contextual {
  right: auto;
  left: 0;
}

/* Ensure the contextual menu works properly on focus states */
.contextual-region.focus {
  outline: 1px dashed #d6d6d6;
  outline-offset: 1px;
}

/* Additional fixes for admin toolbar interference */
body.user-admin .contextual {
  position: absolute !important;
}

body.user-admin .contextual-links {
  position: relative !important;
  display: none !important;
}

body.user-admin .contextual.open .contextual-links {
  display: block !important;
}

/* Prevent any theme styles from interfering */
.contextual * {
  box-sizing: border-box;
}

/* Force proper reset of any inherited display properties */
.contextual:not(.open) .contextual-links {
  display: none !important;
  visibility: hidden !important;
}

.contextual.open .contextual-links {
  display: block !important;
  visibility: visible !important;
}