/* Ma3Memorization — Shared Game CSS
 * Contains all animations and game-specific styles used across all 8 modes
 */

/* ===== BASE ===== */
* { box-sizing: border-box; }
body { font-family: 'DM Sans', system-ui, sans-serif; }

/* ===== ANIMATIONS ===== */

/* Caret blink */
@keyframes caretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}
.caret-blink { animation: caretBlink 0.9s ease-in-out infinite; }

/* Letter pop on correct */
@keyframes letterPop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.letter-pop { animation: letterPop 0.25s ease-out; }

/* Word complete flash */
@keyframes wordComplete {
  0% { background-color: rgba(34,197,94,0.25); }
  100% { background-color: rgba(34,197,94,0.08); }
}
.word-complete { animation: wordComplete 0.5s ease-out; }
.word-complete-flash { animation: wordComplete 0.5s ease-out; }

/* Shake on incorrect */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.shake { animation: shake 0.35s ease-in-out; }

/* Flash red cell (typing modes) */
@keyframes flashRedCell {
  0% { background-color: #fee2e2; color: #b91c1c; }
  100% { background-color: transparent; color: inherit; }
}
.flash-red-cell { animation: flashRedCell 0.5s ease-out; }

/* Auto-advance cascade glow */
@keyframes autoGlow {
  0% { color: #1a71f5; }
  100% { color: inherit; }
}
.auto-glow { animation: autoGlow 0.3s ease-out; }

/* Score bump */
@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.bump { animation: bump 0.25s ease; }

/* Confetti */
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(60px) rotate(360deg); opacity: 0; }
}

/* Pointer pulse (click/drag modes) */
@keyframes pointerPulse {
  0%, 100% { transform: translateY(0px); opacity: 1; }
  50% { transform: translateY(-3px); opacity: 0.7; }
}
.pointer-pulse { animation: pointerPulse 1.2s ease-in-out infinite; }

/* Active slot glow (click/drag modes) */
@keyframes slotGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(26,113,245,0.3); }
  50% { box-shadow: 0 0 0 4px rgba(26,113,245,0.15), 0 0 12px rgba(26,113,245,0.1); }
}
.slot-active { animation: slotGlow 1.8s ease-in-out infinite; }

/* Active blank glow (pic-a-word) */
@keyframes blankGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(26,113,245,0.3); }
  50% { box-shadow: 0 0 0 4px rgba(26,113,245,0.15), 0 0 12px rgba(26,113,245,0.1); }
}
.blank-active { animation: blankGlow 1.8s ease-in-out infinite; }

/* Correct fill animation (click modes) */
@keyframes correctPop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.correct-pop { animation: correctPop 0.35s ease-out; }

