/* ================================================================
   public/css/motion.css
   Motion Design & Animations — Sapere Plus
   
   Philosophy:
   - Subtle, slow, elegant
   - Meditative, precise
   - Intentional, calm, observational
   - No flashy effects, aggressive transitions, or gamified motion
   
   Includes:
   - Page transitions
   - Focus circle animations
   - Editorial fades
   - Subtle line tracing
   - Hover states
   - Layered reveal systems
   - Loading animations
================================================================ */

/* ──────────────────────────────────────────────────────────────
   CORE MOTION VARIABLES
   ────────────────────────────────────────────────────────────– */

:root {
  /* Animation durations */
  --anim-fast: 0.3s;
  --anim-base: 0.5s;
  --anim-slow: 0.8s;
  --anim-slower: 1.2s;
  --anim-slowest: 1.8s;

  /* Easing functions */
  --ease-in-quad: cubic-bezier(0.11, 0, 0.5, 0);
  --ease-out-quad: cubic-bezier(0.5, 1, 0.89, 1);
  --ease-in-out-quad: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-in-cubic: cubic-bezier(0.32, 0, 0.67, 0);
  --ease-out-cubic: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-organic: cubic-bezier(0.25, 0.25, 0.75, 0.75);
}

/* ──────────────────────────────────────────────────────────────
   KEYFRAME ANIMATIONS
   ────────────────────────────────────────────────────────────– */

