/* Reusable wireframe-mesh canvas defaults. Override per-page as needed. */

.wireframe-mesh {
  display: block;
  position: relative;
  width: 100%;
  /* Pages that don't set an explicit height get a sensible default. The
     container is the sizing authority — set width/height in your page CSS to
     control the canvas dimensions. */
  aspect-ratio: 1 / 1;
}

.wireframe-mesh canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'><circle cx='14' cy='14' r='9' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-opacity='0.85'/><circle cx='14' cy='14' r='1.5' fill='%23ffffff' fill-opacity='0.85'/></svg>") 14 14, pointer;
}

.wireframe-mesh canvas.is-active {
  cursor: grab;
}

.wireframe-mesh canvas.is-active.is-grabbing {
  cursor: grabbing;
}

.wireframe-mesh-zoom-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  color: #f4efe2;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  transition: opacity 280ms ease;
  z-index: 1;
}

.wireframe-mesh-zoom-hint svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

@keyframes wireframe-mesh-zoom-pulse {
  0%   { opacity: 0; }
  35%  { opacity: 0.32; }
  100% { opacity: 0.16; }
}

.wireframe-mesh:has(canvas.is-active) .wireframe-mesh-zoom-hint {
  animation: wireframe-mesh-zoom-pulse 1.1s ease-in-out 1 forwards;
}

@media (prefers-reduced-motion: reduce) {
  .wireframe-mesh:has(canvas.is-active) .wireframe-mesh-zoom-hint {
    animation: none;
    opacity: 0.16;
  }
}

.wireframe-mesh-download {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.4);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 1;
}

.wireframe-mesh:hover .wireframe-mesh-download,
.wireframe-mesh-download:focus-visible {
  opacity: 1;
}

.wireframe-mesh-compare {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.4);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 200ms ease;
  z-index: 2;
}

.wireframe-mesh:hover .wireframe-mesh-compare,
.wireframe-mesh-compare:focus-visible {
  opacity: 1;
}

/* ─── Tuner overlay (opt-in via ?wf-edit=1 or data-wf-edit) ─────────────── */

.wireframe-mesh-gear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.4);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 200ms ease;
  z-index: 3;
}

.wireframe-mesh:hover .wireframe-mesh-gear,
.wireframe-mesh-gear:focus-visible,
.wireframe-mesh-gear[aria-expanded="true"] {
  opacity: 1;
}

.wireframe-mesh-tuner {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(13, 11, 14, 0.96);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.25);
  border-radius: 4px;
  padding: 10px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.wireframe-mesh-tuner[hidden] {
  display: none;
}

.wireframe-mesh-tuner fieldset {
  border: 1px solid rgba(244, 239, 226, 0.18);
  border-radius: 3px;
  margin: 0 0 8px 0;
  padding: 6px 8px 8px;
}

.wireframe-mesh-tuner legend {
  padding: 0 4px;
  color: rgba(244, 239, 226, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wfm-tuner-row {
  display: grid;
  grid-template-columns: 70px 1fr 40px;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.wfm-tuner-row--check {
  grid-template-columns: 1fr;
}

.wfm-tuner-row label {
  color: rgba(244, 239, 226, 0.8);
}

.wfm-tuner-row input[type="range"] {
  width: 100%;
  margin: 0;
}

.wfm-tuner-row select,
.wfm-tuner-row--text input[type="text"] {
  grid-column: 2 / span 2;
  background: rgba(0, 0, 0, 0.4);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.3);
  font: inherit;
  padding: 2px 4px;
  width: 100%;
  box-sizing: border-box;
}

.wfm-tuner-row output {
  text-align: right;
  color: rgba(244, 239, 226, 0.6);
  font-variant-numeric: tabular-nums;
}

.wfm-tuner-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.wfm-tuner-actions button {
  flex: 1;
  background: rgba(244, 239, 226, 0.1);
  color: #f4efe2;
  border: 1px solid rgba(244, 239, 226, 0.3);
  border-radius: 2px;
  padding: 4px 6px;
  font: inherit;
  cursor: pointer;
}

.wfm-tuner-actions button:hover {
  background: rgba(244, 239, 226, 0.18);
}

.wfm-tuner-output {
  margin: 8px 0 0;
  padding: 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(244, 239, 226, 0.2);
  border-radius: 2px;
  white-space: pre;
  overflow-x: auto;
  color: rgba(244, 239, 226, 0.85);
  font-size: 10px;
  user-select: text;
}