/* Word flying from bank to slot */
@keyframes flyIn {
  0% { transform: scale(0.6) translateY(20px); opacity: 0; }
  60% { transform: scale(1.05) translateY(-2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.fly-in { animation: flyIn 0.3s ease-out; }

/* Flash red on choice/word bank button */
@keyframes flashRed {
  0% { background-color: #fee2e2; border-color: #ef4444; color: #b91c1c; }
  100% { background-color: white; border-color: #d5c9b5; color: #142957; }
}
.flash-red { animation: flashRed 0.5s ease-out; }

/* Flash green on choice button */
@keyframes flashGreen {
  0% { background-color: #dcfce7; border-color: #22c55e; color: #15803d; }
  100% { background-color: white; border-color: #d5c9b5; color: #142957; }
}
.flash-green { animation: flashGreen 0.5s ease-out; }

/* Scramble Letters swap reveal */
@keyframes swapReveal {
  0% { transform: rotateX(90deg); opacity: 0; }
  100% { transform: rotateX(0deg); opacity: 1; }
}
.swap-reveal { animation: swapReveal 0.3s ease-out; }

/* Hide-n-Seek: fade out completed word */
@keyframes fadeOut {
  0% { opacity: 1; color: #15803d; }
  100% { opacity: 0.2; color: #d5c9b5; }
}
.fade-out { animation: fadeOut 2s ease-out forwards; }

/* Hide-n-Seek: hint reveal */
@keyframes hintReveal {
  0% { opacity: 0; color: #10b981; }
  100% { opacity: 0.6; color: #10b981; }
}
.hint-reveal { animation: hintReveal 0.5s ease-out forwards; }

/* Hide-n-Seek: speed warning pulse */
@keyframes speedWarn {
  0%, 100% { background-color: rgba(239,68,68,0.1); }
  50% { background-color: rgba(239,68,68,0.2); }
}
.speed-warn { animation: speedWarn 0.8s ease-in-out infinite; }

/* Celebrate animation */
@keyframes celebrate {
  0% { transform: scale(1); }
  25% { transform: scale(1.03); }
  50% { transform: scale(1); }
  75% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
.celebrate { animation: celebrate 0.6s ease; }

/* ===== LETTER CELL (typing modes) ===== */
.letter-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 32px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  border-radius: 4px;
  position: relative;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .letter-cell { width: 26px; height: 36px; font-size: 18px; }
}

/* Scramble Letters uses taller cells */
.letter-cell-tall {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 46px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 500;
  border-radius: 5px;
  position: relative;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
  gap: 0;
}
@media (min-width: 640px) {
  .letter-cell-tall { width: 30px; height: 50px; font-size: 19px; }
}

/* Two-row layout inside a scrambled cell */
.cell-scrambled-char {
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  opacity: 0.5;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 640px) {
  .cell-scrambled-char { font-size: 12px; height: 16px; }
}

.cell-answer-char {
  font-size: 17px;
  line-height: 1;
  font-weight: 600;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 640px) {
  .cell-answer-char { font-size: 19px; height: 26px; }
}

/* ===== WORD GROUPS ===== */
.word-group {
  display: inline-flex;
  align-items: center;
  margin: 2px 0;
  padding: 1px 2px;
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
}

/* Hide Words mode word groups */
.word-group.hidden-word {
  background: rgba(232, 224, 212, 0.3);
  border: 1px dashed #d5c9b5;
}
.word-group.hidden-word.active-word {
  background: rgba(26,113,245,0.05);
  border: 1.5px solid rgba(26,113,245,0.25);
}
.word-group.hidden-word.completed-word {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
}
.word-group.visible-word {
  background: transparent;
  border: 1px solid transparent;
}

/* Scramble Letters word groups */
.word-group.scrambled-word {
  background: rgba(254,243,199,0.3);
  border: 1px solid rgba(252,211,77,0.3);
}
.word-group.scrambled-word.active-word {
  background: rgba(254,243,199,0.5);
  border: 1.5px solid rgba(245,158,11,0.4);
}
.word-group.scrambled-word.completed-word {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
}
.word-group.clean-word {
  background: transparent;
  border: 1px solid transparent;
}

/* Expert Level word groups */
.word-group.expert-word {
  background: rgba(250,245,255,0.3);
  border: 1px dashed rgba(192,132,252,0.3);
}
.word-group.expert-word.active-word {
  background: rgba(168,85,247,0.05);
  border: 1.5px solid rgba(168,85,247,0.3);
}
.word-group.expert-word.completed-word {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
}

/* Hide-n-Seek word groups */
.word-group.seek-word {
  background: rgba(236,253,245,0.3);
  border: 1px dashed rgba(110,231,183,0.3);
}
.word-group.seek-word.active-word {
  background: rgba(16,185,129,0.05);
  border: 1.5px solid rgba(16,185,129,0.3);
}
.word-group.seek-word.completed-word {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.25);
  transition: opacity 2s ease-out;
}
.word-group.fading-word {
  opacity: 0.3;
}

/* ===== PASSAGE LAYOUT ===== */
.word-space {
  display: inline-block;
  width: 12px;
  flex-shrink: 0;
}

.passage-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
}

/* ===== ON-SCREEN KEYBOARD ===== */
.kb-key {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  min-width: 30px;
  background: white;
  border: 1.5px solid #e8e0d4;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: #142957;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.kb-key:hover { background: #eef7ff; border-color: #3391ff; }
.kb-key:active { background: #d9edff; transform: scale(0.95); }

/* ===== MOBILE INPUT ===== */
#mobileInput {
  position: absolute;
  left: -9999px;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* ===== UNDERSCORE PLACEHOLDERS ===== */
.underscore-placeholder {
  color: #d5c9b5;
  font-weight: 600;
}

.underscore-expert {
  color: #c084fc;
  font-weight: 600;
}

.underscore-seek {
  color: #6ee7b7;
  font-weight: 600;
}

/* ===== CLICK MODES: PASSAGE WORDS ===== */
.passage-word {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 3px 2px;
  vertical-align: middle;
}

/* Blank word — dashes (pic-a-word) */
.blank-word {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1px;
  color: #d5c9b5;
  font-weight: 600;
}

/* ===== BUTTONS ===== */

/* Choice button (pic-a-word) */
.choice-btn { transition: all 0.15s ease; user-select: none; }
.choice-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.choice-btn:active:not(:disabled) { transform: translateY(0px); }

/* Word bank button (scramble words, word puzzle) */
.word-btn { transition: all 0.15s ease; user-select: none; }
.word-btn:hover:not(:disabled):not(.used) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.word-btn:active:not(:disabled):not(.used) { transform: translateY(0px); }

/* Used word fade (scramble words) */
.used {
  opacity: 0.25;
  pointer-events: none;
  transform: scale(0.95);
  border-style: dashed;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5c9b5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b8a994; }
