/* ============================================
   DICE ROLLING ANIMATION STYLES
   ============================================ */

.dice-modal {
  backdrop-filter: blur(8px);
}

.dice-content {
  text-align: center;
  padding: var(--spacing-xl);
}

.dice-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: var(--spacing-lg);
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: titlePulse 0.5s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.dice-title.done {
  animation: none;
}

/* Dice Container */
.dice-container {
  perspective: 1000px;
  width: 150px;
  height: 150px;
  margin: 0 auto var(--spacing-xl);
}

/* D20 Dice */
.dice {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: diceRoll 1.5s ease-out forwards;
}

.dice.rolling {
  animation: diceRoll 1.5s ease-out forwards;
}

.dice.done {
  animation: none;
}

@keyframes diceRoll {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
  20% {
    transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg);
  }
  40% {
    transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg);
  }
  60% {
    transform: rotateX(540deg) rotateY(270deg) rotateZ(135deg);
  }
  80% {
    transform: rotateX(680deg) rotateY(340deg) rotateZ(170deg);
  }
  100% {
    transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg);
  }
}

.dice-face {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-dark) 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: var(--white);
  box-shadow: 
    inset 0 -5px 15px rgba(0,0,0,0.3),
    0 10px 30px rgba(0,0,0,0.4);
  border: 3px solid rgba(255,255,255,0.2);
}

/* D20 Shape (approximation) */
.dice-face::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-bottom: 25px solid var(--primary-red);
}

.dice-face::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-top: 25px solid var(--primary-red-dark);
}

/* Special Results */
.dice-face.nat-20 {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  animation: critGlow 0.5s ease-in-out infinite alternate;
}

.dice-face.nat-1 {
  background: linear-gradient(135deg, #333333 0%, #111111 100%);
}

@keyframes critGlow {
  from {
    box-shadow: 
      inset 0 -5px 15px rgba(0,0,0,0.3),
      0 10px 30px rgba(0,0,0,0.4),
      0 0 30px rgba(255, 215, 0, 0.5);
  }
  to {
    box-shadow: 
      inset 0 -5px 15px rgba(0,0,0,0.3),
      0 10px 30px rgba(0,0,0,0.4),
      0 0 60px rgba(255, 215, 0, 0.8);
  }
}

/* Dice Result */
.dice-result {
  background: var(--dark-bg);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  max-width: 300px;
  margin: 0 auto var(--spacing-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease-out;
}

.dice-result.visible {
  opacity: 1;
  transform: translateY(0);
}

.result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: var(--spacing-md);
}

.result-breakdown {
  font-family: monospace;
  font-size: 14px;
  color: var(--white);
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
}

.result-row.roll {
  border-bottom: 1px solid var(--text-secondary);
  padding-bottom: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.result-label {
  color: var(--text-light);
}

.result-value {
  font-weight: 600;
}

.result-total {
  display: flex;
  justify-content: space-between;
  padding-top: var(--spacing-sm);
  border-top: 2px solid var(--primary-red);
  margin-top: var(--spacing-sm);
}

.total-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
}

.total-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-red);
}

/* Dice Message */
.dice-message {
  font-size: 18px;
  color: var(--white);
  font-style: italic;
  max-width: 400px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease-out 0.2s;
}

.dice-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.dice-message.crit-success {
  color: #FFD700;
  font-weight: 700;
  text-transform: uppercase;
  font-style: normal;
}

.dice-message.crit-fail {
  color: #FF4444;
}

/* Close/Dismiss */
.dice-modal.done {
  cursor: pointer;
}

.dice-dismiss {
  font-size: 12px;
  color: var(--text-light);
  margin-top: var(--spacing-lg);
  opacity: 0;
  animation: fadeInUp 0.3s ease-out 1.5s forwards;
}

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

/* Sound effect indicator (visual) */
.dice-sound-wave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 3px solid var(--primary-red);
  border-radius: 50%;
  opacity: 0;
  animation: soundWave 1s ease-out;
}

@keyframes soundWave {
  0% {
    width: 120px;
    height: 120px;
    opacity: 0.8;
  }
  100% {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}
