/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

 /* Logo Styles */
 .logo-grid {
  display: inline-grid;
  grid-template-columns: repeat(3, 60px);
  gap: 6px;
  margin: 0 auto;
}

.logo-letter {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  color: #7C3AED;
  font-size: 32px;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.logo-letter:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes bounce-in {
  0% { 
    transform: scale(0);
    opacity: 0;
  }
  50% { 
    transform: scale(1.1);
  }
  100% { 
    transform: scale(1);
    opacity: 1;
  }
}

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

/* Interactive logo animation on page load */
.logo-letter {
  user-select: none;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
  touch-action: manipulation; /* Prevent double-tap zoom */

  &.correct {
    opacity: 1;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    animation: pulse 2s ease-in-out infinite;
  }

  &.incorrect {
    opacity: 1;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.8), rgba(220, 38, 38, 1)) !important;
    animation: shake 0.5s ease-out;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), inset 0 0 20px rgba(239, 68, 68, 0.3) !important;
  }

  &.winning {
    opacity: 1;
    animation: winningPulse 1s ease-in-out infinite;
  }
}

@keyframes winningPulse {
  0%, 100% { 
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
  }
  50% { 
    transform: scale(1.2);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.8);
  }
}

.logo-letter:nth-child(1) { animation-delay: 0.1s; }
.logo-letter:nth-child(2) { animation-delay: 0.2s; }
.logo-letter:nth-child(3) { animation-delay: 0.3s; }
.logo-letter:nth-child(4) { animation-delay: 0.4s; }
.logo-letter:nth-child(5) { animation-delay: 0.5s; }
.logo-letter:nth-child(6) { animation-delay: 0.6s; }
.logo-letter:nth-child(7) { animation-delay: 0.7s; }
.logo-letter:nth-child(8) { animation-delay: 0.8s; }
.logo-letter:nth-child(9) { animation-delay: 0.9s; }

@keyframes letterPop {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Stat cards */
.stat-card {
  min-width: 140px;
}

/* Remove hover effects on touch devices */
@media (hover: hover) and (pointer: fine) {
  /* Apply hover effects only on devices with precise pointers (mouse) */
  .logo-letter:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

/* Touch devices - add active state instead of hover */
@media (hover: none) and (pointer: coarse) {
  .logo-letter:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

/* Small logo for header/footer */
.logo-grid-small {
  display: inline-grid;
  grid-template-columns: repeat(7, 24px);
  gap: 2px;
}

.logo-letter-small {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  color: #7C3AED;
  font-size: 12px;

  &.correct {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
  }
}

/* Mobile-First Bingo Grid */
.bingo-card-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  border-radius: 0.75rem;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem; /* 6px */
  width: 100%;
  box-sizing: border-box;
}

/* Floating background animations */
@keyframes float-up {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(-100vh) rotate(360deg);
    opacity: 0;
  }
}

.floating-emoji {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.1;
  animation: float-up 20s linear infinite;
}

/* Square states and animations */
.square {
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.square::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.square:hover::before {
  transform: translateX(100%);
}

/* Clicked state */
.square.clicked {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.4), rgba(245, 158, 11, 0.6)) !important;
  border-color: #FBBF24 !important;
  transform: scale(0.95);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), inset 0 0 20px rgba(251, 191, 36, 0.3) !important;
}

.square.clicked .emoji {
  animation: emoji-bounce 0.6s ease-out;
}

/* Incorrect state */
.square.incorrect {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(220, 38, 38, 0.6)) !important;
  border-color: #EF4444 !important;
  animation: shake 0.5s ease-out;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), inset 0 0 20px rgba(239, 68, 68, 0.3) !important;
}

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

@keyframes emoji-bounce {
  0%, 100% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.3) rotate(-10deg); }
  75% { transform: scale(1.1) rotate(10deg); }
}

/* Ripple effect */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
  animation: ripple 0.8s ease-out;
  pointer-events: none;
}

/* Remote click animation */
.square.remote-click {
  animation: remoteClick 1.2s ease-out;
}

