/* ==========================================================================
   CRB — Motion (DOPAMINE MAX)
   Keyframes premium + classes utilitaires d'animation.
   prefers-reduced-motion : tout désactivé proprement.
   ========================================================================== */

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

@keyframes crb-halo-pulse {
    0%, 100% { transform: scale(0.92); opacity: 0.55; }
    50%      { transform: scale(1.08); opacity: 0.95; }
}

@keyframes crb-halo-pulse-soft {
    0%, 100% { transform: scale(1);    opacity: 0.40; }
    50%      { transform: scale(1.15); opacity: 0.70; }
}

@keyframes crb-aurora-drift-a {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
    50%  { transform: translate3d(18vw, 12vh, 0) rotate(180deg); }
    100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

@keyframes crb-aurora-drift-b {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
    33%  { transform: translate3d(-15vw, 18vh, 0) rotate(-120deg) scale(1.15); }
    66%  { transform: translate3d(12vw, -10vh, 0) rotate(-240deg) scale(0.95); }
    100% { transform: translate3d(0, 0, 0) rotate(-360deg) scale(1); }
}

@keyframes crb-aurora-drift-c {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(0.9); }
    50%  { transform: translate3d(8vw, -14vh, 0) rotate(180deg) scale(1.2); }
    100% { transform: translate3d(0, 0, 0) rotate(360deg) scale(0.9); }
}

@keyframes crb-marquee {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-50%, 0, 0); }
}

@keyframes crb-marquee-reverse {
    from { transform: translate3d(-50%, 0, 0); }
    to   { transform: translate3d(0, 0, 0); }
}

@keyframes crb-reveal-letter {
    0%   { opacity: 0; transform: translate3d(0, 0.5em, 0) rotateX(-45deg); }
    100% { opacity: 1; transform: translate3d(0, 0, 0) rotateX(0); }
}

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

@keyframes crb-rotate-border {
    from { --crb-angle: 0deg; transform: rotate(0deg); }
    to   { --crb-angle: 360deg; transform: rotate(360deg); }
}

@keyframes crb-pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    70%      { box-shadow: 0 0 0 14px transparent; opacity: 0.4; }
}

@keyframes crb-float-y {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(0, -10px, 0); }
}

@keyframes crb-drift-x {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50%      { transform: translate3d(20px, 0, 0); }
}

@keyframes crb-text-gradient {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

@keyframes crb-fade-up {
    from { opacity: 0; transform: translate3d(0, 24px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes crb-scale-in {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

/* ===== HALO PULSE ===== */

.crb-halo {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: crb-halo-pulse var(--crb-halo-pulse-duration) var(--crb-ease-smooth) infinite;
}
.crb-halo--soft { animation: crb-halo-pulse-soft 8s var(--crb-ease-smooth) infinite; }
.crb-halo--gold  { background: radial-gradient(circle, var(--crb-c-gold-60) 0%, transparent 70%); }
.crb-halo--orange { background: radial-gradient(circle, var(--crb-c-orange-ci-30) 0%, transparent 70%); }
.crb-halo--green  { background: radial-gradient(circle, var(--crb-c-green-leaf-25) 0%, transparent 70%); }

/* ===== AURORA BACKGROUND ===== */

.crb-aurora {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    background: var(--crb-c-green-deep);
}
.crb-aurora__blob {
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(var(--crb-aurora-blur));
    opacity: 0.5;
    will-change: transform;
}
.crb-aurora__blob--orange { background: var(--crb-c-orange-ci); top: -15%; left: -10%; animation: crb-aurora-drift-a var(--crb-aurora-duration) linear infinite; }
.crb-aurora__blob--gold   { background: var(--crb-c-gold);      bottom: -20%; right: -10%; animation: crb-aurora-drift-b calc(var(--crb-aurora-duration) + 12s) linear infinite; }
.crb-aurora__blob--water  { background: var(--crb-c-blue-water); top: 30%; right: 30%; animation: crb-aurora-drift-c calc(var(--crb-aurora-duration) + 6s) linear infinite; opacity: 0.35; }

/* ===== GRAIN OVERLAY ===== */

.crb-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: var(--crb-grain-opacity);
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.85'/></svg>");
    background-size: 240px 240px;
}

/* ===== MARQUEE INFINITE ===== */

.crb-marquee {
    position: relative;
    overflow: hidden;
    width: 100%;
    mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}
.crb-marquee__track {
    display: flex;
    align-items: center;
    gap: clamp(2rem, 4vw, 4.5rem);
    width: max-content;
    animation: crb-marquee var(--crb-marquee-duration) linear infinite;
    will-change: transform;
}
.crb-marquee--reverse .crb-marquee__track { animation-name: crb-marquee-reverse; }
.crb-marquee--slow .crb-marquee__track { animation-duration: calc(var(--crb-marquee-duration) * 1.4); }
.crb-marquee:hover .crb-marquee__track { animation-play-state: paused; }
.crb-marquee__item {
    flex: 0 0 auto;
    font-family: var(--crb-font-display);
    font-size: clamp(1.5rem, 1.2rem + 2vw, 3rem);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--crb-c-cream);
    white-space: nowrap;
}
.crb-marquee__sep {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    background: var(--crb-c-gold);
    border-radius: 50%;
}

/* ===== TICKER ACTUALITES ===== */

.crb-ticker {
    display: flex;
    align-items: center;
    gap: var(--crb-space-3);
    background: rgba(15, 81, 50, 0.65);
    backdrop-filter: var(--crb-glass-blur-soft);
    -webkit-backdrop-filter: var(--crb-glass-blur-soft);
    border-top: 1px solid var(--crb-c-gold-30);
    border-bottom: 1px solid var(--crb-c-gold-30);
    padding: var(--crb-space-3) var(--crb-space-4);
    overflow: hidden;
    position: relative;
}
.crb-ticker__live {
    display: inline-flex;
    align-items: center;
    gap: var(--crb-space-2);
    flex: 0 0 auto;
    font-family: var(--crb-font-body);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--crb-c-orange-ci);
    padding-right: var(--crb-space-4);
    border-right: 1px solid var(--crb-c-gold-30);
}
.crb-ticker__live::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--crb-c-orange-ci);
    color: var(--crb-c-orange-ci);
    animation: crb-pulse-dot 1.8s ease-out infinite;
}
.crb-ticker__track {
    display: flex;
    gap: var(--crb-space-7);
    width: max-content;
    animation: crb-marquee 60s linear infinite;
    will-change: transform;
}
.crb-ticker__item {
    font-family: var(--crb-font-body);
    font-size: 0.875rem;
    color: var(--crb-c-cream);
    white-space: nowrap;
}
.crb-ticker__item strong { color: var(--crb-c-gold); font-weight: 600; }

