/* Custom styles for Randomizer App */

:root {
  --darkBlue: #05081A;
  /* Darker blue background */
  --blackBg: #020617;
  --lightText: #F8FAFC;
  --golden: #F59E0B;
  --lightBlue: rgba(255, 255, 255, 0.9);
  --pastelGreen: #86efac;
}

@keyframes twinkle {

  0%,
  100% {
    opacity: 0.15;
  }

  50% {
    opacity: 0.75;
  }
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--darkBlue);
  color: var(--lightText);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px, 60px 60px, 80px 80px;
  background-repeat: repeat;
  pointer-events: none;
  z-index: 0;
}

/* Create twinkling stars */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(white, rgba(255, 255, 255, 0) 2px),
    radial-gradient(white, rgba(255, 255, 255, 0) 1px),
    radial-gradient(white, rgba(255, 255, 255, 0) 1px),
    radial-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 1px);
  background-size:
    200px 200px,
    150px 150px,
    100px 100px,
    250px 250px;
  background-position:
    0 0,
    20px 40px,
    80px 30px,
    120px 70px;
  animation: twinkle 8s ease-in-out infinite;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.bg-darkBlue {
  background-color: rgb(15 23 42 / var(--tw-bg-opacity))
}

.bg-blackBg {
  background-color: var(--blackBg);
}

.text-lightText {
  color: var(--lightText);
}

.text-golden {
  color: var(--golden);
}

.text-lightBlue {
  color: var(--lightBlue);
}

.border-lightBlue {
  border-color: var(--lightBlue);
}

.bg-golden {
  background-color: var(--golden);
}

.bg-lightBlue {
  background-color: var(--lightBlue);
}

.bg-amber-500 {
  background-color: #f59e0b;
}

/* Golden button hover styles */
.golden-button {
  padding-left: 2rem !important;
  padding-right: 2rem !important;
  transition: all 0.2s ease-in-out;
  margin-top: auto;
  /* Push to bottom of container */
  position: relative;
  bottom: 0;
}

.golden-button:hover {
  background-color: var(--golden);
  color: white !important;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  /* More opaque shadow */
}

/* Button hover scale effect */
button:hover span {
  transform: scale(1.1);
  display: inline-block;
}

.bg-slate-600 {
  background-color: rgba(255, 255, 255, 0.7);
}

.text-blackBg {
  color: var(--blackBg);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Card layout and button positioning */
.card-link {
  height: 280px;
}

.card-link p {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.coin {
  transition: transform 0.6s ease-in-out;
  /* Keep any existing transform */
  transform-style: preserve-3d;
}

.coin.heads {
  transform: rotateY(0deg);
}

.coin.tails {
  transform: rotateY(180deg);
}

.coin.flip {
  /* Spin 5 turns (1800 degrees) */
  animation: flip-animation 0.6s ease-in-out forwards;
}

@keyframes flip-animation {
  0% {
    transform: rotateY(0deg);
  }

  100% {
    transform: rotateY(1800deg);
  }
}

@keyframes winner-glow {
  0% {
    box-shadow: 0 0 10px 2px rgba(255, 215, 0, 0.4);
  }

  50% {
    box-shadow: 0 0 25px 5px rgba(255, 215, 0, 0.7);
  }

  100% {
    box-shadow: 0 0 10px 2px rgba(255, 215, 0, 0.4);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

@keyframes winner-fade-in {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.winner-reveal {
  animation:
    winner-fade-in 0.5s ease-out forwards,
    winner-glow 1.2s infinite ease-in-out 0.5s;
  transition: all 0.5s ease-in-out;
}

.backface-hidden {
  backface-visibility: hidden;
}

/* Custom number input styling */
input[type="number"] {
  -moz-appearance: textfield;
  /* Firefox */
  appearance: textfield;
}

/* Chrome, Safari, Edge, Opera */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
  opacity: 1;
  height: 100%;
}

/* Custom number input controls */
.number-input-container {
  position: relative;
}

.number-controls {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  width: 30px;
}

.number-control-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  color: rgb(255, 215, 0);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.number-control-btn:first-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.number-control-btn:hover {
  background: rgba(15, 23, 42, 0.5);
}

.number-control-btn:active {
  background: rgba(255, 215, 0, 0.2);
}



/* Responsive Classes */
/* Dice Roller Styles */
.bg-pastelGreen {
  background-color: var(--pastelGreen);
}

.text-pastelGreen {
  color: var(--pastelGreen);
}

.border-pastelGreen {
  border-color: var(--pastelGreen);
}

/* Green button hover styles */
.green-button {
  transition: all 0.2s ease-in-out;
  margin-top: auto;
  position: relative;
  bottom: 0;
}

.green-button:hover {
  background-color: var(--pastelGreen) !important;
  color: white !important;
  box-shadow: 0 0 10px rgba(134, 239, 172, 0.8);
}

.dice-svg {
  transition: transform 0.3s ease;
  max-width: 100%;
  height: auto;
}

.dice-type-container:hover .dice-svg {
  transform: scale(1.1);
}

.dice-icon-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Dice result containers with SVG backgrounds */
.dice-result-container {
  position: relative;
  overflow: hidden;
}

.dice-result-container::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 60%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
  z-index: 0;
  pointer-events: none;
}

.dice-result-container>* {
  position: relative;
  z-index: 1;
}

.d4-bg::before {
  background-image: url('/src/assets/Dices/d4.svg');
}

.d6-bg::before {
  background-image: url('/src/assets/Dices/d6.svg');
}

.d8-bg::before {
  background-image: url('/src/assets/Dices/d8.svg');
}

.d10-bg::before {
  background-image: url('/src/assets/Dices/d10.svg');
}

.d12-bg::before {
  background-image: url('/src/assets/Dices/d12.svg');
}

.d20-bg::before {
  background-image: url('/src/assets/Dices/d20.svg');
}

/* Dice result animations */
#dice-results-container div[id$="-results"] .bg-blackBg {
  position: relative;
  transform: scale(0);
  animation: diceAppear 0.4s ease-out forwards;
}

@keyframes diceAppear {
  0% {
    transform: scale(0) rotate(-15deg);
    opacity: 0;
  }

  60% {
    transform: scale(1.1) rotate(5deg);
  }

  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* Stagger animation for dice results */
#d4-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.05s;
}

#d4-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.1s;
}

#d4-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.15s;
}

