// padding: nextCell.style.padding,
// borderBottom: nextCell.style.borderBottom,
// visibility: nextCell.style.visibility
// });
//
// cells.push(nextCell);
// nextCell = nextCell.nextElementSibling;
// }
// if (cells.length === 0) {
// alert("No valid cells found!");
// return;
// }
//
// // Hide all other cells except the selected ones
// document.querySelectorAll(".observablehq").forEach(cell => {
// if (!cells.includes(cell) && cell !== currentCell) {
// cell.style.visibility = "hidden"; // Hide but keep layout intact
// }
// });
// // Get computed background color
// let bgColor = window.getComputedStyle(fullScreenWrapper).backgroundColor;
//
// // Function to determine if color is dark
// function isDark(color) {
// let rgb = color.match(/\d+/g);
// if (!rgb) return false;
// let [r, g, b] = rgb.map(Number);
// let brightness = (r * 299 + g * 587 + b * 114) / 1000; // Luminance formula
// return brightness < 128;
// }
//
// // Determine text color based on background
// let textColor = isDark(bgColor) ? "white" : "black";
//
// // Move selected cells into the fullscreen wrapper
// cells.forEach(cell => fullScreenWrapper.appendChild(cell));
//
// // Apply fullscreen wrapper styles
// fullScreenWrapper.style.position = "fixed";
// fullScreenWrapper.style.top = "0";
// fullScreenWrapper.style.left = "0";
// fullScreenWrapper.style.width = "100vw";
// fullScreenWrapper.style.height = "100vh";
// fullScreenWrapper.style.background = controls.fullScreenBackgroundColor;
// fullScreenWrapper.style.overflow = "hidden"; // Prevents extra scrolling
// fullScreenWrapper.style.padding = "0";
// fullScreenWrapper.style.zIndex = "9999";
// document.body.appendChild(fullScreenWrapper);
//
// // Function to dynamically adjust cell heights while preserving ratios
// function adjustCellHeights() {
// let availableHeight = window.innerHeight; // Total screen height
// cells.forEach((cell, index) => {
// let heightRatio = originalHeights[index] / totalOriginalHeight*1.1; // Preserve proportion
// cell.style.position = "relative";
// cell.style.width = "100%";
// cell.style.height = `${availableHeight * heightRatio}px`; // Scale based on ratio
// cell.style.background = "black";
// cell.style.overflow = "auto";
// cell.style.padding = "0px";
//
// });
// }
//
// // Adjust heights on load and when window resizes
// adjustCellHeights();
// window.addEventListener("resize", adjustCellHeights);
//
// // Enter fullscreen mode on the wrapper
// fullScreenWrapper.requestFullscreen
// ? fullScreenWrapper.requestFullscreen()
// : fullScreenWrapper.webkitRequestFullscreen
// ? fullScreenWrapper.webkitRequestFullscreen()
// : (() => { throw new Error("Fullscreen API not supported"); })();
//
// // Handle exit fullscreen: Restore everything properly
// document.addEventListener("fullscreenchange", () => {
// if (!document.fullscreenElement) {
// // Restore visibility of all cells
// document.querySelectorAll(".observablehq").forEach(cell => {
// cell.style.visibility = "";
// });
//
// // Restore original styles for each cell
// cells.forEach(cell => {
// const originalStyle = originalStyles.get(cell);
// if (originalStyle) {
// Object.assign(cell.style, originalStyle); // Apply saved styles
// }
// });
//
// // Move cells back to their original place
// cells.forEach(cell => {
// currentCell.parentElement.insertBefore(cell, nextCell);
// });
//
// // Cleanup
// fullScreenWrapper.remove();
// window.removeEventListener("resize", adjustCellHeights);
// }
// });
//}}>Fullscreen</button>`;