/* ================================================ */
/*  RAFFLE PAGE - WHITE LABEL THEME AWARE         */
/*  Uses CSS variables from theme-system.css      */
/* ================================================ */

/* ===== HERO ===== */
    .hero-raffles {
        position: relative;
        background: var(--bg-primary);
        overflow: visible;
        padding: 8rem 0 4rem;
        min-height: 40vh;
        display: flex;
        align-items: center;
    }
    .hero-raffles::before {
        content: "";
        position: absolute;
        top: -20%; left: -15%;
        width: 60%; height: 80%;
        background: radial-gradient(circle at center,
            color-mix(in srgb, var(--accent-primary) 15%, transparent) 0%,
            color-mix(in srgb, var(--accent-primary) 8%, transparent) 30%,
            transparent 70%);
        pointer-events: none; z-index: 1;
        animation: pulse-glow 8s ease-in-out infinite;
        filter: blur(60px);
    }
    .hero-raffles::after {
        content: "";
        position: absolute;
        bottom: -20%; right: -15%;
        width: 50%; height: 60%;
        background: radial-gradient(circle at center,
            color-mix(in srgb, var(--accent-secondary) 10%, transparent) 0%,
            color-mix(in srgb, var(--accent-secondary) 5%, transparent) 30%,
            transparent 70%);
        pointer-events: none; z-index: 1;
        animation: pulse-glow 8s ease-in-out infinite 4s;
        filter: blur(60px);
    }
    .hero-raffles > * { position: relative; z-index: 3; }
