/**
 * ========================================
 * HANGAGRAMS TUTORIAL OVERLAY STYLES
 * ========================================
 *
 * Visual styling for the tutorial system including:
 * - Overlay containers
 * - Tooltip modals
 * - Arrow pointers
 * - Highlight effects
 * - Animations
 *
 * DESIGN SYSTEM:
 * - Matches Hangagrams' clean, minimal aesthetic
 * - Uses existing color palette (lavender, indigo, lime green)
 * - Smooth transitions and animations
 * - Accessible contrast ratios
 */

/* ========== OVERLAY CONTAINER ========== */

#tutorial-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none; /* Allow clicks through to game */
  z-index: 999;
  background: transparent;
}

/* ========== TOOLTIP MODAL ========== */

#tutorial-tooltip {
  position: fixed;
  top: 40px; /* Positioned high on screen to avoid blocking puzzle */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: rgb(40, 50, 80); /* Dark navy text */
  padding: 16px 24px;
  border-radius: 12px;
  font-family: 'Poppins', 'Helvetica', sans-serif;
  font-size: 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border: 2px solid rgb(100, 90, 230); /* Indigo border */
  max-width: 90%; /* Increased from 85% to allow wider content */
  min-width: 200px;
  z-index: 1001;
  display: none;
  pointer-events: auto; /* Allow interaction with modal */
  animation: slideInDown 0.3s ease-out;
}

#tutorial-tooltip.instruction {
  border-color: rgb(100, 90, 230); /* Indigo for instructions */
}

#tutorial-tooltip.success {
  border-color: rgb(120, 200, 90); /* Lime green for success */
  background: rgba(240, 255, 240, 0.95);
}

#tutorial-tooltip.warning {
  border-color: rgb(230, 90, 90); /* Red for warnings */
  background: rgba(255, 245, 245, 0.95);
}

.tutorial-tooltip-content {
  line-height: 1.4;
}

.tutorial-tooltip-content strong {
  font-weight: 700;
  color: rgb(100, 90, 230);
}

/* ========== ARROW POINTER ========== */

#tutorial-arrow {
  position: fixed;
  width: 60px;
  height: 80px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 32" fill="none"><line x1="12" y1="2" x2="12" y2="20" stroke="%23645ae6" stroke-width="4" stroke-linecap="round"/><path d="M12 28l-8-8h16z" fill="%23645ae6"/></svg>') no-repeat center;
  background-size: contain;
  animation: bounceFlash 1.2s infinite;
  z-index: 1000;
  pointer-events: none;
  display: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Second arrow for dual-pointing */
#tutorial-arrow-2 {
  position: fixed;
  width: 60px;
  height: 80px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 32" fill="none"><line x1="12" y1="2" x2="12" y2="20" stroke="%23645ae6" stroke-width="4" stroke-linecap="round"/><path d="M12 28l-8-8h16z" fill="%23645ae6"/></svg>') no-repeat center;
  background-size: contain;
  animation: bounceFlash 1.2s infinite;
  z-index: 1000;
  pointer-events: none;
  display: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ========== HIGHLIGHT EFFECTS ========== */

/* Red border highlight for target elements */
.tutorial-highlight-red {
  border: 3px solid rgb(230, 90, 90) !important;
  box-shadow: 0 0 12px rgba(230, 90, 90, 0.6) !important;
  position: relative;
  z-index: 10;
}

/* Blue border highlight for target elements */
.tutorial-highlight-blue {
  border: 3px solid rgb(52, 152, 219) !important;
  box-shadow: 0 0 12px rgba(52, 152, 219, 0.6) !important;
  position: relative;
  z-index: 10;
}

/* Fade non-target elements */
.tutorial-fade {
  opacity: 0.3 !important;
  pointer-events: none !important;
  filter: grayscale(50%);
}

/* Pulse animation for emphasis */
.tutorial-pulse {
  animation: pulse 1.5s infinite;
  position: relative;
  z-index: 10;
}

/* Shake animation for incorrect actions */
.tutorial-shake {
  animation: shake 0.5s ease;
}

/* ========== GUESS MODAL ========== */

.tutorial-guess-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.tutorial-guess-modal p {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: rgb(40, 50, 80);
}

.tutorial-guess-modal input {
  padding: 10px 14px;
  border: 2px solid rgb(220, 210, 240);
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Poppins', sans-serif;
  text-align: center;
  transition: border-color 0.2s ease;
}

.tutorial-guess-modal input:focus {
  outline: none;
  border-color: rgb(100, 90, 230);
  box-shadow: 0 0 0 3px rgba(100, 90, 230, 0.1);
}

