/* Squeaky 3D: the posing / animating app (3d.html). Builds on app.css (colours, buttons, chips). */
:root { --soft: #eef4fd; --rule: #d6e2f3; --muted: #5b6f99; }
body { overflow: hidden; }

/* top bar */
.bar { gap: 12px; padding: 8px 14px; }
.ghostlink { font-weight: 700; font-size: 13px; color: var(--navy); text-decoration: none; border: 2px solid var(--navy); border-radius: 10px; padding: 4px 10px; }
.ghostlink:hover { background: var(--soft); }
.bar > button { padding: 5px 12px; font-size: 13px; }

/* segmented control (Look, L/R, speed, rotate mode) */
.seg { display: inline-flex; border: 2px solid var(--navy); border-radius: 11px; overflow: hidden; background: #fff; flex: none; }
.seg button { background: #fff; color: var(--navy); border: 0; border-radius: 0; box-shadow: none; padding: 5px 12px; font-size: 13px; font-weight: 700; }
.seg button + button { border-left: 2px solid var(--navy); }
.seg button.on { background: var(--navy); color: #fff; }
.seg button:active { transform: none; }
.seg.sm button { padding: 2px 9px; font-size: 12px; }

/* "Show" dropdown */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-weight: 700; font-size: 13px; border: 2px solid var(--navy); border-radius: 10px; padding: 5px 11px; display: flex; gap: 6px; align-items: center; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--navy); color: #fff; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; background: #fff; border: var(--line); border-radius: 14px; box-shadow: 4px 4px 0 var(--navy); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 230px; }
.menu-extra { display: contents; }
.tog { flex-wrap: wrap; row-gap: 0; }
.tog .sub { flex-basis: 100%; padding-left: 22px; margin-top: -2px; }
.sub { font-weight: 500; opacity: .6; font-size: 11px; }

/* layout: rail | panel | stage */
main.app3d { grid-template-columns: 72px minmax(300px, 340px) 1fr; }
.rail { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; border-right: var(--line); background: #fff; }
.rail button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 6px; background: transparent; color: var(--navy); border: 2px solid transparent; border-radius: 12px; box-shadow: none; font-size: 11px; font-weight: 700; }
.rail button:hover { background: var(--soft); }
.rail button.on { background: var(--sky); border-color: var(--navy); box-shadow: 2px 2px 0 var(--navy); }
.rail button:active { transform: none; }
.rail svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail button[data-tab=animate] svg { fill: currentColor; }
.panel { border-right: var(--line); background: #fff; overflow-y: auto; min-height: 0; }
.tab { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 24px; }
.tab-head { display: flex; align-items: baseline; gap: 8px; }
.tab-head h3 { margin: 0; font: 800 20px/1.1 'CS Display', sans-serif; }
.count { font-size: 12px; color: var(--muted); font-weight: 600; }
.tab h4 { margin: 6px 0 -2px; font: 800 13px 'CS Inter', sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sec-head { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.sec-head h4 { margin: 0; flex: 1; }
.sec-head .lbl { flex: 1; font-weight: 600; }
button.sm { padding: 3px 10px; font-size: 12px; border-width: 2px; box-shadow: 2px 2px 0 var(--navy); border-radius: 9px; }
.hint { color: var(--muted); opacity: 1; }
.empty { margin: 4px 0; font-size: 13px; color: var(--muted); }

/* chips that pick one thing: the chosen one is navy */
.chips button { background: var(--soft); box-shadow: none; border: 2px solid var(--rule); font-weight: 600; }
.chips button:hover { border-color: var(--navy); }
.chips button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* moves library */
.search { width: 100%; border: 2px solid var(--navy); border-radius: 12px; padding: 8px 12px; background: #fff; font-size: 14px; }
.search:focus { outline: 3px solid var(--sky); }
.cats { display: flex; flex-wrap: wrap; gap: 5px; }
.cats button { background: #fff; color: var(--navy); border: 2px solid var(--rule); box-shadow: none; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.cats button:hover { border-color: var(--navy); }
.cats button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.cats button:active { transform: none; }
.cats button.dim { opacity: .45; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.cards .grp { grid-column: 1 / -1; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 6px; }
.cards .grp:first-child { margin-top: 0; }
.card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; background: #fff; color: var(--navy); border: 2px solid var(--rule); border-radius: 12px; box-shadow: none; padding: 7px 9px 6px; font-weight: 700; font-size: 13px; line-height: 1.15; min-height: 46px; }
.card:hover { border-color: var(--navy); box-shadow: 2px 2px 0 var(--navy); }
.card:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--navy); }
.card small { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.card.on { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 2px 2px 0 var(--blue); }
.card.on small { color: #c7d6f5; }
.card.on::after { content: ''; position: absolute; right: 8px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: #7CF0B2; box-shadow: 0 0 0 0 #7CF0B2; animation: live 1.2s infinite; }
.card.paused::after { animation: none; background: #ffd166; }
@keyframes live { 70% { box-shadow: 0 0 0 6px rgba(124, 240, 178, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 240, 178, 0); } }
.card-sec { border: 2px solid var(--rule); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; background: var(--soft); }
.card-sec h4 { margin: 0; }
.say { display: flex; gap: 6px; }
.say input { flex: 1; min-width: 0; border: 2px solid var(--navy); border-radius: 10px; padding: 5px 8px; background: #fff; }
.say button { padding: 4px 12px; box-shadow: 2px 2px 0 var(--navy); }

/* sliders */
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.sliders label { font-weight: 600; }
.sliders input[type=range], .group input[type=range] { width: 100%; accent-color: var(--blue); }
#props .lbl { grid-column: 1 / -1; margin-top: 4px; font-weight: 800; }
.val { opacity: .6; font-size: 11px; }

/* collapsible groups (Setup) and the posing help */
details.group { border: 2px solid var(--rule); border-radius: 14px; padding: 0 12px; }
details.group[open] { padding-bottom: 12px; }
details.group > summary { cursor: pointer; font-weight: 800; padding: 10px 0; list-style: none; display: flex; justify-content: space-between; }
details.group > summary::after, details.help > summary::after { content: '+'; font-weight: 800; }
details.group[open] > summary::after, details.help[open] > summary::after { content: '–'; }
details.group > summary::-webkit-details-marker, details.help > summary::-webkit-details-marker { display: none; }
details.group > * + * { margin-top: 8px; }
details.group .tog { margin-top: 8px; }
details.help { background: var(--soft); border-radius: 14px; padding: 8px 12px; margin-top: 8px; font-size: 12.5px; }
details.help > summary { cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; }
details.help ul { margin: 8px 0 2px; padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--navy); vertical-align: -1px; }
.dot.blue { background: #3355dd; } .dot.pink { background: #f0559b; } .dot.white { background: #fff; }
kbd { font: 11px ui-monospace, monospace; border: 1.5px solid var(--navy); border-radius: 5px; padding: 0 4px; background: #fff; }
#poseOut { width: 100%; height: 110px; flex: none; min-height: 0; font: 11px/1.4 ui-monospace, monospace; border: 2px solid var(--navy); border-radius: 10px; padding: 6px; }

/* stage */
.stagewrap { padding: 14px; }
#view { flex: 1; min-height: 0; position: relative; border: var(--line); border-radius: 16px; overflow: hidden; background: #F3F7FD; }
#view canvas { display: block; width: 100%; height: 100%; }
.legend { position: absolute; left: 14px; top: 12px; right: 260px; font-size: 12px; color: var(--muted); pointer-events: none; font-weight: 600; }
.hpad { position: absolute; right: 12px; top: 12px; width: 224px; background: rgba(255, 255, 255, .95); border: var(--line); border-radius: 14px; padding: 8px 12px 10px; font-size: 12px; z-index: 2; user-select: none; }
.hpad .hd { display: flex; gap: 8px; align-items: center; font-weight: 800; margin-bottom: 4px; }
.hpad .hd > span:first-child { flex: 1; }
.hpad .hd button.ghost { padding: 0 8px; box-shadow: none; border-width: 2px; border-radius: 8px; }
.hpad label { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 6px; margin: 3px 0; }
.hpad label.all { font-weight: 700; border-bottom: 2px solid var(--rule); padding-bottom: 6px; margin-bottom: 6px; }
.hpad .ends { display: flex; justify-content: space-between; opacity: .55; font-size: 10px; margin: -2px 0 2px 68px; }
.hpad input { width: 100%; accent-color: var(--blue); }
.hpad.min label, .hpad.min .ends { display: none; }
.hpad.min .hd { margin: 0; }

/* transport bar under him */
.transport { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(720px, calc(100% - 28px)); display: flex; align-items: center; gap: 12px; background: #fff; border: var(--line); border-radius: 18px; box-shadow: 4px 4px 0 var(--navy); padding: 8px 12px 8px 8px; z-index: 3; }
.transport button { flex: none; }
.tp-play { width: 42px; height: 42px; border-radius: 50%; padding: 0; display: grid; place-items: center; }
.tp-play svg { width: 20px; height: 20px; fill: #fff; }
.tp-play .i-pause, .transport.playing .tp-play .i-play { display: none; }
.transport.playing .tp-play .i-pause { display: block; }
.tp-name { display: flex; flex-direction: column; min-width: 92px; max-width: 140px; line-height: 1.15; }
.tp-name b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-name span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tpScrub { flex: 1; min-width: 60px; accent-color: var(--blue); }
.tp-time { font: 600 12px ui-monospace, monospace; color: var(--muted); min-width: 78px; text-align: right; }
.tp-stop { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; background: #fff; border-radius: 10px; box-shadow: 2px 2px 0 var(--navy); }
.tp-stop svg { width: 14px; height: 14px; fill: var(--navy); }
.transport.idle #tpScrub, .transport.idle .tp-stop, .transport.idle #tpSpeed { opacity: .35; pointer-events: none; }

/* narrow screens: the panel goes over the stage's left side */
@media (max-width: 1000px) {
  main.app3d { grid-template-columns: 64px minmax(260px, 300px) 1fr; }
  .bar .brand span, .tp-name span, #tpSpeed { display: none; }
  .hpad { width: 190px; }
}

/* render mode (code-made shots): the stage only */
body.render header, body.render .rail, body.render .panel, body.render .legend, body.render .hpad, body.render .transport { display: none; }
body.render main { padding: 0; height: 100vh; display: block; }
body.render .stagewrap { padding: 0; }
body.render #view { position: fixed; inset: 0; border: 0; border-radius: 0; background: transparent; }

/* hidden wins over every display rule above */
[hidden], .tab.hidden, .empty.hidden { display: none !important; }

@media (max-width: 1000px) { .rail button { font-size: 10px; } }

/* Hands tab: the drawn glove (handui3d.js). Drag a finger; the handles: blue = the finger, pink = just its tip */
.hw { position: relative; background: var(--soft); border: 2px solid var(--rule); border-radius: 16px; padding: 4px 6px 8px; user-select: none; -webkit-user-select: none; }
.hw-svg { display: block; width: 100%; max-height: 300px; touch-action: none; overflow: visible; }
.hw-dig, .hw-palm { cursor: grab; }
.hw.dragging, .hw.dragging * { cursor: grabbing !important; }
.hw-h { cursor: grab; outline: none; }
.hw-h .hw-halo { fill: rgba(34, 85, 204, .14); stroke: none; opacity: 0; transition: opacity .12s; }
.hw-h.near .hw-halo, .hw-h:hover .hw-halo, .hw-h.on .hw-halo, .hw-h:focus-visible .hw-halo { opacity: 1; }
.hw-h:focus-visible .hw-halo { stroke: var(--navy); stroke-width: 2; }
.hw-ro { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; justify-content: center; min-height: 18px; font-size: 12px; color: var(--muted); font-weight: 600; }
.hw-ro b { color: var(--navy); font-weight: 800; }
.hw-ro span { font-variant-numeric: tabular-nums; }
.hw-help { margin: -2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.hw-help b { color: var(--navy); }
.hw-pk { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #f49ac8; border: 1.5px solid #2255cc; vertical-align: -1px; }
#fExact .sliders { margin-top: 4px; }
.sec-head button { white-space: nowrap; }
.sec-head h4 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-h .hw-halo { pointer-events: none; }

/* speech bubble: the overlay over the stage, the text box in the Props tab */
#view canvas.bubble-layer { position: absolute; inset: 0; pointer-events: none; }
.bubtext { width: 100%; box-sizing: border-box; font: italic 800 14px 'CS Inter', sans-serif; color: #082b78; border: 2px solid var(--navy); border-radius: 12px; padding: 7px 10px; height: 64px; min-height: 0; resize: vertical; }

/* shows (show3d.js): the stage takes the video's shape, the 2D kit layers sit under and over the 3D canvas */
#showBack, #showFront { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
#view.show { flex: 0 1 auto; height: 100%; width: auto; max-width: 100%; aspect-ratio: var(--show-ar, 9 / 16); align-self: center; background: #fff; overflow: visible; border-radius: 0; }
#view.show #showBack, #view.show #showFront { display: block; }
#view.show #showBack { z-index: 0; } #view.show > canvas:first-of-type { position: relative; z-index: 1; }
#view.show canvas.bubble-layer { z-index: 3; } #view.show #showFront { z-index: 2; }
#view.show .legend, #view.show .hpad, #view.show #transport { display: none; }
body.showing .stagewrap { padding-bottom: 78px; position: relative; }
#view.show #showBar { position: absolute; top: calc(100% + 12px); bottom: auto; width: max(100%, 460px); }
#showBar .tog { font-size: 12px; white-space: nowrap; }
#showCode { flex: none; width: 100%; height: 42vh; min-height: 220px; font: 11.5px/1.45 ui-monospace, monospace; border: 2px solid var(--navy); border-radius: 10px; padding: 8px; resize: vertical; white-space: pre; overflow: auto; tab-size: 2; }
.tab[data-tab=video] .row { display: flex; gap: 6px; align-items: center; margin: 6px 0; } .tab[data-tab=video] .row select { flex: 1; min-width: 0; }
.tab[data-tab=video] .err { color: #c2264b; font: 600 12px ui-monospace, monospace; margin: 2px 0; white-space: pre-wrap; }
.tab[data-tab=video] code { font: 11px ui-monospace, monospace; background: #fff; padding: 0 3px; border-radius: 4px; }
body.render #showBar { display: none; }
body.render #view.show { position: fixed; inset: 0; height: auto; aspect-ratio: auto; border: 0; background: transparent; }
.transport.hidden { display: none; }

#view iframe.guest { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 1; pointer-events: none; background: transparent; }

#showRender.busy { min-width: 92px; color: #fff; opacity: 1; background: linear-gradient(90deg, #0354D0 var(--p, 0%), #9fbfee var(--p, 0%)); font-variant-numeric: tabular-nums; }
