/* controls.css
   Canvas control buttons and the mobile 3-dot menu. */

/* Canvas Controls Overlay */
.canvas-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: row;
  gap: 10px;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: auto;
  /* Expand hover area for easier triggering */
  padding: 40px;
  margin: -40px;
  /* Prevent touch scrolling on controls */
  touch-action: none;
  overscroll-behavior: contain;
}

/* Desktop: hide controls when inactive */
.canvas-controls.hidden {
  opacity: 0;
}

/* Keep pointer events active even when hidden for hover detection */
.canvas-controls.hidden .control-btn,
.canvas-controls.hidden .controls-menu {
  pointer-events: none;
}

/* Mobile menu toggle button - hidden on desktop, shown on mobile */
.mobile-menu-btn {
  display: none !important;
}

body.is-mobile .mobile-menu-btn {
  display: flex !important;
}

/* Controls menu container - all buttons visible on desktop */
.controls-menu {
  display: flex;
  gap: 10px;
}

.control-btn {
  background: rgba(11, 16, 23, 0.85);
  border: 1px solid rgba(56, 255, 199, 0.3);
  border-radius: 8px;
  padding: 12px;
  color: var(--ax-accent);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
}

.control-btn:hover {
  background: rgba(3, 79, 132, 0.95);
  border-color: var(--ax-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 255, 199, 0.25);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn:focus-visible {
  outline: 2px solid var(--ax-accent);
  outline-offset: 2px;
}

.control-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Hide text labels - icon-only buttons */
.control-btn .btn-text {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  background: rgba(11, 16, 23, 0.95);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  margin-bottom: 0;
  transition: opacity 0.2s ease;
}

/* Show text on feedback */
.control-btn.show-feedback .btn-text {
  opacity: 1;
}

/* Hide fullscreen button if fullscreen API not supported */
body:not(.supports-fullscreen) #fullscreen-btn {
  display: none;
}

/* Mobile-specific adjustments - completely override desktop positioning */
body.is-mobile .canvas-controls {
  position: fixed !important;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px) !important;
  right: calc(env(safe-area-inset-right, 0px) + 4px) !important;
  top: auto !important;
  left: auto !important;
  flex-direction: column-reverse !important;
  align-items: flex-end !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  /* Remove expanded hover area on mobile */
  padding: 0 !important;
  margin: 0 !important;
  transform: none !important;
}

/* Hide controls menu by default on mobile - show 3 buttons only when menu open */
body.is-mobile .controls-menu {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

/* Show controls menu when open on mobile */
body.is-mobile .canvas-controls.menu-open .controls-menu {
  display: flex;
}

/* Mobile: Never hide the controls container (3-dot button always visible) */
body.is-mobile .canvas-controls.hidden {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Mobile: Ensure buttons themselves don't add extra spacing */
body.is-mobile .control-btn {
  margin: 0 !important;
  /* Reduce size by 10% */
  min-width: 40px;
  min-height: 40px;
  width: 40px;
  height: 40px;
  padding: 10px;
  /* Add more transparency (slightly more opaque than before) */
  background: rgba(11, 16, 23, 0.5);
}

/* Mobile: Reduce icon size by 10% */
body.is-mobile .control-btn svg {
  width: 18px;
  height: 18px;
}

/* Prevent page scroll when interacting with mobile menu */
body.is-mobile.menu-open {
  overflow: hidden;
}

/* Hide controls when landscape prompt is showing */
body.show-landscape-prompt .canvas-controls {
  display: none !important;
}

/* Hide controls when loading or error is showing */
#loading-overlay:not(.hidden) ~ .canvas-controls,
#error-message.show ~ .canvas-controls {
  display: none;
}

/* Cookie settings control.
   OneTrust banners are geo-gated (typically EU/UK/CA), and the SDK is not
   loaded at all on localhost, so the preference centre frequently does not
   exist. The button stays hidden until consent.js confirms the SDK actually
   loaded — otherwise it would be a visible control that silently does nothing
   for most visitors. On mobile the parent .controls-menu still governs
   open/closed, so this only decides whether the button participates at all.

   The banner itself needs no z-index handling here: OneTrust renders at its
   own very high stacking level, and fullscreen targets documentElement, so
   the banner stays visible inside fullscreen too. */
#cookie-btn {
  display: none;
}

body.has-consent-manager #cookie-btn {
  display: flex;
}
