﻿/* Page chrome for the parts workbench (workbench.html).
 *
 * The walk-cycle keyframes this page tunes now live in styles/walk.css,
 * and the :root block below is what the sliders write into. The dark ground
 * is deliberate: it keeps the dev tool visually distinct from the site. */

/* Walk-cycle animation.
 *
 * DOM hierarchy emitted by the assembler:
 *   <g class="character">       <- bob (transform: translate)
 *     <g class="lean">          <- static forward rotation, pivot near leg tips
 *       arm-L, arm-R,
 *       part-shadows,
 *       leg-L, leg-R,
 *       body, eyes, mouth
 *
 * The two legs use the same side-view gait and are offset by half a cycle.
 * They are not mirrored: this character faces right, so both knees bend
 * forward in the walk direction.
 */

:root {
  --walk-duration: 1.00s;
  --leg-swing: 35deg;
  --arm-swing: 18deg;
  --bob-amount: 19px;
  --sway-amount: 0px;
  --arm-lag: 0.06s;
  --knee-bend-max: 89deg;
  --forward-lean: 0deg;
  --part-shadow-color: #232323;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #061F0D;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #F6F3E8;
}

h1 { text-align: center; margin: 24px 0 8px; color: #F8F5EA; font-weight: 700; }
.subtitle { text-align: center; color: #D8DEC9; margin: 0 0 24px; font-size: 14px; }

/* --- Live controls --- */

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 14px 24px;
  background: rgba(7, 38, 16, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(248, 245, 234, 0.14);
}
.control {
  display: flex;
  flex-direction: column;
  flex: 1 1 180px;
  min-width: 180px;
  max-width: 240px;
}
.control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: #F6F3E8;
  margin-bottom: 4px;
}
.control .name { font-family: ui-monospace, "SF Mono", monospace; }
.control .val  { color: #F4A261; font-weight: 600; font-family: ui-monospace, "SF Mono", monospace; }
.control input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: #F4A261;
}

/* --- Workbench --- */

.workbench {
  display: grid;
  grid-template-columns: minmax(340px, 2fr) minmax(0, 3fr);
  gap: 18px;
  align-items: start;
  padding: 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.customizer {
  position: sticky;
  top: 96px;
  min-height: calc(100vh - 120px);
}

.customizer-shell {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: minmax(210px, 42%) minmax(220px, 1fr);
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(248, 245, 234, 0.08);
  overflow: hidden;
}

.part-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.08);
  border-right: 1px solid rgba(248, 245, 234, 0.10);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.sidebar-heading {
  color: #F8F5EA;
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  font-family: ui-monospace, "SF Mono", monospace;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 420px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
}

.preview-stage .character-svg {
  width: min(340px, 86%);
  height: auto;
}

.chooser-stack {
  display: grid;
  gap: 14px;
}

.chooser-group {
  display: grid;
  gap: 8px;
}

.chooser-title {
  color: #F6F3E8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: ui-monospace, "SF Mono", monospace;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.body-choice,
.segment-button,
.color-swatch {
  border: 1px solid rgba(248, 245, 234, 0.14);
  background: rgba(255,255,255,0.08);
  color: #F6F3E8;
  cursor: pointer;
}

.body-choice {
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", monospace;
}

.body-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 0.8;
  overflow: hidden;
}

.body-thumb .character-svg {
  width: 74px;
  height: auto;
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segment-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", monospace;
}

.swatch-row {
  display: grid;
  grid-template-columns: repeat(4, 34px);
  gap: 10px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  background: var(--swatch-color);
}

.body-choice:hover,
.segment-button:hover,
.color-swatch:hover {
  border-color: rgba(244, 162, 97, 0.75);
}

.body-choice.is-selected,
.segment-button.is-selected,
.color-swatch.is-selected {
  border-color: #F4A261;
  box-shadow: 0 0 0 2px rgba(244, 162, 97, 0.28);
}

.preset-panel {
  min-width: 0;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 0;
}

.card {
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: inset 0 0 0 1px rgba(248, 245, 234, 0.08);
}
.card .label {
  font-size: 13px;
  color: #F6F3E8;
  margin-top: 8px;
  font-family: ui-monospace, "SF Mono", monospace;
}

.character-svg {
  width: 200px;
  height: 220px;
  display: block;
}

@media (max-width: 920px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .customizer {
    position: static;
    min-height: auto;
  }

  .customizer-shell {
    min-height: 520px;
  }

  .preview-stage {
    min-height: 360px;
  }
}

@media (max-width: 480px) {
  .customizer-shell {
    grid-template-columns: 1fr;
  }

  .part-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(248, 245, 234, 0.10);
  }

  .option-grid {
    grid-template-columns: repeat(6, minmax(64px, 1fr));
    overflow-x: auto;
  }

  .preview-stage {
    min-height: 300px;
  }
}

