/**
 * Bottom-center canvas bar: Front/Back + zoom + fit-to-screen consolidated
 * into one floating pill, matching the mockup. Replaces the old top
 * .canvas-toolbar's side-toggle (left section) and the separate
 * bottom-right .zoom-widget with a single bar -- both real elements are
 * relocated here wholesale (canvas-bar.js) rather than reimplemented, same
 * reparenting approach as every other studio2 module. Positioned
 * absolute within .studio-workspace (already position:relative -- the
 * real .zoom-widget already relied on this), so it stays correctly
 * centered on resize with no JS recalculation needed.
 */

.s2h-canvas-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--s2h-shadow-md);
  z-index: 40;
  pointer-events: auto;
}

.s2h-canvas-bar .side-toggle {
  margin: 0;
}

.s2h-canvas-bar .side-toggle-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.s2h-bar-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  flex-shrink: 0;
}

/* Flatten the real .zoom-widget's own box styling so it blends into the
   bar's pill instead of nesting a second one inside it. */
.s2h-canvas-bar .zoom-widget {
  position: static;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.s2h-canvas-bar .zoom-input {
  width: 50px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: white;
}

.s2h-canvas-bar .zoom-input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.s2h-canvas-bar .zoom-percent {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-left: -4px;
}

.s2h-canvas-bar [data-canvas-action="toggle-mask"].active {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.s2h-canvas-bar #fitToScreenBtn,
.s2h-canvas-bar #rotateTemplateBtn {
  margin: 0;
}

.s2h-canvas-more {
  position: relative;
  flex: 0 0 auto;
}

.s2h-canvas-more-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  list-style: none;
  cursor: pointer;
}

.s2h-canvas-more-trigger::-webkit-details-marker {
  display: none;
}

.s2h-canvas-more-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--s2h-shadow-md);
  z-index: 2;
}

.s2h-canvas-more-panel .icon-btn {
  position: static;
  flex: 0 0 auto;
  margin: 0;
}

/* At full size this bar is ~463px wide (Front/Back with layer counts +
   zoom controls + fit button) -- comfortably fits a desktop canvas, but
   wider than a phone's entire canvas workspace (as narrow as ~340px), so
   it was overflowing off both edges of the screen while still technically
   "visible" (display/opacity/position were all fine -- just off-canvas).
   Compact it at phone widths rather than letting it wrap or clip. */
@media (max-width: 480px) {
  body.studio2-page .s2h-canvas-bar {
    gap: 6px;
    padding: 5px 8px;
    bottom: 10px;
    left: calc(50% + 24px);
    max-width: calc(100vw - 60px);
    box-sizing: border-box;
    z-index: 62;
  }

  .s2h-canvas-bar .side-toggle-option {
    padding: 6px 10px;
  }

  /* The "(0)" layer-count is the least essential part of "Front (0)" --
     drop it first, before touching the icon or label. */
  .s2h-canvas-bar .side-toggle-option .layer-count {
    display: none;
  }

  .s2h-canvas-bar .zoom-widget {
    gap: 4px;
  }

  .s2h-canvas-bar .zoom-widget .icon-btn {
    width: 24px;
    height: 24px;
  }

  .s2h-canvas-bar .zoom-widget .zoom-display {
    min-width: 34px;
    font-size: 0.78rem;
  }

  .s2h-canvas-bar #fitToScreenBtn,
  .s2h-canvas-bar #rotateTemplateBtn {
    width: 30px;
    height: 30px;
  }
}
