/* ==========================================================================
   MIRUREAD — ANIMATIONS
   Calm motion, no neon flicker
   ========================================================================== */

/* ==========================================================================
   VIEW AND CONTENT REVEALS
   ========================================================================== */

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.975);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(22px);
    }

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

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.975);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   HERO BOOK
   ========================================================================== */

@keyframes bookEnter {
    from {
        opacity: 0;
        transform:
            translate3d(0, 34px, 0)
            rotateX(8deg)
            rotateY(-30deg)
            rotateZ(3deg)
            scale(0.94);
    }

    to {
        opacity: 1;
        transform:
            translate3d(0, 0, 0)
            rotateX(3deg)
            rotateY(-17deg)
            rotateZ(2deg)
            scale(1);
    }
@keyframes bookSceneFloat {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-11px);
    }
}

@keyframes bookFloat {
    0%,
    100% {
        transform:
            translate3d(0, 0, 0)
            rotateX(3deg)
            rotateY(-17deg)
            rotateZ(2deg);
    }

    50% {
        transform:
            translate3d(0, -12px, 0)
            rotateX(2deg)
            rotateY(-15deg)
            rotateZ(1deg);
    }
}

@keyframes mobileBookFloat {
    0%,
    100% {
        transform:
            translate3d(0, 0, 0)
            rotateY(-12deg)
            rotateZ(1deg);
    }

    50% {
        transform:
            translate3d(0, -7px, 0)
            rotateY(-10deg)
            rotateZ(0deg);
    }
}

@keyframes bookShadowFloat {
    0%,
    100% {
        opacity: 0.48;
        transform: translateX(-50%) scaleX(1);
    }

    50% {
        opacity: 0.32;
        transform: translateX(-50%) scaleX(0.88);
    }
}

@keyframes ringDrift {
    0% {
        transform: rotateX(68deg) rotateZ(0deg);
    }

    100% {
        transform: rotateX(68deg) rotateZ(360deg);
    }
}

@keyframes chipFloat {
    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }

    50% {
        transform: translate3d(0, -6px, 0);
    }
}

/* ==========================================================================
   AMBIENT BACKGROUND
   ========================================================================== */

@keyframes ambientOne {
    from {
        transform: translate3d(-24px, -16px, 0) scale(0.96);
    }

    to {
        transform: translate3d(48px, 30px, 0) scale(1.06);
    }
}

@keyframes ambientTwo {
    from {
        transform: translate3d(20px, -26px, 0) scale(1);
    }

    to {
        transform: translate3d(-46px, 42px, 0) scale(1.08);
    }
}

@keyframes particleDrift {
    0% {
        transform: translate3d(0, 0, 0);
    }

    50% {
        transform: translate3d(10px, -16px, 0);
    }

    100% {
        transform: translate3d(0, 0, 0);
    }
}

/* ==========================================================================
   FUNCTIONAL ANIMATIONS
   ========================================================================== */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes storageSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

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

    100% {
        background-position: -180% 0;
    }
}

@keyframes progressLoad {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

@keyframes chartGrow {
    from {
        opacity: 0.25;
        transform: scaleY(0.12);
    }

    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

@keyframes chartLineDraw {
    from {
        stroke-dashoffset: 1000;
    }

    to {
        stroke-dashoffset: 0;
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate3d(18px, 0, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }

    to {
        opacity: 0;
        transform: translate3d(18px, 0, 0);
    }
}

@keyframes queuePulse {
    0%,
    100% {
        border-color: var(--border);
        background-color: var(--surface-solid);
    }

    50% {
        border-color: var(--accent-border);
        background-color: rgba(28, 32, 50, 0.96);
    }
}

@keyframes pulseDot {
    0%,
    100% {
        opacity: 0.68;
        transform: scale(0.88);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-4px);
    }

    40%,
    80% {
        transform: translateX(4px);
    }
}

/* ==========================================================================
   SKELETON LOADERS
   ========================================================================== */

.skeleton-shimmer {
    border-radius: var(--radius-sm);

    background:
        linear-gradient(
            100deg,
            rgba(255, 255, 255, 0.025) 20%,
            rgba(255, 255, 255, 0.075) 42%,
            rgba(255, 255, 255, 0.025) 64%
        ),
        var(--surface-solid);

    background-size: 220% 100%;
    animation: shimmer 1.7s linear infinite;
}

.skeleton-card {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-solid);
}

.skeleton-card .skeleton-cover {
    width: 100%;
    height: 100%;

    background:
        linear-gradient(
            100deg,
            rgba(255, 255, 255, 0.02) 20%,
            rgba(255, 255, 255, 0.07) 42%,
            rgba(255, 255, 255, 0.02) 64%
        ),
        var(--surface-soft);

    background-size: 220% 100%;
    animation: shimmer 1.7s linear infinite;
}

.skeleton-card .skeleton-overlay {
    position: absolute;
    inset: auto 0 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 48px 14px 14px;

    background: linear-gradient(
        to top,
        rgba(9, 11, 18, 0.98),
        transparent
    );
}

.skeleton-card .skeleton-title {
    width: 74%;
    height: 14px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.1);
}

