/* ===================================
   アニメーションライブラリ
   css/animations.css
   
   @description プロフェッショナルなアニメーション効果集
   @author Research Portfolio Team
   @version 1.0.0
   =================================== */

/* ===================================
   Animation Configuration
   =================================== */
:root {
  /* Animation Durations */
  --anim-duration-fast: 0.15s;
  --anim-duration-normal: 0.3s;
  --anim-duration-slow: 0.5s;
  --anim-duration-slower: 0.75s;
  --anim-duration-slowest: 1s;
  --anim-duration-very-slow: 2s;
  
  /* Easing Functions */
  --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out-back: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
  --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
  --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
  --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
  --ease-in-back: cubic-bezier(0.6, -0.28, 0.735, 0.045);
  
  --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);
  --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);
  --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);
  --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);
  --ease-in-out-back: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Physics-based Easing */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6);
  
  /* Smooth Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-smooth-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-smooth-out: cubic-bezier(0, 0, 0.2, 1);
}

/* ===================================
   Reduced Motion Support
   =================================== */
@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;
  }
  
  /* Keep essential animations but make them instant */
  .loading-spinner {
    animation: none !important;
  }
  
  .loading-spinner::after {
    content: '⏳';
    font-size: 1.5rem;
  }
}

/* ===================================
   Fade Animations
   =================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translate3d(0, -30px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translate3d(-30px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translate3d(30px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ===================================
   Scale Animations
   =================================== */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale3d(0.8, 0.8, 1);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
  to {
    opacity: 0;
    transform: scale3d(0.8, 0.8, 1);
  }
}

@keyframes scaleInUp {
  from {
    opacity: 0;
    transform: scale3d(0.8, 0.8, 1) translate3d(0, 30px, 0);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
  }
}

@keyframes pulse {
  0% {
    transform: scale3d(1, 1, 1);
  }
  50% {
    transform: scale3d(1.05, 1.05, 1);
  }
  100% {
    transform: scale3d(1, 1, 1);
  }
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.1);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(1);
  }
}

/* ===================================
   Rotation Animations
   =================================== */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg);
    transform-origin: center;
  }
  to {
    opacity: 1;
    transform: rotate(0deg);
    transform-origin: center;
  }
}

@keyframes rotateOut {
  from {
    opacity: 1;
    transform: rotate(0deg);
    transform-origin: center;
  }
  to {
    opacity: 0;
    transform: rotate(200deg);
    transform-origin: center;
  }
}

/* ===================================
   Bounce Animations
   =================================== */
