/* Maths-powered tools: gradient & tile options, object pose, Animate and Effects panels, palette ramps. */

/* Segmented icon control (gradient shape, light direction) in the style of the Edit switch. */
.seg-control { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #dce4d5; border-radius: 8px; background: #fff; }
.seg-option { display: inline-grid; place-items: center; width: 30px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #65735e; cursor: pointer; }
.seg-option svg { width: 16px; height: 16px; }
.seg-option:hover:not(.active):not(:disabled) { background: #f3f6ee; }
.seg-option:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.seg-option.active { border-color: var(--green); background: var(--green); color: #fff; }
.seg-option:disabled { opacity: .35; cursor: default; }

/* Gradient tool options */
.gradient-options { display: grid; gap: 8px; margin-bottom: 10px; }
.gradient-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gradient-label { flex: 0 0 48px; color: #52664d; font-size: 11px; font-weight: 550; }
.gradient-stops { display: flex; flex: 1 1 auto; min-width: 0; height: 22px; overflow: hidden; border: 1px solid #d8e1d0; border-radius: 5px; }
.gradient-stops i { flex: 1 1 0; min-width: 2px; background: var(--swatch); }
.gradient-to { position: relative; flex: 0 0 auto; width: 30px; height: 24px; padding: 0; border: 1px solid #c9d4bd; border-radius: 5px; background: var(--swatch, #fff); cursor: pointer; }
.gradient-to::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid #fff; filter: drop-shadow(0 0 1px #0008); }
.gradient-to:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.gradient-to-picker { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; padding: 6px; border: 1px solid #dce4d5; border-radius: 7px; background: #fff; }
.gradient-to-picker .swatch { height: 20px; }

/* Tile mode: faded repeat around the canvas and a floating status chip. */
.tile-ghost { position: absolute; z-index: 1; pointer-events: none; image-rendering: pixelated; }
.workbench.tile-mode .canvas-wrap { outline-color: transparent; box-shadow: 0 0 0 1px #285b4766; }
.tile-status { position: absolute; z-index: 4; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 16px); padding: 4px 4px 4px 10px; border: 1px solid #d3dfc9; border-radius: 10px; background: #fffefbf2; box-shadow: 0 6px 18px #36482c1f; color: #52664d; font-size: 11px; backdrop-filter: blur(6px); }
.tile-status > svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.tile-status .seams-bad { color: #a3542f; font-weight: 600; }
.tile-status .seams-ok { color: var(--green); font-weight: 600; }

/* Pivot marker */
.pivot-marker { position: absolute; z-index: 4; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; cursor: move; touch-action: none; }
.pivot-marker::before, .pivot-marker::after { content: ""; position: absolute; background: #ff2d87; box-shadow: 0 0 0 1px #fff; }
.pivot-marker::before { left: 10px; top: 0; width: 2px; height: 22px; }
.pivot-marker::after { left: 0; top: 10px; width: 22px; height: 2px; }
.pivot-marker > i { position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; box-sizing: border-box; border: 2px solid #ff2d87; border-radius: 50%; background: #fff; z-index: 1; }
.pivot-marker.dragging > i { background: #ff2d87; }

/* Object pose (Transform panel) */
.object-pose { display: grid; gap: 7px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line, #dce4d5); }
.object-pose .object-action-heading { margin: 0; }
.object-pose .object-action-heading span { margin-left: 4px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.pose-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 7px; color: #52664d; font-size: 11px; }
.pose-label { font-weight: 550; }
.pose-value { min-width: 0; overflow: hidden; color: #6c7865; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.pose-row input[type="range"], .maths-form input[type="range"] { width: 100%; min-width: 0; margin: 0; accent-color: var(--green); }
.pose-number { width: 52px; min-height: 28px; box-sizing: border-box; padding: 3px 5px; border: 1px solid #d8e1d0; border-radius: 5px; background: #fffefb; color: #37503c; font: inherit; font-size: 11px; font-variant-numeric: tabular-nums; }
.pose-number:focus-visible { outline: 2px solid var(--green); outline-offset: 0; }
.pose-deform > span { flex-basis: 46px; }
.pose-params { display: grid; gap: 7px; }
.pose-params:empty { display: none; }
.pose-params select { min-height: 28px; padding: 3px 5px; border: 1px solid #d8e1d0; border-radius: 5px; background: #fffefb; color: #37503c; font: inherit; font-size: 11px; }
.object-pose .pose-check { margin-top: 2px; font-size: 11px; color: #52664d; }
.pose-row.pose-wide { grid-template-columns: 66px minmax(0, 1fr) auto; }
/* On-canvas 3D turn handle, beside the round rotate handle (Transform tool). */
.resize-handle.tilt-handle { left: calc(50% + 24px); top: calc(100% + 22px); width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 3px; transform: rotate(45deg); background: #fff; border-color: #2d7dff; cursor: move; }
.resize-handles.is-rotated .resize-handle.tilt-handle { display: block; }

/* Animate / Effects panels reuse .object-action rows. */
.animate-section .object-action-list, .effects-section .object-action-list { margin-top: 2px; }
.maths-reason { display: block; margin-top: 2px; color: #a3694e; font-size: 10px; line-height: 13px; }

/* Dialogs */
.maths-form .form-grid + .form-grid { margin-top: 13px; }
.maths-form .field { margin: 12px 0 0; }
.maths-form .form-grid .field { margin: 0; }
.maths-form .field-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px; align-items: center; gap: 8px; }
.maths-form .field-row output { color: #52664d; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.maths-error { margin: 12px 0 0; color: #8b302b; font-size: 11px; line-height: 1.5; }
.maths-error:empty { display: none; }
.maths-info { margin: 10px 0 0; color: #627458; font-size: 11px; line-height: 1.55; }
.maths-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 4px; }
.maths-preview figure { display: grid; gap: 5px; margin: 0; }
.maths-preview figcaption { color: #8a9680; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.maths-preview canvas, .easing-curve { width: 100%; height: auto; aspect-ratio: 1; border: 1px solid #dce4d5; border-radius: 7px; background: #f3f5ef; image-rendering: pixelated; }
/* Square previews shrink on short screens so the options and buttons stay in view. */
.maths-preview canvas { width: min(100%, max(128px, 32dvh)); justify-self: center; }
.easing-curve { display: block; aspect-ratio: auto; height: 96px; margin-top: 10px; image-rendering: auto; background: #fff; }
.light-grid { display: grid; grid-template-columns: repeat(3, 28px); gap: 3px; padding: 3px; width: max-content; border: 1px solid #dce4d5; border-radius: 8px; background: #fff; }
.light-grid .seg-option { width: 28px; height: 28px; font-size: 13px; line-height: 1; }
.light-grid .light-centre { display: grid; place-items: center; color: #b4bfab; font-size: 14px; }
.swatch-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch-pick .swatch { width: 24px; height: 24px; flex: 0 0 24px; }
.swatch-pick .swatch[aria-pressed="true"] { outline: 2px solid #536e43; outline-offset: 2px; }
.ramp-strip { display: flex; height: 28px; overflow: hidden; border: 1px solid #d8e1d0; border-radius: 6px; }
.ramp-strip i { flex: 1 1 0; background: var(--swatch); }
.ramp-strip i.base { box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px #253a2b; }
.ramp-strip:empty::before { content: "Pick at least two colours"; padding: 6px 8px; color: #9aa48f; font-size: 11px; }

.palette-actions #shading-ramp, .palette-actions #colour-cycle { white-space: nowrap; }

/* Motion modes: floating bar over the canvas (does not shift it), launch rows, wave preview. */
.motion-bar { position: absolute; z-index: 5; bottom: 10px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; width: max-content; max-width: calc(100% - 16px); padding: 8px 8px 8px 12px; border: 1px solid #d3dfc9; border-radius: 12px; background: #fffefbf5; box-shadow: 0 8px 24px #36482c29; color: #52664d; font-size: 12px; backdrop-filter: blur(6px); }
.motion-bar[hidden] { display: none; }
.motion-bar.docked { top: 10px; bottom: auto; left: 10px; transform: none; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 256px; max-height: calc(100% - 20px); overflow: auto; padding: 12px; }
.motion-bar.docked .motion-head { display: contents; }
.motion-bar.docked .motion-hint { flex: none; line-height: 1.45; }
.motion-bar.docked .motion-steps { flex-direction: column; align-items: flex-start; }
.motion-bar.docked .motion-controls { flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 10px; }
.motion-bar.docked .motion-actions { order: 9; margin: 2px 0 0; padding-top: 10px; border-top: 1px solid #e3eadc; }
.motion-bar.docked .motion-actions .button.small { flex: 1 1 0; justify-content: center; }
.motion-bar.docked .motion-info { order: 8; line-height: 1.4; }
.motion-bar:not(.docked) .motion-label { display: none; }
.motion-bar:not(.docked) .motion-chip:has(.motion-curve) { padding: 0 6px; }
.motion-head, .motion-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.motion-controls { padding-top: 6px; border-top: 1px solid #e3eadc; }
.motion-title { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 12px; white-space: nowrap; }
.motion-title svg { width: 16px; height: 16px; fill: none; stroke: var(--green); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.motion-hint { flex: 1 1 160px; min-width: 0; }
.motion-hint b { color: var(--ink); font-weight: 600; }
.motion-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.motion-bar .button.small { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.motion-bar .button.small svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.motion-bar .flip-x svg { transform: scaleX(-1); }
.motion-bar kbd { padding: 0 4px; border: 1px solid #0002; border-radius: 4px; font: 600 9px/14px inherit; opacity: .7; }
.motion-steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.motion-steps li { counter-increment: step; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 3px; border-radius: 999px; background: #f1f5ec; color: #8a9680; font-size: 11px; white-space: nowrap; }
.motion-steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #dfe7d6; color: #52664d; font-size: 10px; font-weight: 700; }
.motion-steps li.now { background: #e3efe0; color: var(--ink); font-weight: 600; }
.motion-steps li.now::before { background: var(--green); color: #fff; }
.motion-steps li.done::before { content: "✓"; background: #b9d3b0; }
.motion-chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.motion-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border: 1px solid #dce4d5; border-radius: 999px; background: #fff; color: #52664d; font: inherit; font-size: 11px; cursor: pointer; white-space: nowrap; }
.motion-chip:hover:not(.active):not(:disabled) { background: #f3f6ee; }
.motion-chip:focus-visible, .motion-stepper button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.motion-chip.active { border-color: var(--green); background: var(--green); color: #fff; }
.motion-chip:disabled { opacity: .4; cursor: default; }
.motion-toggle i { width: 10px; height: 10px; border: 1.5px solid currentColor; border-radius: 3px; }
.motion-toggle.active i { background: #fff; box-shadow: inset 0 0 0 2px var(--green); }
.motion-curve { width: 18px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.motion-field { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.motion-field input[type="range"] { width: 90px; accent-color: var(--green); }
.motion-field output { min-width: 22px; color: var(--ink); font-weight: 600; text-align: center; }
.motion-stepper { display: inline-flex; align-items: center; border: 1px solid #dce4d5; border-radius: 8px; background: #fff; }
.motion-stepper button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #52664d; font: 600 14px/1 inherit; cursor: pointer; }
.motion-stepper button:hover:not(:disabled) { background: #f3f6ee; }
.motion-stepper button:disabled { opacity: .35; cursor: default; }
.motion-frames { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.motion-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; color: #65735e; font-size: 11px; }
.motion-info[hidden] { display: none; }
.motion-info.is-error { color: #a3542f; font-weight: 550; }
.workbench.motion-active #resize-handles, .workbench.motion-active #pivot-marker, .workbench.motion-active .tile-status, .workbench.motion-active #selection-actions { display: none !important; }
.workbench.motion-active .tool-grid { opacity: .45; pointer-events: none; }
.object-action.active { background: #e3efe0; box-shadow: inset 3px 0 0 var(--green); }
.object-action.active svg { stroke: var(--green); }
.wave-preview { display: block; width: 128px; height: 128px; margin: 10px auto; border: 1px solid #dce4d5; border-radius: 8px; image-rendering: pixelated; }

@media (max-width: 760px) {
  .seg-option { width: 40px; height: 36px; }
  .gradient-options, .object-pose { grid-column: 1 / -1; }
  .gradient-to { width: 40px; height: 36px; }
  .gradient-to-picker .swatch { height: 32px; }
  .pose-number { min-height: 36px; font-size: 16px; width: 64px; }
  .tile-status { bottom: 6px; font-size: 12px; }
  .animate-section, .effects-section { grid-column: 1 / -1; }
  .maths-preview { gap: 8px; }
  .motion-bar { bottom: 6px; font-size: 13px; }
  .motion-chip, .motion-stepper button { height: 34px; min-width: 34px; }
}
#pixel-canvas.picking-point { cursor: crosshair; outline: 2px dashed #ff2d87; outline-offset: 2px; }
.maths-form .form-grid { margin-top: 12px; }
.maths-form > .button.small { margin-top: 10px; }

/* Shade tool ramp and the Pixel cleanup checker. */
.shade-ramp i.current { flex-grow: 1.6; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px var(--green); }
.tool-options .gradient-options .tool-hint { margin: 0; }
.cleanup-results { display: grid; gap: 8px; margin-top: 10px; padding: 9px; border: 1px solid #dce4d5; border-radius: 8px; background: #fffefb; font-size: 11px; color: #52664d; }
.cleanup-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.cleanup-head strong { color: #385440; font-weight: 650; line-height: 1.4; }
.cleanup-actions { display: flex; gap: 5px; }
.cleanup-list { display: grid; gap: 2px; max-height: 220px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.cleanup-list li { display: flex; align-items: center; gap: 4px; padding: 1px 2px; border-radius: 5px; }
.cleanup-list li.focused, .cleanup-list li:hover { background: #f3f6ee; }
.cleanup-go { display: flex; flex: 1 1 auto; align-items: center; gap: 7px; min-width: 0; padding: 4px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.cleanup-go small { margin-left: auto; color: #829674; font-variant-numeric: tabular-nums; }
.cleanup-mark { flex: 0 0 auto; width: 9px; height: 9px; border: 2px solid; border-radius: 2px; }
.cleanup-mark.stray { border-color: #e0344a; border-radius: 50%; }
.cleanup-mark.corner { border-color: #e8892c; }
.cleanup-mark.jaggy { border-color: #2f7de1; }
.cleanup-mark.banding { border-color: #8a4fd6; border-style: dashed; }
.gradient-options > .check-row { margin: 0; }

/* Describe a motion (motion-ask.js) */
.animate-describe { margin: 0 0 8px; padding: 9px 10px; border: 1px solid #cfdcc5; background: var(--green-soft); }
.animate-describe:hover:not([disabled]) { background: #dfead6; }
.animate-describe svg { stroke: var(--green); }
.motion-ask .ma-ask { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.motion-ask .ma-ask input { min-width: 0; font-size: 13px; }
.motion-ask .ma-examples { margin-top: 8px; }
.motion-ask textarea { width: 100%; box-sizing: border-box; margin-top: 6px; font: 11px/1.45 ui-monospace, Menlo, monospace; resize: vertical; }
.ma-result { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ma-grid { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 14px; align-items: start; }
.ma-preview-box { text-align: center; }
.ma-preview { margin: 0 auto 4px; background: repeating-conic-gradient(#f1f4ec 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.ma-frame { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.ma-steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.ma-step { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; }
.ma-step .motion-chip { overflow: hidden; max-width: 100%; text-overflow: ellipsis; cursor: default; justify-self: start; }
.ma-step-meta { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.ma-params { display: flex; grid-column: 1 / -1; flex-wrap: wrap; align-items: center; gap: 8px; color: #627558; font-size: 10px; }
.ma-params input { width: 52px; padding: 3px 5px; font-size: 11px; }
.ma-params select { padding: 2px 4px; font-size: 11px; }
.ma-params .icon-button { width: 26px; height: 26px; margin-left: auto; }
.ma-warnings { margin: 8px 0 0; padding-left: 16px; color: #8a5a12; font-size: 11px; line-height: 1.45; }
.ma-warnings:empty { display: none; }
.ma-json { margin-top: 12px; font-size: 11px; }
.ma-json summary { color: #627558; cursor: pointer; }
.ma-ai { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ma-ai-actions { display: flex; gap: 6px; margin: 6px 0 4px; }
.ma-ai > .button { margin-top: 6px; }
.motion-ask .modal-actions { align-items: center; }
.motion-ask .ma-spacer { flex: 1; }
@media (max-width: 760px) { .ma-grid { grid-template-columns: 1fr; } }
