/* ============================================
   Random Picker - Global Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --glow-purple: 0 0 20px rgba(139, 92, 246, 0.3);
  --glow-blue: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* --- Base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.4);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.6);
}

/* --- Glassmorphism --- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
}

.glass-strong {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 1rem;
}

/* --- Gradient Text --- */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Header --- */
#header-root {
  min-height: 64px;
}

.header-nav {
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header-nav.scrolled {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Dropdown */
.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Mobile menu */
.mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.active {
  max-height: 500px;
}

/* Nav link hover effect */
.nav-link {
  position: relative;
  transition: color 0.3s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-gradient);
  transition: width 0.3s ease;
  border-radius: 1px;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* --- Card Flip Animation --- */
.card-container {
  perspective: 1000px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0.75rem;
  overflow: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

/* --- Coin Flip Animation --- */
.coin-container {
  perspective: 1000px;
}

.coin-inner {
  width: 150px;
  height: 150px;
  transition: transform 0.1s;
  transform-style: preserve-3d;
  position: relative;
}

@keyframes coinFlip {
  0% {
    transform: translateY(0) rotateX(0);
  }
  15% {
    transform: translateY(-120px) rotateX(540deg);
  }
  35% {
    transform: translateY(-200px) rotateX(1080deg);
  }
  55% {
    transform: translateY(-160px) rotateX(1800deg);
  }
  75% {
    transform: translateY(-80px) rotateX(2340deg);
  }
  100% {
    transform: translateY(0) rotateX(var(--final-rotation));
  }
}

.coin-flip {
  animation: coinFlip 1.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  border: 4px solid rgba(255, 255, 255, 0.2);
}

.coin-heads {
  background: linear-gradient(145deg, #fbbf24, #f59e0b, #d97706);
  color: #78350f;
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(245, 158, 11, 0.4);
}

.coin-tails {
  background: linear-gradient(145deg, #9ca3af, #6b7280, #4b5563);
  color: #1f2937;
  transform: rotateX(180deg);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.3), 0 4px 15px rgba(107, 114, 128, 0.4);
}

/* --- Dice Shake Animation --- */
@keyframes diceShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-8px, -6px) rotate(-15deg); }
  20% { transform: translate(6px, 8px) rotate(10deg); }
  30% { transform: translate(-4px, 6px) rotate(-8deg); }
  40% { transform: translate(8px, -4px) rotate(12deg); }
  50% { transform: translate(-6px, -8px) rotate(-5deg); }
  60% { transform: translate(4px, 6px) rotate(15deg); }
  70% { transform: translate(-8px, 4px) rotate(-12deg); }
  80% { transform: translate(6px, -6px) rotate(8deg); }
  90% { transform: translate(-4px, 8px) rotate(-10deg); }
}

.dice-shake {
  animation: diceShake 0.6s ease-in-out;
}

/* --- Scroll Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }
.reveal-delay-6 { transition-delay: 0.6s; }

/* --- Hero Blobs --- */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.08;
  animation: blobFloat 8s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes blobFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -30px) scale(1.1); }
}

.blob-1 {
  width: 250px;
  height: 250px;
  background: #6366f1;
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 220px;
  height: 220px;
  background: #a855f7;
  top: 50%;
  right: -100px;
  animation-delay: -3s;
}

.blob-3 {
  width: 180px;
  height: 180px;
  background: #ec4899;
  bottom: -50px;
  left: 30%;
  animation-delay: -5s;
}

/* --- Tool Card Hover Glow --- */
.tool-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 40px rgba(139, 92, 246, 0.2);
}

.tool-card .icon-box {
  transition: transform 0.3s ease;
}

.tool-card:hover .icon-box {
  transform: scale(1.1) rotate(-5deg);
}

/* --- Spinner Pointer --- */
.spinner-pointer {
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 30px solid #f43f5e;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  z-index: 10;
}

/* --- Button Styles --- */
.btn-primary {
  background: var(--accent-gradient);
  color: white;
  padding: 0.75rem 1.75rem;
  border-radius: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 0.75rem 1.75rem;
  border-radius: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* --- Badge --- */
.result-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1.125rem;
  color: #a5b4fc;
}

/* --- Input Styles --- */
.input-field {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  width: 100%;
}

.input-field:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-field::placeholder {
  color: var(--text-secondary);
}

/* --- Checkbox Custom --- */
.custom-checkbox {
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

.custom-checkbox:checked {
  background: #6366f1;
  border-color: #6366f1;
}

.custom-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

/* --- Color History Dot --- */
.color-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.color-dot:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

/* --- Playing Card Styles --- */
.playing-card {
  width: 120px;
  height: 168px;
  border-radius: 0.75rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.playing-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
  border-radius: 0.75rem;
}

/* --- Name Picker Styles --- */
.name-item {
  transition: all 0.3s ease;
}

.name-item.picked {
  text-decoration: line-through;
  opacity: 0.4;
}

/* --- Pulse Animation --- */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.6); }
}

.pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* --- Single Screen Page Layout --- */
.page-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-layout main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 64px;
  min-height: 0;
}

.result-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 1rem;
}

.controls-area {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* --- Language Switcher --- */
.lang-active {
  background: rgba(99, 102, 241, 0.15);
  color: #fff;
}

/* --- Responsive adjustments --- */
@media (max-width: 640px) {
  .playing-card {
    width: 90px;
    height: 126px;
  }

  .coin-inner {
    width: 120px;
    height: 120px;
  }

  .coin-face {
    font-size: 1.5rem;
  }

  .controls-area {
    padding: 0.75rem 1rem;
  }
}
