/* ══════════════════════════════════════════════════════════════
   CROSSWORDS — builds on atividades.css and puzzles.css
══════════════════════════════════════════════════════════════ */

:root {
  --cw-tile:        #eef2f9;
  --cw-tile-hover:  #dfe7f4;
  --cw-tile-word:   #c9d7ee;
  --cw-tile-active: #f5c9c8;
  --cw-ink:         #032d6f;
}

/* ─── Theme card preview (navy panel) ─── */
.cw-preview rect {
  fill: rgba(238, 242, 249, 0.2);
  transition: fill .3s ease;
}

.cw-preview rect.on { fill: var(--rose); }
.pz-theme-card.complete .cw-preview rect { fill: var(--pz-green); }
.pz-theme-card:hover .cw-preview rect:not(.on) { fill: rgba(238, 242, 249, 0.32); }

/* ─── Grid ─── */
.cw-grid-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cw-grid {
  --cell: 40px;
  --gap: 3px;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  gap: var(--gap);
  animation: pzBoardIn .6s cubic-bezier(0.22, 1, 0.36, 1) .1s both;
}

.cw-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cw-tile);
  color: var(--cw-ink);
  border-radius: calc(var(--cell) * 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(3, 45, 111, 0.06),
    inset 0 -2px 0 rgba(3, 45, 111, 0.16);
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, box-shadow .15s ease;
}

.cw-cell:hover { background: var(--cw-tile-hover); }
.cw-cell.in-word { background: var(--cw-tile-word); }

.cw-cell.is-active {
  background: var(--cw-tile-active);
  box-shadow: inset 0 0 0 max(2px, calc(var(--cell) * 0.06)) var(--red);
}

.cw-num {
  position: absolute;
  top: calc(var(--cell) * 0.05);
  left: calc(var(--cell) * 0.09);
  font-size: max(8px, calc(var(--cell) * 0.25));
  font-weight: 600;
  line-height: 1;
  color: rgba(3, 45, 111, 0.72);
  pointer-events: none;
}

.cw-letter {
  font-size: calc(var(--cell) * 0.56);
  font-weight: 700;
  line-height: 1;
  margin-top: calc(var(--cell) * 0.1);
  pointer-events: none;
}

/* Wrong letter after "Check" */
.cw-cell.is-wrong .cw-letter { color: var(--red); }

.cw-cell.is-wrong::after {
  content: '';
  position: absolute;
  inset: 16%;
  background: linear-gradient(to top right,
    transparent calc(50% - 1px),
    rgba(166, 4, 4, 0.65) calc(50% - 1px),
    rgba(166, 4, 4, 0.65) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
}

/* Revealed letter: locked, with a corner marker */
.cw-cell.is-revealed .cw-letter { color: #5a6f93; }

.cw-cell.is-revealed::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 30%;
  height: 30%;
  background: var(--rose);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  border-top-right-radius: inherit;
  pointer-events: none;
}

.cw-cell.flash-correct { animation: cwCorrect .9s ease; }

@keyframes cwCorrect {
  0%, 35% { background: var(--pz-green-word); }
}

.cw-grid.is-complete .cw-cell { background: var(--pz-green-soft); }
.cw-grid.is-complete .cw-cell.in-word { background: var(--pz-green-word); }
.cw-grid.is-complete .cw-cell.is-active { box-shadow: inset 0 0 0 max(2px, calc(var(--cell) * 0.06)) var(--pz-green); }

/* Hidden input that receives typing (incl. touch keyboards) */
.cw-input {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}

/* ─── Clue lists ─── */
.cw-clue-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cw-clue {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: .93rem;
  line-height: 1.45;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}

.cw-clue:hover { background: var(--hover); }

.cw-clue-num {
  flex-shrink: 0;
  min-width: 1.5em;
  font-weight: 800;
  color: var(--red);
}

.cw-clue-enum {
  font-size: .85em;
  font-weight: 500;
  color: var(--mute);
  white-space: nowrap;
}

.cw-clue.is-filled { color: var(--mute); }
.cw-clue.is-filled .cw-clue-num { opacity: .5; }

.cw-clue.is-cross { background: var(--hover-strong); }

.cw-clue.is-active {
  color: var(--navy);
  background: var(--red-08);
  box-shadow: inset 3px 0 0 var(--red);
}

.cw-clue.is-active .cw-clue-num { opacity: 1; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .cw-grid-wrap { flex: none; padding: 4px 0; }
}
