/*
 * Micro-interactions & Animation Utilities
 * Shared across all pages. Loaded after archive.css.
 * Uses only transform + opacity (GPU-composited, no layout reflows).
 */

/* ===== KEYFRAMES ===== */

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

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes arrowNudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(3px); }
}

@keyframes focusRingPulse {
    0%   { box-shadow: 0 0 0 0 rgba(196, 112, 74, 0.4); }
    100% { box-shadow: 0 0 0 4px rgba(196, 112, 74, 0); }
}

/* ===== ENTRANCE UTILITIES ===== */

.anim-fade-up {
    opacity: 0;
    animation: fadeInUp 0.5s var(--ease-standard) forwards;
}

.anim-fade-up-d1 { animation-delay: 0.1s; }
.anim-fade-up-d2 { animation-delay: 0.2s; }
.anim-fade-up-d3 { animation-delay: 0.3s; }
.anim-fade-up-d4 { animation-delay: 0.4s; }

.anim-fade-in {
    opacity: 0;
    animation: fadeIn 0.4s var(--ease-standard) forwards;
}

.anim-scale-in {
    opacity: 0;
    animation: scaleIn 0.35s var(--ease-standard) forwards;
}

/* ===== SCROLL-TRIGGERED REVEALS ===== */

.anim-on-scroll {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s var(--ease-standard), transform 0.5s var(--ease-standard);
}

.anim-on-scroll.anim-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children when parent becomes visible */
.anim-on-scroll.anim-visible > :nth-child(1) { transition-delay: 0s; }
.anim-on-scroll.anim-visible > :nth-child(2) { transition-delay: 0.06s; }
.anim-on-scroll.anim-visible > :nth-child(3) { transition-delay: 0.12s; }
.anim-on-scroll.anim-visible > :nth-child(4) { transition-delay: 0.18s; }

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

@media (prefers-reduced-motion: reduce) {
    .anim-fade-up,
    .anim-fade-in,
    .anim-scale-in {
        opacity: 1;
        animation: none;
        transform: none;
    }

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

/* ===== Admin-only UI toggle =====
 * Elements marked .admin-only are in the DOM for every user (so the HTML
 * stays user-independent and can be publicly cached by the CDN — see
 * task #14 note in reader.html), but are hidden by default. Auth.js adds
 * `is-admin` to the body after /api/auth/me resolves, which reveals them.
 *
 * `display: none` is non-!important on purpose: elements whose natural
 * display is governed by inline styles or JS (modals, floating toolbars)
 * keep that control. Inline `style="display:..."` beats this class on
 * specificity, which is the right behavior.
 */
.admin-only {
    display: none;
}
body.is-admin .admin-only {
    display: revert;
}
