/* Puzzles: the overview of the three levels, and the solver (the board page layout from
   game.css with its own side panel). */

/* ================================================================ overview */

.puzzles-page:not(.board-page) { max-width: 1120px; }
.overview .page-head { align-items: center; }
.overview .page-head .lead { margin-top: 4px; }
.signin-note { margin: -4px 0 16px; color: var(--dim); }
.levels { display: grid; gap: 16px; }

.level-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.level-dot.easy { background: var(--good); }
.level-dot.medium { background: var(--accent); }
.level-dot.hard { background: var(--bad); }

.level-card .card-head { gap: 8px; }
.level-card .card-head h2 { font-size: 15px; }
.level-card .card-head .muted { font-weight: 500; }
.level-count { margin-left: auto; color: var(--dim); font-weight: 500; font-variant-numeric: tabular-nums; }
.level-count b { color: var(--text-strong); }

.level-body { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 20px; padding: 16px 18px 18px; align-items: start; }

.level-next {
  display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; color: var(--text); background: var(--panel-2); transition: border-color .15s;
}
.level-next:hover { text-decoration: none; border-color: var(--accent); }
.level-next:hover .continue { background: var(--accent-2); border-color: var(--accent-2); }
.level-next-text { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; font-size: 13px; color: var(--dim); }
.level-next-text .player-dot, .peek .player-dot { width: 12px; height: 12px; border-radius: 3px; }
.level-next .continue { margin: 10px 12px 12px; width: auto; gap: 6px; }
.thumb-wrap { background: var(--board); }
.thumb-board { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; }
.thumb-board.placeholder { background: var(--board); }
.thumb-last { fill: #f0b42933; stroke: #f0b429aa; stroke-width: 4; }

.progress { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); }
.progress-solved { background: var(--good); transition: width .3s; }
.progress-failed { background: var(--bad); opacity: .75; transition: width .3s; }
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; margin: 8px 0 14px; font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.solved { background: var(--good); }
.legend i.failed { background: var(--bad); }
.legend i.new { background: var(--panel-3); box-shadow: inset 0 0 0 1px var(--line-2); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.ptile {
  display: grid; place-items: center; height: 32px; border-radius: 6px; font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--dim); background: var(--panel-2); border: 1px solid var(--line);
  transition: border-color .12s, background .12s, color .12s;
}
.ptile:hover { text-decoration: none; border-color: var(--accent); color: var(--text-strong); }
.ptile.solved { background: color-mix(in srgb, var(--good) 22%, var(--panel)); border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--text-strong); }
.ptile.failed { background: color-mix(in srgb, var(--bad) 20%, var(--panel)); border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--text-strong); }
.ptile.next { border-color: var(--accent); color: var(--text-strong); box-shadow: 0 0 0 1px var(--accent); }

.peek { position: fixed; z-index: 50; width: 240px; overflow: hidden; box-shadow: var(--shadow); pointer-events: none; }
.peek-text { padding: 7px 10px; font-size: 12.5px; color: var(--dim); border-top: 1px solid var(--line); }
.peek-text b { color: var(--text-strong); }

.missing { padding: 60px 16px; }

/* ================================================================ solver */

.solver:not([hidden]) { display: contents; }
body.solving .site-footer { display: none; }

.puzzle-side { min-height: 0; }
.puzzle-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 6px; background: var(--panel-2); border-bottom: 1px solid var(--line); min-height: 58px; flex: none; }
.back-link { width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none; }
.back-link:hover { text-decoration: none; }
.ph-title { flex: 1; min-width: 0; }
.ph-title h1 { font-size: 17px; margin: 0; line-height: 1.25; }
.ph-sub { color: var(--dim); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.ph-sub .level-dot { width: 8px; height: 8px; }
.ph-sub .mono { color: var(--faint); }
.puzzle-mark { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: .05em; flex: none; }
.puzzle-mark.solved { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); }
.puzzle-mark.failed { color: var(--bad); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }

