/* Sudoku-specific styles. shared/styles.css carries tokens + base + components. */

/* ---------- Sudoku-specific tokens ---------- */

:root {
  /* All token-driven, so light and dark are handled by the brand layer. */
  --selected:      color-mix(in srgb, var(--gold) 35%, var(--surface)); /* selected cell — strongest gold */
  --selected-soft: var(--gold-wash);                                    /* keypad press / soft fill */
  --peer:          color-mix(in srgb, var(--ink) 8%, var(--surface));   /* same row/col/box — cool grey, no gold */
  --same:          color-mix(in srgb, var(--gold) 26%, var(--surface)); /* matching-number cells — clearly gold */
  --given:         var(--ink);                                          /* clue digits, bold */
  --user:          var(--ink-muted);                                    /* your entries, lighter than clues */
  --conflict:      var(--danger);
  --conflict-bg:   color-mix(in srgb, var(--danger) 14%, var(--surface));
  --game: #E7C25E;        /* Sudoku signature color (matches its hub tile) */
  --game-ink: #1a1817;    /* text/icon on --game */
}

::selection { background: var(--selected); color: var(--ink); }

/* ---------- Layout ---------- */

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Difficulty tabs ---------- */

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 60;
}

.diff-btn {
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-muted);
  transition: background 140ms ease, color 140ms ease;
  letter-spacing: -0.005em;
  position: relative;
}
.diff-btn:hover { color: var(--ink); }
.diff-btn[aria-selected="true"] {
  background: var(--game);
  color: #1a1817;
}
.diff-btn.completed:not([aria-selected="true"])::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--positive);
}
.diff-btn[aria-selected="true"].completed::before {
  content: "✓";
  margin-right: 6px;
  opacity: 0.85;
  font-weight: 700;
}

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  background: var(--line-strong);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  box-shadow: var(--shadow-md);
}

.cell {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background-color 100ms ease;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.cell[data-col="2"], .cell[data-col="5"] { border-right: 2px solid var(--line-strong); }
.cell[data-col="8"] { border-right: none; }
.cell[data-row="2"], .cell[data-row="5"] { border-bottom: 2px solid var(--line-strong); }
.cell[data-row="8"] { border-bottom: none; }

.cell .value {
  font-family: var(--font-num);
  font-size: clamp(18px, 5.5vw, 28px);
  font-weight: 500;
  color: var(--user);
  letter-spacing: -0.01em;
  transition: transform 140ms ease;
}

.cell.given .value {
  color: var(--given);
  font-weight: 600;
}
.cell.given { cursor: default; }

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

.cell .notes span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: clamp(8px, 1.6vw, 10px);
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1;
}

.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.selected { background: var(--selected); }
.cell.selected.peer { background: var(--selected); }
.cell.selected.same { background: var(--selected); }
.cell.conflict .value { color: var(--conflict); }
.cell.conflict { background: var(--conflict-bg); }
.cell.selected.conflict { background: var(--selected); }
.cell.just-set .value { animation: pop 180ms ease; }

@keyframes pop {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- Numpad ---------- */

.numpad {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.num {
  padding: 14px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  transition: background 100ms ease, transform 60ms ease, border-color 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.num:hover { background: var(--peer); border-color: var(--ink-faint); }
.num:active { transform: scale(0.95); background: var(--selected-soft); }
.num.erase { color: var(--ink-muted); }
.num.exhausted {
  color: var(--ink-faint);
  background: transparent;
  cursor: default;
}
.num.exhausted:hover { background: transparent; border-color: var(--line); }

.notes-active .num { color: var(--user); }
.notes-active .num.exhausted { color: var(--ink-faint); }

/* ---------- Actions row ---------- */

.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* ---------- Completion state ---------- */

body.is-completed .numpad,
body.is-completed #notes-btn {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Stats panel (sudoku-specific structure) ---------- */

.stats-difficulty {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.stats-difficulty:last-of-type { border-bottom: none; }
.stats-row-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.stats-row-meta {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */

@media (max-width: 420px) {
  main { padding: 12px; gap: 12px; }
  .numpad { grid-template-columns: repeat(5, 1fr); }
}

@media (hover: none) {
  .cell:hover, .num:hover, .diff-btn:hover, .action-btn:hover { background-color: inherit; }
}

/* ===================== Carousel (sudoku-specific bits) ===================== */
/* Generic .puzzle-slider, .puzzle-card framework lives in shared/styles.css. */

.card-preview-sudoku {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 144px;
  height: 144px;
  background: #1a1817;
  border: 1px solid #1a1817;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.card-preview-sudoku-cell {
  background: #fbfaf7;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 0.5px solid rgba(26, 24, 23, 0.18);
  border-bottom: 0.5px solid rgba(26, 24, 23, 0.18);
  font-family: var(--font-num, ui-monospace, monospace);
  font-size: 9px;
  font-weight: 600;
  color: #1a1817;
  line-height: 1;
}
.card-preview-sudoku-cell[data-col="2"],
.card-preview-sudoku-cell[data-col="5"] { border-right: 1px solid #1a1817; }
.card-preview-sudoku-cell[data-col="8"] { border-right: none; }
.card-preview-sudoku-cell[data-row="2"],
.card-preview-sudoku-cell[data-row="5"] { border-bottom: 1px solid #1a1817; }
.card-preview-sudoku-cell[data-row="8"] { border-bottom: none; }

.puzzle-card-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.diff-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.diff-row:hover {
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-color: color-mix(in srgb, var(--ink) 14%, transparent);
}
.diff-row:active { transform: translateY(0.5px); }

.diff-row-label {
  font-weight: 600;
  letter-spacing: 0.01em;
}
.diff-row-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.diff-row-value.muted { color: var(--ink-muted); font-weight: 500; }
.diff-row-chevron { color: var(--ink-faint); }

.diff-row.state-done {
  background: color-mix(in srgb, var(--positive) 10%, transparent);
  border-color: color-mix(in srgb, var(--positive) 28%, transparent);
}
.diff-row.state-done .diff-row-value { color: var(--positive); }

.diff-row.state-ongoing {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}
.diff-row.state-ongoing .diff-row-value { color: var(--warn); }

@media (max-width: 480px) {
  .card-preview-sudoku { width: 124px; height: 124px; }
}
