/*
 * Vectura Studio — skin/motion.css
 *
 * Keyframe library for skin-driven animations. Mode-independent: every skin uses these
 * same keyframes. Tokens (`--motion-*`) parameterize duration/ease via App.applyTheme().
 *
 * Sourced verbatim from docs/design/themes-mockup.html (lines 491–549). Reduced-motion
 * fallbacks collapse all durations to ≤80 ms or skip outright.
 */

/* Slider thumb release halo — fired on input release. */
@keyframes thumb-release {
  0% {
    box-shadow: 0 0 0 1.5px var(--ui-accent), 0 0 0 7px var(--ui-accent-2);
    transform: scale(1.15);
  }
  100% {
    box-shadow: 0 0 0 1.5px var(--ui-accent), 0 0 0 0 transparent;
    transform: scale(1);
  }
}

/* Slider fill-side pulse — applied to .sld-fx-wrap.fx-active::after. */
@keyframes fx-pulse-fill {
  0% {
    opacity: 0;
    box-shadow: 0 0 0 0 transparent;
  }
  12% {
    opacity: 0.36;
    box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.22);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 0 transparent;
  }
}

/* Button selection blink — applied via .btn-pulse class. */
@keyframes btn-press {
  0%   { opacity: 1; }
  28%  { opacity: 0.42; }
  100% { opacity: 1; }
}

/* Randomize button — hover glow pulse. */
@keyframes rand-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px -1px rgba(217, 70, 239, 0.30); }
  50%       { box-shadow: 0 0 16px  0px rgba(217, 70, 239, 0.55); }
}

/* Randomize button — spark particle scatter (uses --dx, --dy CSS vars per particle). */
@keyframes rand-spark-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0);
    opacity: 0;
  }
}

/* Preset save pip — one-time glow + scale pulse when it appears (dirty state).
   The class is added by JS on the hidden→visible transition; the global
   reduced-motion guard at the bottom of this file neutralizes it. */
@keyframes preset-pip-pulse {
  0%   { transform: scale(0.6); opacity: 0; box-shadow: 0 0 0 0 var(--ui-accent-2, rgba(99,102,241,0.5)); }
  40%  { transform: scale(1.12); opacity: 1; box-shadow: 0 0 0 6px var(--ui-accent-2, rgba(99,102,241,0.45)); }
  100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.hg-preset-save-pip.is-pulsing { animation: preset-pip-pulse 0.6s ease-out; }

/* Indeterminate progress bar — Phase 4. Slides a 30% bar from -30% → 100%. */
@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(333%); }
}

/* Indeterminate progress bar component (used by UI.overlays.ProgressBar). */
.vectura-progress-bar {
  position: relative;
  width: 100%;
  height: 3px;
  background: var(--ui-border, rgba(120, 130, 145, 0.25));
  border-radius: 2px;
  overflow: hidden;
}
.vectura-progress-bar > .vectura-progress-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: var(--ui-accent, #4e9ee1);
  border-radius: 2px;
  animation: progress-indeterminate 1.05s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

/* Wallpaper snapping feedback — flash auto-changed chips + fade the line.
   Namespaced .mp-snap-* per the mirror-panel CSS contract. Implemented with a
   transition (not a @keyframes) so the global reduced-motion guard at the
   bottom of this file neutralizes it without a per-keyframe fallback entry.
   The .mp-snap-flash class is added on snap and removed ~1.4s later by JS; the
   eased box-shadow transition produces the ring pulse on add + fade on remove.
   The compound `.mp-chip.mp-snap-flash` selector out-specifies the base
   `.mp-chip` transition in components.css, so the box-shadow easing applies
   regardless of stylesheet load order. */
.mp-root .mp-chip.mp-snap-flash {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mp-type-color) 55%, transparent);
  transition: box-shadow 0.6s ease;
}
.mp-root .mp-snap-line {
  opacity: 0;
  transition: opacity 0.18s ease;
}
.mp-root .mp-snap-line.mp-snap-show { opacity: 1; }