/* ===== REVEAL LETTER-BY-LETTER ===== */

.crb-reveal-letters { display: inline-block; }
.crb-reveal-letters .crb-letter {
    display: inline-block;
    opacity: 0;
    transform: translate3d(0, 0.5em, 0);
    animation: crb-reveal-letter 0.6s var(--crb-ease-out-expo) forwards;
    will-change: opacity, transform;
}
.crb-reveal-letters .crb-letter--space { width: 0.28em; }

/* ===== GLASS SURFACE ===== */

.crb-glass {
    background: var(--crb-glass-bg);
    backdrop-filter: var(--crb-glass-blur);
    -webkit-backdrop-filter: var(--crb-glass-blur);
    border: var(--crb-glass-border);
    border-radius: var(--crb-radius-lg);
    box-shadow: var(--crb-glass-shadow);
    position: relative;
    isolation: isolate;
}
.crb-glass--strong {
    background: var(--crb-glass-bg-strong);
    border: var(--crb-glass-border-strong);
}
.crb-glass--on-light {
    background: linear-gradient(135deg, rgba(15, 81, 50, 0.06), rgba(15, 81, 50, 0.02));
    border: 1px solid rgba(198, 134, 66, 0.30);
    box-shadow: 0 2px 12px rgba(15, 81, 50, 0.08);
}

/* ===== GRADIENT BORDER ANIMATED (Maquette B) ===== */

.crb-gradient-border {
    position: relative;
    isolation: isolate;
    border-radius: var(--crb-radius-lg);
    overflow: hidden;
}
.crb-gradient-border::before {
    content: "";
    position: absolute;
    inset: -50%;
    z-index: -1;
    background: conic-gradient(
        from var(--crb-angle, 0deg),
        var(--crb-c-orange-ci),
        var(--crb-c-gold),
        var(--crb-c-blue-water),
        var(--crb-c-green-leaf),
        var(--crb-c-orange-ci)
    );
    animation: crb-rotate-border 12s linear infinite;
}
.crb-gradient-border::after {
    content: "";
    position: absolute;
    inset: 2px;
    background: var(--crb-c-green-deep);
    border-radius: calc(var(--crb-radius-lg) - 2px);
    z-index: -1;
}

@property --crb-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

/* ===== DUOTONE PHOTO CSS ===== */

.crb-duotone {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}
.crb-duotone img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 18%;
    filter: contrast(1.06) saturate(0.92);
    transition: filter 0.6s var(--crb-ease-out-expo);
}
.crb-duotone::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.22;
    mix-blend-mode: soft-light;
    transition: background 0.6s var(--crb-ease-out-expo), opacity 0.6s;
}
.crb-duotone--gold::before  { background: linear-gradient(135deg, var(--crb-c-green-deep) 0%, var(--crb-c-gold) 100%); }
.crb-duotone--green::before { background: linear-gradient(135deg, var(--crb-c-green-deep) 0%, var(--crb-c-green-leaf) 100%); }
.crb-duotone--orange::before { background: linear-gradient(135deg, var(--crb-c-green-deep) 0%, var(--crb-c-orange-ci) 100%); }
.crb-duotone--water::before { background: linear-gradient(135deg, var(--crb-c-green-deep) 0%, var(--crb-c-blue-water) 100%); }