.task { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex: none; }
.task .player-dot { width: 26px; height: 26px; border-radius: 6px; flex: none; }
.player-dot.white { background: var(--tile-white); box-shadow: 0 0 0 1px #0005; }
.player-dot.black { background: var(--tile-black); box-shadow: 0 0 0 1px #fff4; }
.task-main { font-size: 18px; font-weight: 700; color: var(--text-strong); line-height: 1.25; }
.task-sub { color: var(--dim); font-size: 13px; line-height: 1.4; }

.feedback {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; min-height: 64px; flex: none;
  border-bottom: 1px solid var(--line); line-height: 1.45; color: var(--text); transition: background .2s;
}
.feedback::before {
  content: ""; flex: none; width: 22px; height: 22px; border-radius: 50%; margin-top: -1px;
  background: var(--panel-3) center / 14px no-repeat;
}
.feedback strong { color: var(--text-strong); }
.feedback code { font-size: 12.5px; }
.feedback.info::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f0b429' stroke-width='3' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3C/svg%3E"); }
.feedback.good::before, .feedback.success::before {
  background-color: var(--good);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.feedback.bad { background: var(--bad-soft); }
.feedback.bad::before {
  background-color: var(--bad);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E");
}
.feedback.hint::before {
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1602' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17.5v.01'/%3E%3C/svg%3E");
}
.feedback.success { background: color-mix(in srgb, var(--good) 15%, transparent); font-size: 14.5px; }
.feedback.success strong { font-size: 16px; }
.feedback.done::before {
  background-color: var(--dim);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

.puzzle-side .moves { min-height: 90px; }
.moves .move.context { color: var(--faint); cursor: default; }
.moves .move.context.active { background: var(--panel-3); color: var(--text); }
.moves .move.good .score { color: var(--good); font-size: 13px; }
.moves .move.active.good .score { color: #c9f2c4; }
.moves .move.wrong { background: var(--bad-soft); color: var(--bad); }
.moves .move.wrong.active { background: var(--bad); color: #fff; }
.moves .move.wrong .score { color: inherit; font-size: 13px; }

.puzzle-side .game-actions { display: flex; gap: 8px; padding: 12px 14px 8px; border-top: 1px solid var(--line); flex: none; }
.puzzle-side .game-actions > * { flex: 1; }
.puzzle-side .game-actions .btn { gap: 7px; }
.puzzle-links { display: flex; justify-content: space-between; gap: 4px; padding: 4px 8px 8px; flex: none; }
.puzzle-links .btn { gap: 5px; color: var(--dim); background: none; border-color: transparent; }
.puzzle-links .btn:hover:not(:disabled) { color: var(--text-strong); background: var(--hover); border-color: transparent; }
.puzzle-links .btn svg { width: 15px; height: 15px; }

/* Hints */
.hint-ring { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linejoin: round; pointer-events: none; animation: hint-pulse 1.2s ease-in-out infinite; }
@keyframes hint-pulse { 50% { stroke-opacity: .35; } }
.reserve.hinted { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* The board when a move is wrong, and when the puzzle is solved */
.board-wrap { transition: box-shadow .2s; }
.board-wrap.wrong { box-shadow: inset 0 0 0 3px var(--bad); }
.board-wrap.wrong .last { fill: #e5534b33; stroke: #e5534bcc; }
.board-wrap.solved { box-shadow: inset 0 0 0 3px var(--good); }
.board-wrap.solved .board-banner { border-color: var(--good); color: var(--good); }

/* ================================================================ narrow windows */

@media (max-width: 860px) {
  .level-body { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 12px; }
  .level-next { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .level-next .thumb-wrap { width: 132px; flex: none; }
  .level-next-text { flex: 1; min-width: 0; padding: 0 12px; }
  .level-next .continue { flex-basis: 100%; margin: 0; border-radius: 0; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
  .ptile { height: 30px; font-size: 12px; }
  .overview .page-head { flex-direction: column; align-items: stretch; }
  .puzzle-side { max-height: none; }
  .task { padding: 10px 14px; }
  .task-main { font-size: 16px; }
  .feedback { min-height: 0; padding: 10px 14px; }
  .puzzle-side .moves { min-height: 70px; max-height: 180px; }
}