/* Reduced-motion: collapse durations and disable expensive halos. */
@media (prefers-reduced-motion: reduce) {
  .mp-root .mp-chip.mp-snap-flash { box-shadow: none !important; }
  .ctrl-slider.just-released::-webkit-slider-thumb,
  .sld-fx-wrap.fx-active::after,
  .btn-pulse {
    animation-duration: 80ms !important;
    animation-iteration-count: 1 !important;
  }
  .vectura-progress-bar > .vectura-progress-bar-fill {
    animation: none;
    width: 100%;
    opacity: 0.55;
  }
  #btn-randomize-params  { animation: none !important; }
  .rand-spark-overlay    { display: none !important; }
  .hg-preset-save-pip.is-pulsing { animation: none !important; }
}

/* === Collapsible control sections (UX1 / WU10) ===
 * `{ type:'section', collapsed:true }` renders `.control-section--collapsible`
 * with a clickable `.control-section-toggle` header and a `.control-section-body`
 * that collects the controls following the section. Closed = `.is-collapsed`.
 *
 * Collapse animation uses a grid-template-rows 0fr↔1fr transition (NOT a
 * display:none↔max-height swap, per CLAUDE.md — that swap causes a visual gap).
 * The body is a single-row grid whose row track animates between 0fr (closed)
 * and 1fr (open); an inner min-height:0 overflow:hidden wrapper clips the
 * content as the track collapses. Reuses the shared panel-slide motion tokens. */
.control-section--collapsible > .control-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  /* Inherit the .control-section-title typography (size/transform/spacing/color). */
  font: inherit;
  color: inherit;
}
.control-section--collapsible > .control-section-toggle .control-section-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  opacity: 0.7;
  transform: rotate(90deg);
  transition: transform var(--motion-panel-slide-dur, 220ms) var(--motion-panel-slide-ease, ease);
}
.control-section--collapsible.is-collapsed > .control-section-toggle .control-section-caret {
  transform: rotate(0deg);
}
/* The SECTION is the grid (header row = auto, body row = 1fr→0fr). The body
 * holds all controls in normal block flow as a single grid item, so the collapse
 * works for ANY number of controls. (Putting the grid on the body itself would
 * leave the 2nd+ controls in implicit `auto` rows that never collapse — only the
 * first control's row would animate.) */
.control-section--collapsible {
  display: grid;
  grid-template-rows: auto 1fr;
  transition: grid-template-rows var(--motion-panel-slide-dur, 220ms) var(--motion-panel-slide-ease, ease);
}
.control-section--collapsible.is-collapsed {
  grid-template-rows: auto 0fr;
}
.control-section--collapsible > .control-section-body {
  overflow: hidden;
  min-height: 0;
}

/* Empty-state section hint (R3/UX10 / WU9) — small muted line. */
.control-section-hint {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--ui-text-2, rgba(150, 160, 175, 0.85));
  opacity: 0.85;
  margin: 0.35rem 0 0.5rem;
}

/* Reduced-motion: drop the caret + row-track animation. */
@media (prefers-reduced-motion: reduce) {
  .control-section--collapsible > .control-section-toggle .control-section-caret,
  .control-section--collapsible {
    transition: none !important;
  }
}

/* === HUD: canvas toast motion (Lane F HUD-3) === */
.canvas-toast {
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}
@media (prefers-reduced-motion: reduce) {
  .canvas-toast {
    transition: none;
    transform: translate(-50%, 0);
  }
}
/* === END HUD toast motion === */

/* === TB: Contextual Task Bar motion (Phase 2 Lane G) === */
/* TB-8: fade/slide show-hide ≤120ms. The pill sits in #viewport-container and
   nudges up 4px on entry. */
.ctxbar {
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
  transform: translateY(4px);
}
.ctxbar.is-visible { transform: translateY(0); }
/* TB-2: "Show panel" blue attention pulse (2 pulses over ~1s) around the
   relevant docked panel. --ctxbar-pulse-count is set inline by context-bar.js. */
