/* ═══════════════════════════════════════════════════════════════════════════
   MAGIC 8 BALL (magic-8-ball-engine.js)
   A glossy 3D sphere with a blue answer window. Theme-neutral (the ball is
   always black — that is the object) but the page chrome uses theme variables.
   ═══════════════════════════════════════════════════════════════════════════ */

.m8-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0 0.5rem;
}

.m8-ball {
    position: relative;
    width: 320px;
    max-width: 78vw;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 28%, #6b7280 0%, #1f2937 34%, #000 78%);
    box-shadow:
        inset -24px -30px 60px rgba(0, 0, 0, 0.75),
        inset 12px 14px 40px rgba(255, 255, 255, 0.12),
        0 26px 50px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Glossy highlight */
.m8-ball::before {
    content: "";
    position: absolute;
    top: 12%;
    left: 20%;
    width: 34%;
    height: 24%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
    filter: blur(3px);
    pointer-events: none;
}

/* Circular answer window */
.m8-window {
    position: relative;
    width: 52%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 38%, #24379c 0%, #0b1e5a 68%, #050d2e 100%);
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.7);
    display: grid;
    place-items: center;
    overflow: hidden;
}

/* Stack triangle + answer in the same grid cell so they stay centred together */
.m8-triangle,
.m8-answer {
    grid-area: 1 / 1;
}

/* The classic upward-pointing blue triangle die (visual only — text overlays it) */
.m8-triangle {
    width: 76%;
    aspect-ratio: 1;
    clip-path: polygon(50% 10%, 88% 82%, 12% 82%);
    background: linear-gradient(160deg, #2f57e6 0%, #1a34a8 55%, #0e1f6e 100%);
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.35);
}

/* Answer text sits ON TOP of the triangle, centred, never clipped */
.m8-answer {
    position: relative;
    width: 58%;
    color: #ffffff;
    font-size: clamp(0.72rem, 2.6vw, 1.05rem);
    font-weight: 800;
    line-height: 1.12;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
    z-index: 2;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Big "8" resting state — when the answer is the literal 8 */
.m8-answer.m8-eight {
    width: auto;
    font-size: clamp(2.6rem, 11vw, 4rem);
    line-height: 1;
}

.m8-answer.m8-answer-hidden {
    opacity: 0;
    transform: scale(0.85) translateY(12px);
}

.m8-window.m8-revealing .m8-answer {
    animation: m8Float 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes m8Float {
    0% { opacity: 0; transform: scale(0.7) translateY(26px); }
    60% { opacity: 1; }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Shake — the ball rattles hard as the oracle "thinks" */
.m8-ball.m8-shaking {
    animation: m8Shake 0.85s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes m8Shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    8%  { transform: translate(-20px, 10px) rotate(-7deg); }
    17% { transform: translate(22px, -12px) rotate(8deg); }
    26% { transform: translate(-24px, 14px) rotate(-9deg); }
    35% { transform: translate(21px, -11px) rotate(8deg); }
    44% { transform: translate(-19px, 12px) rotate(-7deg); }
    54% { transform: translate(17px, -9px)  rotate(6deg); }
    64% { transform: translate(-14px, 8px)  rotate(-5deg); }
    74% { transform: translate(11px, -6px)  rotate(4deg); }
    84% { transform: translate(-7px, 4px)   rotate(-2deg); }
    92% { transform: translate(4px, -2px)   rotate(1deg); }
}

/* Question input + ask button */
.m8-controls {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
}

.m8-ask-btn {
    font-weight: 700;
    letter-spacing: 0.03em;
}

@media (prefers-reduced-motion: reduce) {
    .m8-ball.m8-shaking { animation: none; }
    .m8-window.m8-revealing .m8-answer { animation: none; }
}
