/* Number Search styles */

/* Search Mode: Ensure numbers look like final text */
.search-mode .mini-cell {
  color: var(--text-main);
  cursor: default; /* No interaction for now unless we add search interactions */
}

.search-mode .mini-cell.user-filled {
  color: var(--text-main);
  transition: color 0.4s ease;
}

/* Return to theme color during win animation */
.search-mode .search-win .mini-cell.user-filled {
  color: var(--text-main);
}

/* Ensure no error states linger */
.search-mode .mini-cell.error {
  color: var(--text-main);
  background: none;
}

/* =========================================
   Layout Inheritance (Copied from Sudoku/Peaks)
   ========================================= */

/* Main Layout Stack */
.search-mode .memory-grid-layout {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 15px !important;
  width: 100% !important;
  max-width: 1000px !important;
  margin: 0 auto !important;
  padding-top: 0.2rem !important; /* v2.8.0: Compact top for standard screens */
}


.search-mode .memory-grid-layout {
  /* Use same grid line colors */
  --sudoku-grid-line: #000;
  --sudoku-inner-line: #bbb;
}

.dark-mode .search-mode .memory-grid-layout {
  --sudoku-grid-line: #fff;
  --sudoku-inner-line: #444;
}

/* Board Styling */
.search-mode .memory-board {
  background: var(--bg-secondary) !important;
  padding: 0 !important;
  gap: 0 !important;
  border: 4px solid var(--bg-secondary) !important;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1/1 !important;
}

/* Remove rounding on slots */
.search-mode .sudoku-chunk-slot,
.search-mode .mini-sudoku-grid {
  border-radius: 0 !important;
  box-sizing: border-box !important;
}

/* Internal Grid Borders */
.search-mode .sudoku-chunk-slot {
  border-right: 3px solid var(--sudoku-grid-line);
  border-bottom: 3px solid var(--sudoku-grid-line);
}

.search-mode .sudoku-chunk-slot:nth-child(3n) {
  border-right: none !important;
}

.search-mode .sudoku-chunk-slot:nth-child(n + 7) {
  border-bottom: none !important;
}

/* Hide Unused Elements */
.search-mode .collected-zone,
.search-mode .collected-wrapper,
.search-mode .cards-area {
  display: none !important;
}

/* Center Board Wrapper */
.search-mode .board-wrapper {
  order: 1 !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;

  /* FORCE VERTICAL STACKING */
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .search-mode .memory-grid-layout {
    flex: 1 !important;
    min-height: 0;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    padding-bottom: 2px !important;
    max-height: calc(
      100dvh - var(--header-height) - var(--footer-height)
    ) !important;
    overflow: hidden !important;
  }

  /* Ultra-Short Screens */
  @media (max-height: 660px) {
    .search-mode .memory-grid-layout {
      gap: 4px !important;
      padding-bottom: 0 !important;
      justify-content: space-between !important;
    }
  }

  /* Board Sizing on Mobile */
  .search-mode .memory-board {
    /* Budget reserved for sequences (relaxed slightly for better adaptation) */
    --v-budget: calc(100dvh - var(--header-height) - var(--footer-height) - 150px);
    width: min(92vw, var(--v-budget));
    max-height: var(--v-budget);
  }
}

/* Desktop Adjustments (Critical for Stability) */
@media (min-width: 769px) {
  /* Inherit Board Width from Jigsaw/Sudoku standards */
  .search-mode .memory-board {
    width: min(420px, 45vw) !important;
    height: auto !important;
    aspect-ratio: 1/1 !important;
  }
}

/* =========================================
   Disabled States for Peaks/Valleys
   ========================================= */
.search-mode .peak-found,
.search-mode .valley-found {
  background-color: #e2e8f0 !important; /* Slate 200 */
  box-shadow: none !important;
  color: #94a3b8 !important; /* Slate 400 */
  border-color: #cbd5e1 !important; /* Slate 300 */
  cursor: default !important;
  transition:
    background-color 0.5s ease,
    border-color 0.5s ease,
    color 0.5s ease,
    box-shadow 0.5s ease;
}

.dark-mode .search-mode .peak-found,
.dark-mode .search-mode .valley-found {
  background-color: #1e293b !important; /* Slate 800 */
  color: #475569 !important; /* Slate 600 */
  border-color: #334155 !important; /* Slate 700 */
}

/* =========================================
   UI Interactions & Visuals
   ========================================= */

/* Selection Highlight */
.search-selected {
  background-color: rgba(var(--accent-rgb), 0.4) !important;
  box-shadow: inset 0 0 5px var(--accent-color) !important;
  color: var(--text-main) !important;
  border-radius: 0 !important; /* Square selection */
  /* transform: scale(0.95); Removed to fill cell */
}

/* Error State */
@keyframes errorShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.search-error {
  animation: errorShake 0.4s ease-in-out;
  background-color: #ef4444 !important; /* Red 500 */
  color: #fff !important;
}

/* Found State (Permanent) */
.search-found-cell {
  /* Light Mode: Gray hierarchy for better contrast (darker than peaks) */
  background-color: #94a3b8 !important; /* Slate 400 */
  color: #ffffff !important;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.1) !important;
  /* text-decoration: line-through; REMOVED */
  opacity: 1; /* Ensure visibility */
}

.dark-mode .search-found-cell {
  /* Dark Mode: Darker than peaks (#1e293b) -> Slate 950 */
  background-color: #020617 !important;
  color: var(--text-muted) !important;
}

/* Targets Container */
.search-targets-container {
  margin-top: 10px; /* v2.8.0: Tight gap */
  width: 100%;
  max-width: 600px;
  text-align: center;
  animation: fadeIn 0.5s ease;
  order: 4 !important;
  box-sizing: border-box;
}

.search-targets-container h3 {
  font-family: "Lora", serif;
  color: var(--text-main);
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.search-targets-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.search-target-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: 20px;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.search-target-chip.found {
  background: rgba(var(--accent-rgb), 0.2);
  border-color: var(--accent-color);
  color: var(--accent-color);
  text-decoration: line-through;
  opacity: 0.6;
}

/* Mobile compact view for sequences */
@media (max-width: 768px) {
  .search-targets-container {
    margin-top: 8px;
    padding: 0 15px 12px; /* Margins for sides and bottom */
  }
  .search-targets-container h3 {
    display: none; 
  }
  .search-targets-list {
    gap: 6px;
    width: 100%;
    justify-content: center;
  }
  .search-target-chip {
    padding: 5px 10px;
    font-size: 0.85rem; /* Balanced size */
    font-weight: 600;
    white-space: nowrap;
  }
}

.dark-mode .search-target-chip {
  background: #334155;
  border-color: #475569;
}

/* Win Animation (Reusing keyframes if available, or defining new) */
@keyframes searchWinPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    border-color: rgba(76, 175, 80, 0);
  }
  50% {
    box-shadow: 0 0 30px 10px rgba(76, 175, 80, 0.6);
    border-color: #4caf50;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    border-color: rgba(76, 175, 80, 0);
  }
}

.search-win .memory-board {
  animation: searchWinPulse 0.5s ease-out 1;
}

/* Easter Egg Overlay */
.search-mode .easter-egg-overlay {
  position: absolute;
  /* top/left will be set by JS dynamically over cells */
  transform: translate(-50%, -50%);
  font-size: 3rem;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  animation: egg-pop 2s ease-out forwards;
}

@keyframes egg-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -70%) scale(1.1);
  }
}