@keyframes ctxbar-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(78, 158, 225, 0); }
  50% { box-shadow: 0 0 0 3px var(--ui-accent, #4e9ee1); }
}
.ctxbar-pulse {
  animation: ctxbar-pulse 500ms ease-in-out var(--ctxbar-pulse-count, 2);
  border-radius: inherit;
}
/* Dropdown caret pivot. The 180° rotation itself lives in components.css
   because it encodes STATE (which way the menu opens); only the animation of
   it belongs here, so the reduced-motion block below can remove the motion
   without ever leaving an arrow pointing away from its menu. */
.ctxbar-text-caret,
.ctxbar-text-size-caret {
  transition: transform var(--motion-ctxbar-caret-pivot-dur, 180ms)
              var(--motion-ctxbar-caret-pivot-ease, ease);
}
@media (prefers-reduced-motion: reduce) {
  .ctxbar {
    transition: none;
    transform: translateY(0);
  }
  .ctxbar-pulse { animation: none; }
  /* Dropdown caret up/down pivot: drop the TRANSITION only. The rotation is
     the state, so it must survive — the arrow still points the way its menu
     opens, it just gets there instantly. */
  .ctxbar-text-caret,
  .ctxbar-text-size-caret { transition: none; }
}
/* === END TB task-bar motion === */

/* === TUX-034: touch hold ring + pop ===
   Durations come from Vectura.TOUCH_HOLD via inline custom properties
   (--th-fill-ms on the ring, --th-pop-ms / --th-pop-scale on the card). */
@keyframes touch-hold-fill {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
@keyframes touch-hold-pop {
  0% { transform: scale(1); }
  50% { transform: scale(var(--th-pop-scale, 1.03)); }
  100% { transform: scale(1); }
}
.touch-hold-ring-fill { animation: touch-hold-fill var(--th-fill-ms, 350ms) linear forwards; }
.touch-hold-pop { animation: touch-hold-pop var(--th-pop-ms, 120ms) ease-out; }
@media (prefers-reduced-motion: reduce) {
  .touch-hold-pop { animation: none; }
  .touch-hold-ring-fill { animation: none; transform: scale(1); }
}
/* === END TUX-034 motion === */

/* Start Page: the overlay eases in over the editor (stilled for reduced-motion users). */
@keyframes sp-in {
  from { opacity: 0; transform: scale(0.992); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sp { animation: none; }
  .sp *, .sp *::before, .sp *::after { transition-duration: 0s !important; }
}
/* ===== Start Page — art motion (src/ui/start-page/ink.js) ===== */
.sp-ink-draw {
  transition: opacity 380ms ease-out;
}
.sp-ink-draw.sp-ink-draw-out { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .sp-ink-draw,
  .sp-ink-svg,
  .sp-ink-canvas { transition: none; }
  .sp-ink-draw { display: none; }
  .sp-ink-drawing .sp-ink-svg,
  .sp-ink-drawing .sp-ink-canvas { opacity: 1; }
}
/* Still mode mirrors reduced motion (set by StartPageInk.setMotion). */
html[data-sp-motion="still"] .sp-ink-draw { display: none; transition: none; }
.sp-scene-hint { transition: opacity .4s; }
@media (prefers-reduced-motion: reduce) { .sp-scene-hint { transition: none; } }
html[data-sp-motion="still"] .sp-ink-drawing .sp-ink-svg,
html[data-sp-motion="still"] .sp-ink-drawing .sp-ink-canvas { opacity: 1; }
/* ===== END Start Page — art motion ===== */

/* ===== Start Page - cover motion ===== */
@keyframes sp-cv-in { from { opacity: 0; transform: translateY(8px); } }
.sp-cv-stage > * { animation: sp-cv-in 420ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes sp-roll { to { transform: rotate(360deg); } }
.sp-dice-ico.sp-roll { animation: sp-roll 520ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.sp-pre { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .sp-cv-stage > *, .sp-dice-ico.sp-roll { animation: none; }
  .sp-rail, .sp-colo-wrap, .sp-colo, .sp-bar, .sp-kk { transition: none !important; }
}
html[data-sp-motion="still"] .sp, html[data-start-page-still] .sp,
html[data-sp-motion="still"] .sp-cv-stage > *,
html[data-sp-motion="still"] .sp-dice-ico.sp-roll { animation: none; }
html[data-sp-motion="still"] .sp *, html[data-sp-motion="still"] .sp *::before, html[data-sp-motion="still"] .sp *::after { transition-duration: 0s !important; transition-delay: 0s !important; }
/* ===== END Start Page - cover motion ===== */

/* === Migrated from styles.css (Unit 2.6: reduced-motion fallback, 2026-05-20) === */

/* ===== Start Page - Plates motion ===== */
/* motion: still / reduced motion means no transitions on the plate itself */
html[data-sp-motion="still"] .spl,html[data-sp-motion="still"] .spl-disc{transition:none}
@media (prefers-reduced-motion:reduce){.spl,.spl-disc{transition:none}}

.sp-pl { transition: grid-template-rows 380ms var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)), opacity 300ms var(--ease, ease), visibility 0s linear 0s; transition-delay: var(--sp-pl-delay, 0ms); }
.sp-pl[data-off] { transition: grid-template-rows 300ms cubic-bezier(0.4, 0, 0.2, 1), opacity 220ms ease, visibility 0s linear 320ms; transition-delay: var(--sp-pl-delay, 0ms); }
.sp-pl[data-instant], .sp-pl[data-instant][data-off] { transition: none; }
.sp-pl-btn, .spl-tools .sp-pl-tool { transition: background-color var(--dur-fast, 150ms), border-color var(--dur-fast, 150ms), color var(--dur-fast, 150ms); }
html[data-sp-motion="still"] .sp-pl, html[data-sp-motion="still"] .sp-pl[data-off] { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .sp-pl, .sp-pl[data-off], .sp-pl-btn, .spl-tools .sp-pl-tool { transition: none; }
}
/* Plate editor special fills: @property + keyframes, fan, arrange, use-as-cover */
@property --sp-a{syntax:"<angle>";inherits:false;initial-value:0deg}
:root:not([data-sp-motion="still"]) .spl[data-bgfill="iridescent-animated"],:root:not([data-sp-motion="still"]) .spl[data-txfill="iridescent-animated"]{ animation: spe-turn 14s linear infinite; }
@keyframes spe-turn{to{--sp-a:360deg}}
@media (prefers-reduced-motion: reduce) {
  .spl[data-bgfill], .spl[data-txfill] { animation: none !important; }
  .spe-sec-h::before { transition: none; }
  .sp-arr-list.dnd .sp-arr-row:not(.dragging), .sp-fan-card, .sp-fan-scrim, .sp-fan-head, .sp-fan-cap, .sp-fan-sheet, .sp-lt.sp-lt-new, .sp-pf.sp-pf-old { transition: none !important; }
}
/* ===== END Start Page - Plates motion ===== */
/* ===== Start Page - P3 motion (hover effects, lift cards, live 3D) ===== */
@keyframes sp-hfx-glare { 0% { opacity: 0; transform: translateX(0) skewX(-14deg); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateX(420%) skewX(-14deg); } }
.sp-hfx-wrap.xfade { transition: opacity 180ms linear; }
.sp-hfx-wrap.still { transition: opacity 300ms linear; }
.sp-hfx-glare.go::before { animation: sp-hfx-glare 900ms cubic-bezier(0.3, 0.6, 0.3, 1) both; }
.sp-cm-switch .sp-switch-knob { transition: transform var(--dur-fast, 150ms) var(--ease, ease); }
html[data-sp-motion="still"] .sp-hfx-glare::before, html[data-start-page-still] .sp-hfx-glare::before { animation: none; }
@media (prefers-reduced-motion: reduce) {
  /* sp-hfx-glare: the glare sweep is switched off; nothing animates, hover effects show nothing or their still frame */
  .sp-hfx-glare::before, .sp-hfx-glare.go::before { animation: none; opacity: 0; }
  .sp-hfx-wrap.xfade, .sp-hfx-wrap.still, .sp-cm-switch .sp-switch-knob, .sp-pick-btn { transition: none; }
}
/* ===== END Start Page - P3 motion ===== */


/* Accessibility: respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === ISO: isolation breadcrumb fade (Phase 2 Lane I — ISO-1/2) ===
   Slim fade on show/hide of the breadcrumb strip + top-edge indicator. The
   global prefers-reduced-motion rule above collapses these to ~0ms. */
.iso-breadcrumb,
.iso-edge-indicator {
  transition: opacity 160ms ease, visibility 160ms ease;
}
/* === END ISO motion === */
