/* ==========================================================================
   AGY Motion, Micro-Interactions & Performance Layer (css/motion.css)
   Apple Cupertino Spring Physics • Staggered Scroll Reveal • Magnetic Tactility
   Spotlight Surface Refinement • Reduced-Motion & Keyboard Accessibility
   ========================================================================== */

:root {
  --ag-ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ag-ease-spring: cubic-bezier(0.34, 1.38, 0.48, 1);
  --ag-ease-smooth: cubic-bezier(0.22, 0.68, 0, 1);
  --ag-reveal-distance: 22px;
  --ag-reveal-duration: 0.68s;
}

/* --------------------------------------------------------------------------
   1. IntersectionObserver Staggered Scroll Reveal (.ag-reveal)
   -------------------------------------------------------------------------- */
.ag-reveal {
  opacity: 0;
  transform: translate3d(0, var(--ag-reveal-distance), 0) scale(0.988);
  transition:
    opacity var(--ag-reveal-duration) var(--ag-ease-out-expo),
    transform var(--ag-reveal-duration) var(--ag-ease-out-expo);
  transition-delay: var(--ag-stagger-delay, 0ms);
  will-change: opacity, transform;
}

.ag-reveal.ag-reveal-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: auto;
}

/* --------------------------------------------------------------------------
   2. 3D Perspective Tilt & Spotlight Surface Delicacy (.spotlight-surface)
   -------------------------------------------------------------------------- */
.spotlight-surface {
  position: relative;
  overflow: hidden;
  transform: perspective(1050px)
    rotateX(var(--tilt-rx, 0deg))
    rotateY(var(--tilt-ry, 0deg))
    translate3d(0, var(--tilt-lift, 0px), 0);
  transition:
    transform 0.42s var(--ag-ease-out-expo),
    box-shadow 0.42s var(--ag-ease-out-expo),
    border-color 0.32s ease;
  backface-visibility: hidden;
}

.spotlight-surface.is-pointer-active {
  transition:
    transform 0.12s linear,
    box-shadow 0.28s var(--ag-ease-out-expo),
    border-color 0.24s ease;
}

.spotlight-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.38s var(--ag-ease-out-expo);
  background: radial-gradient(
    420px circle at var(--spot-x, 50%) var(--spot-y, 50%),
    rgba(0, 113, 227, 0.11),
    rgba(255, 255, 255, 0.04) 45%,
    transparent 72%
  );
}

html.light .spotlight-surface::before {
  background: radial-gradient(
    400px circle at var(--spot-x, 50%) var(--spot-y, 50%),
    rgba(0, 113, 227, 0.085),
    rgba(255, 255, 255, 0.45) 42%,
    transparent 70%
  );
}

.spotlight-surface:hover::before,
.spotlight-surface:focus-within::before {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   3. Magnetic & Spring Tactile Buttons (.ag-magnetic, .btn, .pill-control, .chip)
   -------------------------------------------------------------------------- */
.btn,
.pill-control,
.chip,
.mmw-preset-btn,
.di-action-btn {
  --mag-x: 0px;
  --mag-y: 0px;
  transform: translate3d(var(--mag-x), var(--mag-y), 0) scale(1);
  transition:
    transform 0.38s var(--ag-ease-spring),
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    box-shadow 0.26s var(--ag-ease-out-expo);
}

.btn.is-magnetic-active,
.pill-control.is-magnetic-active,
.chip.is-magnetic-active {
  transition:
    transform 0.1s linear,
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    box-shadow 0.22s ease;
}

.btn:active,
.pill-control:active,
.chip:active,
.mmw-preset-btn:active,
.di-action-btn:active {
  transform: translate3d(var(--mag-x), calc(var(--mag-y) + 1px), 0) scale(0.96);
  transition-duration: 0.09s;
}

/* --------------------------------------------------------------------------
   4. Animated Skill Bars & Filter Grid Micro-Transitions
   -------------------------------------------------------------------------- */
.skill-fill {
  transform-origin: left center;
  transform: scaleX(var(--skill-scale, 1));
  transition: transform 0.95s var(--ag-ease-out-expo);
}

.skill-item.ag-reveal:not(.ag-reveal-visible) .skill-fill {
  --skill-scale: 0.04;
}

.skill-item.ag-reveal.ag-reveal-visible .skill-fill {
  --skill-scale: 1;
}

.craft-card[data-category] {
  transition:
    opacity 0.32s var(--ag-ease-out-expo),
    transform 0.38s var(--ag-ease-out-expo),
    box-shadow 0.35s ease;
}

.craft-card.ag-filter-hiding {
  opacity: 0 !important;
  transform: translate3d(0, 10px, 0) scale(0.96) !important;
  pointer-events: none;
}

/* Details / Accordion smooth chevron & content reveal */
details summary {
  transition: color 0.2s ease, background-color 0.2s ease;
}

details[open] > *:not(summary) {
  animation: ag-details-expand 0.34s var(--ag-ease-out-expo) both;
}

@keyframes ag-details-expand {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* --------------------------------------------------------------------------
   5. Keyboard Focus-Visible Ring & High-Contrast Polish (Dawn & Dusk)
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent, #0071e3);
  outline-offset: 2px;
}

.cmdk-item.key-focused,
.cmdk-item:focus-visible {
  transform: translate3d(3px, 0, 0);
  transition: transform 0.18s var(--ag-ease-out-expo), background-color 0.16s ease;
}

/* --------------------------------------------------------------------------
   6. Accessibility: Respect prefers-reduced-motion
   -------------------------------------------------------------------------- */
@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;
  }

  .ag-reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .spotlight-surface,
  .btn,
  .pill-control,
  .chip {
    transform: none !important;
    transition: none !important;
  }
}