@keyframes remoteClick {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.9);
    border-color: #8B5CF6 !important;
  }
  50% {
    box-shadow: 0 0 40px 20px rgba(139, 92, 246, 0);
    transform: scale(1.15);
    background: rgba(139, 92, 246, 0.3) !important;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
  }
}

/* Winning animations */
.square.winning {
  animation: winningPulse 1s ease-in-out infinite;
  background: linear-gradient(135deg, #10B981, #059669) !important;
  border-color: #10B981 !important;
}

/* Celebration overlay */
.celebration-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.celebration-emoji {
  position: absolute;
  font-size: 2rem;
  animation: celebration-fall 3s ease-out forwards;
}

@keyframes celebration-fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

/* Square wrapper - enforce square aspect ratio */
.square-wrapper {
  aspect-ratio: 1;
  width: 100%;
  box-sizing: border-box;
}

/* Square entrance animation for demo room */
.bingo-grid .square-wrapper {
  opacity: 0;
  animation: square-entrance 0.4s ease-out forwards;
}

.bingo-grid .square-wrapper:nth-child(1) { animation-delay: 0.05s; }
.bingo-grid .square-wrapper:nth-child(2) { animation-delay: 0.1s; }
.bingo-grid .square-wrapper:nth-child(3) { animation-delay: 0.15s; }
.bingo-grid .square-wrapper:nth-child(4) { animation-delay: 0.2s; }
.bingo-grid .square-wrapper:nth-child(5) { animation-delay: 0.25s; }
.bingo-grid .square-wrapper:nth-child(6) { animation-delay: 0.3s; }
.bingo-grid .square-wrapper:nth-child(7) { animation-delay: 0.35s; }
.bingo-grid .square-wrapper:nth-child(8) { animation-delay: 0.4s; }
.bingo-grid .square-wrapper:nth-child(9) { animation-delay: 0.45s; }

@keyframes square-entrance {
  0% {
    opacity: 0;
    transform: scale(0) rotate(180deg);
  }
  50% {
    transform: scale(1.1) rotate(-10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .logo-grid {
    grid-template-columns: repeat(3, 50px);
    gap: 4px;
  }
  
  .logo-letter {
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
  
  /* Mobile bingo container - tighter padding */
  .bingo-card-container {
    padding: 0.125rem; /* Reduced from 0.5rem */
    margin: 0;
  }

  /* Mobile square sizing */
  .bingo-grid {
    gap: 0.25rem; /* Reduced from 0.25rem (2px) */
  }
  
  .square {
    padding: 0.25rem; /* Reduced from 0.5rem */
    min-height: 100%;
    gap: 0; /* No gap on mobile */
    font-size: 0.625rem; /* Smaller base font size */
  }
  
  .square-text {
    font-size: 0.75rem; /* Reduced from 0.75rem (10px) */
    line-height: 1.1; /* Tighter line height */
    word-break: normal; /* Don't break words */
    hyphens: none;
    display: block;
    overflow: hidden;
    font-weight: 600; /* bolder for readability */
    text-align: center;
    max-height: 100%; /* Ensure text doesn't overflow */
  }
}

/* Tablet and up */
@media (min-width: 640px) {
  .bingo-card-container {
    border-radius: 1rem;
    padding: 1rem;
    margin: 0 auto; /* Center on larger screens */
  }

  .bingo-grid {
    gap: 0.5rem; /* 8px */
    max-width: 600px;
    margin: 0 auto;
  }
  
  .square {
    padding: 0.75rem; /* 12px */
    gap: 0.25rem; /* Restore gap on larger screens */
  }
  
  .square-text {
    font-size: 0.625rem; /* 10px */
    font-weight: 500; /* Less bold on larger screens */
  }
  
  .floating-emoji {
    font-size: 2rem;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .bingo-card-container {
    border-radius: 1.5rem;
    padding: 1.5rem;
  }

  .bingo-grid {
    gap: 0.75rem; /* 12px */
    max-width: 700px;
  }
  
  .square {
    padding: 1rem; /* 16px */
  }
  
  .square-text {
    font-size: 1rem; /* 12px */
  }
}
