.codeblock {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  cursor: zoom-in; /* Default cursor for zoomable images */
  transition: transform 0.3s ease;
  transform-origin: center;
  touch-action: none; /* Prevents default touch behaviors */
  display: block; /* Ensure proper display in MDBook */
  margin: 0 auto; /* Center images by default */
}

.codeblock-container {
  position: relative;
  overflow: visible; /* Allow image to overflow slightly */
  margin: 0.5em auto; /* Keep margin on container instead of image */
  max-width: 100%;
  line-height: 0; /* Remove extra space below image */
  transition: height 0.3s ease; /* Smooth transition for height changes */
  padding: 2px 0; /* Add small vertical padding to prevent cropping */
  text-align: center; /* Center containers by default */
}

.codeblock.zoomed {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  cursor: grab;
  transform-origin: center;
  transition: none; /* Disable transition for smooth panning */
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* When an image is zoomed, ensure the container adjusts accordingly */
.codeblock-container:has(.zoomed) {
  overflow: hidden; /* Hide overflow only when zoomed */
  height: auto !important; /* Override any inline height */
  min-height: 600px !important; /* Provide enough space for zoomed content */
}

/* .codeblock:hover {
  transform: scale(1.1);
} */

/* Prevent zooming for simple code blocks and align left */
.codeblock.no-zoom {
    cursor: default !important;
    pointer-events: none !important;
    transform: none !important;
    transition: none !important;
    margin: 0; /* Remove auto margins to allow left alignment */
}

.codeblock-container:has(.no-zoom) {
    overflow: hidden;
    pointer-events: none;
    text-align: left; /* Left align container for non-zoomable images */
    margin-left: 0; /* Remove left margin for left alignment */
}

