/**
 * 3D Cylinder Wheel — Slot-Machine Style
 * Perspective-based CSS 3D cylinder with segments, pointer bar, and fade overlays.
 */

/* ============ CONTAINER ============ */

.wheel-3d-container {
    width: 100%;
    max-width: 90vw;
    height: 70vh;
    height: 70dvh;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    clip-path: inset(0 round 20px);
    -webkit-clip-path: inset(0 round 20px);
    perspective: 1000px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Gradient fade overlays — top & bottom of the cylinder */
.wheel-3d-container::before,
.wheel-3d-container::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 40%;
    z-index: 10;
    pointer-events: none;
}
.wheel-3d-container::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(26,26,46,0.95) 0%, rgba(26,26,46,0) 100%);
}
.wheel-3d-container::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(26,26,46,0.95) 0%, rgba(26,26,46,0) 100%);
}

/* ============ POINTER BAR ============ */

/* Selection BAND — the centre highlight a segment lands in. Upgraded (design #1)
   from a thin 4px bar to a full gold-framed band with dual inward arrows. */
.wheel-3d-pointer {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 64px;
    transform: translateY(-50%);
    z-index: 15;
    pointer-events: none;
    background: rgba(255, 210, 74, 0.07);
    border-top: 2px solid rgba(255, 210, 74, 0.6);
    border-bottom: 2px solid rgba(255, 210, 74, 0.6);
    box-shadow: inset 0 0 30px rgba(255, 210, 74, 0.22);
}

/* Left arrow pointing inward */
.wheel-3d-pointer::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-left: 16px solid #ffd24a;
    filter: drop-shadow(2px 0 6px rgba(255,210,74,0.6));
}

/* Right arrow pointing inward */
.wheel-3d-pointer::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-right: 16px solid #ffd24a;
    filter: drop-shadow(-2px 0 6px rgba(255,210,74,0.6));
}

/* ============ 3D WHEEL (CYLINDER) ============ */

.wheel-3d {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    transform-style: preserve-3d;
    transform: rotateX(0deg);
}

/* ============ SEGMENTS ============ */

.wheel-3d__segment {
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

.wheel-3d__segment-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    padding: 0 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
    background: linear-gradient(
        135deg,
        var(--segment-color, #3498db) 0%,
        var(--segment-color-dark, #2471a3) 100%
    );
    border-top: 1px solid rgba(255,255,255,0.15);
    border-bottom: 1px solid rgba(0,0,0,0.2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), inset 0 -1px 0 rgba(0,0,0,0.2);
    transition: box-shadow 0.3s;
}

/* Alternating default colors when no custom color is set */
.wheel-3d__segment:nth-child(6n+1) .wheel-3d__segment-inner { --segment-color: #e74c3c; --segment-color-dark: #c0392b; }
.wheel-3d__segment:nth-child(6n+2) .wheel-3d__segment-inner { --segment-color: #3498db; --segment-color-dark: #2471a3; }
.wheel-3d__segment:nth-child(6n+3) .wheel-3d__segment-inner { --segment-color: #2ecc71; --segment-color-dark: #239b56; }
.wheel-3d__segment:nth-child(6n+4) .wheel-3d__segment-inner { --segment-color: #9b59b6; --segment-color-dark: #7d3c98; }
.wheel-3d__segment:nth-child(6n+5) .wheel-3d__segment-inner { --segment-color: #f39c12; --segment-color-dark: #d68910; }
.wheel-3d__segment:nth-child(6n+6) .wheel-3d__segment-inner { --segment-color: #1abc9c; --segment-color-dark: #148f77; }

/* Winner glow */
.wheel-3d__segment-inner.winner {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), inset 0 0 20px rgba(255, 215, 0, 0.3);
    animation: winner-pulse 1s ease-in-out infinite;
}

@keyframes winner-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255,215,0,0.8), inset 0 0 20px rgba(255,215,0,0.3); }
    50%      { box-shadow: 0 0 40px rgba(255,215,0,1.0), inset 0 0 30px rgba(255,215,0,0.5); }
}

/* ============ RESULT OVERLAY ============ */

.wheel-3d-result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 100;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffc107 100%);
    color: #1a1a2e;
    padding: 30px 50px;
    border-radius: 20px;
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(255, 215, 0, 0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wheel-3d-result.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.wheel-3d-result .result-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    opacity: 0.7;
    margin-bottom: 10px;
}

.wheel-3d-result .result-value {
    font-size: 2.5rem;
    text-shadow: 2px 2px 0 rgba(255,255,255,0.3);
}

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

@media (max-width: 480px) {
    .wheel-3d-container {
        height: 65vh;
        height: 65dvh;
        max-width: 95vw;
        clip-path: inset(0 round 16px);
        -webkit-clip-path: inset(0 round 16px);
    }
    .wheel-3d__segment-inner {
        font-size: 1.1rem;
    }
    .wheel-3d-result .result-value {
        font-size: 1.8rem;
    }
}

/* ============ LOADING STATE ============ */

.wheel-3d-container.loading {
    opacity: 0.7;
}

.wheel-3d-container.loading::before {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffd700;
    font-size: 1.5rem;
    z-index: 50;
}
