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

:root {
  --sudoku-grid-bg: var(--news-ink);
  --sudoku-cell-bg: var(--news-paper);
  --sudoku-cell-border: var(--news-rule-light);
  --sudoku-cell-text: var(--news-ink);
  --sudoku-cell-muted: var(--news-ink-muted);
  --sudoku-cell-disabled-bg: rgba(0,0,0,0.04);
  --sudoku-cell-disabled-text: var(--news-ink-light);
  --sudoku-box-border: var(--news-ink);
  --sudoku-selected-bg: color-mix(in srgb, var(--accent) 20%, transparent);
  --sudoku-related-bg: color-mix(in srgb, var(--accent) 8%, transparent);
  --sudoku-conflict-bg: rgba(198,40,40,0.2);
  --sudoku-conflict-text: var(--news-incorrect);
  --sudoku-conflict-border: var(--news-incorrect);
  --sudoku-pencil-text: var(--news-ink-muted);
  --sudoku-pencil-active: var(--news-ink-light);
  --sudoku-pencil-bg: color-mix(in srgb, var(--accent) 5%, transparent);
  --sudoku-pencil-active-bg: var(--accent);
}

html[data-theme='dark'] {
  --sudoku-cell-disabled-bg: rgba(255,255,255,0.04);
  --sudoku-selected-bg: color-mix(in srgb, var(--accent) 25%, transparent);
  --sudoku-related-bg: color-mix(in srgb, var(--accent) 10%, transparent);
  --sudoku-conflict-bg: rgba(239,83,80,0.2);
  --sudoku-conflict-text: #ef5350;
  --sudoku-conflict-border: #ef5350;
  --sudoku-pencil-active: #b2c0d0;
  --sudoku-pencil-bg: color-mix(in srgb, var(--accent) 6%, transparent);
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: clamp(400px, 90vmin, 540px);
  height: clamp(400px, 90vmin, 540px);
  border: 3px solid var(--sudoku-box-border);
  background: var(--sudoku-grid-bg);
  margin: 0 auto var(--spacing-xl);
}

.sudoku-row { display: contents; }

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--sudoku-cell-border);
  background: var(--sudoku-cell-bg);
  font-family: var(--news-font-display);
  font-size: clamp(1.2rem, 4vmin, 1.75rem);
  font-weight: 700;
  color: var(--sudoku-cell-text);
  overflow: hidden;
}

.sudoku-cell input {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  text-align: center;
  border: none;
  outline: none;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  color: inherit;
  background-color: transparent;
  padding: 0;
  margin: 0;
  caret-color: var(--news-accent);
}

.sudoku-cell input:disabled {
  color: var(--sudoku-cell-disabled-text);
  background-color: var(--sudoku-cell-disabled-bg);
  font-weight: 400;
}

.sudoku-cell:nth-child(3n) {
  border-right-width: 2px;
  border-right-color: var(--sudoku-box-border);
}

.sudoku-cell:nth-child(9n) {
  border-right-width: 1px;
  border-right-color: var(--sudoku-cell-border);
}

.sudoku-row:nth-child(3n) .sudoku-cell {
  border-bottom-width: 2px;
  border-bottom-color: var(--sudoku-box-border);
}

.sudoku-cell input::-webkit-outer-spin-button,
.sudoku-cell input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sudoku-cell input.with-pencil-marks {
  color: transparent;
  caret-color: var(--news-accent);
}

.sudoku-notes {
  position: absolute;
  inset: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  pointer-events: none;
  z-index: 1;
}

.sudoku-note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.42rem, 1.2vmin, 0.68rem);
  font-weight: 600;
  font-family: var(--news-font-body);
  color: transparent;
  line-height: 1;
}

.sudoku-note.is-visible {
  color: var(--sudoku-pencil-active);
}

.sudoku-cell.has-pencil-marks {
  background: var(--sudoku-pencil-bg);
}

.highlight-conflict {
  background-color: var(--sudoku-conflict-bg) !important;
  color: var(--sudoku-conflict-text) !important;
  border-color: var(--sudoku-conflict-border) !important;
}

.highlight-selected {
  background-color: var(--sudoku-selected-bg) !important;
}

.highlight-related {
  background-color: var(--sudoku-related-bg) !important;
}

#pencil-mode-btn.is-active {
  background: var(--sudoku-pencil-active-bg) !important;
  color: #fff !important;
  border: none !important;
}

@media (max-width: 768px) {
  .classic-grid-section {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  .sudoku-grid {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
    margin-bottom: 0;
  }

  .classic-grid-section .classic-progress-bar,
  .classic-grid-section #message-area,
  .classic-grid-section .classic-keyboard-hints {
    display: none;
  }
}