/* Variante "stronger" pour les photos décoratives (patrimoine, actualités). */
.crb-duotone--strong img { filter: grayscale(70%) contrast(1.12) brightness(0.94); mix-blend-mode: luminosity; }
.crb-duotone--strong::before { opacity: 1; mix-blend-mode: color; }

.crb-duotone--flip:hover::before { background: linear-gradient(135deg, var(--crb-c-orange-ci) 0%, var(--crb-c-cream) 100%); }
.crb-duotone--flip:hover img { filter: grayscale(40%) contrast(1.1) brightness(1.05); }

/* ===== TILT 3D ===== */

.crb-tilt {
    transform-style: preserve-3d;
    transition: transform 0.4s var(--crb-ease-smooth);
    will-change: transform;
}
.crb-tilt-wrap { perspective: 1200px; }

/* ===== MAGNETIC CTA ===== */

.crb-magnetic {
    display: inline-flex;
    transition: transform 0.3s var(--crb-ease-spring);
    will-change: transform;
}

/* ===== MASK REVEAL ===== */

.crb-mask-reveal {
    clip-path: circle(0% at 50% 60%);
    transition: clip-path 1.2s var(--crb-ease-out-expo);
    will-change: clip-path;
}
.crb-mask-reveal.is-visible { clip-path: circle(150% at 50% 60%); }

.crb-mask-up {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 1s var(--crb-ease-out-expo);
}
.crb-mask-up.is-visible { clip-path: inset(0 0 0 0); }

/* ===== PARALLAX LAYERS ===== */

.crb-parallax { will-change: transform; transition: transform 0.1s linear; }

/* ===== GLOW TRAIL (curseur leaves trace) ===== */

.crb-glow-trail-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
    mix-blend-mode: screen;
}

/* ===== SHIMMER (boutons or, badges) ===== */

.crb-shimmer {
    background: linear-gradient(110deg,
        transparent 30%,
        rgba(250, 247, 238, 0.35) 50%,
        transparent 70%);
    background-size: 200% 100%;
    animation: crb-shimmer 3s linear infinite;
}

/* ===== TEXT GRADIENT ANIMATED ===== */

.crb-text-gradient {
    background: linear-gradient(110deg,
        var(--crb-c-orange-ci) 0%,
        var(--crb-c-gold) 25%,
        var(--crb-c-cream) 50%,
        var(--crb-c-gold) 75%,
        var(--crb-c-orange-ci) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: crb-text-gradient 6s ease-in-out infinite;
}

/* ===== FLOAT + DRIFT (decorative crocodiles, blobs) ===== */

.crb-float { animation: crb-float-y 6s ease-in-out infinite; }
.crb-drift { animation: crb-drift-x 9s ease-in-out infinite; }

/* ===== SCROLL-DRIVEN typography (Maquette B) ===== */
/* Utilise variable --crb-scroll-y posée par motion.js sur main */
.crb-scroll-scale {
    transform: scale(calc(1 + var(--crb-scroll-y, 0) * 0.15));
    transition: transform 0.1s linear;
    transform-origin: center;
}

/* ===== REVEAL classes simples (élargissent reveal.js existant) ===== */

.crb-fade-up    { animation: crb-fade-up 0.8s var(--crb-ease-out-expo) both; }
.crb-scale-in   { animation: crb-scale-in 0.6s var(--crb-ease-spring) both; }

/* ===== PREFERS-REDUCED-MOTION : tout désactivé ===== */
@media (prefers-reduced-motion: reduce) {
    .crb-halo,
    .crb-aurora__blob,
    .crb-marquee__track,
    .crb-ticker__track,
    .crb-shimmer,
    .crb-text-gradient,
    .crb-float,
    .crb-drift,
    .crb-gradient-border::before,
    .crb-pulse-dot,
    .crb-reveal-letters .crb-letter {
        animation: none !important;
    }
    .crb-reveal-letters .crb-letter { opacity: 1; transform: none; }
    .crb-mask-reveal { clip-path: none; }
    .crb-mask-up { clip-path: none; }
    .crb-tilt { transform: none !important; }
    .crb-glow-trail-canvas { display: none; }
}

/* Sur mobile, on dégrade aurora pour préserver la batterie */
@media (max-width: 767.98px) {
    .crb-aurora__blob--water { display: none; }
    .crb-aurora__blob { animation-duration: calc(var(--crb-aurora-duration) * 1.5); opacity: 0.4; }
}
