/* Tasten-Fidget configurator (partials/keyfidget.php + assets/js/keyfidget.js).
   Uses the Candy Workshop tokens from shop.css. */

/* The 3D stage stays in view while the visitor works through the form */
.kf-visual { position: relative; }
@media (min-width: 821px) { .kf-visual { position: sticky; top: 92px; align-self: start; } }
.kf-stage {
  position: relative; aspect-ratio: 1; border: var(--outline); border-radius: var(--radius); box-shadow: var(--pop-lg);
  background: radial-gradient(circle at 50% 38%, #fff, var(--tile, var(--tile-sky)) 72%); overflow: hidden;
}
.kf-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; opacity: 0; transition: opacity .4s; }
.kf-stage canvas:active { cursor: grabbing; }
.kf-stage-photo { width: 100%; height: 100%; object-fit: cover; transition: opacity .4s; }
.kf-stage.is-3d canvas { opacity: 1; }
.kf-stage.is-3d .kf-stage-photo { opacity: 0; }
.kf-stage-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100% - 24px); text-align: center;
  font-size: .8rem; font-weight: 600; color: var(--ink-2); background: rgba(255,255,255,.85); border-radius: 999px; padding: 4px 12px;
}
.kf-photos { align-items: center; }
.kf-photos-label { font-family: var(--display); font-weight: 700; font-size: .9rem; margin-right: 2px; }
.kf-photo { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; }
.kf-photo img { width: 56px; height: 56px; }
@media (max-width: 480px) { .kf-photos { gap: 8px; } .kf-photo img { width: 46px; height: 46px; } }

/* Steps */
.kf-step { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.kf-step legend { display: flex; align-items: center; gap: 10px; padding: 0; margin-bottom: 12px; font-family: var(--display); font-size: 1.2rem; font-weight: 750; }
.kf-step-num {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; border: var(--outline); font-size: .95rem; box-shadow: 0 2px 0 var(--ink);
}
.kf-help { margin: -4px 0 12px; font-size: .9rem; color: var(--ink-2); }

/* Layout picker */
.kf-layouts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 480px) {
  .kf-layouts { gap: 6px; }
  .kf-layout-card { padding: 6px 2px 7px; }
  .kf-layout-icon svg { width: 40px; height: 40px; }
  .kf-layout-name { font-size: .76rem; }
  .kf-layout-price { font-size: .7rem; }
}
.kf-layout { position: relative; cursor: pointer; }
.kf-layout input { position: absolute; opacity: 0; pointer-events: none; }
.kf-layout-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; padding: 8px 6px 9px; text-align: center;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm); transition: border-color .15s, transform .25s var(--bounce), box-shadow .15s;
}
.kf-layout:hover .kf-layout-card { transform: translateY(-2px); border-color: var(--ink); }
.kf-layout input:checked + .kf-layout-card { border-color: var(--ink); background: var(--tile-sun); box-shadow: 0 3px 0 var(--ink); }
.kf-layout input:focus-visible + .kf-layout-card { outline: 3px solid var(--pop-sky); outline-offset: 2px; }
.kf-layout input:disabled + .kf-layout-card { opacity: .45; cursor: not-allowed; }
.kf-layout-icon svg { width: 56px; height: 56px; display: block; }
.kf-layout-name { font-family: var(--display); font-weight: 700; font-size: .92rem; line-height: 1.15; hyphens: auto; overflow-wrap: anywhere; }
.kf-layout-price { font-size: .78rem; color: var(--ink-2); font-weight: 600; }

/* Key map: one button per key, laid out like the real fidget */
.kf-map {
  --u: 52px;
  position: relative; width: calc(var(--cols) * var(--u)); height: calc(var(--rows) * var(--u));
  margin: 4px 0 16px 18px;
}
.kf-map::before { /* the keyring eyelet on the end module */
  content: ''; position: absolute; left: -16px; top: calc(var(--eye-row, 0) * var(--u) + var(--u) / 2 - 9px);
  width: 14px; height: 18px; border: 2px solid #cfc7b0; border-right: 0; border-radius: 10px 0 0 10px; background: #ece6d4;
}
.kf-key {
  position: absolute; left: calc(var(--x) * var(--u) + 3px); top: calc(var(--y) * var(--u) + 3px);
  width: calc(var(--u) - 6px); height: calc(var(--u) - 6px);
  display: grid; place-items: center; padding: 0; cursor: pointer;
  font-family: var(--display); font-weight: 750; font-size: 1.05rem; color: var(--ink);
  background: var(--c); border: 2px solid rgba(28,19,48,.35); border-radius: 10px;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.12), 0 0 0 4px #ece6d4;
  transition: transform .2s var(--bounce), box-shadow .15s;
}
.kf-key--dark { color: #fff; }
/* translucent caps: their tint over a checkerboard */
.kf-key--clear { background: linear-gradient(color-mix(in srgb, var(--c) 72%, transparent), color-mix(in srgb, var(--c) 72%, transparent)), repeating-conic-gradient(#e9e3d6 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.kf-key:hover { transform: translateY(-2px); }
.kf-key[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 -5px 0 rgba(0,0,0,.12), 0 0 0 4px #ece6d4, 0 0 0 7px var(--accent); transform: translateY(-2px) scale(1.04); z-index: 1; }

/* Colour swatches */
.kf-swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; max-width: 380px; margin-bottom: 12px; }
.kf-swatch {
  aspect-ratio: 1; padding: 0; cursor: pointer; border-radius: 10px; background: var(--c);
  border: 2px solid rgba(28,19,48,.25); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12);
  transition: transform .2s var(--bounce);
}
.kf-swatch--clear { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 85%, transparent), color-mix(in srgb, var(--c) 55%, transparent)), repeating-conic-gradient(#e6e0d4 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
.kf-swatch:hover { transform: translateY(-2px) rotate(-4deg); }
.kf-swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.kf-swatch:focus-visible, .kf-key:focus-visible { outline: 3px solid var(--pop-sky); outline-offset: 3px; }
.kf-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.kf-tools .chip { font-size: .85rem; padding: 4px 12px; }

/* No-JS colour selects */
.kf-fallback-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 360px; margin: 6px 0; font-weight: 600; }

.kf-summary { margin: 0 0 4px; font-size: .9rem; color: var(--ink-2); min-height: 1.4em; }
.kf-share { margin: 10px 0 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .kf-key, .kf-swatch, .kf-layout-card { transition: none; }
}