/* ── Fade In / Out ─────────────────────────────────────────– */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ── Fade In Up ────────────────────────────────────────────– */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade In Down ──────────────────────────────────────────– */
@keyframes fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade In Left ──────────────────────────────────────────– */
@keyframes fade-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Fade In Right ─────────────────────────────────────────– */
@keyframes fade-in-right {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Scale In ──────────────────────────────────────────────– */
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Slide In ──────────────────────────────────────────────– */
@keyframes slide-in-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ── Expand Height ─────────────────────────────────────────– */
@keyframes expand-height {
  from {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
  }
  to {
    max-height: 500px;
    opacity: 1;
    overflow: visible;
  }
}

/* ── Collapse Height ───────────────────────────────────────– */
@keyframes collapse-height {
  from {
    max-height: 500px;
    opacity: 1;
    overflow: visible;
  }
  to {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
  }
}

/* ── Line Draw (SVG paths) ─────────────────────────────────– */
@keyframes line-draw {
  from {
    stroke-dashoffset: 100%;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* ── Subtle Pulse ──────────────────────────────────────────– */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ── Gentle Float ──────────────────────────────────────────– */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* ── Gentle Drift ──────────────────────────────────────────– */
@keyframes drift {
  0%,
  100% {
    transform: translateX(0) translateY(0);
  }
  25% {
    transform: translateX(2px) translateY(-2px);
  }
  50% {
    transform: translateX(0) translateY(4px);
  }
  75% {
    transform: translateX(-2px) translateY(0);
  }
}

/* ── Rotate (Slow) ─────────────────────────────────────────– */
@keyframes rotate-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ── Rotate Counter ────────────────────────────────────────– */
@keyframes rotate-counter {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

/* ── Shimmer ───────────────────────────────────────────────– */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ── Loading Spinner ───────────────────────────────────────– */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ──────────────────────────────────────────────────────────────
   ELEMENT ANIMATION CLASSES
   ────────────────────────────────────────────────────────────– */

/* ── Fade Effects ──────────────────────────────────────────– */
.animate-fade-in {
  animation: fade-in var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-fade-out {
  animation: fade-out var(--anim-base) var(--ease-in-cubic) forwards;
}

/* ── Entrance Animations ───────────────────────────────────– */
.animate-fade-in-up {
  animation: fade-in-up var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-fade-in-down {
  animation: fade-in-down var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-fade-in-left {
  animation: fade-in-left var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-fade-in-right {
  animation: fade-in-right var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-scale-in {
  animation: scale-in var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-slide-in-left {
  animation: slide-in-left var(--anim-slow) var(--ease-out-cubic) forwards;
}

.animate-slide-in-right {
  animation: slide-in-right var(--anim-slow) var(--ease-out-cubic) forwards;
}

.animate-slide-in-up {
  animation: slide-in-up var(--anim-slow) var(--ease-out-cubic) forwards;
}

/* ── Continuous Animations ────────────────────────────────– */
.animate-pulse {
  animation: pulse var(--anim-slower) ease-in-out infinite;
}

.animate-float {
  animation: float var(--anim-slowest) var(--ease-smooth) infinite;
}

.animate-drift {
  animation: drift 4s var(--ease-organic) infinite;
}

.animate-rotate-slow {
  animation: rotate-slow var(--anim-slowest) linear infinite;
}

.animate-rotate-counter {
  animation: rotate-counter var(--anim-slowest) linear infinite;
}

.animate-spin {
  animation: spin var(--anim-base) linear infinite;
}

/* ── Expand/Collapse ───────────────────────────────────────– */
.animate-expand {
  animation: expand-height var(--anim-base) var(--ease-out-cubic) forwards;
}

.animate-collapse {
  animation: collapse-height var(--anim-base) var(--ease-in-cubic) forwards;
}

/* ──────────────────────────────────────────────────────────────
   STAGGERED ANIMATIONS
   ────────────────────────────────────────────────────────────– */

/* Create staggered effect with nth-child delays */
.animate-stagger > * {
  animation: fade-in-up var(--anim-base) var(--ease-out-cubic) both;
}

.animate-stagger > :nth-child(1) {
  animation-delay: 0s;
}
.animate-stagger > :nth-child(2) {
  animation-delay: 0.1s;
}
.animate-stagger > :nth-child(3) {
  animation-delay: 0.2s;
}
.animate-stagger > :nth-child(4) {
  animation-delay: 0.3s;
}
.animate-stagger > :nth-child(5) {
  animation-delay: 0.4s;
}
.animate-stagger > :nth-child(n + 6) {
  animation-delay: 0.5s;
}

/* ──────────────────────────────────────────────────────────────
   HOVER & INTERACTION STATES
   ────────────────────────────────────────────────────────────– */

/* ── Gentle Hover ──────────────────────────────────────────– */
.hover-lift {
  transition:
    transform var(--anim-fast) var(--ease-smooth),
    box-shadow var(--anim-fast) var(--ease-smooth);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ── Hover Glow ────────────────────────────────────────────– */
.hover-glow {
  transition: all var(--anim-fast) var(--ease-smooth);
}

.hover-glow:hover {
  filter: drop-shadow(0 0 8px rgba(161, 75, 42, 0.2));
}

/* ── Hover Fade ────────────────────────────────────────────– */
.hover-fade {
  transition: opacity var(--anim-fast) var(--ease-smooth);
}

.hover-fade:hover {
  opacity: 0.7;
}

/* ── Hover Scale ───────────────────────────────────────────– */
.hover-scale {
  transition: transform var(--anim-fast) var(--ease-smooth);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* ── Hover Shift ───────────────────────────────────────────– */
.hover-shift-right {
  transition: transform var(--anim-fast) var(--ease-smooth);
}

.hover-shift-right:hover {
  transform: translateX(4px);
}

.hover-shift-left {
  transition: transform var(--anim-fast) var(--ease-smooth);
}

.hover-shift-left:hover {
  transform: translateX(-4px);
}

/* ── Underline Animation ───────────────────────────────────– */
.hover-underline {
  position: relative;
  transition: color var(--anim-fast) var(--ease-smooth);
}

.hover-underline::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-accent-primary);
  transition: width var(--anim-base) var(--ease-out-cubic);
}

.hover-underline:hover::after {
  width: 100%;
}

/* ──────────────────────────────────────────────────────────────
   PAGE TRANSITIONS
   ────────────────────────────────────────────────────────────– */

/* ── Exit Animation ────────────────────────────────────────– */
.page-exit {
  animation: fade-out var(--anim-base) var(--ease-in-cubic) forwards;
}

/* ── Page Content Enter ────────────────────────────────────– */
.page-content {
  animation: fade-in-up var(--anim-base) var(--ease-out-cubic) forwards;
}

/* ──────────────────────────────────────────────────────────────
   FOCUS & FOCUS CIRCLES
   ────────────────────────────────────────────────────────────– */

/* ── Rotating Focus (already in symbol-system.css) ─────────– */
.focus-rotate {
  animation: rotate-slow var(--anim-slowest) linear infinite;
}

/* ── Pulsing Focus ─────────────────────────────────────────– */
.focus-pulse {
  animation: pulse var(--anim-slow) ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────
   LOADING STATES
   ────────────────────────────────────────────────────────────– */

.loading {
  animation: pulse var(--anim-slower) ease-in-out infinite;
}

.loading-spinner {
  animation: spin var(--anim-base) linear infinite;
}

.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border-light) 0%,
    var(--color-surface-secondary) 50%,
    var(--color-border-light) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* ──────────────────────────────────────────────────────────────
   TRANSITIONS
   ────────────────────────────────────────────────────────────– */

/* ── Smooth Color Transition ───────────────────────────────– */
.transition-colors {
  transition:
    background-color var(--anim-fast) var(--ease-smooth),
    color var(--anim-fast) var(--ease-smooth),
    border-color var(--anim-fast) var(--ease-smooth);
}

/* ── Smooth Transform ──────────────────────────────────────– */
.transition-transform {
  transition: transform var(--anim-fast) var(--ease-smooth);
}

/* ── Smooth All (careful with performance) ────────────────– */
.transition-all {
  transition: all var(--anim-base) var(--ease-smooth);
}

/* ──────────────────────────────────────────────────────────────
   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;
  }
}

/* ──────────────────────────────────────────────────────────────
   PERFORMANCE UTILITIES
   ────────────────────────────────────────────────────────────– */

.will-animate {
  will-change: opacity, transform;
}

/* ──────────────────────────────────────────────────────────────
   DARK MODE ADJUSTMENTS
   ────────────────────────────────────────────────────────────– */

[data-theme="dark"] .hover-glow:hover {
  filter: drop-shadow(0 0 8px rgba(212, 98, 64, 0.3));
}

/* ──────────────────────────────────────────────────────────────
   END MOTION
   ────────────────────────────────────────────────────────────– */