.tutorial-guess-modal button {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutorial-guess-modal .btn-hg-success {
  background: rgb(120, 200, 90);
  color: white;
}

.tutorial-guess-modal .btn-hg-success:hover {
  background: rgb(110, 190, 80);
  transform: translateY(-1px);
}

.tutorial-guess-modal .btn-hg-secondary {
  background: rgb(200, 200, 200);
  color: rgb(40, 50, 80);
}

.tutorial-guess-modal .btn-hg-secondary:hover {
  background: rgb(180, 180, 180);
}

/* ========== WORD COUNT POPUP ========== */

.tutorial-word-count-popup {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.tutorial-word-count-popup h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: rgb(100, 90, 230);
}

.word-count-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.word-count-item {
  background: rgba(240, 240, 250, 0.5);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.word-count-item.highlight-common {
  background: rgba(120, 200, 90, 0.15);
  border-color: rgb(120, 200, 90);
  box-shadow: 0 0 12px rgba(120, 200, 90, 0.3);
}

.word-count-item.highlight-rare {
  background: rgba(230, 90, 90, 0.15);
  border-color: rgb(230, 90, 90);
  box-shadow: 0 0 12px rgba(230, 90, 90, 0.3);
  animation: pulse 1.5s infinite;
}

.count-number {
  font-size: 32px;
  font-weight: 700;
  color: rgb(40, 50, 80);
  margin-bottom: 4px;
}

.count-label {
  font-size: 13px;
  font-weight: 600;
  color: rgb(80, 80, 100);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========== ERROR MODAL ========== */

.tutorial-error {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.tutorial-error h3 {
  margin: 0;
  font-size: 18px;
  color: rgb(230, 90, 90);
}

.tutorial-error p {
  margin: 0;
  font-size: 14px;
  color: rgb(40, 50, 80);
}

.tutorial-error button {
  padding: 10px 24px;
  background: rgb(100, 90, 230);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutorial-error button:hover {
  background: rgb(90, 80, 220);
  transform: translateY(-1px);
}

/* ========== COMPLETION MODAL ========== */

.tutorial-completion-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  animation: fadeIn 0.3s ease;
}

.tutorial-completion-content {
  background: white;
  padding: 32px 24px;
  border-radius: 16px;
  text-align: center;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.4s ease;
}

.tutorial-completion-content h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
  color: rgb(100, 90, 230);
}

.tutorial-completion-content p {
  margin: 0 0 24px 0;
  font-size: 16px;
  color: rgb(40, 50, 80);
}

.tutorial-completion-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.tutorial-completion-buttons button {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tutorial-completion-buttons .btn-hg-success {
  background: rgb(120, 200, 90);
  color: white;
}

.tutorial-completion-buttons .btn-hg-success:hover {
  background: rgb(110, 190, 80);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(120, 200, 90, 0.4);
}

.tutorial-completion-buttons .btn-hg-secondary {
  background: rgb(220, 210, 240);
  color: rgb(100, 90, 230);
}

.tutorial-completion-buttons .btn-hg-secondary:hover {
  background: rgb(210, 200, 230);
  transform: translateY(-2px);
}

/* ========== ANIMATIONS ========== */

/* Bounce animation for arrow */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(10px);
  }
}

/* Bounce + Flash animation for arrow (combines vertical bounce with opacity flash) */
@keyframes bounceFlash {
  0%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  25% {
    opacity: 0.4;
  }
  50% {
    transform: translateY(10px);
    opacity: 1;
  }
  75% {
    opacity: 0.4;
  }
}

/* Pulse animation for emphasized elements */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(100, 90, 230, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(100, 90, 230, 0);
  }
}

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

/* Slide in animation for tooltip (from top) */
@keyframes slideInDown {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Legacy slide in animation (kept for compatibility) */
@keyframes slideInUp {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Fade in animation */
@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Scale in animation */
@keyframes scaleIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Mobile phones */
@media (max-width: 480px) {
  #tutorial-tooltip {
    top: 30px; /* Positioned high on screen to avoid blocking puzzle on mobile */
    padding: 14px 20px;
    font-size: 14px;
    max-width: 92%;
  }

  #tutorial-arrow {
    width: 50px;
    height: 50px;
  }

  .tutorial-completion-content {
    padding: 24px 20px;
    width: 90%;
  }

  .tutorial-completion-content h2 {
    font-size: 20px;
  }

  .tutorial-completion-buttons {
    flex-direction: column;
  }

  .tutorial-completion-buttons button {
    width: 100%;
  }
}

/* Small screens */
@media (max-width: 365px) {
  #tutorial-tooltip {
    top: 20px; /* Positioned high on screen to avoid blocking puzzle on small screens */
    padding: 12px 16px;
    font-size: 13px;
  }

  .tutorial-guess-modal input {
    font-size: 14px;
    padding: 8px 12px;
  }

  .tutorial-guess-modal button {
    font-size: 13px;
    padding: 8px 16px;
  }
}

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

/* Ensure sufficient contrast */
.tutorial-tooltip-content,
.tutorial-guess-modal,
.tutorial-error {
  color: rgb(40, 50, 80); /* WCAG AAA compliant */
}

/* Focus styles for keyboard navigation */
.tutorial-guess-modal input:focus,
.tutorial-guess-modal button:focus,
.tutorial-error button:focus,
.tutorial-completion-buttons button:focus {
  outline: 3px solid rgba(100, 90, 230, 0.5);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #tutorial-arrow,
  #tutorial-arrow-2,
  .tutorial-pulse,
  .tutorial-shake,
  #tutorial-tooltip,
  .tutorial-completion-modal,
  .tutorial-completion-content {
    animation: none !important;
  }

  #tutorial-tooltip {
    transition: none;
  }

  .tutorial-guess-modal button,
  .tutorial-error button,
  .tutorial-completion-buttons button {
    transition: none;
  }
}

/* ========== NEXT BUTTON STYLING ========== */

/* Smaller NEXT buttons throughout tutorial */
#tutorial-next-btn {
  padding: 6px 16px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
}

/* ========== DISABLED LETTER PAIRS ========== */

/* Style for disabled letter pairs during tutorial */
.tutorial-disabled {
  opacity: 0.35 !important;
  pointer-events: none !important;
  filter: grayscale(100%) brightness(1.1);
  cursor: not-allowed !important;
  border: 2px solid rgb(200, 200, 200) !important;
  box-shadow: none !important;
}

/* ========== Z-INDEX HIERARCHY ========== */
/*
 * 999:  Tutorial overlay (non-interactive)
 * 1000: Tutorial arrow
 * 1001: Tutorial tooltip
 * 1002: Tutorial completion modal
 * 1003: Floating word box (from game)
 */
