/**
 * Global Animations & Transitions
 * Loaded on ALL pages via functions.php
 * Provides shared keyframes, scroll-triggered entrance animations,
 * hover/active effects, and transition utilities.
 */

/* ═══════════════════════════════════
   Smooth Scroll
   ═══════════════════════════════════ */
html {
    scroll-behavior: smooth;
}

/* ═══════════════════════════════════
   Branded Text Selection
   ═══════════════════════════════════ */
::selection {
    background: rgba(224, 122, 95, 0.2);
    color: #1f2937;
}

::-moz-selection {
    background: rgba(224, 122, 95, 0.2);
    color: #1f2937;
}

/* ═══════════════════════════════════
   Custom Scrollbar (Webkit)
   ═══════════════════════════════════ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f9fafb;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #e07a5f, #f4a261);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #c65b3f, #e07a5f);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #e07a5f #f9fafb;
}

/* ═══════════════════════════════════
   Focus-Visible Accessibility Ring
   ═══════════════════════════════════ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #e07a5f;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ═══════════════════════════════════
   Page Entrance
   ═══════════════════════════════════ */
body {
    animation: pageFadeIn 0.4s ease-out;
}

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

/* ═══════════════════════════════════
   Shared Keyframes
   ═══════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

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

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

@keyframes popIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
    50%      { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 30px rgba(224, 122, 95, 0.3); }
}

@keyframes fillBar {
    from { width: 0; }
}

@keyframes pulse-border {
    0%, 100% { border-color: #e5e7eb; }
    50%      { border-color: #e07a5f; }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

@keyframes bounceIn {
    0%   { opacity: 0; transform: scale(0.3); }
    50%  { opacity: 1; transform: scale(1.05); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* ═══════════════════════════════════
   Scroll-Triggered Entrance Animations
   (activated by IntersectionObserver JS)
   ═══════════════════════════════════ */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    /* Safety: if JS never fires, show after 1.5s */
    animation: safetyReveal 0s 1.5s forwards;
}

@keyframes safetyReveal {
    to { opacity: 1; transform: translateY(0); }
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
    animation: none;
}

.animate-on-scroll.animate-left {
    transform: translateX(-24px);
}
.animate-on-scroll.animate-left.animated {
    transform: translateX(0);
}

.animate-on-scroll.animate-right {
    transform: translateX(24px);
}
.animate-on-scroll.animate-right.animated {
    transform: translateX(0);
}

.animate-on-scroll.animate-scale {
    transform: scale(0.9);
}
.animate-on-scroll.animate-scale.animated {
    transform: scale(1);
}

/* ═══════════════════════════════════
   Stagger Delay Utilities
   ═══════════════════════════════════ */
.delay-100 { transition-delay: 0.1s !important; animation-delay: 0.1s !important; }
.delay-200 { transition-delay: 0.2s !important; animation-delay: 0.2s !important; }
.delay-300 { transition-delay: 0.3s !important; animation-delay: 0.3s !important; }
.delay-400 { transition-delay: 0.4s !important; animation-delay: 0.4s !important; }
.delay-500 { transition-delay: 0.5s !important; animation-delay: 0.5s !important; }

/* ═══════════════════════════════════
   Global Card Hover Effects
   ═══════════════════════════════════ */
.card,
.feature-card,
.tool-card,
.page-card,
.post-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover,
.feature-card:hover,
.page-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

.post-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════
   Global Button Effects
   ═══════════════════════════════════ */
.upload-btn,
.color-search-btn,
.search-btn,
.download-btn,
.share-btn,
.share-color-btn,
.copy-btn,
.read-more,
#backToTop {
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}

.upload-btn:hover,
.color-search-btn:hover,
.search-btn:hover,
.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(224, 122, 95, 0.3);
}

.upload-btn:active,
.color-search-btn:active,
.search-btn:active,
.download-btn:active,
.share-color-btn:active,
.copy-btn:active {
    transform: scale(0.97);
}

/* ═══════════════════════════════════
   Global Input Focus Effects
   ═══════════════════════════════════ */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
textarea:focus,
.search-input:focus,
.color-search-input:focus {
    outline: none;
    border-color: #e07a5f;
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}

/* ═══════════════════════════════════
   Copy Toast Notification
   (used by both homepage and color info)
   ═══════════════════════════════════ */
.copy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1f2937;
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    pointer-events: none;
}

.copy-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ═══════════════════════════════════
   Skeleton Shimmer Loading State
   ═══════════════════════════════════ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* ═══════════════════════════════════
   Image Hover Zoom
   ═══════════════════════════════════ */
.img-hover-zoom {
    overflow: hidden;
    border-radius: inherit;
}

.img-hover-zoom img {
    transition: transform 0.4s ease;
}

.img-hover-zoom:hover img {
    transform: scale(1.06);
}

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

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }
}
