/* Animation pickers, motion backgrounds and small editor motion. Tokens come from app.css. */

/* ---------- Animation panel ---------- */
.an-panel { display: flex; flex-direction: column; gap: 10px; }
.an-tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 2px; }
.an-tabs button { position: relative; border: 0; background: none; color: var(--text-2); font: 700 12px var(--font); padding: 7px 4px; border-radius: 4px; cursor: pointer; transition: background .15s, color .15s; }
.an-tabs button.on { background: var(--accent); color: var(--on-accent); }
.an-tabs button.set::after { content: ''; position: absolute; top: 5px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.an-tabs button.on.set::after { background: var(--on-accent); }
.an-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; animation: an-panel-in .25s ease both; }
.an-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 0 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text-2); cursor: pointer; overflow: hidden; transition: border-color .15s, transform .15s, background .15s; }
.an-tile:hover { border-color: var(--border-2); transform: translateY(-1px); }
.an-tile.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.an-tile em { font: 600 10.5px var(--font); font-style: normal; line-height: 1.1; text-align: center; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.an-stage { width: 100%; height: 44px; display: grid; place-items: center; background: var(--stage); overflow: hidden; position: relative; }
.an-obj { display: inline-block; font: 800 17px var(--display); font-style: normal; color: #fff; line-height: 1; }
.an-tile.on .an-obj { color: var(--accent); }
.an-box { width: 20px; height: 20px; border-radius: 4px; background: #fff; }
.an-tile.on .an-box { background: var(--accent); }
.an-none { width: 18px; height: 18px; border: 2px solid var(--muted); border-radius: 50%; position: relative; }
.an-none::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); transform: translateX(-50%) rotate(45deg); }
.an-words b, .an-letters b { display: inline-block; font-weight: inherit; }
.an-draw { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; }
.an-tile.on .an-draw { stroke: var(--accent); }

/* Previews play on hover and on the chosen tile once. */
.an-tile:hover .an-in, .an-tile.on .an-in { animation: var(--k) .9s cubic-bezier(.2, .8, .2, 1) both; }
.an-tile:hover .an-out, .an-tile.on .an-out { animation: var(--k) .9s cubic-bezier(.6, 0, .8, .2) reverse both; }
.an-tile:hover .an-loop, .an-tile.on .an-loop { animation: var(--k) 1.2s ease-in-out infinite; }
.an-tile:hover .an-words b, .an-tile.on .an-words b { animation: an-rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.an-tile:hover .an-words b + b, .an-tile.on .an-words b + b { animation-delay: .18s; }
.an-tile:hover .an-letters b, .an-tile.on .an-letters b { animation: an-letter .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 60ms); }
.an-tile:hover .an-draw, .an-tile.on .an-draw { animation: an-draw 1s ease both; }

.an-k-fade { --k: an-fade; } .an-k-pop { --k: an-pop; } .an-k-slide { --k: an-slide; } .an-k-rise { --k: an-rise; }
.an-k-drop { --k: an-drop; } .an-k-left { --k: an-left; } .an-k-right { --k: an-right; } .an-k-zoom { --k: an-zoom; }
.an-k-blur { --k: an-blur; } .an-k-bounce { --k: an-bounce; } .an-k-spin { --k: an-spin; } .an-k-flip { --k: an-flip; }
.an-k-stretch { --k: an-stretch; } .an-k-wipe { --k: an-wipe; } .an-k-type { --k: an-type; } .an-k-glitch { --k: an-glitch; }
.an-k-lift { --k: an-lift; }
.an-l-pulse { --k: an-l-pulse; } .an-l-float { --k: an-l-float; } .an-l-wiggle { --k: an-l-wiggle; } .an-l-swing { --k: an-l-swing; }
.an-l-shake { --k: an-l-shake; } .an-l-heartbeat { --k: an-l-heartbeat; } .an-l-spin { --k: an-l-spin; } .an-l-flicker { --k: an-l-flicker; }
.an-l-hue { --k: an-l-hue; } .an-l-glitch { --k: an-glitch; }
.an-l-spin { animation-timing-function: linear !important; }

@keyframes an-fade { from { opacity: 0; } }
@keyframes an-pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } }
@keyframes an-slide { from { transform: translateY(8px); opacity: 0; } }
@keyframes an-rise { from { transform: translateY(18px); opacity: 0; filter: blur(3px); } }
@keyframes an-lift { from { transform: translateY(-18px); opacity: 0; filter: blur(3px); } }
@keyframes an-drop { 0% { transform: translateY(-34px); opacity: 0; } 45% { transform: translateY(0); opacity: 1; } 65% { transform: translateY(-8px); } 82% { transform: translateY(0); } 92% { transform: translateY(-2px); } }
@keyframes an-left { from { transform: translateX(-34px); opacity: 0; filter: blur(2px); } }
@keyframes an-right { from { transform: translateX(34px); opacity: 0; filter: blur(2px); } }
@keyframes an-zoom { from { transform: scale(2.6); opacity: 0; filter: blur(3px); } }
@keyframes an-blur { from { filter: blur(8px); opacity: 0; transform: scale(1.1); } }
@keyframes an-bounce { 0% { transform: scale(0); } 40% { transform: scale(1.25); } 60% { transform: scale(.88); } 80% { transform: scale(1.06); } }
@keyframes an-spin { from { transform: rotate(-200deg) scale(0); opacity: 0; } }
@keyframes an-flip { 0% { transform: scaleY(0); } 60% { transform: scaleY(1.15); } }
@keyframes an-stretch { 0% { transform: scale(1.9, 0); } 45% { transform: scale(.85, 1.2); } 70% { transform: scale(1.06, .94); } }
@keyframes an-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes an-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.an-k-type { animation-timing-function: steps(4) !important; }
@keyframes an-letter { from { transform: translateY(12px) rotate(-20deg) scale(.4); opacity: 0; } }
@keyframes an-glitch { 0%, 100% { text-shadow: none; transform: none; } 10% { text-shadow: -3px 0 #00f0ff, 3px 0 #ff2bd6; transform: translateX(2px); } 20% { text-shadow: 3px 1px #00f0ff, -3px -1px #ff2bd6; transform: translateX(-3px); opacity: .5; } 30% { text-shadow: -2px 0 #00f0ff, 2px 0 #ff2bd6; transform: none; opacity: 1; } 45% { text-shadow: none; } 55% { text-shadow: 4px 0 #00f0ff, -4px 0 #ff2bd6; transform: translateX(1px); } 65% { text-shadow: none; transform: none; } }
@keyframes an-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes an-l-pulse { 50% { transform: scale(1.18); } }
@keyframes an-l-float { 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes an-l-wiggle { 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes an-l-swing { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
@keyframes an-l-shake { 20% { transform: translate(-2px, 1px); } 40% { transform: translate(2px, -1px); } 60% { transform: translate(-2px, -1px); } 80% { transform: translate(2px, 1px); } }
@keyframes an-l-heartbeat { 10% { transform: scale(1.2); } 20% { transform: scale(1); } 30% { transform: scale(1.14); } 45% { transform: scale(1); } }
@keyframes an-l-spin { to { transform: rotate(360deg); } }
@keyframes an-l-flicker { 0%, 100% { opacity: 1; } 8% { opacity: .2; } 12% { opacity: 1; } 50% { opacity: 1; } 54% { opacity: .35; } 58% { opacity: 1; } }
@keyframes an-l-hue { to { filter: hue-rotate(360deg); } }
.an-l-hue.an-obj { color: #ff4d6d; } .an-l-hue.an-box { background: #ff4d6d; }

.an-foot { display: flex; align-items: center; gap: 8px; }
.an-foot .seg { flex: 1; }
.an-foot .seg button { font-size: 11px; padding: 5px 4px; }

/* ---------- Motion backgrounds ---------- */
.bd-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.bd-tile { display: flex; flex-direction: column; gap: 4px; padding: 3px 3px 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text-2); cursor: pointer; transition: border-color .15s, transform .15s; }
.bd-tile:hover { transform: translateY(-1px); border-color: var(--border-2); }
.bd-tile.on { border-color: var(--accent); color: var(--text); }
.bd-tile span { height: 34px; border-radius: 4px; background-size: cover; }
.bd-tile em { font: 600 10.5px var(--font); font-style: normal; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-colors { display: flex; gap: 6px; }
.bd-colors input { width: 34px; height: 28px; padding: 0; border: 1px solid var(--border-2); border-radius: 4px; background: none; cursor: pointer; }
.bd-lib { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bd-swatch { position: relative; aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--border-2); cursor: pointer; overflow: hidden; background-size: cover; transition: transform .15s; }
.bd-swatch::before { content: ''; position: absolute; inset: -50%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .28) 50%, transparent 60%); transform: translateX(-60%); transition: transform .6s ease; }
.bd-swatch:hover { transform: scale(1.05); }
.bd-swatch:hover::before { transform: translateX(60%); }
.bd-swatch em { position: absolute; left: 4px; right: 4px; bottom: 4px; font: 700 9.5px var(--font); font-style: normal; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Editor motion ---------- */
@keyframes an-panel-in { from { opacity: 0; transform: translateY(6px); } }
.lib-pane:not(.hidden) { animation: an-panel-in .22s ease both; }
.swatch, .theme, .el-btn, .emoji-btn, .shape-btn { transition: transform .15s cubic-bezier(.2, .8, .2, 1), border-color .15s; }
.el-btn:active, .emoji-btn:active, .shape-btn:active, .swatch:active, .bd-swatch:active, .an-tile:active, .bd-tile:active { transform: scale(.94); }

@media (prefers-reduced-motion: reduce) {
  .an-grid, .lib-pane:not(.hidden) { animation: none; }
  .an-tile .an-obj, .an-tile b, .an-draw { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

/* Ticker and equalizer loop previews */
.an-l-marquee { --k: an-l-marquee; } .an-l-marquee-r { --k: an-l-marquee-r; } .an-l-eq { --k: an-l-eq; }
.an-tile:hover .an-l-marquee, .an-tile.on .an-l-marquee, .an-tile:hover .an-l-marquee-r, .an-tile.on .an-l-marquee-r { animation-timing-function: linear !important; }
@keyframes an-l-marquee { from { transform: translateX(26px); } to { transform: translateX(-26px); } }
@keyframes an-l-marquee-r { from { transform: translateX(-26px); } to { transform: translateX(26px); } }
@keyframes an-l-eq { 0%, 100% { transform: scaleY(1); } 25% { transform: scaleY(.3); } 50% { transform: scaleY(.8); } 75% { transform: scaleY(.45); } }

/* Newer entrances, exits and loops */
.an-k-slam { --k: an-slam; } .an-k-tilt { --k: an-tilt; } .an-k-mask { --k: an-mask; } .an-k-count { --k: an-count; } .an-k-scramble { --k: an-glitch; } .an-k-fall { --k: an-fall; }
.an-l-bob { --k: an-l-bob; } .an-l-jelly { --k: an-l-jelly; } .an-l-orbit { --k: an-l-orbit; } .an-l-drift { --k: an-l-drift; } .an-l-blink { --k: an-l-blink; }
.an-l-blink { animation-timing-function: steps(1) !important; } .an-l-orbit { animation-timing-function: linear !important; }
@keyframes an-slam { 0% { transform: scale(3); opacity: 0; } 55% { transform: scale(1); opacity: 1; } 65% { transform: translate(3px, -2px); } 75% { transform: translate(-3px, 2px); } 85% { transform: translate(2px, 1px); } }
@keyframes an-tilt { from { transform: translateY(14px) rotate(-16deg); opacity: 0; } 70% { transform: rotate(3deg); opacity: 1; } }
@keyframes an-mask { from { clip-path: inset(0 0 0 0); transform: translateY(110%); } to { clip-path: inset(0 0 0 0); transform: none; } }
@keyframes an-count { from { opacity: 0; transform: translateY(10px); filter: blur(2px); } }
@keyframes an-fall { from { transform: translateY(40px) rotate(24deg); opacity: 0; } }
@keyframes an-l-bob { 0%, 100% { transform: none; } 50% { transform: translateY(-8px); } }
@keyframes an-l-jelly { 0%, 100% { transform: none; } 25% { transform: scale(1.12, .88); } 50% { transform: scale(.92, 1.08); } 75% { transform: scale(1.04, .96); } }
@keyframes an-l-orbit { 0% { transform: translate(5px, 0); } 25% { transform: translate(0, 5px); } 50% { transform: translate(-5px, 0); } 75% { transform: translate(0, -5px); } 100% { transform: translate(5px, 0); } }
@keyframes an-l-drift { 0%, 100% { transform: translateX(-6px) rotate(-1deg); } 50% { transform: translateX(6px) rotate(1deg); } }
@keyframes an-l-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
