/* TourScratch Custom Styles */

/* ===========================
   GLOBAL STYLES
   =========================== */

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Brand Colors (Tailwind overrides) */
:root {
  --brand-primary: #3B82F6;
  --brand-secondary: #8B5CF6;
  --brand-success: #10B981;
  --brand-warning: #F59E0B;
  --brand-danger: #EF4444;
  --scratch-silver: #C0C0C0;
  --scratch-overlay: rgba(192, 192, 192, 0.95);
}

/* ===========================
   SCRATCH CANVAS STYLES
   =========================== */

/* Scratch item container */
.scratch-item {
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: none;
  aspect-ratio: 1;
}

/* Scratch container */
.scratch-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background-color: #f3f4f6;
}

/* Scratch reveal image */
.scratch-reveal {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Scratch canvas overlay */
.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.scratch-canvas:active {
  cursor: pointer;
}

/* Item overlay (emoji and number) */
.item-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(160, 160, 160, 0.3));
}

.item-emoji {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.item-number {
  color: white;
  font-weight: bold;
  font-size: 1.125rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Info button */
.info-btn {
  position: absolute;
  top: -10%;
  right: -10%;
  width: 50%;
  height: 50%;
  background-color: transparent;
  border: none;
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

.info-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.info-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.info-btn:active {
  transform: scale(0.95);
}

/* Check mark */
.check-mark {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 2rem;
  height: 2rem;
  background-color: var(--brand-success);
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  animation: checkmarkPop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkmarkPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===========================
   PROGRESS RING STYLES
   =========================== */

/* Progress ring container */
.progress-ring-container {
  position: relative;
  width: 8rem;
  height: 8rem;
}

/* Progress circle animation */
#progress-circle {
  transition: stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

/* Progress text animation */
#progress-text {
  animation: progressTextPulse 0.5s ease-out;
}

@keyframes progressTextPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Progress count highlight */
#progress-count {
  transition: color 0.3s ease;
}

/* ===========================
   COMPLETION CELEBRATION
   =========================== */

/* Completion certificate modal */
.completion-modal {
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Confetti container (if custom confetti is added later) */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===========================
   COUNTRY BUTTON STYLES
   =========================== */

/* Country button hover effects */
.country-btn {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.country-btn:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Responsive flag images */
.country-btn img {
  object-fit: cover;
  object-position: center;
}

/* ===========================
   LOADING & ANIMATIONS
   =========================== */

/* Loading animation for counters */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

#total-scratches:empty,
#total-users:empty,
#top-item:empty {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Offline indicator styles */
#offline-indicator {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===========================
   BUTTON INTERACTIONS
   =========================== */

/* Share button hover effect */
#share-btn:active,
#share-progress-btn:active {
  transform: scale(0.95);
}

/* Button transitions */
button {
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* ===========================
   TOAST NOTIFICATIONS
   =========================== */

/* Toast notification styles */
.toast {
  animation: toastSlideUp 0.3s ease-out;
}

@keyframes toastSlideUp {
  from {
    transform: translate(-50%, 100%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* ===========================
   VIEW CONTROLS & LAYOUTS
   =========================== */

/* View button active state */
.view-btn.active {
  border-color: #3B82F6;
  background-color: #EFF6FF;
}

.view-btn.active svg {
  color: #3B82F6;
}

/* Grid View - 10 items per row (default) */
/* Mobile: 5 items per row */
#scratch-grid[data-view="grid-10"] {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* Tablet: 8 items per row */
@media (min-width: 768px) {
  #scratch-grid[data-view="grid-10"] {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

/* Desktop: 10 items per row */
@media (min-width: 1024px) {
  #scratch-grid[data-view="grid-10"] {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

/* Grid View - 5 items per row */
/* Mobile: 3 items per row */
#scratch-grid[data-view="grid-5"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Tablet: 4 items per row */
@media (min-width: 768px) {
  #scratch-grid[data-view="grid-5"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Desktop: 5 items per row */
@media (min-width: 1024px) {
  #scratch-grid[data-view="grid-5"] {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* List View - 1 item per row */
#scratch-grid[data-view="list"] {
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* List view item styling */
#scratch-grid[data-view="list"] .scratch-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}

#scratch-grid[data-view="list"] .scratch-container {
  width: 120px;
  min-width: 120px;
  height: 120px;
  flex-shrink: 0;
}

#scratch-grid[data-view="list"] .item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

#scratch-grid[data-view="list"] .item-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.4;
}

#scratch-grid[data-view="list"] .item-desc {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.5;
}

/* Hide info in list view (shown in item-info instead) */
#scratch-grid[data-view="list"] .item-info {
  display: flex;
}

/* Show info only in list view */
#scratch-grid:not([data-view="list"]) .item-info {
  display: none;
}

/* ===========================
   RESPONSIVE ADJUSTMENTS
   =========================== */

/* Mobile optimizations */
@media (max-width: 640px) {
  .country-btn {
    padding: 1rem;
  }
  
  .item-emoji {
    font-size: 2rem;
  }
  
  .item-number {
    font-size: 1rem;
  }
  
  .check-mark {
    width: 1.75rem;
    height: 1.75rem;
  }
}

/* Tablet and up */
@media (min-width: 768px) {
  .scratch-item:hover .info-btn {
    transform: scale(1.1);
  }
}

/* ===========================
   ACCESSIBILITY
   =========================== */

/* Focus visible for keyboard navigation */
.scratch-item:focus-visible,
.info-btn:focus-visible,
.country-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* ===========================
   PERFORMANCE OPTIMIZATIONS
   =========================== */

/* GPU acceleration for animations */
.scratch-canvas,
.check-mark,
.progress-ring-container,
.country-btn {
  will-change: transform;
}

/* Prevent layout shift */
.scratch-container::before {
  content: '';
  display: block;
  padding-top: 100%; /* 1:1 aspect ratio */
}

.scratch-container > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
