/* ===========================================================
   animations.css — Remake : langage de motion piloté par tokens
   (--motion-scale, --ease, --dur-*) — voir contracts/design-tokens.md
   Toutes durées ≤ 0.8s ; neutralisées sous prefers-reduced-motion.
   =========================================================== */

@keyframes alaouiFadeUp {
    from { opacity: 0; transform: translateY(var(--reveal-shift, 14px)); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Reveal principal (IntersectionObserver ajoute .in) */
.fade-up { opacity: 0; }
.fade-up.in { animation: alaouiFadeUp calc(0.55s + 0.25s * var(--motion-scale, 0.85)) var(--ease) forwards; }
.fade-up.in.delay-1 { animation-delay: calc(0.10s * var(--motion-scale, 1)); }
.fade-up.in.delay-2 { animation-delay: calc(0.20s * var(--motion-scale, 1)); }
.fade-up.in.delay-3 { animation-delay: calc(0.30s * var(--motion-scale, 1)); }

/* Anciennes classes — rétrocompatibilité */
.fade-in-up { opacity: 0; transform: translateY(var(--reveal-shift, 14px)); transition: opacity var(--dur-slow, 0.7s) var(--ease), transform var(--dur-slow, 0.7s) var(--ease); will-change: opacity, transform; }
.fade-in-up.visible { opacity: 1; transform: translateY(0); }
.delay-100 { transition-delay: 0.1s; animation-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; animation-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; animation-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; animation-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; animation-delay: 0.5s; }

/* ── Tracé d'encre : filets & ornements SVG (stroke-dashoffset) ── */
@keyframes alaouiInkDraw {
    from { stroke-dashoffset: var(--ink-length, 240); }
    to   { stroke-dashoffset: 0; }
}
.ink-draw path,
.ink-draw circle,
.ink-draw rect {
    stroke-dasharray: var(--ink-length, 240);
    stroke-dashoffset: var(--ink-length, 240);
}
.ink-draw.in path,
.ink-draw.in circle,
.ink-draw.in rect {
    animation: alaouiInkDraw 0.8s var(--ease) forwards;
}
.ink-draw.in path:nth-child(2),
.ink-draw.in rect:nth-child(2) { animation-delay: 0.15s; }
.ink-draw.in path:nth-child(3),
.ink-draw.in circle:nth-child(3) { animation-delay: 0.3s; }

/* ── Illumination : les ornements « s'allument » à l'entrée en vue ── */
.section-numeral,
.ornament {
    opacity: calc(var(--ornament-opacity, 0.1) * 0.4);
    color: var(--ornament-color, var(--color-secondary));
    transition: opacity 0.8s var(--ease);
}
.section-numeral.lit,
.ornament.lit {
    opacity: var(--ornament-opacity, 0.1);
}

/* ── Liseré d'accent au survol des cartes (balayage) ── */
.book, .writing-card, .travail {
    position: relative;
}
.book::after, .writing-card::after, .travail::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--color-secondary);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform calc(0.3s + 0.2s * var(--motion-scale, 0.85)) var(--ease);
    pointer-events: none;
}
.book:hover::after, .writing-card:hover::after, .travail:hover::after {
    transform: scaleX(1);
}

/* Scroll-margin pour ancres */
[id] {
    scroll-margin-top: 110px;
}

/* Reading progress bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    z-index: 9999;
    transition: width 0.1s linear;
    width: 0%;
}

/* Curseur custom (activé par styles à --cursor-dot:1 ; off tactile) */
.cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: var(--color-secondary);
    pointer-events: none;
    z-index: 99999;
    opacity: 0.7;
}
@media (hover: none), (pointer: coarse) {
    .cursor-dot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .fade-up, .fade-in-up {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        transition: none !important;
    }
    .ink-draw path, .ink-draw circle, .ink-draw rect {
        stroke-dasharray: none !important;
        stroke-dashoffset: 0 !important;
        animation: none !important;
    }
    .section-numeral, .ornament { opacity: var(--ornament-opacity, 0.1) !important; transition: none !important; }
    .book::after, .writing-card::after, .travail::after { transition: none !important; }
    .cursor-dot { display: none !important; }
    html { scroll-behavior: auto; }
}
