/* Word Search puzzle-specific styles — builds on unified-2d-game.css + newspaper-theme.css */

:root {
  --ws-cell-bg: var(--news-paper);
  --ws-cell-border: var(--news-rule-light);
  --ws-cell-text: var(--news-ink);
  --ws-selected-bg: var(--news-active-bg);
  --ws-selected-text: #fff;
  --ws-found-bg: var(--news-correct);
  --ws-found-text: #fff;
  --ws-hint-bg: var(--news-accent);
  --ws-hint-text: #fff;
  --ws-toggled-found-bg: #facc15;
  --ws-toggled-found-text: #000;
}

html[data-theme='dark'] {
  --ws-selected-bg: var(--accent);
  --ws-found-bg: var(--news-correct);
  --ws-hint-bg: var(--news-accent);
}

#word-search-grid {
  display: grid;
  gap: 0;
  padding: 4px;
  touch-action: none;
  background: var(--news-ink);
  border: 1px solid var(--news-ink);
}

.grid-cell {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--ws-cell-bg);
  border: 1px solid var(--ws-cell-border);
  font-family: var(--news-font-display);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.1s;
  color: var(--ws-cell-text);
  text-transform: uppercase;
}

.grid-cell.selected {
  background: var(--ws-selected-bg);
  color: var(--ws-selected-text);
}

.grid-cell.found {
  background: var(--ws-found-bg);
  color: var(--ws-found-text);
}

.grid-cell.hint {
  background: var(--ws-hint-bg);
  color: var(--ws-hint-text);
}

.grid-cell.found.toggled {
  background: var(--ws-toggled-found-bg);
  color: var(--ws-toggled-found-text);
}

.word-list-item {
  font-family: var(--news-font-body);
  color: var(--news-ink-light);
  padding: var(--spacing-xs) 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.word-list-item.found {
  text-decoration: line-through;
  opacity: 0.5;
}

@media (max-width: 900px) {
  #word-search-grid .grid-cell {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  #word-search-grid { gap: 0; }
}

/* Mobile: make the wordsearch grid fill its container and keep square cells */
@media (max-width: 768px) {
  #word-search-grid {
    width: 100%;
    max-width: 100%;
    padding: 4px;
    box-sizing: border-box;
    /* ensure rows scale to fill available width */
    grid-auto-rows: 1fr;
    gap: 0;
    /* Reserve the board's height before the JS builds it.
       Below 768px the layout stacks, so the board sits ABOVE the clue list and its
       growth pushes the whole list down: measured 10px -> 348px, moving
       .classic-clues-section 338px, which is the mobile CLS. Here the board is
       width:100% with 1:1 cells, so its height IS its width — reserving the square
       costs nothing and matches the built board exactly. */
    aspect-ratio: 1 / 1;
  }

  /* Remove fixed cell pixels and rely on grid fraction sizing with aspect-ratio */
  #word-search-grid .grid-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    font-size: 1rem;
  }

  /* Reduce surrounding card padding so grid can use more space */
  .classic-grid-section .card { padding: 2px; }
}

@media (max-width: 360px) {
  #word-search-grid {
    padding: 2px;
  }
  #word-search-grid .grid-cell {
    font-size: 0.85rem;
  }
}

/* Remove the line and expand the grid to fill the space */
.classic-progress-bar {
    display: none;
}
