/* ============================================================
   ASTER PROTOTYPE · interaction & motion layer
   Loaded after the design system. Prototype-surface only.
   ============================================================ */

/* ---------- Motion primitives ---------- */
@keyframes ap-fade-in        { from { opacity: 0; } to { opacity: 1; } }
@keyframes ap-scale-in       { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes ap-slide-up       { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes ap-rise           { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ap-pop            { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes ap-spin           { to { transform: rotate(360deg); } }
@keyframes ap-shimmer        { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes ap-pulse-dot      { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes ap-countdown      { from { width: 100%; } to { width: 0%; } }

/* ---------- Modal / dialog ---------- */
.ap-backdrop {
  animation: ap-fade-in 160ms ease-out;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.ap-dialog { animation: ap-scale-in 200ms cubic-bezier(0.2, 0.9, 0.3, 1.1); }

/* ---------- Toast ---------- */
.ap-toast { animation: ap-slide-up 220ms cubic-bezier(0.2, 0.9, 0.3, 1.15); }

/* ---------- Cards / rows ---------- */
.ap-rise { animation: ap-rise 240ms ease-out both; }
.ap-hover-lift { transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease; }
.ap-hover-lift:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.ap-row { transition: background 120ms ease; }
.ap-row:hover { background: var(--surface-sunken); }

/* ---------- Chips / segmented ---------- */
.ap-chip {
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease, transform 90ms ease;
  user-select: none;
}
.ap-chip:active { transform: scale(0.96); }

/* ---------- Tabs ---------- */
.ap-tab { position: relative; transition: color 140ms ease; }
.ap-tab::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--brand); border-radius: 2px 2px 0 0;
  transform: scaleX(0); transition: transform 180ms ease;
}
.ap-tab[data-active="true"]::after { transform: scaleX(1); }

/* ---------- Buttons / focus ---------- */
.ap-pressable { transition: transform 90ms ease, opacity 120ms ease; }
.ap-pressable:active { transform: scale(0.97); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Loading ---------- */
.ap-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-default); border-top-color: var(--brand);
  animation: ap-spin 700ms linear infinite; display: inline-block; vertical-align: -2px;
}
.ap-skeleton {
  border-radius: var(--radius-card);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-card) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: ap-shimmer 1.3s linear infinite;
}
.ap-typing-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-subtle);
  display: inline-block; animation: ap-pulse-dot 1.1s ease infinite;
}
.ap-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ap-typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* ---------- Success mark ---------- */
.ap-pop { animation: ap-pop 380ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }

/* ---------- Countdown bar ---------- */
.ap-countdown-track {
  height: 4px; border-radius: 2px; background: var(--warning-soft); overflow: hidden;
}
.ap-countdown-fill { height: 100%; background: var(--warning); border-radius: 2px; }

/* ---------- Level bar segments ---------- */
.ap-levelbar-seg { transition: width 500ms cubic-bezier(0.2, 0.8, 0.3, 1); }

/* ---------- Scroll areas ---------- */
.ap-scroll { scrollbar-width: thin; scroll-behavior: smooth; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ap-backdrop, .ap-dialog, .ap-toast, .ap-rise, .ap-pop { animation: none; }
  .ap-hover-lift, .ap-chip, .ap-tab, .ap-tab::after, .ap-pressable, .ap-levelbar-seg { transition: none; }
}
