/* Direction: Sunday puzzle book — pale mint paper, plum ink for timers and best times, pillowy cards */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #e8f4ec;
  --surface: #fbfdfb;
  --surface-2: #d9ebe0;
  --border: #c2dbca;
  --border-strong: #a7ada9;
  --ink: #22332b;
  --muted: #556d61;
  --accent: #6d3b63;
  --accent-hover: #5d3254;
  --accent-ink: #ffffff;
  --accent-text: #65375d;
  --accent-strong: #4b2744;
  --accent-soft: #f1e4ef;
  --accent-border: #b1a1ae;
  --success: #27694a;
  --success-ink: #ffffff;
  --success-soft: #d1e3d9;
  --success-strong: #27694a;
  --warning: #8a5713;
  --warning-ink: #ffffff;
  --warning-soft: #dde1d2;
  --warning-strong: #8a5713;
  --danger: #9c3535;
  --danger-ink: #ffffff;
  --danger-soft: #dfddd6;
  --danger-strong: #9c3535;
  --chart-1: #6d3b63;
  --chart-2: #a64731;
  --chart-3: #5c4c01;
  --chart-4: #0d7643;
  --chart-5: #055766;
  --chart-6: #515daf;

  --font-display: "Baloo 2", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;
  --display-weight: 700;
  --display-tracking: -0.01em;
  --radius-card: 28px;
  --radius-btn: 999px;
  --radius-input: 16px;
  --shadow-card: 0 22px 48px -30px rgba(34, 51, 43, 0.55);
  --card-pad: 1.6rem;
  --font-sans: "Nunito", system-ui, sans-serif;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #0f080e;
  --surface: #272126;
  --surface-2: #1b141a;
  --border: #312b30;
  --border-strong: #575256;
  --ink: #e8f4ec;
  --muted: #919693;
  --accent: #6d3b63;
  --accent-hover: #83587a;
  --accent-ink: #ffffff;
  --accent-text: #a787a1;
  --accent-strong: #9f7d99;
  --accent-soft: #241321;
  --accent-border: #391f34;
  --success: #27694a;
  --success-ink: #ffffff;
  --success-soft: #141d1b;
  --success-strong: #64937c;
  --warning: #8a5713;
  --warning-ink: #ffffff;
  --warning-soft: #2a190f;
  --warning-strong: #ab8656;
  --danger: #9c3535;
  --danger-ink: #ffffff;
  --danger-soft: #2e1217;
  --danger-strong: #b86f6f;
  --chart-1: #925d86;
  --chart-2: #ce6c53;
  --chart-3: #967f0f;
  --chart-4: #339d63;
  --chart-5: #188fa6;
  --chart-6: #7481d7;
}

/* Nook — puzzle grids, pillowy surfaces, gentle motion */

main {
  animation: nook-page 0.5s ease both;
}

@keyframes nook-page {
  from {
    opacity: 0.4;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pillow {
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset, var(--shadow-card);
}

.tile {
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-7px);
  box-shadow: 0 32px 60px -28px rgba(34, 51, 43, 0.5);
}

.board-wrap {
  padding: 10px;
  border-radius: calc(var(--radius-card) - 2px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

/* ---------- sudoku ---------- */
.sudoku {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  box-sizing: border-box;
  overflow: hidden;
}

.sudoku-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 16px;
  background: var(--border);
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

.cell {
  min-width: 0;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border: 0;
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.95rem, 3.4vw, 1.5rem);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cell.is-given {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

.cell.is-peer {
  background: var(--accent-soft);
}

.cell.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.cell.is-clash,
.cell.is-clash-peer {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.cell.is-clash {
  animation: nook-shake 0.5s ease;
}

@keyframes nook-shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  30%,
  70% {
    transform: translateX(3px);
  }
  50% {
    transform: translateX(-5px);
  }
}

/* ---------- crossword ---------- */
.xword {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.xcell {
  position: relative;
}

.xnum {
  position: absolute;
  top: 3px;
  left: 7px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  pointer-events: none;
}

.xword input {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 5vw, 1.6rem);
  padding: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.xword input:focus {
  outline: none;
}

.xword input.is-word {
  background: var(--accent-soft);
}

.xword input.is-active {
  box-shadow: 0 0 0 3px var(--accent);
}

.clue {
  display: flex;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.clue.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.clue.is-done {
  color: var(--muted);
}

.clue.is-done .clue-text {
  text-decoration: line-through;
}

.clue-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding-top: 0.2rem;
  color: var(--accent-text);
}

/* ---------- mines ---------- */
.mines {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}

.msq {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 0;
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.8rem, 3vw, 1.2rem);
  box-shadow: 0 2px 0 rgba(34, 51, 43, 0.12);
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.msq:hover {
  background: var(--accent-soft);
}

.msq:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.msq.is-open {
  background: var(--surface-2);
  box-shadow: none;
  cursor: default;
}

.msq.is-flag,
.msq.is-mine {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.msq.is-boom {
  background: var(--accent);
  color: var(--accent-ink);
  animation: nook-shake 0.5s ease;
}

.msq .icon {
  width: 58%;
  height: 58%;
}

.msq[data-n="1"] {
  color: var(--muted);
}
.msq[data-n="2"] {
  color: var(--success);
}
.msq[data-n="3"] {
  color: var(--warning);
}
.msq[data-n="4"],
.msq[data-n="5"],
.msq[data-n="6"],
.msq[data-n="7"],
.msq[data-n="8"] {
  color: var(--accent-strong);
}

/* ---------- solved ripple ---------- */
.is-solved .cell,
.is-solved .msq,
.is-solved input {
  animation: nook-ripple 0.75s ease both;
}

@keyframes nook-ripple {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.86);
  }
  70% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

.best-pop {
  animation: nook-pop 0.6s ease both;
}

@keyframes nook-pop {
  0% {
    transform: scale(0.92) rotate(-2deg);
  }
  60% {
    transform: scale(1.04) rotate(1deg);
  }
  100% {
    transform: none;
  }
}

html.reduced-motion main,
html.reduced-motion .is-solved .cell,
html.reduced-motion .is-solved .msq,
html.reduced-motion .is-solved input,
html.reduced-motion .cell.is-clash,
html.reduced-motion .msq.is-boom,
html.reduced-motion .best-pop {
  animation: none;
}

html.reduced-motion .tile:hover,
html.reduced-motion .tile:focus-visible {
  transform: none;
}