@keyframes bounceIn {
  0%, 20%, 40%, 60%, 80%, 100% {
    transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  20% {
    transform: scale3d(1.1, 1.1, 1.1);
  }
  40% {
    transform: scale3d(0.9, 0.9, 0.9);
  }
  60% {
    opacity: 1;
    transform: scale3d(1.03, 1.03, 1.03);
  }
  80% {
    transform: scale3d(0.97, 0.97, 0.97);
  }
  100% {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

@keyframes bounceInUp {
  0%, 60%, 75%, 90%, 100% {
    transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: translate3d(0, 3000px, 0) scaleY(5);
  }
  60% {
    opacity: 1;
    transform: translate3d(0, -20px, 0) scaleY(0.9);
  }
  75% {
    transform: translate3d(0, 10px, 0) scaleY(0.95);
  }
  90% {
    transform: translate3d(0, -5px, 0) scaleY(0.985);
  }
  100% {
    transform: translate3d(0, 0, 0) scaleY(1);
  }
}

/* ===================================
   Slide Animations
   =================================== */
@keyframes slideInUp {
  from {
    transform: translate3d(0, 100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInDown {
  from {
    transform: translate3d(0, -100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translate3d(-100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInRight {
  from {
    transform: translate3d(100%, 0, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideOutUp {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    visibility: hidden;
    transform: translate3d(0, -100%, 0);
  }
}

@keyframes slideOutDown {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    visibility: hidden;
    transform: translate3d(0, 100%, 0);
  }
}

/* ===================================
   Flip Animations
   =================================== */
@keyframes flipInX {
  from {
    transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
    transition-timing-function: ease-in;
    opacity: 0;
  }
  40% {
    transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
    transition-timing-function: ease-in;
  }
  60% {
    transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
    opacity: 1;
  }
  80% {
    transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
  }
  100% {
    transform: perspective(400px);
  }
}

@keyframes flipInY {
  from {
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    transition-timing-function: ease-in;
    opacity: 0;
  }
  40% {
    transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
    transition-timing-function: ease-in;
  }
  60% {
    transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    opacity: 1;
  }
  80% {
    transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  100% {
    transform: perspective(400px);
  }
}

/* ===================================
   Loading & Progress Animations
   =================================== */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loading-dots {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes progress-bar {
  0% {
    width: 0%;
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    width: var(--progress-width, 100%);
    opacity: 1;
  }
}

@keyframes skeleton-loading {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}

/* ===================================
   Attention Seekers
   =================================== */
@keyframes shake {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translate3d(-5px, 0, 0);
  }
  20%, 40%, 60%, 80% {
    transform: translate3d(5px, 0, 0);
  }
}

@keyframes wobble {
  0% {
    transform: translate3d(0, 0, 0);
  }
  15% {
    transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
  }
  30% {
    transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
  }
  45% {
    transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
  }
  60% {
    transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
  }
  75% {
    transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes swing {
  20% {
    transform: rotate3d(0, 0, 1, 15deg);
  }
  40% {
    transform: rotate3d(0, 0, 1, -10deg);
  }
  60% {
    transform: rotate3d(0, 0, 1, 5deg);
  }
  80% {
    transform: rotate3d(0, 0, 1, -5deg);
  }
  100% {
    transform: rotate3d(0, 0, 1, 0deg);
  }
}

/* ===================================
   Floating Elements
   =================================== */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes float-rotate {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-5px) rotate(90deg);
  }
  50% {
    transform: translateY(-10px) rotate(180deg);
  }
  75% {
    transform: translateY(-5px) rotate(270deg);
  }
  100% {
    transform: translateY(0) rotate(360deg);
  }
}

@keyframes orbit {
  0% {
    transform: rotate(0deg) translateX(100px) rotate(0deg);
  }
  100% {
    transform: rotate(360deg) translateX(100px) rotate(-360deg);
  }
}

/* ===================================
   Morphing Animations
   =================================== */
@keyframes morph-circle-square {
  0% {
    border-radius: 50%;
  }
  50% {
    border-radius: 25%;
    transform: scale(1.1);
  }
  100% {
    border-radius: 0%;
  }
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ===================================
   Text Animations
   =================================== */
@keyframes typewriter {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

@keyframes text-focus-in {
  0% {
    filter: blur(12px);
    opacity: 0;
  }
  100% {
    filter: blur(0px);
    opacity: 1;
  }
}

@keyframes text-shadow-pop {
  0% {
    text-shadow: 0 0 0 transparent;
    transform: translateX(0);
  }
  50% {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transform: translateX(-2px);
  }
  100% {
    text-shadow: 0 0 0 transparent;
    transform: translateX(0);
  }
}

/* ===================================
   3D Effects
   =================================== */
@keyframes flip-3d-horizontal {
  0% {
    transform: perspective(800px) rotateY(0deg);
  }
  50% {
    transform: perspective(800px) rotateY(-90deg);
  }
  100% {
    transform: perspective(800px) rotateY(0deg);
  }
}

@keyframes flip-3d-vertical {
  0% {
    transform: perspective(800px) rotateX(0deg);
  }
  50% {
    transform: perspective(800px) rotateX(-90deg);
  }
  100% {
    transform: perspective(800px) rotateX(0deg);
  }
}

@keyframes tilt-shaking {
  0% {
    transform: rotateZ(0deg);
  }
  10% {
    transform: rotateZ(2deg);
  }
  20% {
    transform: rotateZ(-2deg);
  }
  30% {
    transform: rotateZ(2deg);
  }
  40% {
    transform: rotateZ(-2deg);
  }
  50% {
    transform: rotateZ(0deg);
  }
  100% {
    transform: rotateZ(0deg);
  }
}

/* ===================================
   Utility Animation Classes
   =================================== */

/* Duration Classes */
.anim-fast { animation-duration: var(--anim-duration-fast); }
.anim-normal { animation-duration: var(--anim-duration-normal); }
.anim-slow { animation-duration: var(--anim-duration-slow); }
.anim-slower { animation-duration: var(--anim-duration-slower); }
.anim-slowest { animation-duration: var(--anim-duration-slowest); }

/* Timing Function Classes */
.anim-ease-out-quad { animation-timing-function: var(--ease-out-quad); }
.anim-ease-out-cubic { animation-timing-function: var(--ease-out-cubic); }
.anim-ease-spring { animation-timing-function: var(--ease-spring); }
.anim-ease-bounce { animation-timing-function: var(--ease-bounce); }

/* Fill Mode Classes */
.anim-fill-both { animation-fill-mode: both; }
.anim-fill-forwards { animation-fill-mode: forwards; }
.anim-fill-backwards { animation-fill-mode: backwards; }

/* Iteration Classes */
.anim-infinite { animation-iteration-count: infinite; }
.anim-once { animation-iteration-count: 1; }
.anim-twice { animation-iteration-count: 2; }

/* Delay Classes */
.anim-delay-100 { animation-delay: 0.1s; }
.anim-delay-200 { animation-delay: 0.2s; }
.anim-delay-300 { animation-delay: 0.3s; }
.anim-delay-500 { animation-delay: 0.5s; }
.anim-delay-1000 { animation-delay: 1s; }

/* ===================================
   Pre-built Animation Combinations
   =================================== */

/* Fade In Animations */
.animate-fade-in {
  animation: fadeIn var(--anim-duration-normal) var(--ease-out-cubic) both;
}

.animate-fade-in-up {
  animation: fadeInUp var(--anim-duration-normal) var(--ease-out-cubic) both;
}

.animate-fade-in-down {
  animation: fadeInDown var(--anim-duration-normal) var(--ease-out-cubic) both;
}

.animate-fade-in-left {
  animation: fadeInLeft var(--anim-duration-normal) var(--ease-out-cubic) both;
}

.animate-fade-in-right {
  animation: fadeInRight var(--anim-duration-normal) var(--ease-out-cubic) both;
}

/* Scale Animations */
.animate-scale-in {
  animation: scaleIn var(--anim-duration-normal) var(--ease-out-back) both;
}

.animate-scale-in-up {
  animation: scaleInUp var(--anim-duration-slow) var(--ease-out-back) both;
}

.animate-pulse {
  animation: pulse var(--anim-duration-very-slow) var(--ease-in-out-cubic) infinite;
}

/* Rotation Animations */
.animate-spin {
  animation: spin var(--anim-duration-slowest) linear infinite;
}

.animate-rotate-in {
  animation: rotateIn var(--anim-duration-slow) var(--ease-out-back) both;
}

/* Bounce Animations */
.animate-bounce-in {
  animation: bounceIn var(--anim-duration-slower) var(--ease-out-cubic) both;
}

.animate-bounce-in-up {
  animation: bounceInUp var(--anim-duration-slowest) var(--ease-out-cubic) both;
}

/* Slide Animations */
.animate-slide-in-up {
  animation: slideInUp var(--anim-duration-slow) var(--ease-out-quart) both;
}

.animate-slide-in-down {
  animation: slideInDown var(--anim-duration-slow) var(--ease-out-quart) both;
}

.animate-slide-in-left {
  animation: slideInLeft var(--anim-duration-slow) var(--ease-out-quart) both;
}

.animate-slide-in-right {
  animation: slideInRight var(--anim-duration-slow) var(--ease-out-quart) both;
}

/* Attention Seekers */
.animate-shake {
  animation: shake var(--anim-duration-slower) var(--ease-in-out-cubic);
}

.animate-wobble {
  animation: wobble var(--anim-duration-slowest) var(--ease-in-out-cubic);
}

.animate-swing {
  animation: swing var(--anim-duration-slowest) var(--ease-out-cubic);
  transform-origin: top center;
}

/* Floating Elements */
.animate-float {
  animation: float 3s var(--ease-in-out-cubic) infinite;
}

.animate-float-rotate {
  animation: float-rotate 20s linear infinite;
}

.animate-orbit {
  animation: orbit 30s linear infinite;
}

/* Text Animations */
.animate-typewriter {
  animation: typewriter 3s steps(40, end), blink 0.75s step-end infinite;
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid;
}

.animate-text-focus {
  animation: text-focus-in var(--anim-duration-slower) var(--ease-out-cubic) both;
}

/* Loading Animations */
.animate-progress {
  animation: progress-bar var(--anim-duration-very-slow) var(--ease-out-cubic) both;
}

.animate-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.2s ease-in-out infinite;
}

/* ===================================
   Performance Optimizations
   =================================== */

/* Hardware Acceleration Hints */
.gpu-accelerated,
[class*="animate-"] {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Smooth Animations */
.smooth-animation {
  will-change: transform, opacity;
}

.smooth-animation:hover {
  will-change: auto;
}

/* ===================================
   Debug Animations (Development Only)
   =================================== */
@keyframes debug-highlight {
  0%, 100% {
    box-shadow: 0 0 0 2px transparent;
  }
  50% {
    box-shadow: 0 0 0 2px #ff0000;
  }
}

.debug-animation {
  animation: debug-highlight 1s infinite;
}

/* Animation State Indicators */
.animation-running::after {
  content: '▶️ Running';
  position: absolute;
  top: -20px;
  left: 0;
  font-size: 10px;
  color: #00ff00;
  pointer-events: none;
}

.animation-paused::after {
  content: '⏸️ Paused';
  position: absolute;
  top: -20px;
  left: 0;
  font-size: 10px;
  color: #ffff00;
  pointer-events: none;
}

/* ===================================
   Interaction-Based Animations
   =================================== */

/* Hover Animations */
.hover-lift {
  transition: transform var(--anim-duration-normal) var(--ease-out-cubic);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

.hover-scale {
  transition: transform var(--anim-duration-normal) var(--ease-out-cubic);
}

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

.hover-rotate {
  transition: transform var(--anim-duration-normal) var(--ease-out-cubic);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-glow {
  transition: box-shadow var(--anim-duration-normal) var(--ease-out-cubic);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(31, 61, 84, 0.28);
}

/* Focus Animations */
.focus-ring {
  transition: box-shadow var(--anim-duration-fast) var(--ease-out-cubic);
}

.focus-ring:focus-visible {
  box-shadow: 0 0 0 3px rgba(31, 61, 84, 0.28);
}

/* Active Animations */
.active-press {
  transition: transform var(--anim-duration-fast) var(--ease-out-cubic);
}

.active-press:active {
  transform: scale(0.98);
}

/* ===================================
   Custom Property Animations
   =================================== */

/* Color Transitions */
.animate-color-shift {
  background: linear-gradient(-45deg, #1f3d54, #2f4c63, #5d7386, #b08c67);
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
}

/* Border Animations */
@keyframes border-dance {
  0%, 100% {
    border-color: #1f3d54;
  }
  25% {
    border-color: #2f4c63;
  }
  50% {
    border-color: #5d7386;
  }
  75% {
    border-color: #b08c67;
  }
}

.animate-border-dance {
  animation: border-dance 2s ease-in-out infinite;
}

/* ===================================
   Responsive Animations
   =================================== */
@media (max-width: 768px) {
  /* Reduce animation intensity on mobile */
  [class*="animate-"] {
    animation-duration: calc(var(--anim-duration-normal) * 0.75);
  }
  
  /* Disable complex animations on mobile for performance */
  .animate-orbit,
  .animate-float-rotate {
    animation: none;
  }
}

@media (max-width: 480px) {
  /* Further reduce animations on small screens */
  [class*="animate-"] {
    animation-duration: calc(var(--anim-duration-normal) * 0.5);
  }
}