50% { opacity: 0.7; transform: scale(1.1); }
    }

    /* Live indicator in hero */
    .live-indicator {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        background: rgba(239,68,68,0.12);
        border: 1px solid rgba(239,68,68,0.3);
        color: #f87171;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        padding: 0.25rem 0.65rem;
        border-radius: 9999px;
        margin-top: 0.75rem;
    }
    .live-dot {
        width: 7px; height: 7px;
        border-radius: 50%;
        background: #ef4444;
        animation: live-pulse 1.2s ease-in-out infinite;
        flex-shrink: 0;
    }
    @keyframes live-pulse {
        0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
        50% { opacity: 0.8; transform: scale(1.15); box-shadow: 0 0 0 5px rgba(239,68,68,0); }
    }

    /* ===== RAFFLE CARDS ===== */
    .raffles-main-section { padding: 3rem 0; }
    .raffle-card {
        background: linear-gradient(145deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
        border: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
        border-radius: 1.5rem;
        padding: 2rem;
        position: relative;
        transition: border-color 0.3s ease, transform 0.3s ease;
    }
    .raffle-card:hover {
        border-color: color-mix(in srgb, var(--accent-secondary) 30%, transparent);
        transform: translateY(-4px);
    }

    .date-badge {
        background: var(--gradient-primary);
        color: var(--bg-primary);
        padding: 0.5rem 1rem; border-radius: 9999px;
        font-weight: 600; font-size: 0.875rem;
        box-shadow: var(--glow-effect);
    }
    .time-badge {
        background: color-mix(in srgb, var(--bg-secondary) 50%, transparent);
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
        padding: 0.25rem 0.75rem; border-radius: 9999px;
        font-size: 0.8125rem; font-weight: 500;
    }

    /* ===== WINNER SECTION ===== */
    .winner-section {
        background: linear-gradient(135deg,
            color-mix(in srgb, var(--accent-primary) 10%, transparent),
            color-mix(in srgb, var(--accent-secondary) 10%, transparent));
        border: 1px solid color-mix(in srgb, var(--accent-primary) 20%, transparent);
        border-radius: 1.25rem; padding: 2rem; text-align: center;
        margin-bottom: 2rem; position: relative; overflow: hidden;
    }
    .winner-section::before {
        content: "";
        position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
        background: conic-gradient(from 0deg,
            transparent,
            color-mix(in srgb, var(--accent-primary) 20%, transparent),
            transparent 40%);
        animation: rotate-glow 4s linear infinite;
    }
    @keyframes rotate-glow { to { transform: rotate(360deg); } }

    .trophy-icon {
        width: 4rem; height: 4rem; border-radius: 0.875rem;
        background: var(--gradient-primary);
        display: flex; align-items: center; justify-content: center;
        margin: 0 auto 1rem;
        box-shadow: var(--glow-effect);
        animation: float 3s ease-in-out infinite;
    }
    @keyframes float {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-8px); }
    }
    @keyframes sparkleFloat {
        0% { opacity: 0; transform: translateY(0px) scale(0); }
        50% { opacity: 1; transform: translateY(-20px) scale(1); }
        100% { opacity: 0; transform: translateY(-40px) scale(0); }
    }

    .substitute-card {
        background: color-mix(in srgb, var(--bg-secondary) 60%, transparent);
        border: 1px solid var(--border-color);
        border-radius: 1rem; padding: 1.5rem;
        transition: all 0.3s ease;
    }
    .substitute-card:hover {
        background: var(--bg-tertiary);
        border-color: var(--border-secondary);
        transform: translateY(-2px);
    }

    .empty-state-card {
        background: var(--surface-gradient-1);
        border: 1px solid var(--border-primary);
        border-radius: 1.5rem; padding: 2rem;
        position: relative;
    }

    .back-to-top {
        position: fixed; bottom: 1.5rem; right: 1.5rem;
        height: 3.5rem; width: 3.5rem; border-radius: 50%; border: none;
        display: flex; align-items: center; justify-content: center;
        opacity: 0; visibility: hidden; transition: all 0.3s ease;
        cursor: pointer; z-index: 50;
        background: var(--gradient-primary); color: var(--bg-primary);
        box-shadow: 0 8px 30px color-mix(in srgb, var(--accent-primary) 40%, transparent);
        font-size: 1.25rem;
    }
    .back-to-top.show { opacity: 1; visibility: visible; }
    .back-to-top:hover { transform: translateY(-3px) scale(1.05); }

    .raffle-card, .empty-state-card { animation: fadeIn 0.6s ease-out both; }
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* ===== LIVE OVERLAY ===== */
    #live-overlay {
        position: fixed; inset: 0; z-index: 200;
        display: none;
        background: rgba(0,0,0,0.97);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        align-items: center;
        justify-content: center;
        flex-direction: column;
        overflow: hidden;
    }
    #live-overlay.active { display: flex; }

    /* Scanline effect */
    #live-overlay::before {
        content: '';
        position: absolute; inset: 0;
        background: repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(255,255,255,0.015) 3px,
            rgba(255,255,255,0.015) 4px
        );
        pointer-events: none;
        z-index: 0;
    }

    .overlay-inner {
        position: relative; z-index: 1;
        display: flex; flex-direction: column; align-items: center;
        width: 100%; max-width: 480px; padding: 2rem;
        text-align: center;
    }

    .overlay-live-badge {
        display: inline-flex; align-items: center; gap: 0.5rem;
        background: rgba(239,68,68,0.15);
        border: 1px solid rgba(239,68,68,0.4);
        color: #f87171;
        font-size: 0.7rem; font-weight: 800;
        letter-spacing: 0.2em; text-transform: uppercase;
        padding: 0.3rem 0.8rem; border-radius: 9999px;
        margin-bottom: 2.5rem;
    }

    /* ── Drum roll reel (slot machine) ── */
    #phase-roll { width: 100%; }
    .roll-subtitle {
        font-size: 0.75rem; font-weight: 600;
        letter-spacing: 0.2em; text-transform: uppercase;
        color: #6b7280; margin-bottom: 1rem;
    }
    .reel-window {
        position: relative;
        background: rgba(255,255,255,0.03);
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 1rem;
        height: 10.5rem; /* exactly 3 × 3.5rem items */
        overflow: hidden;
    }
    /* Fade masks top & bottom */
    .reel-window::before, .reel-window::after {
        content: '';
        position: absolute; left: 0; right: 0;
        height: 3.5rem; pointer-events: none; z-index: 3;
    }
    .reel-window::before {
        top: 0;
        background: linear-gradient(to bottom, rgba(3,3,3,0.96) 0%, transparent 100%);
    }
    .reel-window::after {
        bottom: 0;
        background: linear-gradient(to top, rgba(3,3,3,0.96) 0%, transparent 100%);
    }
    /* Accent highlight on centre row */
    .reel-highlight {
        position: absolute; left: 0; right: 0;
        height: 3.5rem; top: 50%; transform: translateY(-50%);
        background: color-mix(in srgb, var(--accent-primary,#CBFC02) 5%, transparent);
        border-top: 1px solid color-mix(in srgb, var(--accent-primary,#CBFC02) 22%, transparent);
        border-bottom: 1px solid color-mix(in srgb, var(--accent-primary,#CBFC02) 22%, transparent);
        z-index: 1;
        pointer-events: none;
    }
    /* The scrolling strip */
    #reel-strip {
        display: flex;
        flex-direction: column;
        transform: translateY(0);
        /* transition set dynamically by JS */
        will-change: transform;
        position: relative; z-index: 2;
    }
    .reel-item {
        height: 3.5rem;
        display: flex; align-items: center; justify-content: center;
        font-size: 1.45rem; font-weight: 900; font-style: italic;
        letter-spacing: 0.01em;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        padding: 0 1rem;
        max-width: 100%;
        box-sizing: border-box;
        transition: color 0.15s, opacity 0.15s;
    }
    .reel-item.reel-prev { opacity: 0.18; color: #9ca3af; transform: scale(0.88); }
    .reel-item.reel-curr { opacity: 1;    color: #fff;    transform: scale(1); }
    .reel-item.reel-next { opacity: 0.18; color: #9ca3af; transform: scale(0.88); }

    /* Progress bar below reel */
    #roll-progress {
        height: 3px;
        background: rgba(255,255,255,0.07);
        border-radius: 9999px;
        margin-top: 0.9rem;
        overflow: hidden;
    }
    #roll-progress-bar {
        height: 100%;
        width: 0%;
        background: var(--gradient-primary, linear-gradient(90deg,#CBFC02,#a3d600));
        border-radius: 9999px;
        transition: width 0.3s ease;
    }

    /* ── Floating background particles ── */
    @keyframes particle-float {
        0%   { opacity: 0;   transform: translateY(0)     translateX(0); }
        15%  { opacity: 0.6; }
        85%  { opacity: 0.3; }
        100% { opacity: 0;   transform: translateY(-55vh) translateX(var(--pdrift, 18px)); }
    }

    /* Winner reveal */
    #phase-reveal { width: 100%; display: none; }
    #phase-reveal.active { display: block; }

    .winner-trophy-anim {
        font-size: 4rem;
        animation: trophy-bounce 0.6s cubic-bezier(0.36,0.07,0.19,0.97) both;
        display: block; margin-bottom: 0.75rem;
    }
    @keyframes trophy-bounce {
        0% { transform: scale(0) rotate(-10deg); opacity: 0; }
        60% { transform: scale(1.2) rotate(4deg); opacity: 1; }
        80% { transform: scale(0.95) rotate(-2deg); }
        100% { transform: scale(1) rotate(0deg); }
    }

    .overlay-winner-label {
        font-size: 0.65rem; font-weight: 800;
        letter-spacing: 0.3em; text-transform: uppercase;
        color: var(--accent-primary,#CBFC02);
        margin-bottom: 0.5rem;
    }
    #winner-name-display {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
        font-weight: 900; font-style: italic;
        color: #fff; line-height: 1.1;
        margin-bottom: 0.5rem;
        animation: winner-zoom-in 0.5s cubic-bezier(0.22,1,0.36,1) both,
                   winner-shimmer 2.2s ease-in-out 0.6s infinite;
    }
    @keyframes winner-zoom-in {
        from { opacity: 0; transform: scale(0.7); }
        to   { opacity: 1; transform: scale(1); }
    }
    @keyframes winner-shimmer {
        0%, 100% { text-shadow: 0 0 20px rgba(203,252,2,0.35); }
        50%       { text-shadow: 0 0 50px rgba(203,252,2,0.75), 0 0 90px rgba(203,252,2,0.2); }
    }
    #raffle-name-display {
        font-size: 0.8rem; color: #9ca3af; margin-bottom: 1.5rem;
    }

    .overlay-subs {
        display: none; /* shown via JS */
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem; width: 100%; margin-bottom: 1.5rem;
    }
    .overlay-subs.visible { display: grid; }
    .overlay-sub-card {
        background: rgba(255,255,255,0.05);
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 0.75rem; padding: 0.75rem 0.5rem;
        animation: fadeIn 0.4s ease both;
    }
    .overlay-sub-label {
        font-size: 0.6rem; font-weight: 700;
        letter-spacing: 0.15em; text-transform: uppercase;
        color: #6b7280; margin-bottom: 0.25rem;
    }
    .overlay-sub-name {
        font-size: 0.9rem; font-weight: 700; color: #e5e7eb;
    }

    #dismiss-btn {
        display: none; /* shown via JS */
        background: var(--gradient-primary,linear-gradient(135deg,#CBFC02,#a3d600));
        color: #000; font-weight: 800;
        border: none; cursor: pointer;
        padding: 0.75rem 2rem; border-radius: 9999px;
        font-size: 0.9rem; letter-spacing: 0.05em;
        transition: transform 0.2s, box-shadow 0.2s;
        box-shadow: 0 0 24px color-mix(in srgb, var(--accent-primary,#CBFC02) 40%, transparent);
        animation: fadeIn 0.4s ease both;
    }
    #dismiss-btn:hover { transform: scale(1.05); }
    #dismiss-btn.visible { display: inline-block; }

    /* Confetti */
    .confetti-piece {
        position: fixed;
        pointer-events: none;
        z-index: 201;
        animation: confetti-fall linear forwards;
        will-change: transform, opacity;
    }
    @keyframes confetti-fall {
        0%   { opacity: 1; transform: translateY(0) translateX(0)            rotate(0deg); }
        100% { opacity: 0; transform: translateY(100vh) translateX(var(--cdrift,0px)) rotate(var(--cspin,540deg)); }
    }
