/* =====================================================================
   sunoku.app — board.css

   The game's board, marks, hint bar, toolbar and solved card, ported from
   the game's css/styles.css so the free puzzles look and feel exactly like
   the app. The comments there explain why each rule is the way it is;
   this copy keeps the rules and drops the history. The board sizes itself
   to its container here, not to the screen.
   ===================================================================== */

/* ------------------------------------------------------------- board */

.board {
  --n: 8;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 5px;
  box-shadow: var(--shadow);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: opacity 0.18s;
}

.board.solved-glow {
  box-shadow: var(--shadow), 0 0 0 2px color-mix(in srgb, var(--good) 55%, transparent);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.tile {
  position: absolute;
  inset: clamp(1px, 5%, 3.5px);
  border-radius: var(--tile-radius);
  background: var(--tile);
  transition: transform 0.11s ease, filter 0.11s;
}

.cell:focus-visible {
  outline: none;
}

.cell:focus-visible .tile {
  box-shadow: 0 0 0 3px var(--text), 0 0 0 5px var(--bg);
  z-index: 3;
}

/* The ✕: two square-ended bars, contrast from a drop shadow. */
.cell .x {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}

.cell .x::before,
.cell .x::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60%;
  height: 12.5%;
  min-height: 2px;
  border-radius: 1px;
  background: var(--ink-out);
  transform: translate(-50%, -50%) rotate(45deg);
}

.cell .x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cell[data-mark='1'] .x,
.cell[data-mark='4'] .x {
  opacity: 1;
}

.cell[data-mark='4'] .x {
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.65)) drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

.cell[data-mark='4'] .x::before,
.cell[data-mark='4'] .x::after {
  background: var(--ink-wrong);
}

.cell[data-mark='4'] .tile {
  box-shadow: inset 0 0 0 100px color-mix(in srgb, var(--bg) 74%, transparent);
}

