/* Pendule divinatoire : remplace la boule de cristal dans le kit (même script oracle.js).
   États posés par oracle.js sur #crystal-ball : thinking, revealing, answer-oui, answer-non.
   Convention des sourciers : va-et-vient avant-arrière (vers soi) = oui, gauche-droite = non. */

.crystal-ball.pendulum {
    width: min(300px, 72vw);
    height: calc(min(300px, 72vw) * 1.18);
    border-radius: 0;
    overflow: visible;
    background: none;
    box-shadow: none;
    display: block;
    cursor: pointer;
    perspective: 700px;
    perspective-origin: 50% 0;
}
.crystal-ball.pendulum:focus-visible { border-radius: 18px; }
.crystal-ball.pendulum.thinking { animation: none; cursor: progress; }
.crystal-ball.pendulum .reveal-ripple { border-radius: 50%; inset: auto; width: 140px; height: 140px; left: calc(50% - 70px); bottom: -10px; }

.pendulum-pivot {
    position: absolute;
    top: 0;
    left: 50%;
    width: 64px;
    height: 14px;
    margin-left: -32px;
    border-radius: 7px;
    background: linear-gradient(90deg, #5e4318, #c9a458 20%, #f7e7b5 40%, #a98035 60%, #e6ca86 80%, #5e4318);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    z-index: 3;
}
.pendulum-pivot::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 9px;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: var(--gold-hi);
}

.pendulum-arm {
    position: absolute;
    top: 14px;
    left: 50%;
    width: 0;
    height: calc(100% - 14px);
    transform-origin: 0 0;
    transform-style: preserve-3d;
    animation: pendulumIdle 4.5s ease-in-out infinite;
}
.pendulum-chain {
    position: absolute;
    left: -1px;
    top: 0;
    width: 2px;
    height: 62%;
    background: repeating-linear-gradient(180deg, var(--gold-hi) 0 5px, #8a6a2c 5px 7px);
    box-shadow: 0 0 6px rgba(226, 199, 126, 0.45);
}
.pendulum-bob {
    position: absolute;
    top: 61%;
    left: -34px;
    width: 68px;
    height: 104px;
    clip-path: polygon(50% 100%, 2% 34%, 18% 4%, 50% 0, 82% 4%, 98% 34%);
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 34%),
        linear-gradient(245deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 40%),
        linear-gradient(180deg, var(--violet) 0%, #3b1f73 55%, #150d24 100%);
    filter: drop-shadow(0 0 26px rgba(124, 77, 255, 0.55));
    display: flex;
    align-items: center;
    justify-content: center;
}
.pendulum-bob .inner-glow {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 24px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 243, 220, 0.75) 0%, rgba(251, 243, 220, 0) 70%);
    opacity: 0.55;
}

.pendulum-answer {
    min-height: 70px;
    margin: 10px 0 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pendulum-answer .answer {
    position: static;
    width: auto;
    color: var(--gold-hi);
    text-shadow: 0 0 30px rgba(226, 199, 126, 0.55);
}

.crystal-ball.pendulum.thinking .pendulum-arm { animation: pendulumThink 1.3s ease-in-out infinite; }
.crystal-ball.pendulum.answer-non .pendulum-arm { animation: pendulumNon 1.05s ease-in-out infinite alternate; }
.crystal-ball.pendulum.answer-oui .pendulum-arm { animation: pendulumOui 1.05s ease-in-out infinite alternate; }

@keyframes pendulumIdle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}
@keyframes pendulumThink {
    0% { transform: rotate(-12deg) rotateX(6deg); }
    25% { transform: rotate(9deg) rotateX(-14deg); }
    50% { transform: rotate(-5deg) rotateX(16deg); }
    75% { transform: rotate(13deg) rotateX(-6deg); }
    100% { transform: rotate(-12deg) rotateX(6deg); }
}
@keyframes pendulumNon {
    from { transform: rotate(-26deg); }
    to { transform: rotate(26deg); }
}
@keyframes pendulumOui {
    from { transform: rotateX(-38deg); }
    to { transform: rotateX(38deg); }
}

.pendulum-legend {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--dim);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .pendulum-arm, .crystal-ball.pendulum .pendulum-arm { animation: none !important; }
}
