/* ============================================================================
   DICE ROLLER STYLES
   ============================================================================ */

/* Floating Dice Button - Bottom Right Corner */
#dice-roller-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ccac00, #c1ab2f);
    border: 3px solid #d4af37;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(204, 172, 0, 0.4);
    z-index: 2999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dice-roller-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 16px rgba(204, 172, 0, 0.6);
    background: linear-gradient(135deg, #d4af37, #ccac00);
}

#dice-roller-toggle:active {
    transform: scale(0.95);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #dice-roller-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
}

/* Dice Roller Modal */
#dice-roller-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Modal Content - Positioned in bottom right */
.dice-roller-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #ccac00;
    border-radius: 12px;
    width: 380px;
    max-height: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.dice-roller-header {
    background: linear-gradient(135deg, #ccac00, #c1ab2f);
    padding: 1rem 1.25rem;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dice-roller-header h3 {
    margin: 0;
    color: white;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dice-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.dice-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Body */
.dice-roller-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Quick Dice Buttons */
.quick-dice {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.quick-dice-btn {
    flex: 1;
    min-width: 45px;
    padding: 0.6rem 0.4rem;
    background: linear-gradient(135deg, #6B46C1, #805AD5);
    border: 2px solid #6B46C1;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.quick-dice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.4);
    background: linear-gradient(135deg, #805AD5, #9F7AEA);
}

.quick-dice-btn:active {
    transform: translateY(0);
}

/* Custom Roll Section */
.custom-roll {
    margin-bottom: 1.25rem;
}

.custom-roll label {
    display: block;
    color: #cbd5e1;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

.custom-roll input {
    flex: 1;
    padding: 0.7rem;
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid #475569;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.custom-roll input:focus {
    outline: none;
    border-color: #ccac00;
    box-shadow: 0 0 0 3px rgba(204, 172, 0, 0.2);
}

.custom-roll button {
    padding: 0.7rem 1.5rem;
    white-space: nowrap;
}

.dice-help {
    display: block;
    color: #94a3b8;
    font-size: 0.8rem;
    margin-top: 0.4rem;
    font-style: italic;
}

/* Results Display */
.dice-results {
    background: rgba(30, 41, 59, 0.5);
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 1rem;
    max-height: 280px;
    overflow-y: auto;
}

.dice-results-empty {
    text-align: center;
    color: #64748b;
    padding: 2rem 1rem;
}

.dice-results-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.dice-results-empty p {
    margin: 0;
    font-size: 0.9rem;
}

/* Individual Result Item */
.dice-result-item {
    background: linear-gradient(135deg, rgba(107, 70, 193, 0.2), rgba(128, 90, 213, 0.2));
    border: 1px solid rgba(107, 70, 193, 0.4);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    animation: fadeInSlide 0.3s ease;
}

.dice-result-item:last-child {
    margin-bottom: 0;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.result-notation {
    color: #ccac00;
    font-weight: 600;
    font-size: 1rem;
}

.result-total {
    color: #22c55e;
    font-weight: 700;
    font-size: 1.4rem;
}

.result-breakdown {
    color: #cbd5e1;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

/* Custom Scrollbar for Results */
.dice-results::-webkit-scrollbar {
    width: 8px;
}

.dice-results::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 4px;
}

.dice-results::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

.dice-results::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #dice-roller-modal {
        padding: 1rem;
        align-items: center;
        justify-content: center;
    }
    
    .dice-roller-content {
        width: 100%;
        max-width: 100%;
        max-height: 70vh;
    }
    
    .quick-dice {
        gap: 0.4rem;
    }
    
    .quick-dice-btn {
        min-width: 40px;
        padding: 0.5rem 0.3rem;
        font-size: 0.85rem;
    }
    
    .dice-results {
        max-height: 200px;
    }
}

/* Accessibility - Keyboard Focus */
.quick-dice-btn:focus,
.custom-roll input:focus,
.custom-roll button:focus,
.dice-close-btn:focus {
    outline: 2px solid #ccac00;
    outline-offset: 2px;
}

/* ============================================================================
   DICE ROLL ANIMATIONS
   ============================================================================ */

/* Floating Button Roll Animation */
@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.15); }
    50% { transform: rotate(180deg) scale(1); }
    75% { transform: rotate(270deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes diceShake {
    0%, 100% { transform: translateX(0) translateY(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px) translateY(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(3px) translateY(2px); }
}

#dice-roller-toggle.rolling {
    animation: diceRoll 0.6s ease-in-out, diceShake 0.6s ease-in-out;
    pointer-events: none; /* Prevent clicking while rolling */
}

/* Rolling State Display */
.dice-rolling-state {
    background: linear-gradient(135deg, rgba(107, 70, 193, 0.3), rgba(128, 90, 213, 0.3));
    border: 2px solid rgba(204, 172, 0, 0.5);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 0.75rem;
    text-align: center;
    animation: pulse 0.6s ease-in-out;
}

.dice-rolling-state i {
    font-size: 3rem;
    color: #ccac00;
    animation: spin3D 0.6s ease-in-out infinite;
    display: block;
    margin-bottom: 0.5rem;
}

.dice-rolling-state p {
    margin: 0;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 1px;
}

@keyframes spin3D {
    0% { transform: rotateY(0deg) rotateX(0deg); }
    50% { transform: rotateY(180deg) rotateX(180deg); }
    100% { transform: rotateY(360deg) rotateX(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

/* Result Pop-In Animation */
.dice-result-item {
    background: linear-gradient(135deg, rgba(107, 70, 193, 0.2), rgba(128, 90, 213, 0.2));
    border: 1px solid rgba(107, 70, 193, 0.4);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
    0% { 
        opacity: 0;
        transform: scale(0.3) translateY(-20px);
    }
    50% {
        transform: scale(1.05) translateY(0);
    }
    100% { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Number Count-Up Effect */
.result-total {
    color: #22c55e;
    font-weight: 700;
    font-size: 1.4rem;
    display: inline-block;
}

.result-total.counting {
    animation: countUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes countUp {
    0% { 
        opacity: 0;
        transform: scale(0.5) translateY(10px);
    }
    60% {
        transform: scale(1.2) translateY(-5px);
    }
    100% { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Breakdown Slide-In */
.result-breakdown {
    color: #cbd5e1;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    animation: slideInLeft 0.3s ease-out 0.2s backwards;
}

@keyframes slideInLeft {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Critical Hit Animation (Natural 20 on d20) */
.result-total.critical-success {
    color: #ffd700;
    animation: criticalHit 0.8s ease-out;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes criticalHit {
    0% { 
        transform: scale(0.5) rotate(-10deg);
        opacity: 0;
    }
    25% {
        transform: scale(1.3) rotate(5deg);
    }
    50% {
        transform: scale(0.9) rotate(-3deg);
    }
    75% {
        transform: scale(1.15) rotate(2deg);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Critical Fail Animation (Natural 1 on d20) */
.result-total.critical-fail {
    color: #ef4444;
    animation: criticalFail 0.6s ease-out;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

@keyframes criticalFail {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Sparkle Effect for Critical Success */
.critical-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 1s ease-out forwards;
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--sparkle-x), var(--sparkle-y)) scale(0);
    }
}

/* Button Hover Animations Enhanced */
.quick-dice-btn:active {
    animation: buttonPress 0.1s ease-out;
}

@keyframes buttonPress {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(2px) scale(0.98); }
    100% { transform: translateY(0) scale(1); }
}

/* Roll Button Pulse */
#dice-roll-btn {
    position: relative;
    overflow: hidden;
}

#dice-roll-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

#dice-roll-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Smooth Fade Out for Old Results */
.dice-result-item.fading-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.95) translateX(-20px);
    }
}