/* ==========================================================================
   ANIMATIONS & TRANSITIONS - UX Polish
   ========================================================================== */

/* ========== GLOBAL TRANSITIONS ========== */

* {
  transition-property: color, background-color, border-color, box-shadow, transform, opacity;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}

/* Disable transitions on page load */
.preload * {
  transition: none !important;
}

/* ========== FADE IN ANIMATIONS ========== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* Apply fade in to elements */
.site-content article,
.widget,
.entry-content > *,
.page-header {
  animation: fadeInUp 0.5s ease forwards;
}

.site-content article:nth-child(1) { animation-delay: 0s; }
.site-content article:nth-child(2) { animation-delay: 0.1s; }
.site-content article:nth-child(3) { animation-delay: 0.2s; }
.site-content article:nth-child(4) { animation-delay: 0.3s; }
.site-content article:nth-child(5) { animation-delay: 0.4s; }

/* ========== HOVER EFFECTS ========== */

/* Scale on hover */
.hover-scale {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Lift on hover */
.hover-lift {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Glow on hover */
.hover-glow:hover {
  box-shadow: 0 0 20px rgba(13, 148, 136, 0.3);
}

/* ========== BUTTON ANIMATIONS ========== */

button,
.btn,
input[type="submit"],
.more-link,
.header-cta {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Ripple effect on click */
button::after,
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

button:active::after,
.btn:active::after {
  width: 200px;
  height: 200px;
}

/* ========== LINK ANIMATIONS ========== */

/* Underline animation */
.animated-underline {
  position: relative;
  text-decoration: none;
}

.animated-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--hamnus-accent);
  transition: width 0.3s ease;
}

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

/* Menu link animation */
#site-primary-menu > li > a {
  position: relative;
}

#site-primary-menu > li > a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--hamnus-accent);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

#site-primary-menu > li > a:hover::before,
#site-primary-menu > li.current-menu-item > a::before {
  width: 80%;
}

/* ========== IMAGE ANIMATIONS ========== */

/* Image zoom on hover */
.post-cover,
.entry-thumbnail {
  overflow: hidden;
}

.post-cover img,
.entry-thumbnail img {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-cover:hover img,
.entry-thumbnail:hover img,
article:hover .post-cover img,
article:hover .entry-thumbnail img {
  transform: scale(1.08);
}

/* ========== LOADING STATES ========== */

/* Skeleton loading animation */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--hamnus-gray-100) 25%,
    var(--hamnus-gray-50) 50%,
    var(--hamnus-gray-100) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--hamnus-radius-md);
}

/* Pulse loading */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s infinite;
}

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

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--hamnus-gray-200);
  border-top-color: var(--hamnus-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== SCROLL ANIMATIONS ========== */

/* Reveal on scroll - using CSS only */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== PROGRESS INDICATORS ========== */

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--hamnus-accent) 0%, var(--hamnus-accent-light) 100%);
  z-index: 9999;
  transition: width 0.1s ease-out;
}

/* Page load progress */
@keyframes loadProgress {
  0% {
    width: 0%;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

.page-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--hamnus-accent);
  animation: loadProgress 1s ease-out forwards;
  z-index: 9999;
}

/* ========== TOOLTIP ANIMATIONS ========== */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--hamnus-gray-900);
  color: var(--hamnus-white);
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--hamnus-radius-md);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 1000;
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--hamnus-gray-900);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ========== NOTIFICATION ANIMATIONS ========== */

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.notification {
  animation: slideInRight 0.3s ease forwards;
}

.notification.hide {
  animation: slideOutRight 0.3s ease forwards;
}

/* ========== FOCUS STATES ========== */

:focus-visible {
  outline: 2px solid var(--hamnus-accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--hamnus-accent);
  outline-offset: 2px;
}

/* ========== REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .post-cover img,
  .entry-thumbnail img {
    transform: none !important;
  }
}

/* ========== SMOOTH SCROLLING ========== */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ========== DARK MODE TRANSITION ========== */

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}