/* The sun. */
.cell .face {
  position: absolute;
  inset: 6%;
  width: 88%;
  height: 88%;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.14s, transform 0.2s cubic-bezier(0.2, 1.5, 0.4, 1);
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.cell[data-mark='3'] .face {
  opacity: 1;
  transform: scale(1);
}

/* A square the player has lit up (press and hold): the hint's pool of
   light, held still. */
.cell[data-mark='2'] {
  z-index: 5;
}

.cell[data-mark='2'] .glow {
  opacity: 0.85;
}

.cell[data-mark='2'] .tile {
  filter: brightness(1.1) saturate(1.12);
  box-shadow:
    0 0 0 2.5px rgba(255, 231, 140, 0.92),
    0 0 0 4.5px rgba(150, 74, 0, 0.5);
}

.board.hinting .cell[data-mark='2']:not(.hl-cell) .glow {
  opacity: 0;
}

.cell.pop .tile {
  animation: pop 0.24s ease;
}

.cell.shake .tile {
  animation: shake 0.32s ease;
}

@keyframes pop {
  40% {
    transform: scale(1.13);
  }
}

@keyframes shake {
  20% {
    transform: translateX(-13%) rotate(-3deg);
  }
  50% {
    transform: translateX(11%) rotate(3deg);
  }
  80% {
    transform: translateX(-6%);
  }
}

/* Letters for when colour alone will not do: in the markup, as in the
   app, but the site never turns them on. */
.cell .letter {
  position: absolute;
  left: 8%;
  top: 3%;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  color: rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------- hint highlighting */

.cell .glow {
  position: absolute;
  inset: -105%;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(
    closest-side,
    rgba(255, 226, 130, 0.95) 0%,
    rgba(255, 196, 60, 0.66) 22%,
    rgba(255, 150, 25, 0.34) 44%,
    rgba(255, 120, 10, 0.13) 64%,
    rgba(255, 110, 0, 0) 80%
  );
  mix-blend-mode: plus-lighter;
  transition: opacity 0.2s;
}

.board.hinting .cell:not(.hl-cell):not(.hl-unit):not(.hl-will-cross) .tile {
  filter: saturate(0.22) opacity(0.4);
}

.board.hinting .cell.hl-unit:not(.hl-cell):not(.hl-will-cross) .tile {
  filter: saturate(0.9) opacity(0.85);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
}

.cell.hl-cell {
  z-index: 6;
}

.cell.hl-cell .glow {
  opacity: 1;
  animation: pulse-mark var(--pulse, 1.6s) ease-in-out var(--pulse-delay, 0s) infinite;
}

.cell.hl-cell .tile {
  filter: brightness(1.12) saturate(1.15);
  box-shadow:
    0 0 0 3px rgba(255, 231, 140, 0.95),
    0 0 0 5.5px rgba(150, 74, 0, 0.55);
}

/* What a hint is about to do, pulsing in step with the glow: a ✕ arriving,
   or a ghost sun on the square it is about to fill. */
.board.hinting .cell.hl-will-cross .tile {
  filter: none;
}

.cell.hl-will-cross .x {
  opacity: 1;
  animation: pulse-mark var(--pulse, 1.6s) ease-in-out var(--pulse-delay, 0s) infinite;
}

.cell.hl-will-place .face {
  opacity: 1;
  animation: pulse-mark var(--pulse, 1.6s) ease-in-out var(--pulse-delay, 0s) infinite;
}

:root {
  --pulse: 1.6s;
}

@keyframes pulse-mark {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* The lesson's opening tour: one colour lifted at a time. */
.board .cell.tour {
  z-index: 4;
}

.board .cell.tour .tile {
  transform: scale(1.09);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 0 4.5px rgba(0, 0, 0, 0.22),
    0 5px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.28s cubic-bezier(0.2, 1.4, 0.4, 1), box-shadow 0.28s;
}

/* ---------------------------------------------------------- hint bar */

.hint-bar {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 10px 6px 9px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  animation: rise 0.2s ease;
}

.hint-body {
  flex: 1;
  min-width: 0;
}

.hint-text {
  overflow-wrap: break-word;
  hyphens: auto;
}

.hint-text b {
  color: var(--accent);
  font-weight: 650;
}

/* Always there, empty or not, so the gesture line under it never jumps. */
.why-note {
  display: block;
  height: 1.2rem;
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.2rem;
  color: var(--text-faint);
}

.hint-gesture {
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.hint-gesture.teaching {
  color: var(--accent);
  font-size: 12px;
  line-height: 1.45;
}

.hint-gesture b {
  font-weight: 650;
}

.icon-btn {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 10px;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.hint-x {
  width: 30px;
  height: 30px;
  flex: none;
  margin-top: -2px;
}

.hint-x svg {
  width: 15px;
  height: 15px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 0 1 68px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 14px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, color 0.15s, border-color 0.15s;
}

.tool svg {
  width: 20px;
  height: 20px;
}

.tool:hover:not(:disabled) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text-dim) 45%, transparent);
}

.tool:active:not(:disabled) {
  transform: scale(0.94);
}

.tool:disabled {
  opacity: 0.32;
  cursor: default;
}

.tool.tool-hint {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ------------------------------------------------------------- win */

.win {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  border-radius: 18px;
  z-index: 8;
  animation: fade 0.25s ease;
}

.win-card {
  position: relative;
  text-align: center;
  padding: 16px 20px;
}

.win-face {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
  animation: bounce 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.win-card h2 {
  margin: 6px 0 2px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.win-card p {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.win-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(15rem, 68vw);
  margin: 0 auto;
  pointer-events: none;
}

.win.armed .win-actions {
  pointer-events: auto;
}

@keyframes bounce {
  0% {
    transform: scale(0.2) rotate(-25deg);
  }
  60% {
    transform: scale(1.12) rotate(6deg);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 11px;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 0.1s, filter 0.15s;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
}

.btn-lg {
  font-size: 15px;
  padding: 12px 18px;
  border-radius: 12px;
}

.btn-small {
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 9px;
}

/* ----------------------------------------------------- the confirm card */

.modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border-radius: inherit;
  animation: fade 0.2s ease;
}

.modal-card {
  width: min(100%, 20rem);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  text-align: left;
}

.modal-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.modal-card p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

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

/* ------------------------------------------------------------- dots */

.dots {
  display: flex;
  gap: 4px;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.2s, transform 0.2s;
}

.dots i.past {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.dots i.on {
  background: var(--accent);
  transform: scale(1.5);
}

@media (prefers-reduced-motion: reduce) {
  .board *,
  .hint-bar,
  .win,
  .win-face,
  .modal {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
