.fold-card {
  padding: clamp(1rem, 3vw, 2rem);
  margin-block: 1.75rem;
}

.fold-widget {
  --paper: #ece0c4;
  --paper-dim: #cdbd93;
  --ink: #241b10;
  --accent: #b8862c;
  --bad: #a83f2b;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.fold-stage-outer {
  width: min(100%, 32rem);
  margin-inline: auto;
  perspective: 62rem;
}

.fold-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.fold-3d {
  position: absolute;
  inset: 0;
  transform: rotateX(50deg);
  transform-style: preserve-3d;
}

.hinge {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--boxw, 100px);
  height: var(--boxh, 60px);
  transform-origin: var(--ox, 50px) var(--oy, 0px);
  transform-style: preserve-3d;
  will-change: transform;
}

.wedge-face {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, var(--paper), var(--paper-dim));
  transition: filter .05s linear;
}

.wedge-face[data-i="0"] { --tint: 0deg; }

.dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.dot--target {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(184, 134, 44, .22);
}
.dot--free {
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(36, 27, 16, .18);
}

.fold-tick {
  position: absolute;
  width: 2px;
  height: 14px;
  background: var(--accent);
  transform: translate(-50%, -50%);
  z-index: 3;
}
.fold-tick span {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font: 600 .65rem/1 var(--mz-font-mono, monospace);
  color: var(--accent);
  white-space: nowrap;
  margin-top: 2px;
}

.fold-handle {
  position: absolute;
  z-index: 4;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  cursor: grab;
  touch-action: none;
  padding: 0;
}
.fold-handle:hover { filter: brightness(1.12); }
.fold-handle:active { cursor: grabbing; }
.fold-handle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.fold-readout { margin-top: .25rem; }

.fold-control--wide { flex: 1 1 220px; }

.fold-hint { margin-top: -.25rem; }

@media (max-width: 640px) {
  .fold-stage-outer { width: min(100%, 20rem); perspective: 46rem; }
  .fold-handle { width: 30px; height: 30px; margin: -15px 0 0 -15px; }
}

@media (prefers-reduced-motion: reduce) {
  .wedge-face { transition: none; }
}