#d4-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.2s;
}

#d4-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.25s;
}

#d6-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.1s;
}

#d6-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.15s;
}

#d6-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.2s;
}

#d6-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.25s;
}

#d6-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.3s;
}

#d8-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.15s;
}

#d8-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.2s;
}

#d8-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.25s;
}

#d8-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.3s;
}

#d8-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.35s;
}

#d10-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.2s;
}

#d10-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.25s;
}

#d10-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.3s;
}

#d10-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.35s;
}

#d10-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.4s;
}

#d12-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.25s;
}

#d12-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.3s;
}

#d12-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.35s;
}

#d12-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.4s;
}

#d12-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.45s;
}

#d20-results .bg-blackBg:nth-child(1n) {
  animation-delay: 0.3s;
}

#d20-results .bg-blackBg:nth-child(2n) {
  animation-delay: 0.35s;
}

#d20-results .bg-blackBg:nth-child(3n) {
  animation-delay: 0.4s;
}

#d20-results .bg-blackBg:nth-child(4n) {
  animation-delay: 0.45s;
}

#d20-results .bg-blackBg:nth-child(5n) {
  animation-delay: 0.5s;
}

/* Mobile First Responsive Design */
/* Small screens (phones) */
@media (max-width: 640px) {
  .logo-svg {
    height: 80px !important;
    /* Smaller logo on mobile */
  }

  header {
    padding-top: 1rem !important;
  }

  main {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  h1 {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
    margin-bottom: 0.75rem !important;
  }

  h2 {
    font-size: 1.25rem !important;
  }

  p {
    font-size: 0.9rem !important;
  }

  /* Adjust spacing between sections */
  .mb-8 {
    margin-bottom: 1.25rem !important;
  }

  .mb-6 {
    margin-bottom: 1rem !important;
  }

  /* Make heading text more readable on small screens */
  .text-center {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  /* Adjust card heights for mobile */
  .card-link {
    height: 270px !important;
  }

  /* Adjust coin size */
  #coin-element {
    width: 120px !important;
    height: 120px !important;
  }

  /* Reduce padding for containers */
  .p-6 {
    padding: 1rem !important;
  }

  /* Adjust input fields and buttons on mobile */
  input[type="text"],
  input[type="number"],
  button {
    font-size: 16px !important;
    /* Prevents zoom on iOS */
  }

  /* Ensure buttons are easily tappable */
  .golden-button,
  .green-button {
    padding: 0.75rem 1.5rem !important;
    min-height: 44px !important;
    /* iOS accessibility guideline */
    margin-bottom: 0.75rem !important;
  }

  /* Add padding under Try It buttons on cards */
  .card-link .flex.justify-center.mt-auto {
    padding-bottom: 0.75rem !important;
  }

  /* Mobile-specific adjustments for dice */
  .dice-icon-container img {
    height: 40px !important;
    width: 40px !important;
  }

  /* Reduce margin and padding for dice result containers */
  #dice-results-container .grid {
    gap: 0.5rem !important;
  }

  /* Adjust dice grid layout on mobile */
  .grid-cols-3.md\:grid-cols-6 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Adjust dice result containers for mobile */
  .dice-result-container {
    min-height: 100px !important;
    padding: 0.5rem !important;
  }

  /* Smaller dice result heading on mobile */
  .dice-result-container h4 {
    font-size: 0.8rem !important;
    margin-bottom: 0.25rem !important;
  }

  /* Adjust dice display on homepage for mobile */
  #home .dice-icon-container {
    margin: 0 -5px !important;
  }

  /* Additional padding for dice card button on mobile */
  #home .col-span-1.md\:col-span-2 .flex.justify-center.mt-auto {
    padding-bottom: 1.5rem !important;
  }

  /* Make form elements full width on mobile */
  form .flex {
    flex-direction: column !important;
  }

  form .flex>* {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
  }

  /* Adjust dice selection on mobile */
  .dice-selector {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }

  .dice-type-container {
    margin: 0.25rem !important;
  }
}

/* Medium screens (tablets) */
@media (min-width: 641px) and (max-width: 1023px) {
  .logo-svg {
    height: 100px !important;
  }

  /* Adjust card layouts for tablets */
  .card-link {
    height: 260px !important;
  }

  /* Two column layout for some elements on tablet */
  .tablet-grid-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
}

/* Larger screens (desktops) */
@media (min-width: 768px) {
  .md\:flex {
    display: flex;
  }

  .md\:items-center {
    align-items: center;
  }

  .md\:space-x-4>*+* {
    margin-left: 1rem;
  }

  .md\:hidden {
    display: none;
  }

  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .md\:text-3xl {
    font-size: 1.875rem;
    line-height: 2.25rem;
  }
}