.skeleton-card .skeleton-badge {
    width: 42%;
    height: 10px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.055);
}

.skeleton-catalog-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;

    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-solid);
}

.skeleton-catalog-cover {
    width: 72px;
    height: 102px;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);

    background:
        linear-gradient(
            100deg,
            rgba(255, 255, 255, 0.02) 20%,
            rgba(255, 255, 255, 0.07) 42%,
            rgba(255, 255, 255, 0.02) 64%
        ),
        var(--surface-soft);

    background-size: 220% 100%;
    animation: shimmer 1.7s linear infinite;
}

.skeleton-catalog-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
}

.skeleton-catalog-title {
    width: 62%;
    height: 15px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.095);
}

.skeleton-catalog-sub {
    width: 42%;
    height: 11px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.055);
}

.skeleton-catalog-btn {
    width: 96px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.055);
}

.skeleton-chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 18px;

    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-solid);
}

.skeleton-chapter-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
}

.skeleton-chapter-title {
    width: 52%;
    height: 14px;
    border-radius: var(--radius-pill);

    background:
        linear-gradient(
            100deg,
            rgba(255, 255, 255, 0.025) 20%,
            rgba(255, 255, 255, 0.075) 42%,
            rgba(255, 255, 255, 0.025) 64%
        ),
        var(--surface-soft);

    background-size: 220% 100%;
    animation: shimmer 1.7s linear infinite;
}

.skeleton-chapter-meta {
    width: 30%;
    height: 10px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.05);
}

.skeleton-chapter-action {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.055);
}

/* ==========================================================================
   ANIMATION ASSIGNMENTS
   ========================================================================== */

.view.active {
    animation: fadeIn var(--duration-medium) var(--ease-out) both;
}

.hero {
    animation: reveal 620ms var(--ease-out) both;
}

.content-section {
    animation: reveal 520ms var(--ease-out) both;
}

.content-section.delay-one {
    animation-delay: 60ms;
}

.content-section.delay-two {
    animation-delay: 110ms;
}

.content-section.delay-three {
    animation-delay: 160ms;
}

.chart-bar {
    transform-origin: bottom;
    animation: chartGrow 720ms var(--ease-out) both;
}

.chart-column:nth-child(2) .chart-bar {
    animation-delay: 40ms;
}

.chart-column:nth-child(3) .chart-bar {
    animation-delay: 80ms;
}

.chart-column:nth-child(4) .chart-bar {
    animation-delay: 120ms;
}

.chart-column:nth-child(5) .chart-bar {
    animation-delay: 160ms;
}

.chart-column:nth-child(6) .chart-bar {
    animation-delay: 200ms;
}

.chart-column:nth-child(7) .chart-bar {
    animation-delay: 240ms;
}

.catalog-card {
    animation: fadeInUp 320ms var(--ease-out) both;
}

.queue-item.downloading {
    animation: queuePulse 2.4s ease-in-out infinite;
}

.storage-update-btn.spinning svg,
.icon-btn.spinning svg {
    animation: storageSpin 800ms linear infinite;
}

/* ==========================================================================
   MOBILE PERFORMANCE
   ========================================================================== */

@media (max-width: 760px) {
    .view.active,
    .hero,
    .content-section,
    .catalog-card {
        animation-duration: 240ms;
    }

    .content-section.delay-one,
    .content-section.delay-two,
    .content-section.delay-three {
        animation-delay: 0ms;
    }

    .ambient-orb,
    .floating-ring,
    .page-particle {
        animation: none !important;
    }

    .chart-bar {
        animation-duration: 420ms;
    }

    .queue-item.downloading {
        animation: none;
    }

    .skeleton-shimmer,
    .skeleton-card .skeleton-cover,
    .skeleton-catalog-cover,
    .skeleton-chapter-title {
        animation-duration: 2.2s;
    }
}

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

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

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }

    .book-3d,
    .book-scene {
        transform:
            rotateX(3deg)
            rotateY(-17deg)
            rotateZ(2deg);
    }

    .ambient-orb,
    .spotlight,
    .floating-ring {
        display: none !important;
    }
}
